Matlab 3 PDF

Title Matlab 3
Course Control and Guidance
Institution Universitat Politècnica de Catalunya
Pages 14
File Size 964.9 KB
File Type PDF
Total Downloads 89
Total Views 137

Summary

Download Matlab 3 PDF


Description

Names: Alex Arevalo, Diego Pisco

MatLab tutorial 3: Digital Control Systems Report: due BEFORE December, 2 2020 15:10 (just before short exam 2) In this tutorial you will study MatLab applications to digital control. Notice the strong similarities between the analog (continuous time) and digital (discrete time) MatLab commands. 1. Satellite attitude control Satellites need an attitude control system in order to properly orientate their antennas and captors with respect to the Earth, and often also their solar panels with respect to the Sun. The following figure shows the case when only one movement around one axis is considered. The movement equation is:

Discrete transfer function The first step to digitally control a system is to find the discrete equivalent transfer function of the continuous plant (plus actuators plus sensors). For that, you can use the MatLab function called c2d. To use this c2d, you need to specify 2 or 3 arguments: the continuous transfer function G, the sampling time (Ts), and the discretization method. When the latter parameter is not entered, MatLab assumes the zero-order holder ('zoh'), and this is our assumption for this plant, a ZOH D/A converter. Now, introduce the analog (continuous) transfer function (in a M-file if you want) and to calculate the discrete transfer function use the commands either Gz = c2d (G, Ts, 'zoh') or just Gz = c2d (G, Ts) you can also introduce functions with z= tf('z', Ts) and Cz = poly1(z)/ poly2(z). It is always a good idea to try to simplify all transfer functions (especially the discrete ones) with the command minreal(Gz). 1

Question 1) Is our (continuous) plant stable in open and closed loop? Check it directly, and also with the root locus, the Bode (double) diagram and indicate both the gain and phase margins. First of all we are going to study the open system and the first thing we can observe is that we have two poles at the origin, therefore we can deduce that the system will be completely unstable. In Figure 1 we can see the step response of the open loop and we confirm the unstability.

Figure 1. Impulse response in open loop.

Figure 2. Root locus and impulse response in closed loop.

2

Now we are going to analyze the closed loop, for that we must observe the root locus and the step response of Figure 2 . We can see that in this case the system will be marginally unstable and we will need to see its bode diagram.

Figure 3. Bode diagram.

As you can see the phase is always -180º so both GM and PM are 0 dB and this ensures that the closed loop is marginally unstable.

Question 2) What sampling time should you select and why? (Nyquist criterion) Try different sampling times, for instance 1, 0.1 and 0.01. Do you perceive any difference in the open loop transfer function? In its step response (zoom-in)? What about the closed loop with unit feedback? First of all we can say that the natural frequency of our system is 0, so the sampling frequency is:

W s >10 · W n , 20· W n , 30· W n =0 T <

2·π =∞ 0

This means that any T(period) will be correct for this system, so for this particular system every period will also give us the same information, with a bit different constants, we can see it in the next table:

3

Ts=1 s.

Ts=0.1 s.

Ts=0.01 s.

In the table we see how as we decrease the sampling time the K factor that multiplies our TF decreases.

Figure 4. Step response in open loop for different values of sampling time.

In Figure 4 we can see that the step response seems to be the same for all the sampling times but when we see the zoom they are not exactly the same; the bigger the sampling times, the bigger the time between two samples and consequently the less it will look like the step response in continuous time.

Now we are going to do the same with the closed loop:

Ts=1 s.

Ts=0.1 s.

Ts=0.01 s.

4

Figure 5. Step response in closed loop for different values of sampling time.

In the case of closed loop we see exactly the same as in the open loop, as the sampling time decreases also the K factor that multiplies the TF. In this case we see that the poles change from one sampling time to another. The smaller the sampling time, the more the poles look like the ones in open loop.

Question 3) Draw the root locus for the different sampling period discretizations. Any difference at all? Sure? We will draw the three different plots, with different sampling periods. A priori, the root locus is the same. We know that the open loop system is unstable due to the branches that start in the poles and end in the zero are always outside the unity radius circle.

