finn haugen. telemark university collegenational instruments confidential 1

27
Finn Haugen. Telemark University College National Instruments Confidential 1

Post on 19-Dec-2015

223 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

Finn Haugen. Telemark University CollegeNational Instruments Confidential

1

Page 2: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 2

Contents of the presentation:

• Description of the case (student assignment): Temperature control of heated air tube • Block diagram of control system• Performance indexes• Control strategies (Blind; Manual feedback; Automatic feedback.)• Measurement noise• Easy controller tuning• Gain scheduling (adaptive control)• Feedforward control (added to feedback control)

Learning PID control essentials with LabVIEWBy Assistant Prof. Finn Haugen, Telemark University College, Norway

Page 3: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 3

Fieldpoint

Case: Temperature control of air heater with LabVIEW

FieldPoint(Dual Channel Voltage I/O)

RS232 Serial

Fan

Fan speedadjust

Pt100sensor

(primary) Laptop PCwith

LabVIEW

Pulse WidthModulator (PWM)

Pt100 sensor(secondary)

Air tube

Pt100-mAtransducer

PWMindicator

3 x Voltage AI(Temp 1, Temp 2, Fan indication)1 x Voltage AO(Heating)

AC/DC

Air

Heater

Page 4: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 4

Block diagram of control system

The students will implement this system from scratch in LabVIEW.

Process

Sensor

ySP yue Feedbackcontroller

Trans-ducer

[oC][%]Scaling

[0%,100%]

u0

Auto

Man

[0V,5V]

[0%,100%]

[4mA,20mA]

Scalingym

Distur-bances

Fan speed

AmbienttemperatureControl

errorSetpoint(scaled)

Measurementsignal

Lowpassfilter [0%,

100%]

Effective measurement

noise, n

ym

ymf[20oC,70oC]

Scaling

Setpoint

[20oC,70oC]

ySP0

[%]

Filtered measurement

signalADC

[2V,10V]

DAC

LabVIEW

Feed-forward

controller

Sen-sor

Fan speed

Scaling

uffuPID

DAC

Off On

[0%,100%]

[2V,10V]

Gainschedu-

ling

Controlsignal

Page 5: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 5

Some performance indexes of control systems

f

i

t

tif

mean dt|e|tt

1|e|

f

i

t

t dtdu

ifmeandt

du dt||tt

1||

max|e|Maximum of absolute value of control error:

Mean of absolute value of control error:

Mean of absolute value of time-derivative of control signal:

Should be small or large?

Should be small or large?

Should be small or large?

(Inspired by optimal control, e.g. MPC, where the objective function includes the variation of the control signal.)

(Almost the same as the popular IAE index – Integral of Absolute value of control Error.)

Page 6: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 6

Implementation of performance indexesThe three performance indexes defined above can be implementedas follows.

max|e|

• The maximum control error index:

can be implemented with the following code:

Page 7: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 7

Implementation of performance indexes cont.

f

i

t

tif

mean dt|e|tt

1|e|

The mean of absolute error index:

can be implemented with the following code:

(Alternatively, could have used the MeanPtByPt.vi.)

Page 8: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 8

Implementation of performance indexes cont.And the control signal time-derivative index:

can be implemented with the following code:

f

i

t

t dtdu

ifmeandt

du dt||tt

1||

(Alternatively, could have used the MeanPtByPt.vi.)

Page 9: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 9

Trying out three control strategies

• Blind control, i.e. control with a fixed control signal• Manual feedback control, i.e. the human (student) does the control• Automatic feedback (PID) control, i.e. the computer does the control

The three performance indexes (|e|max, |e|mean, |du/dt|mean) arerecorded for each of the below control strategies:

For the PID control:• PID settings: Kc = 40,8; Ti = 8.0s; Td = 2.0s. (found from the LabVIEW PID Autotuning.vi with ”fast response”).• The meas. filter is lowpass 2. order Butterworth with bandwidth 0.4Hz.

Page 10: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 10

Trying out three control strategies cont.

• Setpoint = 40% (fixed)• Fan speed = 60% (initial value)• A disturbance change: Increasing the fan speed for about 10 sec from 60% to 100% and then back to 60% again.• Temp1 sensor in the outmost position• Duration of experiment: 60 seconds

The process is operated as follows:

Page 11: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 11

