Lecture 2 non linear control system

21
1 In this lecture, you will learn the following. 1. Basics of real-time control engineering 2. Effects of fixed and unfixed (also probably unknown) sampling rate on the control system performance. By using a simple system, we will demonstrate the effects of use of an real-time system and a nonreal-time system on the controller performance.

Transcript of Lecture 2 non linear control system

Page 1: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 1/21

1

In this lecture, you will learn the following.

1. Basics of real-time control engineering

2. Effects of fixed and unfixed (also probably unknown) sampling rate on the control systemperformance.

By using a simple system, we will demonstrate the effects of use of an real-time system anda nonreal-time system on the controller performance.

Page 2: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 2/21

2

1. Basics of Real-Time Control Engineering

Vast majority of the computer based systems operates in a way that some data produced bysensors or by something else are written to a file, which this may be a text (.txt) file or a datafile (.dat), then the data are read by the computer, and the results produced by the algorithmembedded into the computer is written a file again.

A real-time system, on the other hand, must be able to keep up with external events. Writing

to or reading from a file takes a while and this may cause loosing some events occurringduring the reading and/or writing period.

Consider our famous motor control system again. It will be meaningless to write the speedand current information produced by speed and current sensors to a file, run the controlalgorithm by reading the data from the file, and finally write the resulting voltage information

to a file again. During reading and writing period, a huge load may be suddenly loaded to themotor, and the control system will be failed to maintain the control objective in such a case.

This example reveals only the “fastness” aspect of the real time systems. Let us take a lookthe definition of real time systems made by IEEE:

Page 3: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 3/21

3

1. Basics of Real-Time Control Engineering

A real-time system is one in which the correctness of a result not only depends onthe logical correctness of the calculation but also upon the time at which the resultis made available . *

This definition emphasizes the notion that time is one of the most important entities of thesystem, and there are timing constraints associated with systems tasks. Such tasks have

normally to control or react to events that take places in the outside world, which arehappening in “real time ”. Thus, a real-time task must be able to keep up with external events,with which it is concerned. **

*IEEE POSE Standard (Portable Operation System Interface for Computer Environments)

** Real-time Control Systems: A Tutorial, A. Gambier

Page 4: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 4/21

4

1. Basics of Real-Time Control Engineering In general, real-time implementation of an analog feedback control system involves the

following components.

System to becontrolled

State measurementsensors for feedback

Data acquisitionsystem

PC-based system witha real-time softwareDrive system

Sensors measure the system states for feedback and produce a low amplitude electrical signal(voltage or current). A data acquisition system (generally a data acquisition card, or inputports of a microcontroller) receives this signal, converts it to a digital signal, and then sends toPC-based system that runs the control algorithm designed. Information produced by thecontrol algorithm is sent by PC-based system (a host PC, or microprocessor unit of amicrocontroller) to data acquisition system again. Data acquisition system converts this signalto an analog signal, and then sends it to drive system via its output ports. Main function ofthe drive system is to produce drive signals proper for the plant, that is, the system to becontrolled. The drive system may be linear amplifier, or a power electronic system.

Page 5: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 5/21

Page 6: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 6/21

6

Real-time System

Soft Hard

Dynamic Static

SYSTEMS

Non-Real-time System

Speed and predictability areboth critical.

Response to input has tocome at a precise time.

System timingparameters are knownbefore execution.

Emphasis will not be upon the theory of real-time systems in this class. Instead, we willintroduce the hardware and software that we will use during the experiments. But, even so,some important points explained below should be considered.

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

Degraded operation in ararely occurring peak load

can be tolerated.

Timing parameters and thepriority for tasks is modifiedat run-time.

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

Page 7: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 7/21

7

HardReal-timeSystem

SoftReal-timeSystem

D/A

D/A

Error in outputwaveform

Error in executiontime

Example: Produce a sinusoid output

Page 8: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 8/21

8

MATLAB/SIMULINK have a toolbox called xPC Target. This toolbox enables you to real-timecontrol prototyping and testing. It provides a library of drivers, a real-time kernel, and a host-target interface for real-time monitoring, parameter tuning, and data logging. You create areal-time testing environment for Simulink models by connecting a host computer (a laptop),a target computer (a desktop), and your hardware under test (PMDC motor). You connectthe host computer running xPC Target, Simulink, and a C compiler to the target computer viaa single TCP/IP communications link (an ethernet cable). You then connect the targetcomputer to your hardware under test and download code generated by Simulink Coder

from a Simulink model to the target computer via the communication links.

Page 9: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 9/21

9

You create an xPC Target application using xPC Target with Simulink Coder to automaticallygenerate and compile a C/C++ code representation of a Simulink model. You then

download the target application via a LAN (Ethernet) connection from the host computerto the target computer.

