Professional Documents
Culture Documents
A very important category of real time systems are automatic control systems. In fact all control systems are real-time systems because they must react to external events within a specified amount of time.
The operation of computer control systems is usually synchronized by a clock signal that determines the sampling period. This sampling period specifies the maximum total amount of time that is available for A/D and D/A conversions and control computations.
Control loop variables y(t) or y(k) - controlled variable (temperature, pressure, water level, flow, speed etc.) r(k) - reference or setpoint i.e. the desired value of the controlled variable e(k) - control error the difference between the desired value of the controlled variable and its actual value e(k)= r(k) - y(k) u(t) or u(k) manipulated variable represents the action that is used by the controller to change the controlled variable (control valve position, power input of a heating element, speed of a cooling fan, fuel flow to an engine or to a boiler) Besides, there is usually also one or more disturbance variable(s) d(t) that are external influences affecting the controlled variable (changing temperature of the environment, changing load of a electric drive or of an engine etc.)
Examples:
Control valves with electrical drive typically two phase induction motor
Operation of the analog-to-digital converter (ADC), the digitalto-analog converter (DAC) and the zero order hold (ZOH)
ADC performs two functions: 1. Analog signal sampling Continuous signal is replaced with a sequence of values equally spaced in the time domain 2. Quantization amplitude of the signal is represented with a discrete set of different values
Zero order hold is described by the formula y (t ) ! y (kTv ) kTv e t (k 1)Tv The behavior of the output of standard DAC is that of zero order hold. Discontinuous step changes at ZOH output can excite poorly damped mechanical modes of the physical process and also cause wear in the actuators of the system. A theoretically possible solution is higher order hold circuits. First order hold: t kTv y (t ) ! y (kTv ) y ((k 1)Tv ) y (kTv ) kTv e t (k 1)Tv Tv This form of FOH is not causal. Causal FOH can be obtained by introducing a delay of one sampling period or using output prediction based on extrapolation from previous sampling period. t kTv y (t ) ! y (kTv ) y (kTv ) y ((k 1)Tv ) kTv e t (k 1)Tv Tv First and higher order hold circuits are normally not used in control systems because of the high phase shift they introduce.
1. The higher is the control error the higher the control action (manipulated variable) must be Proportional or P controller u (t ) ! ro e(t ) r0 proportional gain If the control error equals zero, the manipulated variable is also zero. As a result of it, if the controlled plant is non-integrating (i.e. nonzero plant input is necessary to have non-zero output), there will always be some non-zero steady state error. The value of error will be the smaller the higher the proportional gain will be. This is a significant drawback as the majority of the controlled plants are non-integrating (some non-zero value of the plant input is necessary to compensate for thermal losses, mechanical friction, load torque etc. depending on the particular plant being controlled).
Ti s 1 1 U ( s ) ! ro [1 ]E ( s ) ! ro E ( s) Ti s Ti s Due to the presence of the integral term, the manipulated variable (=plant input) can be non-zero even if control error is zero. Achieving zero steady state error is therefore possible)
3. Proportional Integral Derivate PID controller 1t de(t ) u (t ) ! ro [e(t ) e(X )dX Td ] Ti 0 dt 1 Td s ]E ( s ) U ( s ) ! ro [1 Ti s Td derivative time constant
The derivative term does not affect the steady state behavior of the control loop (derivative of constant is zero), however it can be used to speed up and improve the dynamics response of the control loop
Individual terms are often discretized using different methods. The proportional term requires no approximation because it is a purely static part. Integral term: rectangular rule, trapezoid rule Backward rectangular rule:
roTv k ro t e( X ) } T e( i ) ! I O ( k ) Ti 0 i i !1
(it is better than forward rule as it immediately reacts to setpoint changes) Trapezoid rule:
ro t roTv k e( X ) } 2T ( e( i ) e( i 1 )) ! I L ( k ) Ti 0 i i !1
The formula for calculating the integral term includes summation from the beginning (1 or 0 depending on the particular rule that is used). For implementation it is converted to the form of difference equation that is updated recursively at each sampling instant. For the trapezoid method this can be written in the following way roTv k I L (k ) ! (e(i) e(i 1)) 2Ti i !1 roTv k 1 I L (k 1) ! (e(i) e(i 1)) 2Ti i !1 roTv (e(k ) e(k 1)) I L (k ) I L (k 1) ! 2Ti and finally I L (k ) ! I L (k 1) roTv (e(k ) e(k 1)) 2Ti
Derivative term:
The simplest approach: backward difference de roTd } roTd (e(k ) e(k 1)) Tv ! D(k ) dt This simple approximation is very sensitive to noise and combined effects of quantization and sampling may result in erratic behavior, in particular if sampling time is small (the response to a slowly and linearly growing signal e(t) is then not a small constant but a sequence of short peaks with high magnitude)
Better Alternative:
Multipoint difference: Derivative at time kTv is approximated with an average speed of control error change at several sampling intervals Average error ek ek 1 ek 2 ek 3 ek ! 4 (ek 1 ek ek ek 1 ek ek ek 2 ek ek 3 D(k ) ! ! 1,5T 0,5T 0,5T 1,5T ! Tv 4 v v v v
Integral Wind-up WindInternal computation of the integral term is practically unlimited, while the physical manipulated variable is always limited and the limits are hard. As a result of it the value of the integral term can significantly exceed the value of the physically realizable manipulated variable. In such a situation, if the setpoint is reached and the control error changes sign, it takes the a long time before this change can also be observed at manipulated variable output. Long lasting overshoots as can be seen from the figure and other problems then result.
Wind-up can be prevented by using the dynamic limitation of the integral term. The procedure is as follows: 1. At each time step k compute the individual terms P(k), I(k) and D(k) 2. Sum these terms up to calculate the manipulated variable u(k)= P(k)+I(k)+D(k) 3. If the value of the manipulated variable is within limits, it is sent to the D/A converter. If not, manipulated variable remains at one of its limits, the current value of the integral term I(k) is discarded and replaced with I(k-1) In the next sampling instant this procedure is repeated. Thus the integral term is frozen for the whole time during which the manipulated variable is at its limits and if its value becomes smaller after the change of control error sign the effect on manipulate variable is immediate. As the integral term is frozen at some static value that is not specified a priori, this limitation is called dynamic.
Aliasing
Harmonic signal with frequency f Sampling with period Tv
u( t ) ! A sin( 2Tft ) u( k ) ! A sin( 2TfkTv )
In other words, it is not possible to distinguish between nf sampled signal with frequency f and f s ! f O v
Then
This theorem cannot be satisfied for noise signals anti-aliasing filter is necessary Usually analogue low-pass filter is combined with digital filter that works with smaller sampling time that is the sampling time of the control algorithm.
Two different objectives of PID controllers tuning: a) Set-point tracking b) Disturbance rejection
If the dynamics of w(t) and d(t) changes is significantly different (and typically it will be different: setpoint is often changed in steps resulting in step changes of control error while the disturbances usually cause gradual changes of the controlled variable and control error), the controller tuning must be optimized either with respect to setpoint tracking or with respect to disturbance rejection but it is not possible to achieve both objectives with the same controller tuning.
Ziegler Nichols method. This method is suitable for disturbance rejection. It exists in two variants. 1. Variant Ultimate gain method: only P controller is used, I and D terms are switched off. Proportional gain is gradually increased until the stability limit is reached (undamped oscillations with constant magnitude). This value of the gain is called the ultimate gain rk and the period of oscillations is denoted as the ultimate period Tk. Using these two pieces of information the recommended controller tuning can be calculated using the table below. Controller ro Ti Td P 0,5rk PI PID 0,45rk 0,6rk 0,85Tk 0,5Tk 0,125Tk
Tangent in the inflection point of the response (the point where the slope of the response is maximum) Tu dead time Tn rise time K steady state gain Normalized dead time (y (g) K! (u (g) Tu 5! Tn
Controller P PI PID
ro 1/(K 5
Ti
Td
Chien Hrones Reswick method Based on the first order plus time delay approximation of the controlled plant dynamics. Two possible choices: aperiodic closed loop response and closed loop response with ca 20% overshoot. This method gives tuning formulae both for the setpoint tracking and for the disturbance rejection.
P PI
PID
Ke sTD Gs ( s ) ! (Xs 1)