Professional Documents
Culture Documents
Systems
More interfacing and examples
• Latency
– Hardware delays in uC subsystems
– Software delays
Input Device:
busy done waiting busy done waiting busy
uC software:
process waiting read process waiting read
data data data data
fixed delay
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Synchronization - Interrupts
• Interrupts – hardware causes software to
execute ISR.
• Global data structures used to communicate data
between main program and ISR.
• Timer interrupts used to execute specific functions
at regular intervals.
DMA Controller
I/O
uC
device
addr
Memory
data
led
always more than the loaded
l
sta
uC can provide.
no load
• Need an interface
circuit between uC Applied voltage (volts)
and motor.
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Interfacing Motors
Digital Outputs
• Basic idea is to use a flyback diode
switch of some kind to
isolate current in uC
from motor current. External Voltage
+
• Motor is an inductor switch open current
though, so it stores
swi urren
current.
t ch
motor
c
• Flyback diode used to
cl o
sed
t
route current away from
Control
switch when switch signal from
opens to avoid damage uC
to switch.
N1
N5
+ Changing polarity of
S4 S1
phase 1
- N2 stator magnets causes
N4
step.
S3
S2
N3
1010
1.8°
1001
1.8 °
0101
1.8 °
0110
1.8 °
1010
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Output Display Example:
LCD Display
• LCD – Liquid Crystal Display
– Lower power than LED display
– More flexible in size and shape
– Slower response time
60 Hz
Oscillator
liquid crystal material
60 Hz
Oscillator
uC
Real
Control Driving control
commands Forces variables
Desired
U(t) V(t) Physical X(t)
control Actuators
variables uC Plant
X*(t)
Sensor
Sensor
Real
control
Desired variables
output + e(n) uC u(n) p(t) Physical x(t)
x* PID Actuator
- Plant
controller
x’(n)
Sensor
Actual
Desired Output
output + e(n) uC u(n) p(t) Physical x(t)
x* PID Actuator
- Plant
controller
x’(n)
Sensor
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
PID Controller
u(t) = P(t) + I(t) + D(t)
e(t) I(n)
Ki large
t n
Ki small
I(t) I(n) I(n)
∆t
t 1 2 3 4 5 n n
∆ t is sampling period
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Equation for Integral Component
Discrete time: I(n) = Ki ∆ t ∑ E(n)
= 1/∆ t
∆ t is sampling period
Desired Actual
position position
θ 1* uC θ 2(t)
(potentiometer)
uf(n) Servo p(t) DC
PI
θ 2(n) Amplifier Motor
controller ub(n)
potentiometer
multiplexor
potentiometer -15 to +15V
0 - 2.45V
voltage
conversio ADC0
ADC0.1 to SA1SOD
output n DAC0 Output Input 1
potentiometer -15 to +15V interface 0 - 2.45V DAC0
0 - 2.45V voltage
conversion to SA1SOD
DAC1 interface Input 2
DAC1
0 - 2.45V
DB (θ 1) = θ 1- θ 2