MIDDLE EAST TECHNICAL UNIVERSITY
EE 402 RECITATION #13
REPORT
LEAD-LAG COMPENSATOR DESIGN
F. Kağan İPEKUtku KIRAN Ç. Berkan Şahin
Contents
INTRODUCTION ... 3
MODELLING ... 3
OBTAINING PTF of OPEN LOOP ... 6
SAMPLING PERIOD PROBLEM ... 8
LAG-LEAD COMPENSATOR DESIGN ... 10
EFFECT OF LEAD-LAG COMPENSATOR ON TRANSIENT RESPONSE ... 21
INTRODUCTION
In this week’s recitation, lead-lag compensator design on a real system, which is a solution to the fifth senior design project, will be discussed. The importance of sampling on representing a continuous system in discrete domain and possible problems that can occur will be analyzed. A complete lead-lag design procedure will be given for the system and then effect of a lead-lag
compensator on a system will be analyzed by changing poles and zeros of lead and lag compensator.
MODELLING
The robot has two wheels at the back and a caster ball at the front for drive system. It has a separate DC motor for each wheel for differential driving. Expectation from the drive system is the ability to go in a certain heading with a certain speed. In order to meet these requirements two encoders and a magnetometer are placed on the robot. Encoders enable the robot to control the speed of its wheels and magnetometer, which is configured to function as a compass, enables the robot to head to a particular direction.
In order to implement control loops, DC motor model should be obtained. Motors on the robot have the following specifications:
τstall=0.42 Nm
𝐼𝑠𝑡𝑎𝑙𝑙 = 1.6 𝐴
𝑁𝑜 𝑙𝑜𝑎𝑑 𝑠𝑝𝑒𝑒𝑑 = 120 𝑟𝑝𝑚 = 4𝜋 𝑟𝑎𝑑/𝑠𝑒𝑐 @6𝑉 𝑁𝑜 𝑙𝑜𝑎𝑑 𝑐𝑢𝑟𝑟𝑒𝑛𝑡 = 70 𝑚𝐴 @6𝑉
𝑅𝑖𝑛𝑡𝑒𝑟𝑛𝑎𝑙 = 3 Ω
Torque and back EMF constants are needed to derive mathematical model. To find torque constant: 𝐾𝜏=𝐼τstall
𝑠𝑡𝑎𝑙𝑙 =
0.42
1.6 = 0.2625 𝑁/𝐴
To find back EMF constant, use the DC motor equivalent circuit under no load conditions (@6V): 𝐾𝑏=
6 − 𝑅𝑖𝑛𝑡𝑒𝑟𝑛𝑎𝑙 ∗ 𝑁𝑜 𝑙𝑜𝑎𝑑 𝑐𝑢𝑟𝑟𝑒𝑛𝑡
𝑁𝑜 𝑙𝑜𝑎𝑑 𝑠𝑝𝑒𝑒𝑑 =
6 − 3 ∗ 0.07
4 ∗ 𝜋 ≅ 0.461 𝑉𝑠𝑒𝑐/𝑟𝑎𝑑
Since robot controls the motor voltages by the means of PWM duty cycle with 8 bit resolution, conversion from PWM duty cycle to voltage is also included in the motor model. This conversion is in the following form:
𝑣𝑜𝑙𝑡𝑎𝑔𝑒 = 𝑏𝑎𝑡𝑡𝑒𝑟𝑦 𝑣𝑜𝑙𝑡𝑎𝑔𝑒 2𝑃𝑊𝑀 𝑟𝑒𝑠𝑜𝑙𝑢𝑡𝑖𝑜𝑛 − 1
Overall DC motor model is shown in Figure 1.
Figure 1: DC Motor Model
Figure 2: Overall System
As it can be seen from Figure 2, speed control is established by just feeding linear velocity output of the DC motor block to the controller. For heading control, first distance travelled by two wheels are subtracted and halved and then feedback to the heading controller.
Figure 3: Overall System in Action
OBTAINING PTF of OPEN LOOP
The open loop pulse transfer function of the system is needed to design a lead/lag compensator. The compensator is designed for heading control. To obtain the PTF MATLAB “Control and Estimation” tool is used.
Note: Sampling period is set to 0.05 sec, since the robot is actually running the control loops every 50 msecs. However, this sampling period is problematic for this system. The problem will be discussed later on.
Figure 4: Open Loop PTF for Heading Control
Figure 5: Linear Analysis with Control and Estimation Tool
Then from the new window opened “Linearize Model” is selected and then the model is exported to the MATLAB workspace. At this point MATLAB generates the transfer function in z-domain since; there is a zero order hold in front of the DC motor model. Generated PTF is:
𝐺 𝑧 =0.001861 ∗ 𝑧 + 0.0004032 𝑧2− 1.004 ∗ 𝑧 + 0.004136
The PTF should be transformed to w-domain before compensator design procedure. In order to perform transformation from z-domain to w-domain MATLAB function “d2c()” is used with ‘tustin’ as the method argument. Tustin method is the bilinear transformation as discussed in lectures.
𝐺 𝑤 =−0.0007259 ∗ 𝑤
2− 0.01606 ∗ 𝑤 + 1.804
𝑤2+ 39.67 ∗ 𝑤
SAMPLING PERIOD PROBLEM
In continuous domain the system has the open loop transfer function of:
𝐺 𝑠 = 4.991
𝑠2+ 109.8 ∗ 𝑠
Notice that the system has two poles: one is at zero and the other is at -109.8. Figure 6 shows the bode plots of previously obtained G(z), G(w) and G(s).
Figure 6: Bode Plot of G(z), G(w), G(s). Ts=0.05sec
Note that the vertical line in Figure 6 is 𝑤𝑠/2 =
𝜋 𝑇𝑠=
𝜋
0.05≅ 63 𝑟𝑎𝑑/𝑠𝑒𝑐
63 rad/sec. When w-domain transform is performed, resulting transfer function is only able to represent the actual system for frequencies lower than ws/2. Therefore, same error can be seen in G(w).
In order to represent the system properly in z or w domain, sampling frequency should be such that ws/2 is much greater than the higher pole of the system. For example, if the sampling period is reduced to 0.001 sec, new bode plots of G(z), G(w) and G(s) becomes as shown in Figure 7.
Figure 7: : Bode Plot of G(z), G(w), G(s). Ts=0.001 sec
Note that the system pole at 109.8 rad/sec is now left of the vertical line, and it is represented in the both z and w domain.
LAG-LEAD COMPENSATOR DESIGN
For the design part of the recitation, a lead-lag compensator is designed to connect in a cascaded manner to the plant. By adding the lead-lag compensator, it is aimed to improve some performance criteria of the overall system, i.e. stability.
The design procedure is started with a lead compensator design which is followed by the lag
compensator design part. Before starting the compensator design, the design is multiplied by a gain, K to satisfy the error coefficient specification which will be mentioned later in this report.
The procedure that is followed during the lead-lag compensator design is lined up below. 1) Finding out the system type.
2) Calculating the gain, K that need to be added to the system. 3) Obtaining the Bode Plots of the system.
4) Designing the LEAD compensator part of the overall compensator.
5) Finding the new system transfer function which is obtained by adding the lead compensator part.
6) Obtaining the Bode plots of this new system.
7) Designing the LAG compensator part of the compensator.
8) Checking the resultant system if it satisfies the specifications or not. 9) Some modifications according to step 8.
After that point, the design procedure will be applied step by step to finalize the design. During the design, the necessary information will also be given.
The open loop transfer function of the position control part of the project (EE494) in W domain is given below.
This transfer function is obtaining from the discrete time transfer function(PTF) and 0.05 seconds is used a sampling period, T. This T is exactly the period of the control loop of the project.
The lead-lag compensator is designed using this transfer function.
The following specifications are selected to be achieved on the compensated system.
PM : 60⁰ GM = 8 dB
ess(under unit ramp) ≤ 0.05
The gain margin specification seems a little bit extraordinary. A low value is selected because obtaining a higher gain margin is too hard by adding a lead-lag compensator to the given W domain transfer function. This problem is caused by the sampling period. Sampling period is not changed to remain true to the real system and to observe the effect of sampling period on the system.
Step by step design:
1) Finding out the system type.
According to the specifications, there should be no steady state error under unit step input and a constant one under unit ramp.
To achieve that, the system should be type 1 and it is type 1, hence there is no need to add a pole at the origin to increase the type of the system.
2) Calculating the gain, K that need to be added to the system.
The design specification that is satisfied first is the steady state error specification. Steady state error can be found using the basic formula :
sse=1/
K
V , whereK
V is the velocity error coefficient.0.05=1/ =20
Velocity error coefficient is given by the following formula
At that point selecting an appropriate K value is so significant. During the design procedure, first the lead compensator will be designed. Lead compensator design procedure can only by applied to the stable systems, hence an appropriate K which both satisfies the design specifications and does not violates the stability of the system should be carefully selected. Increasing K value increases the positive gain that is added to the system and that shifts the magnitude part of the Bode plots up. This may end up with a negative gain margin which means the system becomes unstable.
By considering the issues mentioned above, K is selected as 600.
K=600
3) Obtaining the Bode Plots of the system.
After multiplying the system with K=600, the following transfer function is obtained.
The design will be continued according to this new transfer function. Thus, the Bode plots of it should be obtained to understand the system well and attack to it for lead compensator design part.
Figure 8: Bode Plots of the uncompensated system
Phase and gain margin of the uncompensated system: PM = 41.5 deg.
GM = 7.22 dB
It is seen that the uncompensated system has a gain margin of 7.22 dB. If the gain, K were selected as 2000, for example, instead of 600, it will result in 20log(2000/600)=10.45 dB shift in the magnitude and the GM would be -3.23 dB which means instability. Thus, K=600 can, again, be considered as an acceptable value.
4) Designing the LEAD compensator part of the overall compensator.
The Bode plots are obtained and the system is ready to be used for a lead compensator design. Adding a lead compensator improves the PM but decreases the GM of a system. In the system whose Bode plots are drawn above has already a low GM and decreasing it more by adding a lead
compensator is not an acceptable solution for achieving the desired PM. Thus the effort of the lead compensator part is limited and the principal part of the compensation to achieve the desired PM is handled by the lag compensator part.
The PM of the system is tried to be made 46.5 degrees from 41.5 degrees by adding 5 degrees. First, the maximum phase of the lead compensator to be designed should be calculated.
𝛷𝑚𝑎𝑥 = 𝑃𝑀𝑠𝑝𝑒𝑐𝑖𝑓𝑖𝑒𝑑 + 𝑐𝑜𝑟𝑟𝑒𝑐𝑡𝑖𝑜𝑛 𝑓𝑎𝑐𝑡𝑜𝑟 − 𝑃𝑀𝑢𝑛𝑐𝑜𝑚𝑝𝑒𝑛𝑠𝑎𝑡𝑒𝑑 𝛷𝑚𝑎𝑥 = 46.5 + 5 − 41.5 = 10
Then, α should be calculated using this maximum phase. α =1−𝑠𝑖𝑛 𝛷1+𝑠𝑖𝑛 𝛷𝑚𝑎𝑥
𝑚𝑎𝑥 =
1−𝑠𝑖𝑛 10
1+𝑠𝑖𝑛 10=0.704
For a lead compensator of the form , this α gives the location of the
pole of the compensator.
The gain that is introduced by the uncompensated system at the new gain crossover frequency can be found using the following formula
20log α = 20log 0.704 = -1.52 dB
After finding this gain we can use it to find the new gain crossover frequency by using the Bode plots of the uncompensated system. The uncompensated system introduces -1.52 dB gain at the frequency
𝜔𝑀=38 rad/sec which is the gain crossover frequency of the overall system after adding the lead compensator. Then, T= 𝜔1 𝑀 α= 1 38∗ 0.704= 0.0314 αT = 0.704 ∗ 0.0314 = 0.022
The transfer function of the designed lead compensator:
=
Figure 9: Bode Plots of the designed lead compensator
5) Finding the new system transfer function which is obtained by adding the lead compensator part.
Overall system’s transfer function after adding the lead compensator is given below.
Now, let’s check the Bode plots of the system with lead compensator. 6) Obtaining the Bode plots of this new system.
Figure 10: Bode Plots of the lead compensated system
PM = 44.2 deg. GM = 4.13 dB
It can be said that the desired phase margin which is 46.5 degrees can not be achieved. The phase margin of the system must increase by 2.7 degrees although a 5 degrees correction factor is added during design. On the other hand, the GM of the system decreases by nearly 3 dB (from 7.22 to 4.13) even though the desired PM cannot be achieved. This means that lead compensator is not a good solution to increase the PM of the system by not decreasing the GM too much. This reason of this problem is the slope of the magnitude Bode plot of the system around the gain crossover frequency. This slope too small, hence the lead compensator cannot really affect the system. This small slope is a result of the selected sampling period that is used to transform the PTF to W domain.
If a higher 𝛷𝑚𝑎𝑥 were used in the lead compensator design, a larger drop on the GM would occur
and the system would become unstable which is not preferable. 7) Designing the LAG compensator part of the compensator.
Lag compensator design is started by finding out the phase of the overall compensated system. To do that the following calculation is done.
Phase(𝐺𝑓𝑖𝑛𝑎𝑙)= -180 + 𝑃𝑀𝑑𝑒𝑠𝑖𝑟𝑒𝑑 + correction factor
Phase(𝐺𝑓𝑖𝑛𝑎𝑙)= -180 + 60 + 5 = -115 degrees
The lead compensated system’s Bode plots is used to find the frequency at which the system has the phase of -115 degrees and
𝜔𝑀=18.5 rad/sec
This 𝜔𝑀 will be the gain crossover frequency of the system that is obtained after adding lag
compensator.
𝜔𝑊𝑜 should be selected sufficiently small enough than the gain crossover frequency not to affect the
system’s behavior. Selecting it 1 of 10 of the gain crossover frequency is sufficiently enough. Then,
𝜔𝑤𝑜=0.1*𝜔𝑀=1.85 rad/sec
After finding that,
𝜔𝑤𝑝 should also be found. To do that, the gain that is introduced by the lag compensator at the final gain crossover frequency have to be calculated.
𝐺𝑐𝑔∗ 𝐺𝑎𝑓𝑡𝑒𝑟𝑙𝑒𝑎𝑑 = 1 = 0 𝑑𝐵 at 18.5 rad/sec which is the final gain crossover frequency 𝐺𝑎𝑓𝑡𝑒𝑟𝑙𝑒𝑎𝑑 can be found using the Bode plots of the lead compensated system.
𝐺𝑎𝑓𝑡𝑒𝑟𝑙𝑒𝑎𝑑 = 1.6538 at 18.5 rad/sec. Then, | 1 𝐺𝑎𝑓𝑡𝑒𝑟𝑙𝑒𝑎𝑑 |= |𝐺𝑐𝑔|= 1 1.6538 = 0.6046
If the lag compensator is considered to be a unity gain compensator.
|𝐺𝑐𝑔|= 0.6046 = 𝜔𝜔𝑤𝑝
𝜔𝑤𝑝 = 0.6046 * 𝜔𝑤𝑜
𝜔𝑤𝑝 = 0.6046 * 1.85 rad/sec 𝜔𝑤𝑝 = 1.119 rad/sec
Then, the transfer functions of the lag compensator and the overall system which is compensated by the lead-lag compensator is shown below.
Figure 11: Bode Plots of the designed lag compensator
Figure 12: Bode Plots of the lead-lag compensated system
PM = 62.4 deg GM = 8.45 dB
The overall system has a PM of 62.4 and a GM of 8.45 dB which are okay according to the design specifications.
It was already mentioned that, this low gain margin is caused by the sampling period used in the z to w domain transformation. If a better sampling period were selected, the resultant system would have a better GM.
The following equations are system transfer function for T=0.001 instead of T=0.05, the lead compensator transfer function and the lag compensator transfer function respectively.
The uncompensated system has the following properties:
Figure 13: Bode Plots of the uncompensated system which is obtained for T=0.001
PM=38.6 deg. GM=21 dB
After the lead-lag compensator design is completed the following Bode plots are obtained.
Figure 14: Bode Plots of the lead-lag compensated system which is obtained for T=0.001
When the sampling period decreases the system is improved and a better GM is obtained.
Decreasing the sampling period also decreases the settling time of the system and as a trade off, it introduces a higher percent overshoot. These results can be observed from the following 2 figures, one is the step response of the lead-lag compensated system for T=0.05 and the other is for T=0.001
Figure 15: Step response of the lead-lag compensated system which is obtained for T=0.05
EFFECT OF LEAD-LAG COMPENSATOR ON TRANSIENT RESPONSE
Effect of lead-lag compensator is demonstrated in MATLAB environment with the help of “Control and Estimation” tool. This tool enables user to design lead-lag compensator for a system and observe its effects in real time. It offers diverse plots (step response, Nyquist, pole-zero, bode plots etc.). In this section compensator design is not done in a formal way but it is done with trial and errors. Figure 17 shows bode plots and Figure 18 shows step response of the closed loop of uncompensated system. The goal is to improve transient response and stability margins.
Note that a gain of 2000 is added to the plant to improve steady state errors to some degree. Steady state error under unit step is also improved by the compensator design. For the plant:
𝐺𝑀 = 11.2 𝑑𝐵 𝑃𝑀 = 85.5⁰ 𝑅𝑖𝑠𝑒 𝑇𝑖𝑚𝑒 = 0.00242 𝑠𝑒𝑐 𝑒𝑠𝑠 𝑢𝑛𝑖𝑡 𝑠𝑡𝑒𝑝 = 1 − 0.833
1 ∗ 100 = 16.7%
The controller is designed for speed control loop mentioned in modeling section. The pulse transfer function of the system is:
𝐺 𝑧 = 0.00026 𝑧 − 0.896
First, system is transformed to w-domain and then MATLAB tool is started with the command “sisotool(<system>)”.
Note: For this case the sampling period is chosen as 0.001 sec, because in continuous system, there is a pole at 109.8 rad. In order to see the effect of this only pole, sampling frequency should be high.
From the tool’s window under “Analysis Plots” tab, different plots of the system can be observed in real time. To observe the compensators effect on transient response, step response of closed system is selected. Then under “Compensator Editor” tab, by right clicking in “Dynamics” panel, a lead compensator is added. Next task is to choose pole and zero of the lead compensator. Since it is not a formal design, it is done based on basic properties of lead compensator.
First thing to remember about lead compensators is that they mostly affect high frequency behavior and they add positive phase to the system near gain crossover frequency of the plant. In our case plant has a single pole at 109.8 rad, therefore it is expected that this plant has a gain cross over frequency above 109.8 rad. Thus zero and pole of the lead compensator is chosen as -110 and -140 respectively. As it can be seen from the window, MATLAB calculates the maximum phase and the frequency at which the compensator provides that phase. For this lead compensator maximum phase is 6.8 degrees at 124.1 rad, so it is a reasonable design. After lead compensator the system’s bode plot is as shown in Figure 19 and transient response is as shown in Figure 20. As expected, the plant’s phase margin is increased and gain margin is decreased. However, it should be noted that rise time of the system is almost halved. Lead compensators introduce a high frequency pole-zero pair to the system and this pair cause the roots of the closed system to shift left, making system faster at the expense of gain margin.
Now it is time to decrease steady state error. To do so, gain of the plant is increased; however this action also decreases gain margin and may push the system to unstable region. In order to prevent this, a lag compensator is added and then gain is increased. Adding a lag compensator is the same as adding a lead compensator for “Control and Estimation” tool. After adding the lag compensator, again its pole and zero should be defined. The default pole and zero is actually suitable for this particular plant, which are a pole at -1 and a zero at -10.
Figure 19: Bode plot of Lead+Plant
Then, overall system’s bode plot becomes as shown in Figure 21.
Figure 21: Bode plot of Lag+Lead+Plant
Now that the system has a considerable gain margin (23.1 dB), gain of the plant can be increased to obtain better steady state error. For this case it is increased to 7000 from 2000, then the system’s transient response becomes as shown in Figure 22.
After lead-lag compensator systems specifications become: 𝐺𝑀 = 12.2 𝑑𝐵
𝑃𝑀 = 87.70
𝑅𝑖𝑠𝑒 𝑡𝑖𝑚𝑒 = 0.004 𝑠𝑒𝑐
𝑒𝑠𝑠 𝑢𝑛𝑖𝑡 𝑠𝑡𝑒𝑝 =1 − 0.9461 ∗ 100 = 5.4%
compensator, on the other hand, makes high plant gain possible and thus decreases steady state error.
Figure 22:Tansient Response of Lag+Lead+Plant