xPC Target enables you to access the target application and control it directly from thehost computer using either the xPC Target Explorer tool or the MATLAB command line. Youcan download your target application, start and stop real-time test execution, change the

sample time and stop time, and modify other target application properties.

To monitor and acquire data, xPC Target includes scopes for both the host and targetcomputers. Scopes support several trigger modes you can use to control the acquisition,timing, and duration of data collection. You can also display multiple signals in a singlescope and attach multiple scopes to a single model.

Signal monitoring enables you to view signal values at the current sample rate. Signaltracing lets you capture, store, and display bursts of data, similar to the behavior of adigital oscilloscope. Signal logging lets you acquire and store signals during the entire testexecution. You can then upload the logged data to the host computer for signal display,analysis, or archiving.

Page 10: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 10/21

Design a Simulinkmodel 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 fordownloading programs

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

Host Computer Target Computer

Page 12: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 12/21

• 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 provides data acquisition for feedback. Output ports ofthe card is used to send the control signal calculated by the control algorithm implementedin Simulink to the linear amplifier.

Page 13: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 13/21

13

Analog Out (D/A)Channels

Ext Interrupt andSignal Pins(PWM,Watchdog)

Analog In (A/D)

Channels

Encoder

Channels

Digital I/O Ports

From Q4 board

Q4 Terminal Board

Page 14: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 14/21

14

Finally, a linear amplifier is used to produce actual control signals to be applied the system.

Page 16: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 16/21

16

The software and hardware introduced so far are not the only option to design andimplement real time control systems. These are the things available in our labs.

Of course there are some other software/hardware combinations to achieve a good realtime performance. For example dSPACE provides a very useful hardware (dSPACE dataacquisition card) and software (Real Time Interface - RTI) to implement the controlalgorithms embedded in MATLAB/Simulink environment.

Page 17: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 17/21

17

2. Real Time vs. Non-Real Time

In this section, we will use a very simple system to compare the effects of use of a real timesystem and a non-real time system on the controller performance.

Consider the following first-order scalar system dynamics;

x x u where x is the state variable and u is the control input. The control objective is to drive x toa desired trajectory, xd . To observe the performance of the controller to be designed, anerror signal can be defined as follows:

d e x x Let’s use a simple PID controller to stabilize the system,

( ) ( ) ( ) ( ) p d I u t K e t K e t K e t dt

where K p, K d , and K I are control gains. Having a real time system means that the controlsystem software uses the last two samples of e(t ) to calculate its derivative and integral witha fixed sampling period. This does not necessarily mean that the sampling rate must be fixed.Most of solvers provide variable (but known) step solving algorithms. By using Simulink, wewill compare the controller performances with (i) fixed and known sampling period (to mimica real time system), (ii) unfixed and unknown sampling period (to mimic a non-real timesystem).

Page 18: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 18/21

18

First consider the following simulation. This blocks simulates the system with a fixed andknown sampling rate. The desired trajectory is just a constant, 1, and the values of the

control gains are K p=8 , K d =3 , and K I =0.01.

Scope

PID(s)

PID Controll er

k yfcn

MATLAB Function

1s

Integrator

1

Constant

Page 19: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 19/21

19

Time-variation of tracking error signal is shown in the following figure.

0 20 40 60 80 1000

0.02

0.04

0.06

0.08

0.1

0.12

Time

e ( t )

After a very short transient, the error settles to a small constant and the system is stable.

Page 20: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 20/21

20

Now we will use the same system, same control rule, and the same values of the controlgains, but, for this time, we will also use some additional blocks to make the system a non-

real time system.

ToVariable

Time Delay

Uniform RandomNumber

Scope

PID(s)

PID Controller

k1 y1

fcnMATLAB Function

1s

Integrator

1

Constant

Newly-added “Variable Time Delay ” block holds the last 10 samples of the error signal and“Uniform Random Number ” block generates an integer ranging from 1 to 10 at each timestep. In this way, the derivative and integrator embedded in PID Controller block use theexisting value of the error signal and any random one of the last 10 sampled values of theerror signal to calculate the derivative and integral of e(t ). This means that this system is nota real time system anymore. Indeed, such a system can be used to simulate a non-real time

system.

Page 21: Lecture 2 non linear control system

8/10/2019 Lecture 2 non linear control system

http://slidepdf.com/reader/full/lecture-2-non-linear-control-system 21/21

21

Time-variation of tracking error signal for this non-real time system is shown in thefollowing figure.

The tracking error goes to infinity as time goes to infinity.

This implies that use of a non-real time system to implement the controller may

make the overall system unstable even if your control system stable . This is thekey point

0 20 40 60 80 100

-5

0

5

10

15x 10 12

Time

e ( t )