Presentation on theme: "ECE 495: Integrated System Design I"— Presentation transcript:
1ECE 495: Integrated System Design I CLEMSONU N I V E R S I T YECE 495: Integrated System Design IIntroduction to Real-Time, Closed-loop Control
2OutlineReal-time systemsMotivationExamplesxPC targetClosed-loop SystemsReal-time, Closed-loop SystemsApply theory from ECE409 to a physical systemImplementing Real-time, Closed-loop SystemsxPC target + Quanser hardware
3Real-time System Computer-based execution of a program loop: Speed and predictability of execution times distinguish systemsInstructionsor algorithmSystemReal-time system: the correctness of the system behavior depends not only on the logical results of the computations, but also on the physical instant at which these results are produced.
4Classification of Real-time Systems System must remain synchronous with the state of the environment.Degraded operation in a rarely occurring peak load can be tolerated.SoftHardDynamicStaticTiming parameters and the priority for tasks is modified at run-time.Timing parameters for the system are set during compilation.
5Classification of Real-time Systems Example: Produce a sinusoid outputHardReal-timeSystemD/AError in output waveformSoftReal-timeSystemD/AError in execution time
6Examples of Real-time Systems QUARC from QuanserSoft Real-time System using PC with WindowsQUARC from QuanserHard Real-time System using QNX
7Hardware Systems in ECE 495 MotorAmplifierIf you were controlling the position of the motor, you would want the motor to stop at a certain shaft angle. But you would also want to stop at the right time to prevent overshooting and potentially damaging components!
8Which system would you use in ECE 495? SystemsSpeed and predictability are both criticalNon-Real-time SystemReal-time SystemResponse to input has to come at a precise timeSoftHardSystem timing parameters are known before executionDynamicStaticIn ECE 495, we use a Static, Hard Real-Time System
9How is a Real-time System formulated? More generally, to Relate Theory to ApplicationDigitalSystem4. Execute algorithms(assume a continuous system can be approximated by a “fast” digital system)ContinuousProcess1. Want to measure or control this processError if execution timing doesn’t match assumptions in model and algorithms - results are not predictable.Design3. Formulate interaction algorithms based on the models(For example ECE409, ECE 467)2. Use engineering tools to model the process using continuous or fixed sample time discrete models(For example ECE409, ECE 467)Model ofContinuousProcess
11Real-time System – xPC Target HostTargetDesign a Simulink model on the host PCBoot CD installs a real-time kernel on targetBuild the Simulink modelHost and target coordinate for downloading programsProgram is downloaded to target for real-time executionSome parameters can be changed on host. This change is communicated to target.
12Closed-Loop Control System Open-loop control:Input designed to move the system to a desired state based on current conditions and model of the system.Example: Fill a water tank to a specified level based on flow-rate and time.If some of the water evaporates during filling then the level will be wrongIf flow rate is not exactly as expected then the level will be wrong.Inaccurate time will lead to the wrong levelDesired levelActual level
13Closed-Loop Control System Input changes as the error, difference between the desired output and the measured output, changes.Example – fill a tank to a specified level based on measuring the tank level and turning flow “on” or “off” to reach the desired level.Anything that prevents the tank from being filled to the desired level will be compensated.Desired level = Actual level
14Closed-Loop Control System Desired outputInput=ErrorOutput+System_FeedbackOpen-loop control:Input designed to move the system to a desired state without knowing if it achieves the stateClosed-loop control:Input= changes as the error based on output until a desired state is reached.
15Real-time Closed-loop Control What is Real-time Control ?Any change in the feedback produces change in the input to the system within the guaranteed response time. (Hard Real Time Control)Desired outputInputOutput+System_Feedback
16Real-time Closed-loop Control Typical response times and the applications which need them …Seconds : Temperature, pressure, and flow control; aircraft controlMilliseconds (control with < 1 kHz): Productions lines, motor control, robot controlMicroseconds : High speed test stands, fast digital controllers, control with 5 kHz – 500 kHz
17Implementing Real-time, Closed-loop Systems HostMATLAB with SimulinkC++Desired outputSystemInputOutput+_Target PCOSQ4 Control Board and Terminal BoardFeedback
18The utility of MATLAB Simulink MATLAB/Simulink are used to prototype, simulate and visualize performance of systems.Math model of systemMATLAB Simulink ModelVisualization: Plots, Scopes, etc.
19Why MATLAB/SIMULINK over C++? MATLAB is a huge collection of C/C++ libraries for system prototyping and hardware interfacing.No need to reinvent the wheel! Would you rather spend weeks writing device drivers and libraries for the Q4 than test your system in a few hours?Prototyping ideas is easy and fast.Visualization of data is easy.
20Using C/C++ Code in MATLAB MATLAB allows the use of user defined C/C++ executables (MEX files) to augment functionality.Computationally expensive tasks can be carried out using C and data can be sent to MATLAB. E.g. Camera interfacing for image processing.Specific manipulation of data can be programmed into a user defined function (called the S-function) in Simulink. S-functions are C-code snippets embedded in the Simulink environment.
21Implementing Real-time, Closed-loop Systems Quanser Q4 card in the Target PCTo terminal board4 x 14 bit Analog Inputs4 x 12 bit D/A Outputs4 Quadrature Encoder Inputs16 Programmable Digital IO Channels2 x 32 bit dedicated Counter/ Timers2 External Interrupt sources32 bit, 33MHz PCI Bus Interface
22Implementing Real-time, Closed-loop Systems Q4 Terminal BoardFrom Q4 boardDACChannelsADCChannelsExt Interrupt and Signal PinsEncoderChannelsDigital IOPorts
23A final thought …The Q4 cards being used for data acquisition and control are very useful… and very expensive. Read the manuals for voltage limitations and proper use.