1 / 57

Embedded Microcontroller Systems

Prof. Cherrice Traver. EE/CS-152: Microprocessors and Microcontrollers. Overview. Performance metricsSynchronization methodsI/O Devices and hardware interface issuesMicrocontroller in control systemsControl block diagramsActuators, plant, sensorsOpen loop, closed loop controlProportional and

makenna
Download Presentation

Embedded Microcontroller Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


    1. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Embedded Microcontroller Systems More interfacing and examples

    2. 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

    3. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Performance Metrics 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.

    4. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Performance Metrics Latency Hardware delays in uC subsystems Software delays

    5. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Performance Metrics 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

    6. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Performance Metrics 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 low-priority request that is currently being processed. may want to implement equal priority so that no device monopolizes the uC.

    7. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Real time systems Hard real-time – guarantees a maximum latency. Soft real-time – system supports priority.

    8. 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.

    9. 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 the status flag is set.

    10. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Synchronization – Gadfly Scenarios No Buffering

    11. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Synchronization – Gadfly Scenarios Buffering

    12. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Synchronization – Blind Cycle Software waits a fixed amount of time and assumes I/O will complete within the delay. No status flag from I/O device. Used for I/O that has predictable delays.

    13. 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.

    14. 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) but infrequent. Buffering can also be used with interrupts to allow for better throughput. Must not forget that interrupts slow the main program loop!

    15. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Buffering – FIFO Queue 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.

    16. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Synchronization – Periodic Polling Periodic polling – uses a clock/timer interrupt to periodically check the I/O status. Used in cases where interrupts are desirable (there is much to do in the main program) but the I/O device does not support interrupts. Keypad is an example – will investigate in the next exercise.

    17. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers 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.

    18. 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 during cycles when the uC is not using the bus. used when uC rate is faster than I/O

    19. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Slow I/O Interface Keypad – how slow can we go?

    20. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers I/O Devices and hardware interface issues

    21. 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

    22. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers 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

    23. 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

    24. 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 mechanical energy. For some range of voltage, the torque of the motor shaft is proportional to value of voltage.

    25. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers 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.

    26. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers 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.

    27. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Interfacing Motors Digital Outputs H-Bridge – circuit topology that allows bi-directional control of motor.

    28. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers 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

    29. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers 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

    30. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Basic Operation Simplified stepper motor

    31. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Stepper Motor Interface

    32. 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

    33. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers LCD Operation 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.

    34. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers LCD Interfacing Simple parallel interface – similar to LED:

    35. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers LCD Interfacing Serial driver interface

    36. 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

    37. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers 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

    38. 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

    39. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Open-loop Control Example Stepper motor

    40. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Open-loop Control Example Traffic light controller

    41. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Closed-loop Control Feedback from plant to controller

    42. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Closed-loop Control “Bang-bang control” Bang-bang – control output can only turn something ON or OFF. No variable control. Requires a “deadband” or “hysteresis” which defines a range of acceptable values for output - otherwise the control system components can wear out from too many switching cycles. (Relays, for example, have a limited lifetime). Works well with physical plant with a slow response time.

    43. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Closed-loop Control Systems Bang-bang control – temperature control example.

    44. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Closed-loop Position Control Incremental control – adds or subtracts a small constant from the output control command, U(t), in response to X(t) sensed.

    45. 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 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.

    46. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Closed-loop Control PID Controller Faster and more accurate than previous systems. Based on linear control theory. Three components – sometimes fewer are used. Proportional – 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.

    47. 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

    48. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers PID Controller

    49. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers PID Controller

    50. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Equation for Integral Component Discrete time: I(n) = Ki ?t ? E(n)

    51. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers PID Controller

    52. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers PI Controller for Position Control

    53. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers PI Controller Hardware Setup

    54. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers

    55. 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

    56. 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 output differs from the input after it has settled. For position controller – DEADBAND is a measure of the steady state error.

    57. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Total DeadBand Measurements TDB(?1) = |DB(?1)| + | DB(-?1)|

    58. Prof. Cherrice Traver EE/CS-152: Microprocessors and Microcontrollers Control your position! Prelab – software only

More Related