Professional Documents
Culture Documents
r[k]
e[k]
C ( z)
D/ A
u(t)
P( s)
y(t) Y(s)
A/ D
P( z ) =
Y ( z) U ( z)
P (s) =
e s s =P 1 ( s )e (1 + 10s )(1 + 5s )
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 the e 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):
s
P 1 1 ( s) P 1 ( z ) = (1 z ) Z s
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 P 1 ( z ) with z , since The z variable can be defined similarly to the z variable. z=zpk(z,Ts) Pz=P1z/z
1
Z {e s } = z 1 .
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. Ti is the largest time constant of the system and
Ts Ti
=e
1 10
= e 0.1 = 0.9048
=e
1 0.5
= e 0.2 = 0.8187
C ( z ) = kc
z 0.9048 z 0.8187 z 1 z
The kc parameter is calculated to set the 60 phase margin. First assume kc =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 The kc parameter can be calculated by the margin command or read from a table. a/ Use the margin command. The bode command tests the Ts sampling time to see if the system continuous or discrete. If Ts = 0 the system is considered to be a continuous-time system, if Ts > 0 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 gain kc as follows: kc=1/0.0622 The gain of the discrete-time controller is kc = 16 . 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
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 the y and u vectors.
1.5
0.5
10
12
14
16
18
20
20 15 10 5 0 -5 0 2 4 6 8 10 12 14 16 18 20