Embedded Micro Controller Systems
-
Upload
mateja-yango -
Category
Documents
-
view
216 -
download
0
Transcript of Embedded Micro Controller Systems
-
8/8/2019 Embedded Micro Controller Systems
1/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Embedded Microcontroller
SystemsMore interfacing and examples
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
2/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
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
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
3/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Performance Metrics
Latency time delay between when I/Odevice is ready for service and when uCresponds. 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.
uCI/O Device
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
4/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Performance Metrics
Latency Hardware delays in uC subsystems Software delays
uCI/O Device
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
5/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Performance Metrics
Throughput maximum data flow (bytes per second) that can be processed from theI/O device. can be limited by uC or by I/O device can be reported as long term average or short
term maximum
uC I/O Device
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
6/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Performance Metrics
Priority determines the order of service whenmore than two or more devices request at the sametime. determines if a high-priority device can suspend a low-
priority request that is currently being processed. may want to implement equal priority so that no device
monopolizes the uC.
uC I/O Device
I/O Device
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
7/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Real time systems
Hard real-time guarantees a maximumlatency.
Soft real-time system supports priority.
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
8/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
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.
Busy to done transitions cause status flags to become true.
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
9/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Synchronization Gadfly Loop
Polling loop Gadfly loop Busy-waiting loop software checks status
flag in a loop that does not exit until thestatus flag is set.
waiting for input - busy
new input isready - done
new data, gadfly loop completes
software reads data, asks for another
INPUTDEVICE:
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
10/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Synchronization Gadfly Scenarios No Buffering
busy done busy doneInput Device:
waiting for new
input
read
data
process
datawaiting read
data
uC software: I/O bound
busy done
Input Device:
readdata
waiting
uC software: processdata
CPU bound
readdata
processdata
busy done waiting
processdata
busy
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
11/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Synchronization Gadfly ScenariosBuffering
busy done
Input Device:
readdata
uC software:
processdata
readdata
processdata
busy done
processdata
busy
BUFFER
done busy
As long as buffer is large enough, both software
and I/O canoperate at their maximum rate
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
12/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Synchronization Blind Cycle
Software waits a fixed amount of time andassumes I/O will complete within the delay.
No status flag from I/O device.
Used for I/O that has predictable delays.
busy done busy doneInput Device:
processdata
waiting readdata
uC software: processdata
waiting readdata
fixed delay
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
13/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Synchronization - Interrupts
Interrupts hardware causes software toexecute ISR.
Global data structures used to communicate data
between main program and ISR. Timer interrupts used to execute specific functions
at regular intervals .
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
14/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
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) butinfrequent.
Buffering can also be used with interrupts toallow for better throughput.
Must not forget that interrupts slow the main program loop!
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
15/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Buffering FIFO Queue
Data is received (Get) in the same order that it wastransmitted (Put)
As long as FIFO is not full or empty, both producer andconsumer operate at their own rate.
Need a way for producer and consumer to know if FIFO isfull or empty.
Producer (uC or I/O)
Consumer (uC or I/O)FIFO
Put Get
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
16/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Synchronization Periodic Polling
Periodic polling uses a clock/timer interrupt to periodically check the I/Ostatus.
Used in cases where interrupts are desirable(there is much to do in the main program) butthe I/O device does not support interrupts.
Keypad is an example will investigate in thenext exercise.
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
17/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Synchronization - DMA
Direct Memory Access I/O transfers datadirectly 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.
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
18/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
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 duringcycles when the uC is not using the bus. used when uC rate is faster than I/O
uC
DMA Controller
Memory
I/Odeviceaddr
data
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
19/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Slow I/O Interface
Keypad how slow can we go?
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
20/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
I/O Devices and hardware interfaceissues
Overview: Categories of I/O Input and Output examples
Output actuator examples DC Motor (analog and digital control) Stepper Motor
Output display example
LCD display (parallel and serial)
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
21/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
I/O Categories Input devices
Sensors, User-input
Output devices Actuators, Displays
Complex I/O devices (printers, faxes, coprocessors, etc)
Analog I/O Digital I/O Voltage levels - Voltage levels Current draw - Synchronization Sampling frequency - Throughput Noise - Noise
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
22/58
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
23/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
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
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
24/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Example DC Motor
Important in LOTS of applications cameras, drives, elevators, trains, robots
Many types, but all work similarly: Apply voltage across + and leads,
electrical energy is converted to mechanicalenergy.
For some range of voltage, the torque of themotor shaft is proportional to value of voltage.
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
25/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
DC Motor
Current required bymotor depends onhow it is loaded.
Current is almostalways more than theuC can provide.
Need an interfacecircuit between uCand motor.
Applied voltage (volts)
no load
loaded s t a l l e
d
Motor current(A)
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
26/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Interfacing MotorsDigital Outputs
Basic idea is to use aswitch of some kind toisolate current in uCfrom motor current.
Motor is an inductor though, so it storescurrent.
Flyback diode used to
route current away fromswitch when switchopens to avoid damageto switch.
motor
External Voltage+
Controlsignal from
uC
flyback diode
s w i t c h c l o s e d
c u r r e n t
switch open current
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
27/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Interfacing MotorsDigital Outputs
H-Bridge circuit topology that allows bi-directional control of motor.
motor
+externalvoltage
-
Each switch
controlled by anoutput of the uC.
Switchesimplemented byrelays, solid-stateswitches, or transistors
Diodes omitted for simplicity.
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
28/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Interfacing MotorsAnalog Output
8051 DAC can provide up to 15 mA of current, up to 3.3V voltage.
Must provide both voltage and currentamplification to drive a DC motor. Amplifiers Power MOSFETs Motor driver ICs Relays
used in the upcoming control lab
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
29/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Stepper Motors
Inherent digitalinterface
Can easily control both position andvelocity
Used in disk drives, printers, etc.
Small, fixed rotation per change in controlsignals
http://images.google.com/imgres?imgurl=www.interq.or.jp/japan/se-inoue/picture/step1.jpg&imgrefurl=http://www.interq.or.jp/japan/se-inoue/e_step.htm&h=382&w=533&sz=25&tbnid=fRACYB_AJrkJ:&tbnh=92&tbnw=128&start=7&prev=/images%3Fq%3Dstepper%2Bmotor%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26sa%3DGhttp://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
30/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Basic Operation
Simplified stepper motor
N 1
N 2 N 3
N 4
S 1
S 2 S 3
S 4
S 5 N
5 + phase 1
-
- phase 2
+
5 teeth360 5 = 72 moves 72 per step
Changing polarity of stator magnets causesstep.
Typical stepper motors have 200 steps
per revolution, with1.8 per step.stator
rotor
electromagnets
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
31/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Stepper Motor Interface
8051
port pins
AABB
VDD
Inverting buffers
+Vmotor
10101001010101101010
4-phasestepper motor
1.8 1.8 1.8 1.8
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
32/58
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
http://images.google.com/imgres?imgurl=www.armyradio.com/Pictures/Radios/British%2520Radios/Ship%2520Speed%2520LCD%2520Display%2520B1.jpg&imgrefurl=http://www.armyradio.com/publish/Bits_and_Pieces.htm&h=280&w=516&sz=23&tbnid=V6QB4wcwzVgJ:&tbnh=69&tbnw=127&start=5&prev=/images%3Fq%3DLCD%2Bdisplay%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26sa%3DGhttp://images.google.com/imgres?imgurl=www.irtrans.de/images/products/lcd-blau-640.jpg&imgrefurl=http://www.irtrans.de/lcd.htm&h=394&w=640&sz=28&tbnid=giPgHHLkoMAJ:&tbnh=83&tbnw=134&start=13&prev=/images%3Fq%3DLCD%2Bdisplay%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26sa%3DGhttp://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
33/58
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
34/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
LCD Interfacing
Simple parallel interface similar to LED:
8051
7-segmentLCD
Driver/Decoder
port pins
ABC
D
a bcdef
g
60 HzOscillator
Common Back Plane
Separate Front Planes
VDD
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
35/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
LCD Interfacing
Serial driver interface
48 bit shift register
48 bit latch register
MC145000 LCD Driver
BP1 BP2 BP3 BP4 FP1 FP2 FP3 FP4 FP5 FP6 FP7 FP8 FP9 FP10 FP11 FP12
48 segment LCD display
data in
clock data out
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
36/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Using Microcontrollers for Control
Overview Open-loop control systems Simple closed-loop control systems
Closed-loop position control PID controllers
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
37/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Some Terminology
Control variables properties we want tocontrol (position, velocity, temperature, etc)
Control commands output to actuators
Driving forces the actuator forces thatcause the control variables to change (heat,force, etc)
Physical plant the thing being controlled
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
38/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Open-loop Control Systems
No feedback path from the plant Note that these are all a function of time
uC ActuatorsPhysical
Plant
Desiredcontrol
variablesX*(t)
Controlcommands
U(t)
DrivingForcesV(t)
Real
controlvariablesX(t)
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
39/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Open-loop Control Example
Stepper motor
uC ActuatorsPhysical
Plant
Controlcommands
U(t)
DrivingForces
V(t)
Realcontrol
variablesX(t)
uC
Desiredcontrol
variablesX*(t)
Invertingdriving buffers
stepper motor shaft position
desired
shaft positionspecified
in program
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
40/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Open-loop Control Example
Traffic light controller
uC
Invertingdriving buffers
desired light patternin software
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
41/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Closed-loop Control
Feedback from plant to controller
uC ActuatorsPhysical
Plant
Desiredcontrol
variablesX*(t)
Controlcommands
U(t)
DrivingForcesV(t)
Real
controlvariablesX(t)
Sensor
Cl d l C l
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
42/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Closed-loop ControlBang-bang control
Bang-bang control output can only turn something ONor OFF. No variable control.
Requires a deadband or hysteresis which defines a
range of acceptable values for output - otherwise thecontrol system components can wear out from too manyswitching cycles. (Relays, for example, have a limitedlifetime).
Works well with physical plant with a slow responsetime.
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
43/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Closed-loop Control Systems Bang-bang control temperature control
example.
Heater
Temperaturesensor
uC
plantDesired temperature,
Tlow < T < Thigh
estimate T
TT
Turn off Leave Turn on
T > Thigh T < Tlow
Flowchart of control algorithm
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
44/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Closed-loop Position Control
Incremental control adds or subtracts a smallconstant from the output control command, U(t),in response to X(t) sensed.
uC+1or -1
Actuators PhysicalPlant
Desiredcontrol
variablesX*t
ControlcommandsU(t)
DrivingForcesV(t)
Real
controlvariablesX(t)
Sensor
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
45/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
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 willnot keep up with plant.
Rule of thumb for rate: control executionrate is 10x the step response of the plant.
Must check for underflow and overflowafter increment or decrement.
l d l l
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
46/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Closed-loop ControlPID Controller
Faster and more accurate than previous systems. Based on linear control theory. Three components sometimes fewer are used.
P roportional output is linearly related to error signal.
Integral output is related to integral of the error
signal.
Derivative output is related to derivative of the error.
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
47/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
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
uCPID
controller Actuator
PhysicalPlant
Desiredoutput
x*u(n) p(t)
Real
controlvariablesx(t)
Sensor x(n)
e(n)
error signal: e(n) = x*(n) - x(n)
+
-
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
48/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
PID Controller
uCPID
controller
Actuator Physical
Plant
Desiredoutput
x* u(n) p(t)
ActualOutput
x(t)
Sensor x(n)
e(n)+
-
u(t) = P(t) + I(t) + D(t)
Proportional output is proportional to error inputContinuous time: P(t) = Kp * E(t)Discrete time: P(n) = Kp * E(n)
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
49/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
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)
t is sampling period
e(t)
t
I(t)
t
I(n)
n
t
1 2 3 4 5
I(n)
n
Ki large
I(n)
n
Ki small
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
50/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Equation for Integral Component
Discrete time: I(n) = Ki t E(n)
integral += errorsig; //integral = integral + errorsig//integral is sum of errorsignals
//integral includes: M_MEAS samples of error //multiplied by GAIN_PRECISION
...output = Kp*errorsig / M_MEAS/GAIN_PRECISION +
Ki * integral / M_MEAS / SAMPLERATE /GAIN_PRECISION
= 1/ t
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
51/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
PID Controller u(t) = P(t) + I(t) + D(t)
Derivative output is proportional to derivative of error signal
Continuous: D(t) = Kd*dEdt
E(n) E(n-1) t
Discrete: D(n) = Kd *
t is sampling period
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
52/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
PI Controller for Position Control
uCPI
controller ServoAmplifier DCMotor
uf (n)
p(t)
Actual position
2(t)
Desired position
1*
(potentiometer)
potentiometer
2(n) u b(n)
(we will not use the derivative term, which can cause instability)
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
53/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
PI Controller Hardware Setup
8051Microcontroller
ADC0
Inputvoltage
conversion
interface
ADC0.0
ADC0.1
setpointpotentiometer
outputpotentiometer
0 - 2.45V
0 - 2.45V-15 to +15V
-15 to +15V
Output
voltageconversioninterface
DAC0
DAC1
0 - 2.45V
0 - 2.45V
m u l t i p l e x o r
DAC0
DAC1
to SA1SODInput 1
to SA1SODInput 2
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
54/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Circuit Schematics for Interface Circuits
Input voltage conversion interface Output voltage conversioninterface
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
55/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
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
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
56/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Controller Performance Metrics
Stability a requirement Response time how fast the output responds
to the input.
Steady state error how much the outputdiffers from the input after it has settled.
For position controller DEADBAND is ameasure of the steady state error.
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
57/58
Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers
Total DeadBand Measurements
TDB( 1) = |DB( 1)| + | DB(- 1)|
input position output position 1 2
DB ( 1) = 1- 2
repeat for a negative angle, - 1 DB (- 1) = 2- 1
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8 -
8/8/2019 Embedded Micro Controller Systems
58/58
Control your position!
Prelab software only
http://images.google.com/imgres?imgurl=www.atarimagazines.com/startv4n10/microprocessor.jpg&imgrefurl=http://www.atarimagazines.com/startv4n10/news_notes_quotes.html&h=284&w=262&sz=13&tbnid=nqaEbd2Z-lAJ:&tbnh=109&tbnw=101&prev=/images%3Fq%3Dmicroprocessor%26hl%3Den%26lr%3Dlang_en%26ie%3DUTF-8%26oe%3DUTF-8