Figure 6. Root locus with Ts=1 s (left) and with Ts=0.1 s (right).

5

Figure 7. Root locus with Ts=0.01 s.

As we can see in Figures 6 and 7 for different sampling times the gain in the same points changes like we have calculated in the previous section. Another change is the frequency at the same point that varies inversely proportional to the sampling times as we know. Question 4) Now let us try a different discretization method assuming that the D/A converter has a FOH, Gz2 = c2d(G,Ts,'FOH'). What should this method guarantee? Compare the open loop step responses of the original functions and their discretizations (only for a common sampling time, 1, 0.1 or 0.01). What is the effect of different sampling times? Hint: represent 20 seconds, step(G, G1, G2, 20) The method of FOH (First Order Hold) does a linear interpolation of inputs, reconstructed the original by a linear approximation between samples. This method guarantees a good global approximation when going from continuous to discrete time, in this case, when inputting a step to the plant.

Figure 8. Step response with different discretization and Ts=1 s (left), Ts=0.1 s(right).

6

Figure 9. Step response with different discretization and Ts=0.01 s.

On a global view, for all sampling times, the step response is the same for both methods and for continuous time. This fact validates what the FOH should guarantee, neither ZOH nor FOH changes the step response shape. Root locus and compensation Question 5) From now on, choose and stay with a single sampling time and therefore just a Gz (ZOH method) from now on. Draw its root locus, how can you stabilize it? It seems that just adding a zero would do the trick. Is it really so? Describe which one would be the feasible part of the root locus for the closed-loop poles to satisfy the design requirements. If we want to stabilize the plant we can add a zero to move part of the asymptotes which birth in the poles to the unitary circle of stability. We are going to locate this zero at 0.425. The only problem it has is that it is unfeasible as a controller cannot have more zeros than poles which means having a non-causal system. That is why we put a pole on -0.9028 resulting in a feasible controller, with the same number of poles than of zeros (meaning having a causal system) and at the same time allows to stabilize the system for small values of proportional gain.

Figure 10. Root locus and step response adding a Lead controller.

7

Question 6) Now let us use the SISOtool. Make it show transfer functions in zpk (gain.szeros.poles) form:

Can you use a differentiator (as MatLab understands it) to compensate the plant? Why? Choose a suitable compensator, select the gain value and plot the response of the closed-loop system to a discrete step entry θ ref=12º. Obtain the overshoot M and the peak time t p corresponding to the requirements. A differentiator is to put a zero in the origin. The problem is the same than before, the resulting controller would not be causal and thus not feasible, therefore a pole is needed to accomplish feasibility. For this we need a suitable compensator that would be:

With this compensator we obtain the next plot and this values of overshoot and peak time:

8

Figure 11. Root locus and step response adding a differentiator.

Figure 12. Zoom of the values of M and Tp.

Dead-beat controller (variation of Truxal method) Question 7) Discrete-time systems can be very flexible, and we can design our closed loop transfer function to operate just as a delay of a sampling period, the simplest pure dead-beat controller. Is the controller feasible, physically possible? Why? First of all we have to compute the controller function needed knowing the already designed plant:

T ( z)=

G ( z )⋅C ( z) ; with H(z) =1 1+G ( z ) ⋅C ( z) ⋅ H ( z) C( z)=

T (z) G ( z ) ⋅ ( 1−T (z))

We know that a global transfer function that acts as a single delay corresponds to:

T ( z)=¿

Z

−1

and knowing that our plant with Ts=0.01 is: 9

G (z)=

5 ⋅10−5 z +5 ⋅10−5 z 2−2 z +1

We can calculate the dead-beat controller:

(z 2−2 z +1)⋅ z −1 z−1 C( z)= =20000⋅ −5 −5 −1 z +1 (5 ⋅10 z +5 ⋅10 )⋅ (1−z )

We can assure that a dead-beat controller would be feasible and physically possible as it accomplishes the rule of having equal or more poles than zeros, meaning that the controller and thus the global system are causal. We can confirm too that the system stability is always fulfilled with these controllers as the global system acts as a single delay.

10

