Professional Documents
Culture Documents
Overview
Performance metrics Synchronization methods I/O Devices and hardware interface issues Microcontroller in control systems Control block diagrams Actuators, plant, sensors Open loop, closed loop control Proportional and integral controllers
Performance Metrics
uC I/O Device
Latency time delay between when I/O device is ready for service and when uC responds.
input device time between when data is ready and when it is actually latched into uC output device time between when device is ready for new data and when it is sent.
Performance Metrics
uC I/O Device
Latency
Hardware delays in uC subsystems Software delays
Performance Metrics
uC I/O Device
Throughput maximum data flow (bytes per second) that can be processed from the I/O device.
can be limited by uC or by I/O device can be reported as long term average or short term maximum
Performance Metrics
uC I/O Device I/O Device
Priority determines the order of service when more than two or more devices request at the same time.
determines if a high-priority device can suspend a lowpriority request that is currently being processed. may want to implement equal priority so that no device monopolizes the uC.
Synchronization Methods
I/O devices can be in one of 3 states
idle disabled or inactive, no I/O occurs busy working on generating an input (input I/O) or accepting an output (output I/O) done ready for a new transaction.
done
busy
done
I/O bound
waiting read data
Input Device:
busy done waiting busy done waiting busy
CPU bound
read process data data read process data data
BUFFER
As long as buffer is large enough, both software and I/O can operate at their maximum rate
process data
uC software:
fixed delay
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.
Synchronization - Interrupts
Use interrupts when:
Arrival times of input is variable. There are other things to do in main program. I/O is important (alarm, hardware failure) but infrequent.
Buffering can also be used with interrupts to allow for better throughput. Must not forget that interrupts slow the main program loop!
Data is received (Get) in the same order that it was transmitted (Put) As long as FIFO is not full or empty, both producer and consumer operate at their own rate. Need a way for producer and consumer to know if FIFO is full or empty.
Synchronization - DMA
Direct Memory Access I/O transfers data directly to/from memory.
Requires a DMA controller between memory and I/O device. Used when bandwidth and latency are important parameters. Data transfer only no processing of data.
DMA
Burst mode DMA a block transferred while the uC is halted
used when uC and DMA rates are similar
Cycle-stealing DMA data is transferred during cycles when the uC is not using the bus.
used when uC rate is faster than I/O DMA Controller uC
I/O device
Input devices
I/O Categories
Sensors, User-input
Output devices
Actuators, Displays
Analog I/O
Voltage levels Current draw Sampling frequency Noise
Digital I/O
- Voltage levels - Synchronization - Throughput - Noise
Input Examples
Sensors
light force sound position orientation proximity tactile temperature pressure humidity speed acceleration displacement
User input
keyboards joysticks mouse keypad switches touchpad dial slider
Output Examples
Actuators
motors solenoids relays heaters lights piezoelectric materials (buzzers, linear actuator) speakers
Displays
LED displays LCD displays CRT displays indicator lights indicator gauges
Example DC Motor
Important in LOTS of applications
cameras, drives, elevators, trains, robots
DC Motor
Current required by motor depends on how it is loaded. Current is almost always more than the uC can provide. Need an interface circuit between uC and motor.
Motor current (A)
loaded no load
Interfacing Motors
Digital Outputs
Basic idea is to use a switch of some kind to isolate current in uC from motor current. Motor is an inductor though, so it stores current. Flyback diode used to route current away from switch when switch opens to avoid damage to switch.
flyback diode External Voltage +
Interfacing Motors
Digital Outputs H-Bridge circuit topology that allows bidirectional control of motor.
Each switch controlled by an output of the uC.
motor
+ external voltage -
Switches implemented by relays, solid-state switches, or transistors Diodes omitted for simplicity.
Interfacing Motors
Analog Output 8051 DAC can provide up to 15 mA of current, up to 3.3V voltage. Must provide both voltage and current amplification to drive a DC motor.
Amplifiers Power MOSFETs Motor driver ICs Relays
used in the upcoming control lab
Stepper Motors
Inherent digital interface Can easily control both position and velocity Used in disk drives, printers, etc. Small, fixed rotation per change in control signals
Basic Operation
Simplified stepper motor
phase 2 + + phase 1 -
5 teeth 360 5 = 72 moves 72 per step Changing polarity of stator magnets causes step.
rotor
electromagnets stator
Typical stepper motors have 200 steps per revolution, with 1.8 per step.
AC voltage required DC voltage damages LCD Control changes reflectivity of the liquid crystal material. Actual light energy supplied by room light or back light. front plane
CMOS
back plane control
LCD Operation
60 Hz Oscillator
LCD Interfacing
Simple parallel interface similar to LED:
VDD 8051
7-segment LCD Driver/Decoder
Separate Front Planes a b c d e f g
port pins
60 Hz Oscillator
A B C D
LCD Interfacing
Serial driver interface
data in
clock
data out
Some Terminology
Control variables properties we want to control (position, velocity, temperature, etc) Control commands output to actuators Driving forces the actuator forces that cause the control variables to change (heat, force, etc) Physical plant the thing being controlled
uC
Actuators
Plant
uC
Actuators
Plant
uC
stepper motor
shaft position
uC
Closed-loop Control
Feedback from plant to controller
Control commands U(t)
uC
Actuators
Plant
Sensor
plant
Heater
uC
T > Thigh
T
Leave
T < Tlow
Temperature sensor
Turn off
Turn on
uC
+1 or -1
Actuators
Plant
Sensor
Incremental Control
Rate of sampling is very important
If sampling rate is too fast, actuators are saturated and a bang-bang system results. If sampling rate is too slow, then controller will not keep up with plant.
Rule of thumb for rate: control execution rate is 10x the step response of the plant. Must check for underflow and overflow after increment or decrement.
PID Controller
To understand, must transform parts of control diagram into discrete time domain. Very important to have periodic sampling and processing. In the figure below, n is the sample number
Real control variables x(t) Physical
Desired output + x*
e(n)
uC
PID controller
u(n)
Actuator
p(t)
x(n)
Plant
Sensor
error signal: e(n) = x*(n) - x(n)
PID Controller
u(t) = P(t) + I(t) + D(t)
Proportional output is proportional to error input Continuous time: P(t) = Kp * E(t) Discrete time: P(n) = Kp * E(n)
Desired output + x*
e(n)
uC
PID controller
u(n)
Actuator
p(t)
x(n)
Physical Plant
Sensor
PID Controller
u(t) = P(t) + I(t) + D(t)
Integral output is proportional to integral of error signal Continuous time: I(t) = Ki E(t) dt Discrete time: I(n) = Ki E(n) t = Ki t E(n) e(t) t I(t) t I(n)
t
I(n)
Ki large
n
I(n)
1 2 3 4 5
Ki small
n t is sampling period
= 1/t
PID Controller
u(t) = P(t) + I(t) + D(t)
Derivative output is proportional to derivative of error signal dE Continuous: D(t) = Kd* dt Discrete: D(n) = Kd * E(n) E(n-1) t t is sampling period
uC
ADC0.0
0 - 2.45V
multiplexor
ADC0
DAC0 DAC0
0 - 2.45V
ADC0.1
0 - 2.45V
DAC1
DAC1
0 - 2.45V
to SA1SOD Input 1
PI Control Algorithm
Controller must execute the following tasks:
Sample inputs Compute error value Compute integral value Compute output signal from error value, integral value and preset Kp and Ki. Send computed output signals to amplifier
output position
2
DB (1) = 1- 2
DB (-1) = 2- 1