Sei sulla pagina 1di 27

Finn Haugen.

Telemark University College


National Instruments Confidential

Learning PID control essentials with LabVIEW


By Assistant Prof. Finn Haugen, Telemark University College, Norway

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)
National Instruments Confidential

Case: Temperature control of air heater with LabVIEW


PWM
indicator

Pt100 sensor
(secondary)

AC/DC

Pulse Width
Modulator (PWM)
Fan Heater

Air tube

RS232 Serial

Air
Pt100-mA
transducer
Fan speed
adjust
3 x Voltage AI
(Temp 1, Temp 2, Fan indication)
1 x Voltage AO
(Heating)

Pt100
sensor
(primary)

Laptop PC
with
LabVIEW
Fieldpoint
FieldPoint
(Dual Channel Voltage I/O)

National Instruments Confidential

Block diagram of control system

The students will implement this system from scratch in LabVIEW.


National Instruments Confidential

Some performance indexes of control systems


Maximum of absolute value of control error:

| e |max

Should be small or large?

Mean of absolute value of control error:


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

1
| e |mean
tf ti

tf

ti

| e | dt

Should be small or large?

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


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

du
dt mean

tf ti

tf

ti

| du
dt | dt

National Instruments Confidential

Should be small or large?

Implementation of performance indexes


The three performance indexes defined above can be implemented
as follows.
The maximum control error index:

| e |max
can be implemented with the following code:

National Instruments Confidential

Implementation of performance indexes cont.


The mean of absolute error index:

1
| e |mean
tf ti

tf

ti

| e | dt

can be implemented with the following code:

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


National Instruments Confidential

Implementation of performance indexes cont.


And the control signal time-derivative index:

du
dt mean

tf ti

tf

ti

| du
dt | dt

can be implemented with the following code:

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


National Instruments Confidential

Trying out three control strategies


The three performance indexes (|e|max, |e|mean, |du/dt|mean) are
recorded for each of the below 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
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.

National Instruments Confidential

Trying out three control strategies cont.


The process is operated as follows:
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

National Instruments Confidential

10

Trying three control strategies cont.


Blind control:

Control

Manual feedback:

Automatic feedback
(PID):

Setpoint
Filtered temp

National Instruments Confidential

11

Trying three control strategies cont.


Control Blind control: Manual
strategy:
feedback:

Automatic
feedb (PID):

Perform.
index:

|e|max

0.78 %

0.86

0.44

|e|mean

0.39

0.21

0.12

|du/dt|mean

4.54

7.00

Observation: Automatic feedback (PID) gives smallest max and


mean control error, but the control action is the most aggressive!
This is general, too.
National Instruments Confidential

12

The problem with measurement noise


In a feedback control system measurement noise is propagated
via the controller to the control signal, causing variations in
the 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.)

National Instruments Confidential

13

Block diagram of control system (repeted)

The students will implement this system from scratch in LabVIEW.


National Instruments Confidential

14

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!


National Instruments Confidential

15

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).
strm-Hgglunds 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.)

National Instruments Confidential

16

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_gains
local variable. The FALSE case above (which is active when the tuning
is finished), contains the PID Advanced.vi which is used in normal operation.

National Instruments Confidential

17

Tuning cont.
One of the dialog windows
of 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 :-)

National Instruments Confidential

18

Tuning cont.: Relay-based tuner


In the tuning phase, the PID controller must be replaced by
an 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) is
Kcu = (Ampl out (by Fourier))/(Ampl in) = (4*A/)/E
The PID setting can now be found from the Ziegler-Nichols formulas.
National Instruments Confidential

19

Relay-based
tuning cont.

A = 20%
Pu = 12 sec

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.
2E = 0.8%
(The PID Autotune.vi gave
Kc = 40,8; Ti = 8.0 s; Td = 2.0 s
not so different.)

National Instruments Confidential

20

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 unstable
at the minimum flow rate (3.2%).
National Instruments Confidential

21

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.

National Instruments Confidential

22

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 tuning
Tune 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.)
National Instruments Confidential

23

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.
National Instruments Confidential

24

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!
National Instruments Confidential

25

Block diagram of control system (repeted)

The students will implement this system from scratch in LabVIEW.


National Instruments Confidential

26

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.

National Instruments Confidential

27

Potrebbero piacerti anche