Trying three control strategies cont.Blind control: Manual feedback: Automatic feedback

(PID):Control

SetpointFiltered temp

Page 12: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 12

Trying three control strategies cont.

Observation: Automatic feedback (PID) gives smallest max and mean control error, but the control action is the most aggressive!This is general, too.

Blind control: Manual feedback:

Automatic feedb (PID):

|e|max 0.78 % 0.86 0.44

|e|mean 0.39 0.21 0.12

|du/dt|mean 0 4.54 7.00

Controlstrategy:

Perform.index:

Page 13: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 13

The problem with measurement noiseIn a feedback control system measurement noise is propagatedvia the controller to the control signal, causing variations inthe control signal.

The derivative term of the controller amplifies these variations.

These variations can be reduced in several ways:

• Using a measurement lowpass filter, e.g. IIR filter or FIR filter. (The FIR filter on the PID Control Palette is inflexible. The Butterworth PtByPt filter on Signal Processing Palette is flexible and easy to tune.)• Setting the derivative gain to zero, i.e. using PI in stead of PID

(Block diagram is repeated on next slide for easy reference.)

Page 14: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 14

Block diagram of control system (repeted)

The students will implement this system from scratch in LabVIEW.

Process

Sensor

ySP yue Feedbackcontroller

Trans-ducer

[oC][%]Scaling

[0%,100%]

u0

Auto

Man

[0V,5V]

[0%,100%]

[4mA,20mA]

Scalingym

Distur-bances

Fan speed

AmbienttemperatureControl

errorSetpoint(scaled)

Measurementsignal

Lowpassfilter [0%,

100%]

Effective measurement

noise, n

ym

ymf[20oC,70oC]

Scaling

Setpoint

[20oC,70oC]

ySP0

[%]

Filtered measurement

signalADC

[2V,10V]

DAC

LabVIEW

Feed-forward

controller

Sen-sor

Fan speed

Scaling

uffuPID

DAC

Off On

[0%,100%]

[2V,10V]

Gainschedu-

ling

Controlsignal

Page 15: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 15

Measurement noise cont.The figure below shows the PID control signal in four situations:• No measurement filter. (Max amplitude is due to the LSB of the 12 bits ADC!)• Using the 5. order FIR filter on the PID Control Palette• Using an IIR filter in the form of a 2. order Butterworth filter with bandwidth 0.4Hz (tuned by trial and error)• IIR filter, and setting derivative time to zero, i.e. PI control

No filter FIR, PID contr IIR, PID contr IIR, PI contr

No surprise that PI is more popular than PID in industry!

Page 16: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 16

Easy controller tuning

Two easily available tuning tools or procedures in LabVIEW:(Tuning based on estimated process model is in advanced assignments.)

• The PID Autotuning.vi, which invokes a tuning wizard. The tuning principle is to automatically change the setpoint stepwise, and to calculate the controller parameters from the response. The autotuner requires that the control loop is stable initially (with P, PI or PID controller).

• Åstrøm-Hägglund’s relay-based tuning method with the PID Advanced.vi or the PID.vi. (This method is basically a practical implementation of the Ziegler-Nichols’ ultimate gain method.)

Page 17: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 17

Controller tuning cont.PID Autotuning.vi

The wizard is opened when the autotune? input is TRUE. When the tuning is finished, the new PID settings are written to the PID_gainslocal variable. The FALSE case above (which is active when the tuningis finished), contains the PID Advanced.vi which is used in normal operation.

Page 18: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 18

Tuning cont.One of the dialog windowsof the PID Autotuning.vi wizard is shown in the figure:

Results: Kc = 40,8 Ti = 8.0 s Td = 2.0 s.Representative setpoint step response after tuning:

Seems ok :-)

Page 19: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 19

Tuning cont.: Relay-based tunerIn the tuning phase, the PID controller must be replaced byan On/Off-controller, creating sustained oscillations in the loop.How to turn the PID controller into an On/Off-controller:• Kc very large, e.g. 1000.• Ti = Inf• Td = 0• The control signal amplitude, A, is set via the output range input to the LabVIEW PID functions, since A = (umax – umin)/2.Assume:• The oscillatory control error amplitude is measured as E.• The period of the oscillations is measured as Pu.

By representing the square wavy controller signal by fundamental Fourier series term, the ultimate gain (relay gain) isKcu = (Ampl out (by Fourier))/(Ampl in) = (4*A/π)/EThe PID setting can now be found from the Ziegler-Nichols’ formulas.