Question 8) Calculate the needed controller, indicating every step, and then plot, with the aid of MatLab, the consequent closed loop step response. Represent also the input that the controller should supply to the plant. How would the controller change if we prefer T (z)=0.62 z−1+0.38 z−2as closed loop response (total transfer function)? Why could we prefer this second approach? The needed controller is the one calculated in question 7. Now we are going to see the step response of the closed loop:

Figure 13. Step response in closed loop with controller of question 7.

In Figure 13 we can see how it is practically impossible to obtain such a drastic change in just an instant of time in real life. This means that we will have to change the controller as a global system represented by a single delay it is not very realistic. If we want to have a new TF we will have to calculate the new controller like in question 7: Now the T(z) that we want is:

T (z)=0.62 z−1+0.38 z−2

And the plant is the same of before:

G (z)=

5 ⋅10−5 z +5 ⋅10−5 z 2−2 z +1

So the new controller will be:

11

C( z)=

1 0.62⋅ z−1 +0.38 ⋅ z−2 2 (z −1)❑ ⋅ 2 ⋅(z +0.613) =12400⋅ 5 ⋅10−5 z + 5 ⋅10−5 (z +1)⋅(z −0.62 z−0.38) (1−(0.62 ⋅ z−1+0.38 ⋅ z−2)) 2 z −2 z +1

Once we have calculated the new controller, we are going to see its step response and compare it with the previous one to see which one would be more realistic:

Figure 14. Step response in closed loop with the new controller.

In this case we think that we have improved the performance of the system. The step response is not so fast and increases stepwise, this means that is more accurate to a real physical system and becomes the best option. 2. Additional considerations on the sampling period Consider the transfer function of the QUANSER plant when we make it act as a helicopter and we control the yaw angle (heading) by the voltage input to the corresponding rotor:

Questions 9 and 10) What is the effect of the sampling time on its discretization (let us assume ZOH)? Try 0.1 and 10 seconds, check stability (with care, pay attention to the details) and the theoretical impulse and step responses in both open and close loop (with unit feedback). Can you notice something unexpected? We know that the plant has one pole at zero and another pole at -1. So the naturals frequencies would be ωc = 0 rad/s for the first pole and ωc = 1 rad/s for the second. If we take the higher value, we know that the sampling frequency would be 10 times this value so theoretically the sampling times would be 0.63 s. Therefore theoretically the more stable would be with sampling time 0.1 s. 12

First of all we are going to analyze the root locus and the bode diagram with both sampling times:

Figure 15. Root locus and bode diagram with Ts=0.1 s.

Figure 16. Root locus and bode diagram with Ts=10 s.

In Figures 15 and 16 we can see in the root locus with sampling time 0,1 s that the system is unstable because the asymptotes leave quickly the unit circle and with sampling time 10 s the system is stable because it is in the unit circle. From the bode diagrams we know that the GM and PM with Ts = 0.1 s. are 46.2 dB and 84º respectively, and with Ts = 10 s. the GM and PM are 7.96 dB and 56.3º. Knowing these values we can assure that the system would be stable in the two cases for some values of proportional gain. Now we are going to plot the impulse and step response of open and closed loop with both sampling times to continue analyzing the stability of the plant:

13

Figure 17. Step response in open loop (left) and closed loop (right) with different Ts.

In Figure 17 we can see that the step responses in open loop with different sampling times are equal, in both cases the amplitude tends to infinity so the system becomes unstable, but for the step response in closed loop the system is stable, we have a difference between the sampling times, if we have a Ts = 10 s. the step response has an overshoot while with Ts = 0.1 s. we do not have that overshoot, therefore is better the case with 0.1 s.

Figure 18. Impulse response in open loop (left) and closed loop (right) with different Ts.

Finally, looking at the impulse responses we can assure that when we have a bigger sampling time, the total number of samples is smaller so the approximation is worse and slower. This fact plus the conclusion that we have commented at the beginning of this question, leads us to conclude that taking the sampling time of 10 s. we are wrong due to the fact that we are not taking enough samples to have a good and realistic approximation of the system.

14...


Similar Free PDFs