ece 495: integrated system design i clemson u n i v e r s i t y introduction to real- time,...

23
1 ECE 495 – Integrated System Design I ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real-Time, Closed-loop Control

Upload: wade-gaye

Post on 29-Mar-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

ECE 495: Integrated

System Design I

CLEMSONU N I V E R S I T Y

Introduction to Real-Time, Closed-loop

Control

Page 2: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

2ECE 495 – Integrated System Design I

Outline

• Real-time systems–Motivation– Examples– xPC target

• Closed-loop Systems–Motivation

• Real-time, Closed-loop Systems– Apply theory from ECE409 to a physical system

• Implementing Real-time, Closed-loop Systems– xPC target + Quanser hardware

Page 3: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

3ECE 495 – Integrated System Design I

Real-time System

Computer-based execution of a program loop:

Instructions or algorithm

System

Speed and predictability of execution times

distinguish systems

Real-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.http://www.ece.cmu.edu/~koopman/des_s99/real_time/

Page 4: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

4ECE 495 – Integrated System Design I

Classification of Real-time Systems

http://www.ece.cmu.edu/~koopman/des_s99/real_time/

Real-time System

Soft Hard

Dynamic Static

System must remain synchronous with the

state of the environment.

Degraded operation in a rarely occurring peak load can be tolerated.

Timing parameters for the system are set during

compilation.

Timing parameters and the priority for tasks is

modified at run-time.

Page 5: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

5ECE 495 – Integrated System Design I

HardReal-time

System

SoftReal-time

System

Example: Produce a sinusoid output

D/A

D/A

Error in output

waveform

Error in execution time

Classification of Real-time Systems

Page 6: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

6ECE 495 – Integrated System Design I

Examples of Real-time Systems

QUARC from QuanserSoft Real-time System using PC

with Windows

QUARC from QuanserHard Real-time System using QNX

Page 7: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

7ECE 495 – Integrated System Design I

Hardware Systems in ECE 495

Amplifier

Motor

If 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!

Page 8: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

8ECE 495 – Integrated System Design I

Which system would you use in ECE 495?

Real-time System

Soft Hard

Dynamic Static

Systems

Non-Real-time System

Speed and predictability are both critical

Response to input has to come at a precise time

System timing parameters are known before execution

In ECE 495, we use a Static, Hard Real-Time System

Page 9: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

9ECE 495 – Integrated System Design I

How is a Real-time System formulated?

More generally, to Relate Theory to Application

ContinuousProcess

DigitalSystem

Model ofContinuous

Process

1. Want to measure or control this

process

2. Use engineering tools to model the process using continuous or fixed

sample time discrete models(For example ECE409, ECE 467)

3. Formulate interaction algorithms based on the models(For example ECE409, ECE 467)

4. Execute algorithms(assume a continuous system

can be approximated by a “fast” digital system)

Design

Error if execution timing doesn’t match assumptions in model and algorithms - results are not predictable.

Page 10: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

10ECE 495 – Integrated System Design I

Real-time System – xPC Target

Page 11: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

11ECE 495 – Integrated System Design I

Real-time System – xPC Target

Design a Simulink model on the host PC

Program is downloaded to target for real-time execution

Boot CD installs a real-time kernel on target

Build the Simulink model Host and target coordinate for downloading

programs

Some parameters can be changed on host. This change is communicated to target.

Host Target

Page 12: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

12ECE 495 – Integrated System Design I

Closed-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 wrong • If flow rate is not exactly as expected then the level will be wrong.• Inaccurate time will lead to the wrong level

Desired level

Actual level

Page 13: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

13ECE 495 – Integrated System Design I

Closed-Loop Control System

Closed-loop control:• 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

Page 14: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

14ECE 495 – Integrated System Design I

Closed-Loop Control System

System

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

Output

Feedback

Desired output

=Error+

_

Input

Page 15: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

15ECE 495 – Integrated System Design I

Real-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)

SystemOutput

Feedback

Desired output +

_

Input

Page 16: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

16ECE 495 – Integrated System Design I

Real-time Closed-loop Control

Typical response times and the applications which need them …

Seconds : Temperature, pressure, and flow control; aircraft control

Milliseconds (control with < 1 kHz): Productions lines, motor control, robot control

Microseconds : High speed test stands, fast digital controllers, control with 5 kHz – 500 kHz

Page 18: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

18ECE 495 – Integrated System Design I

The utility of MATLAB Simulink

MATLAB/Simulink are used to prototype, simulate and visualize performance of systems.

Math model of system

MATLAB Simulink Model

Visualization: Plots, Scopes,

etc.

Page 19: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

19ECE 495 – Integrated System Design I

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

Page 20: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

20ECE 495 – Integrated System Design I

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

Page 21: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

21ECE 495 – Integrated System Design I

Implementing Real-time, Closed-loop Systems

• 4 x 14 bit Analog Inputs• 4 x 12 bit D/A Outputs• 4 Quadrature Encoder Inputs• 16 Programmable Digital IO Channels• 2 x 32 bit dedicated Counter/ Timers• 2 External Interrupt sources• 32 bit, 33MHz PCI Bus Interface

Quanser Q4 card in the Target PC

To terminal board

Page 22: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

22ECE 495 – Integrated System Design I

Implementing Real-time, Closed-loop Systems

DAC

Channels

Ext Interrupt and Signal Pins

ADC

Channels

Encoder

Channels

Digital IO

Ports

From Q4 board

Q4 Terminal Board

Page 23: ECE 495: Integrated System Design I CLEMSON U N I V E R S I T Y Introduction to Real- Time, Closed-loop Control

23ECE 495 – Integrated System Design I

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