Page 20: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 20

Relay-based tuning cont.

Result from an experiment:

A = 20 %. E = 0.4 %. Pu = 12 sec.Thus, Ku = 4*A/(pi*E) = 63.7.PID setting: Kc = 0.6* Kcu = 38.2.Ti = Pu/2 = 6 s. Td = Pu/8 = 1.5 s.

(The PID Autotune.vi gaveKc = 40,8; Ti = 8.0 s; Td = 2.0 s– not so different.)

A = 20%

2E = 0.8%

Pu = 12 sec

Page 21: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 21

Gain scheduling (adaptive control)The problem:It can be shown both experimentally and mathematically (using a simplified model) that the gain and the transport delay of a flow process increases as the flow descreases. If the (temperature) controller is tuned at a high flow rate, the control system may get poor stability if the flow rate decreases. The figures to the right illustrate this for the air heater. The PID controller was tuned at flow rate 100%: Kc = 42.0; Ti = 5.0s; Td = 1.25s.This control system becomes unstableat the minimum flow rate (3.2%).

Page 22: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 22

Gain scheduling cont.One simple solution:Since the stability of the control system depends on the flow rate, let us try varying the controller parameter settings as functions of the flow rate. This is implemented using the PID Gain Schedule.vi. The scheduling is based on three PID settings each found by using relay-based tuning:

Flow 67%: Kc = 24.1; Ti = 8.0s; Td = 2.00s.Flow 33%: Kc = 30.6; Ti = 7.0s; Td = 1.75s.Flow 3%: Kc = 34.7; Ti = 5.5s; Td = 1.38s.

Page 23: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 23

Gain scheduling cont.The result:The figures to the right illustrates that the control system now has good stability for the minimum flow (and for the maximum flow).

An alternative solution: Conservative tuningTune the controller at one specific flow rate, and keep the controller settings fixed for all flow rates. For which flow rate? Any drawback?(This solution is not demonstrated here.)

Page 24: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 24

Feedforward control (+ feedback control)Variations of the air flow act as disturbances to the process. The feedback controller tries to compensate for such variations using the temperature measurement. Can we obtain improved control by also basing the control signal on measured air flow, which is here available as the fan speed indication?

Let us first try without feedforward. The figure shows ordinary PID control as the fan speed was changed from minimum to maximum, and back again. Performance indexes: |e|max = 1.01. |e|mean = 0.36.

Page 25: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 25

Feedforward cont.Now, let us try feedforward from fan speed (air flow). (Block diagram is repeated on next slide for easy ref.) A number of corresponding values of fan speed and control signal was found experimentally. Temperature setpoint was 40 deg C. The feedforward control signal, u_ff, was calculated by linear interpolation with Interpolate 1D Array.vi, and was added to the PID control signal to make up the total control signal: u = u_PID + u_ff. Performance indexes:|e|max = 0.27 (vs 1.01). Much better! |e|

mean = 0.073 (vs 0.36). Much better!

Page 26: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 26

Block diagram of control system (repeted)

The students will implement this system from scratch in LabVIEW.

Process

Sensor

ySP yue Feedbackcontroller

Trans-ducer

[oC][%]Scaling

[0%,100%]

u0

Auto

Man

[0V,5V]

[0%,100%]

[4mA,20mA]

Scalingym

Distur-bances

Fan speed

AmbienttemperatureControl

errorSetpoint(scaled)

Measurementsignal

Lowpassfilter [0%,

100%]

Effective measurement

noise, n

ym

ymf[20oC,70oC]

Scaling

Setpoint

[20oC,70oC]

ySP0

[%]

Filtered measurement

signalADC

[2V,10V]

DAC

LabVIEW

Feed-forward

controller

Sen-sor

Fan speed

Scaling

uffuPID

DAC

Off On

[0%,100%]

[2V,10V]

Gainschedu-

ling

Controlsignal

Page 27: Finn Haugen. Telemark University CollegeNational Instruments Confidential 1

National Instruments Confidential 27

Conclusions

• LabVIEW with PID Toolkit offers a flexible and user-friendly environment for students to learn practical PID control.

• Practical control is best learned in (practical) labs because the students will then experience important realistic problems and phenomena related to e.g. noise.