Design of Compensators For Discrete Models With MATLAB
Design of Compensators For Discrete Models With MATLAB
MATLAB
Davood Shaghaghi
Design of Compensators for
MATLAB
Using
CONTROL TOOLBOX
By
Davood Shaghaghi
In the name of Allah
This article is about the design of compensator in Matlab by using of Rltool and Control Toolbox.
I hope that this article will be useful for you and help you in your design.
Here four examples are provided from familiar book, DISCRETE CONTROL SYSTEMS – K. OGATA.
Best regards.
Davood Shaghaghi
Email: [email protected]
Student of Electrical Engineering
Department of Electrical Engineering
Hamadan University of Technology (HUT)
July 2009
Solution:
1
Design of Compensators Using MATLAB
Rltool is loaded. In the ‘Control and Estimation Tool Manager’ window you can see and change the
architecture of the system , mathematical equation of compensator (after designing),graphical
tuning (related to type of your design– Root Locus or Bode diagram-you can draw any plots needed
for design),analysis plot ( can plot impulse response, step response ,bode diagram ,nyquist diagram
and so on in form of open loop, close loop and etc.) and finally you can tune PID and other forms of
controller automatically.
2
Design of Compensators Using MATLAB
In other window (SISO Design for Design Task) you can see Root Locus plot or Bode plot or any
plots that you choose in managing window. You can add single zero, single pole and conjugate
zeroes or poles for compensator by use of specified section:
[email protected]
Cleaning zero
single pole conjugate pole or pole
First, we must consider the problem conditions. Problem conditions – in this problem - are damping
ratio (zeta) and close-loop dominant pole.
Damping ratio value equals to 0.5, we must calculate close-loop dominant pole first:
3
Design of Compensators Using MATLAB
2 1
Choose damping ratio from menu
3 2
Press OK to accept Setting value
4
Design of Compensators Using MATLAB
2
Type close-loop dominant pole
3
Press Close after
Editing or OK to
accept
Secant location
Locus of close-loop
dominant pole (is equal to
z .5629 j .4090 )
5
Design of Compensators Using MATLAB
In above window, black lines show the conditions of problem. If Root Locus passes from secant-
location of black lines (desirable conditions), your compensator satisfies conditions!
[email protected]
The problem has another condition and it is presence of integrator in the controller.
We set this condition by adding a pole in z=1 or select ‘Integrator’ from below menu in ‘Control and
6
Design of Compensators Using MATLAB
[email protected]
2
You can change the location of pole
from this section.
7
Design of Compensators Using MATLAB
From ‘Control and Estimation Tool Manager’ window >> analysis plot, you can see closed-loop
step response of the system:
[email protected]
8
Design of Compensators Using MATLAB
But the system is sorely unstable! Here we use a zero for achieving desirable conditions. Therefore
you should change the location of zero until Root Locus passes the crossover:
Note:
When you move the pole or zero, be careful don't move the value of the gain of compensator!
You see the step response of system after adding one integrator and one zero:
9
Design of Compensators Using MATLAB
The value of over shoot is equal to zero .We should change the gain of compensator to achieve the
desirable overshoot (16.3).
Similar to moving pole or zero, you can drag the gain (red quadrangular on the root locus) and
move it to satisfy the overshoot.
[email protected]
Compensator is designed!
10
Design of Compensators Using MATLAB
For damping ratio equals to .5, overshoot value is equal to 16.3 that are satisfying.
Also the compensated system has good rise time to step input and this is desirable!
To achieve this goal we must export the compensator transfer function(C) and maybe plant transfer
function (G) from Rltool to work space:
For exporting plant transfer function, repeat above steps, from step 4 and this time select plant G.
Now the plant transfer function and compensator are imported to work space and we can continue
the calculation:
11
Design of Compensators Using MATLAB
[email protected]
Solution:
We solve this problem analytically first and then test our solution with Rltool.
12
Design of Compensators Using MATLAB
The system is type zero and so velocity error tends to be infinity! Therefore we add an integrator to
the system before compensator design (indeed we design two compensators: C1=1/s and C2=….).
[email protected]
As you see, velocity error is Kv=2.5. To compensate it, we multiply it by 2 until Kv be equal to 5:
13
Design of Compensators Using MATLAB
Static velocity error constant is compensated. Now we can design the controller. The Bode diagram
of uncompensated system is as below:
[email protected]
Bode Diagram
Gm = -5.62 dB (at 1.32 rad/sec) , Pm = -18 deg (at 1.8 rad/sec)
100
50
Magnitude (dB)
-50
-100
-150
270
Phase (deg)
180
90
0
-2 -1 0 1 2 3 4
10 10 10 10 10 10 10
Frequency (rad/sec)
Phase margin and gain margin is equal to -18 deg and -5.62 dB respectively. System is sorely
unstable .By using a phase-lag compensator; we will change PM to 60 deg and GM to 12 dB.
1
s
Gd ( s)
1 T Ts 1
s 1 Ts 1
T
14
Design of Compensators Using MATLAB
According to Bode diagram, 247 phase deg occurs in 0.259 rad/sec frequency.
Bode Diagram
Gm = -5.62 dB (at 1.32 rad/sec) , Pm = -18 deg (at 1.8 rad/sec)
100
System: Gw
50 Frequency (rad/sec): 0.259
Magnitude (dB): 25.4
Magnitude (dB)
-50
-100
-150
270
System: Gw
Frequency (rad/sec): 0.259
Phase (deg): 247
180
Phase (deg)
90
0
-2 -1 0 1 2 3 4
10 10 10 10 10 10 10
Frequency (rad/sec)
Magnitude of frequency response function in this frequency is equal to 25.5 dB, then:
1 1 1
* *.259 .0259
T 10 10
Ts 1 38.6 s 1
Gd ( s) Gd ( s)
Ts 1 718.91 s 1
15
Design of Compensators Using MATLAB
Compensator is designed! For testing the results, we plot the compensated Bode diagram:
[email protected]
16
Design of Compensators Using MATLAB
Bode Diagram
Gm = 19.5 dB (at 1.3 rad/sec) , Pm = 62 deg (at 0.259 rad/sec)
200
Magnitude (dB)
0
-100
-200
270
Phase (deg)
180
90
0
-4 -2 0 2 4
10 10 10 10 10
Frequency (rad/sec)
The desirable condition has been obtained .Finally we should convert Continuous controller to
digital form.
17
Design of Compensators Using MATLAB
[email protected]
Solution:
Note:
We can ignore from value 3.804e-013
And consider that the system is type one
And a
18
Design of Compensators Using MATLAB
We should first compensate static velocity error constant. This parameter for uncompensated
system is equal to 1 but the desirable value is 10. Then:
[email protected]
Plot bode diagram for system (K *Gw). PM is equal to .0761 deg that less than desirable value (50
deg).
19
Design of Compensators Using MATLAB
Bode Diagram
Gm = 0.0733 dB (at 3.18 rad/sec) , Pm = 0.0761 deg (at 3.16 rad/sec)
50
[email protected]
Magnitude (dB)
-50
270
225
Phase (deg)
180
135
90
-2 -1 0 1 2 3 4 5
10 10 10 10 10 10 10 10
Frequency (rad/sec)
1 Ts
Gd ( s)
1 Ts
We calculate the requirement phase:
We should find the frequency from bode diagram that satisfies below equation:
20
Design of Compensators Using MATLAB
Bode Diagram
Gm = 0.0733 dB (at 3.18 rad/sec) , Pm = 0.0761 deg (at 3.16 rad/sec)
100
50 System: Gw
Magnitude (dB)
-50
-100
270
225
Phase (deg)
180
135
90
-2 -1 0 1 2 3 4 5
10 10 10 10 10 10 10 10
Frequency (rad/sec)
wm 5.92
wm 1 5.92 1 T 0.568
T. T . 0.0882
T 0.568 T 0.050
1 .568s
Gd ( s)
1 .050s
21
Design of Compensators Using MATLAB
Compensator is designed! For testing the results, plot the Bode diagram of compensated system:
[email protected]
50
Magnitude (dB)
-50
-100
270
225
Phase (deg)
180
135
90
-2 -1 0 1 2 3 4 5
10 10 10 10 10 10 10 10
Frequency (rad/sec)
22
Design of Compensators Using MATLAB
The phase margin after compensation, approach to 45.5. This value is less than desirable phase
margin; therefore we use Rltool to achieve this phase margin:
[email protected]
Select ‘ Open-Loop
Bode’ for Plot 2
23
Design of Compensators Using MATLAB
You see Rltool window for the system with its compensator in below. Similar to problem B-4-10,
you can move the pole and zero by drag it.
[email protected]
We should move the pole or zero of compensator, to compensate requirement phase (50 - 45.5 =5.5
deg).
In this case we change the location of pole:
24
Design of Compensators Using MATLAB
To achieve the transfer function of new compensator, we must export the compensator transfer
function (C) from Rltool to Work space:
[email protected]
Then we test the result so that is the phase margin satisfied or no?
25
Design of Compensators Using MATLAB
Bode Diagram
Gm = 10.6 dB (at 22.9 rad/sec) , Pm = 50 deg (at 6.03 rad/sec)
100
Magnitude (dB) 50
[email protected]
-50
270
225
Phase (deg)
180
135
90
-2 -1 0 1 2 3 4 5
10 10 10 10 10 10 10 10
Frequency (rad/sec)
26
Design of Compensators Using MATLAB
First using the magnitude condition, we find the closed loop dominant poles:
[email protected]
magnitude condition 1 k * f ( z ) 0
27
Design of Compensators Using MATLAB
Using the magnitude condition, we find that the closed loop poles are located at z=0.3164 + 0.2462i.
28
Design of Compensators Using MATLAB
[email protected]
z=0.3164 + 0.2462i
?
.2462
tan 1 ( ) 37.88 o z=0.3164 - 0.2462i
.3164
29
Design of Compensators Using MATLAB
The green line connecting the closed loop pole in the upper half of the z plane and the origin has an
[email protected]
angle 37.88 o .Hence, the number of samples per cycle of damped sinusoidal oscillation is:
360o
9.5
37.88o
30
Design of Compensators Using MATLAB
[email protected]
Solution:
31
Design of Compensators Using MATLAB
We should first compensate static velocity error constant. This parameter for uncompensated
system is equal to 1 but the desirable value is 10. Then:
[email protected]
Then plot bode diagram for system (K *Gw). PM is equal to 5.56 deg that less than desirable value
(50 deg).
Bode Diagram
Gm = 1.69 dB (at 11.2 rad/sec) , Pm = 5.56 deg (at 9.88 rad/sec)
80
60
Magnitude (dB)
40
20
-20
-40
315
270
Phase (deg)
225
180
135
90
-2 -1 0 1 2 3 4
10 10 10 10 10 10 10
Frequency (rad/sec)
32
Design of Compensators Using MATLAB
1 Ts
Gd ( s)
1 Ts
[email protected]
Bode Diagram
Gm = 1.69 dB (at 11.2 rad/sec) , Pm = 5.56 deg (at 9.88 rad/sec)
80
60
System: Gw
Magnitude (dB)
-20
-40
315
270
Phase (deg)
225
System: Gw
180 Frequency (rad/sec): 3.2
Phase (deg): 237
135
90
-2 -1 0 1 2 3 4
10 10 10 10 10 10 10
Frequency (rad/sec)
Design calculations:
1 1 1
* *3.2 .32
T 10 10
3.125s 1
Gd ( s)
16 s 1
33
Design of Compensators Using MATLAB
Bode Diagram
Gm = 15.5 dB (at 10.8 rad/sec) , Pm = 52.3 deg (at 3.21 rad/sec)
100
Magnitude (dB)
50
-50
270
225
Phase (deg)
180
135
90
-3 -2 -1 0 1 2 3 4
10 10 10 10 10 10 10 10
Frequency (rad/sec)
The desirable conditions have been obtained. Finally we should convert Continuous controller to
digital form.
34
Design of Compensators Using MATLAB
35
Design of Compensators Using MATLAB
Similar to previous problem, we should use the magnitude condition and find the close loop poles:
magnitude condition 1 k * f ( z ) 0
[email protected]
36
Design of Compensators Using MATLAB
We determine these points on the root-locus diagram. the line connecting the closed loop pole in
the upper half of the z plane and the origin has an angle 37.88 o .Hence, the number of samples per
cycle of damped sinusoidal oscillation is: 360o/22.83o =15.76.
[email protected]
.3155
tan 1 ( ) 22.83 o
.7494
360o
15.76
22.83o
Root Locus
2
1.5
1
System: Gp
Gain: 0.992
Pole: 0.748 + 0.31i
Damping: 0.474
0.5 Overshoot (%): 18.4
Frequency (rad/sec): 4.46
Imaginary Axis
?
0
-0.5
-1
-1.5
-2
-3 -2.5 -2 -1.5 -1 -0.5 0 0.5 1 1.5 2
Real Axis
37