constructing discrete time system

10 views (last 30 days)
Junhwi
Junhwi on 12 Dec 2023
Commented: Lucas on 11 Jul 2024
I consturcted the loop for disturbance rejection for discrete time system.
But I wonder, why two steps are different?
Gdtest case: discretization and then constructed closed loop
Gdd2 case: constructed closed loop and then discretized the closed loop
I'm confused which one is right.
And I wonder how to check output of controller which is input of system Gd.
Thank you in advance
s = tf('s');
G = 4000/(s*(s+10)*(s+20));
st = 0.02;
Gd= c2d(G,st,'foh');
Cdr = 20 + 100/s + 2*s/(s/1000 + 1);
Gdr0= c2d(Cdr,st,'foh');
Gdtest = feedback(Gd,Gdr0);
Gdd2= c2d(feedback(G, Cdr),st,'foh');
figure;
step(Gdtest)
figure;
step(Gdd2)

Answers (1)

Paul
Paul on 13 Dec 2023
Hi Junhwi,
The short answer is that the sample time, st, is too large for discretizing Cdr before forming the closed-loop system.
First, I think it's easier to see what's happening by using the zpk form instead of the tf form.
s = zpk('s');
Now form G and discretize it.
G = 4000/(s*(s+10)*(s+20))
G = 4000 --------------- s (s+10) (s+20) Continuous-time zero/pole/gain model.
st = 0.02;
Gd = c2d(G,st,'foh')
Gd = 0.0011851 (z+8.814) (z+0.887) (z+0.08924) ----------------------------------------- (z-1) (z-0.8187) (z-0.6703) Sample time: 0.02 seconds Discrete-time zero/pole/gain model.
We see that all the poles have been mapped in accordance with z = exp(s*T).
exp(pole(G)*st)
ans = 3×1
1.0000 0.8187 0.6703
Note that the sampling time, 0.02, is more 2x smaller than the smallest time constant in G, which is 1/20 = 0.05.
Form Cdr
Cdr = 20 + 100/s + 2*s/(s/1000 + 1)
Cdr = 2020 (s^2 + 9.95s + 49.5) ------------------------- s (s+1000) Continuous-time zero/pole/gain model.
The sample time, 0.02, is 20x larger than the smallest time constant in Cdr, which is 1/1000 = 0.001. Hence, the discretization will not be what we want.
Gdr0 = c2d(Cdr,st,'foh')
Gdr0 = 121 (z^2 - 1.81z + 0.8264) -------------------------- z (z-1) Sample time: 0.02 seconds Discrete-time zero/pole/gain model.
The pole at the origin s=0 in Cdr maps to z = 1, and the pole at s = -1000 maps to exp(-1000*st), which is effectively at the origin. This pole at the origin is an open-loop pole.
Now we form the closed-loop system, and because that open-loop pole at the origin isn't really in the correct location, the feedback is wrong and we get an unstable system (poles outside the unit circle)
Gdtest = feedback(Gd,Gdr0)
Gdtest = 0.0010364 z (z+8.814) (z+0.887) (z-1) (z+0.08924) ----------------------------------------------------------- (z+0.05193) (z^2 - 1.811z + 0.8274) (z^2 - 0.2919z + 1.683) Sample time: 0.02 seconds Discrete-time zero/pole/gain model.
abs(pole(Gdtest))
ans = 5×1
1.2973 1.2973 0.0519 0.9096 0.9096
Here, we form the continuous-time closed-loop system
feedback(G,Cdr)
ans = 4000 s (s+1000) -------------------------------------------------- (s+1008) (s^2 + 9.887s + 49.81) (s^2 + 12s + 7966) Continuous-time zero/pole/gain model.
Looking at the time constants associated with the poles
-1./real(pole(ans))
ans = 5×1
0.0010 0.1667 0.1667 0.2023 0.2023
we see that the st is considerably smaller than all of them, except the time constant associated with the pole at s = -1008. So that pole will incorrectly map to the origin after discretization. BUT, that pole is a closed-loop pole (not an open-loop pole) and in this case it's nearly cancelled by the zero at s = -1000, which will also result in a near cancellation after discretization
Gdd2 = c2d(feedback(G, Cdr),st,'foh')
Gdd2 = 0.0010929 (z+7.365) (z+0.9108) (z-1) (z+0.1141) (z-1.221e-06) ------------------------------------------------------------- z (z^2 - 1.803z + 0.8206) (z^2 + 0.3702z + 0.7866) Sample time: 0.02 seconds Discrete-time zero/pole/gain model.
As expected, we have a closed-loop pole essentially at the origin and a zero there as well at z = 1.221e-6. So the fact that st is too large doesn't really have an impact when discretizing the closed-loop system.
The solution for the first case is to use a much smaller sample time
st = st/100;
Gd = c2d(G,st,'foh');
Gdr0 = c2d(Cdr,st,'foh');
Gdtest = feedback(Gd,Gdr0);
Gdd2 = c2d(feedback(G, Cdr),st,'foh');
figure; % put all three systems on the same plot
step(feedback(G,Cdr),Gdtest,Gdd2)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!