discpid_2004
TRANSCRIPT
-
7/27/2019 DiscPID_2004
1/3
Discrete PID control .
1
11. Discrete PID Control
This demo shows how to use MATLAB to design and simulate sampled-data control systems. The design uses
frequency domain considerations leading to a pole-cancellation PID control method.
)(zC)(
sPAD/
DA /
u[k]e[k] y(t)u(t)
y[k]
r[k]
-
( )( )
( )
Y zP z
U z=
U(z)
Y(z)
Y(s)
The continuous-time process is given by
( )( ) ( )
1( )1 10 1 5
sseP s P s e
s s
= =
+ +
Observe that the system has a delay term of 1 sec. The sampling time is 1 sec.
Design a series PID compensator to meet the following design specifications:
- Phase Margin60- Settling time should be minimal
- The closed-loop system should follow unit step reference signal without steady error (type one system).
Define the continuous-time process without these time delay.
s=zpk(s);
P1s=1/((1+10*s)*(1+5*s));
Find the discrete-time process model assuming zero-order hold (without delay):
( ) 1 11( )
(1 )P s
P z z Zs
=
By MATLAB: Ts=1;
P1z=c2d(P1s,Ts,zoh);
Note that it is not necessary to include the default zoh string.Add the time-delay to the process by multiplying 1( )P z with
1z , since { } 1se zZ = .The z variable can be defined similarly to the z variable.
z=zpk(z,Ts) Pz=P1z/z
( ) ( ) ( )( )
( ) ( )1
1 1
0.904810.00905
0.9048 0.8187
zP z z P z P z
z z z z
+= = =
The zeros and poles of the discrete system are [zd,pd,kd]=zpkdata(Pz,v)
PI term is necessary to achieve the steady state zero error requirement. PD term is used to accelerate the system
response. The PI and PD break frequencies can be calculated similarly to the continuous system. iT is the largesttime constant of the system and dT is the second largest time constant.
PI : break frequency at 0.1
1
0.110
s
i
T
Te e e
= = = 0.9048
PD : break frequency at 0.2
1
0.20.5
s
d
T
Te e e
= = = 0.8187The discrete controller is
-
7/27/2019 DiscPID_2004
2/3
Discrete PID control .
2
0.9048 0.8187( )
1c
z zC z k
z z
=
Thec
kparameter is calculated to set the 60 phase margin.
First assumec
k =1 :
kc=1;
Cz=((z-0.9048)*(z-0.8187))/((z-1)*z);or with the poles of the discrete plant transfer function
Cz=((z-pd(1))*(z- pd(2)))/((z-1)*z)
Calculate the discrete-time loop transfer function ( ) ( ) ( )L z C z P z= . Lz=Cz*Pz;
Lz=minreal(Lz, 0.001); % cancel the zero-pole pairs
Thec
kparameter can be calculated by the margin command or read from a table.
a/ Use the margin command. The bode command tests thes
T sampling time to see if the system continuous or
discrete. If 0s
T = the system is considered to be a continuous-time system, if 0s
T > positive than the system is
considered to be a discrete-time system. [mag,phase,w]=bode(Lz);
kc=margin(mag,phase-60,w);b/Use a table
[numz,denz]=tfdata(Lz,v); [mag,phase,w]=dbode(numz,denz,Ts);
T=[mag, phase, w] % setting up a table
T =
0.0781 -114.8936 0.2200
0.0697 -117.8611 0.2462
0.0622 -121.1822 0.2756
0.0555 -124.8991 0.3084
0.0495 -129.0589 0.3452
It is seen that the phase shift of about -120 (required by the specification of PM=60) is achieved at a magnitude of
0.062. Consequently, gain by 1/0.0622 defines the proper gainc
k as follows:
kc=1/0.0622
The gain of the discrete-time controller is 16c
k = . Notice that the margin has to forms; its input can be a transfer
function or the bode amplitude and phase values.
Verify now the system behaviour. Check the phase margin by the margin command. Cz=kc*((z-pd(1))*(z- pd(2)))/((z-1)*z);
Lz=Cz*Pz; Lz=minreal(Lz);
margin(Lz);
The closed loop performance can be investigated by a Simulink model.
simulink % starts SIMULINK
Create a new file and copy the various blocks. The parameters of the block should be set to the required value.SIMULINK uses the variables defined in the MATLAB workspace.
C(z), P1(s): Control System Toolbox >LTI system :Cz, P1s
Sum: Simulink>Math>Sum: +-
Dead time, delay: Simulink>Continuous>Transport Delay: 1
Step input: Simulink>Sources>Step, Change the Step time parameter to zero
Zero-Order-Hold: Simulink>Discrete> Zero-Order-Hold, Sampling time: Ts
Scope: Simulink>Sinks>Scope
-
7/27/2019 DiscPID_2004
3/3
Discrete PID control .
3
Zero-Order
Hold
Transport
Delay
Step ScopeY
ScopeU
P1s
LTI System1
Cz
LTI System
The scope blocks can also be used to transfer the results of the simulation to the Matlab workspace. Change the
parameters in the Scope graphic window properties menu.
Data history: Save data to workspace
Variable name: My for ScopeY and Mu for ScopeU
Matrix format
From the Menu change the Simulation>Parameters>Stop Time parameter to 20
After the simulation the time, the output and control vectors can be gained from the transferred matrix form. ty=My(:,1), y=My(:,2) tu=Mu(:,1), u=Mu(:,2)
Plot the output, y(t) subplot(211), plot(ty,y), grid
and the control signal u(t). The u(t) control signal is the output of the zero order hold. subplot(212), stairs(tu,u) , grid
The discrete u[k] signal can also be ploted. hold on, plot(tu,u,*)
The performance parameters (settling time, overshoot) of the system can be calculated from they and u vectors.
0 2 4 6 8 10 12 14 16 18 200
0.5
1
1.5
0 2 4 6 8 10 12 14 16 18 20-5
0
5
10
15
20