Microcontrollers exam Flashcards
Characteristics of a PC computer
Fixed location
Linked to mains power
Extendable buses
Add memory
Add devices
Examples of distributed control systems
Protection systems
Data housing
R&D
Education
What is telemetry
Taking data from a distance and feeding it into a computer system
Components in a microprocessor
CPU - brains of the operation, will be executing the code you have loaded on to it
ALU - optimised to carry out AND/OR/NOT operations
FPCP - optimised to carry out mathematical operations
ROM
RAM
BIOS - low level code (firmware)
ADC
DAC
What is RISC and CISC
Reduced instruction set computer (microprocessor uses this) - 50/60 instructions
Complex instruction set computer - 500+ instructions
Characteristics of microcontroller
Small, mobile, standalone, battery powered, fixed, can be embedded
Differences between Harvard and Von Neumann
VN: Uses one memory unit for both instructions and data
H: Has separate memory units for instructions and data
VN: Uses one set of buses for both instructions and data
H: Has separate buses for instructions and data
VN: Commonly used in general purpose computers
H: Commonly used in embedded systems (e.g. digital signal processing)
VN: Enables a more flexible use of main memory, enabling the processor to run a variety of programs that aren’t necessarily known in advance
H: For systems with a predetermined use, instruction memory can be implemented as ROM which protects the programs from hacking
4 advantages of Harvard
⏰️ Instruction and data can be accessed simultaneously
📝 Instruction and data memory can have different word lengths
🤖 Different technologies can be used to implement instruction and data memory
🧑💻️ For systems with a predetermined use, instruction memory can be implemented as ROM which protects the programs from hacking
Name some microcontrollers
Arduino
Raspberry Pi
Where is power indicator (1)
(2)
Where is USB in (1)
(3)
Board rate =
Bits per second
Where is DC power in (power supply) (1)
(4)
draw the diode bridge
(5)
voltage drop of a diode
0.7V
(6)
Time period = 0.1s
so t = 0.1
r*C = 0.01
7.6e^0.01/0.1
Where does the battery go (Vin) (1)
(9)
draw a zener diode
(10) doesn’t have line through the middle
draw a circuit for a regulated voltage supply to a microcontroller
(12)
Draw IV for zener diode
(11)
(13)
Vr = Vin - Vz
Vr = 7-5.1 = 1.9
I = 1.9/100 = 19mA
Power in r = Iz^2 * r
=0.019^2 * 100 = 0.0361W
Pz = Vz * Ir
= 5.1 * 0.019 = 0.0969W
identify which is harvard and which is von neumann
insert pic
Draw SBD for the schematic
(13)
What is pin 1 used for
It is a serial pin for if you did not want to use a USB cable
(14)
write psuedo code using an active low
logic is reversed, 0 means LED on and 1 means lED off
draw arduino circuit with a tilt switch
(15)
draw LED symbol
(16)
what is the forward voltage of bright red and what current does it need to work (17)
2-2.5
20mA
Draw an arduino schematic with a mechanical push switch and a capacitor in parallel with the 10k resistor. Calculate the size of the capacitor
(19)
C = 0*10^-6
Draw schematic with BCD chip integrating a 7 seg display
(22)
3
write code to read a byte from digital input 0
and then output 0x79 to channel 0
diginByte0 = digitalRead(DI0)
digoutByte0 = 0x79
digitalWrite(0, digoutByte0)
convert 0x79 to 7 seg display
letter E
convert to binary and then apply to 7 seg display
what is a masking operation
bitwise AND the byte with a 1 where you are looking at and if the answer is the masking operation = true
how do you set a bit in a byte to 1
OR it with a 1 where the bit is and the rest of the byte is 0s
how to set a bit in a byte to 0
AND the byte with another byte which has all 1’s except a 0 for the bit you want to change to 0 (its complement)
draw arduino schematic with a default on three leds with switch
(23)
code for a debouncing a push button
digin2 = read_digin(2)
If digin2 ! = to old_digin2 then
Wait 50 //wait 50 ms for signal to settle to avoid multiple triggers
End if
old_digin2 = digin2
draw a schematic using a relay output
(24)
draw a schematic with a 7 seg display
(25) with a matched resistor (need to calculate) and ground it
draw a schematic with a 7 seg display and a bcd
(21)
if ABCD on the BCD chip is allocated pins 2,3,4,5 then write the code to display the number 2 on the 7 seg display
digitalWrite(2,Low)
digitalWrite(3,High)
digitalWrite(4,Low)
digitalWrite(5,Low)
as a byte:
Digout && 11110010
what does this mean (26)
there are 4 wires in this cable
(27)
(28)
Pseudocode:
(29)
If something is called a swittch it is
digital
sensors and transducer’s are
analogue
what is a transducer
takes one signal and converts it into another
e.g. converts 0-100 degrees to 0-5V
draw an arduino schematic with an analogue input (potentiometer)
(30)
current vs voltage signals sensors
current signals:
wires can be as long as possible
much more expensive
draw a variable resistor
draw a light dependent resistor
(31)
pseudocode for reading analogue signal
int sensorVal = analogRead(A0)
write pseudocode if you have a temperature sensor which is 0-5 V = 0 - 100 °C,
rawTemp = readAnin(0) // reads in a bit value from the analogue input A0
realTemp = rawTemp * (100/255) // scale the bit value to a temperature in deg C
resolution for analogue to digital scaling =
range/255
write pseudocode using a deadband for a window opener
If realTemp > 24 then // if its too hot open a window
openWindow
Else if realTemp < 22 then // put a 2 deg C deadband around the switching
closeWindow
End if
analogue vs digital
analogue represents the real world better
digital will always suffer from sample and hold quantisation errors
why are there no analogue outputs on an arduino
driving AO takes a lot of power
It makes the board more expensive and complicated
scaling from digital to analogue if drive = 20%
*Reverse calc for inputs
*If the drive to a motor is 0-5V for 0-100% drive
*If the DAC is an 8 bit device
*Then if the code wants to output 20% (=1V)
*SpeedOut = 20
AnalogOut = (20/100) (2^8 -1) = 51
symbol for a motor
(32)
(33)
5V = 255 bits
3V = 253 * 0.5 = 153 bits
motorspeed = 0
void loop()
{
delay(1000) /1s
motorspeed = motorspeed + 1
anoutWrite(0) = (motorSpeed/100)*153
What is pulse width modulation
Modulating the width of a pulse to give quasi analogue control
what is a pulse
when something goes
high
low
high
low…
what happens when you increase the width of the pulse. include diagram
letting the motor see a higher analogue input because it is integrating between the pulses as the speed of the pulses is faster than the reaction time of the motor (33)
PWM has a
fixed frequency
speed when mark:space ratio is 100:0
100%
speed when mark:space ratio is 30:70
30%
what % duty cycle is analogWrite(255) on an arduino
100%
what % duty cycle is analogWrite(127) on an arduino
50%
what % duty cycle is analogWrite(0) on an arduino
0%
duty cycle =
mark:space ratio
duty cycle is 70% =
70:30 M:S
resolution of a shaft encoder
360 / 2^(number of layers)
write gray code for 3 bits
000
001
011
010
110
111
draw a 3 bit grey code shaft encoder
(34)
draw a H-bridge circuit
(35)
draw a control system diagram for a heater (negative feedback)
(36)
what is hunting
when there is a time delay, it can cause the system to be constantly turning on and off
define hysteresis
the dependence of the state of a system on its history. For example, a magnet may have more than one possible magnetic moment in a given magnetic field
draw the mechanical hysteresis graph
(37)
how to fix hunting
using a deadband
what is an open loop
does not have any feedback and therefore cannot correct any changes (unplugging a heater, turning off a tap)
what is a closed loop
does have any feedback and therefore can correct any changes
(38)
(39)
Yorkshire water scenario:
explain d1,d2,d3
A radar sensor, set at a fixed height measures the reservoir water level, this is then converted to water depth by knowing the distance to the reservoir bottom
draw harvard and von neumann
last photo
always on - resitor is … the switch
always off - resitor is … the switch
up
down
why would you use a pull up or a pull down resistor
A pull up resistor is used to hold the signal high (+5V) as its default state, a pull down resistor
holds the signal low (0V) as its default state
What is debounce and why does it happen?
Debounce happens as mechanical switches are imperfect, the ability of the contact to make a
perfect connection instantly and hold that connection is not possible due to the surface finish
and internal reactive spring mechanism
Draw a debounce circuit, including component values for a 100ms time constant
2nd last photo
Draw a circuit for a simple analogue input such as a temperature sensor
last photo
Suitable resistor values for
Switch
PTC (thermistor)
Led
10k ohms
5k ohms
220 ohms