Feature similar to feedback command in simulink

1 次查看(过去 30 天)
Hi everyone,
I have an issue with discrete controller I am trying to implement. I discretized a PID controller C and the plant G with the Tustin method. The discretization is stable with the feedback command:
feedback(C*G, 1)
But when I use the normal feedback equation the system becomes unstable:
(C*G)/(1 + C*G)
I read in the feedback command documentation that this is a numerical(?) issue and that the feedback command gives the correct answer. I confirmed this by comparing the frequency response of the system with the normal equation and the feedback command. The DC gain with the normal equation is completely off.
In any other case, I would just use the feedback command, but I would like to use the model in SIMULINK, so I can scope the input u and implement saturation blocks.
How can I implement the correct stable closed-loop system in SIMULINK and still be able to scope the input and add saturation limits?
Thank you in advance!
For reference my C and G are listed below (d indicates discrete):
s = tf('s');
C = 180*( ( s+0.1 )*( s+0.04 ) )/(s*(s+60));
G = 1/(s^2*(0.1*s + 1));
T = 0.05;
Cd = c2d(C, T, 'tustin');
Gd = c2d(Gd, T, 'tustin');
Hd = feedback(Cd*Gd, 1);
Hd2 = Cd*Gd/(1+Cd*Gd);
isstable(Hd)
isstable(Hd2)

采纳的回答

Paul
Paul 2021-12-16
Two separate issues.
The first is that, as you've discovered, it's (almost?) always better to use the feedback() command as for Hd, rather than lti algebra, as for Hd2. Having said that, it's also (almost?) always preferred to use the zpk (or ss) form rather than the tf form. Using the zpk form gives the expected result, even for Hd2:
s = tf('s');
C = 180*( ( s+0.1 )*( s+0.04 ) )/(s*(s+60));
G = 1/(s^2*(0.1*s + 1));
Hc = feedback(C*G,1);
T = 0.05;
Cd = c2d(zpk(C), T, 'tustin');
Gd = c2d(zpk(G), T, 'tustin');
Hd = feedback(Cd*Gd, 1);
Hd2 = Cd*Gd/(1+Cd*Gd);
Compare the frequency responses, and show Hd and Hd2 match, and they approximate Hc.
bode(Hd,Hd2,Hc,{1e-4 62})
legend('Hd','Hd2','Hc')
However, isstable() still returns different answers
isstable(Hd)
ans = logical
1
isstable(Hd2)
ans = logical
0
Look at Hd and Hd2
Hd
Hd = 0.0089507 (z+1)^3 (z-0.998) (z-0.995) ------------------------------------------------------- (z+0.2047) (z-0.9947) (z-0.998) (z^2 - 1.572z + 0.6291) Sample time: 0.05 seconds Discrete-time zero/pole/gain model.
Hd2
Hd2 = 0.0089507 (z-0.995) (z-0.998) (z-1)^3 (z-0.6) (z+1)^3 (z+0.2) ------------------------------------------------------------------------------- (z-1)^3 (z-0.998) (z-0.9947) (z-0.6) (z+0.2047) (z+0.2) (z^2 - 1.572z + 0.6291) Sample time: 0.05 seconds Discrete-time zero/pole/gain model.
All poles of Hd are inside the unit circle, but Hd2 has three poles at z = 1, which is why isstable returns false. But those poles only show up because of the lti algebra and they cancel with three zeros z
minreal(Hd2)
ans = 0.0089507 (z-0.995) (z-0.998) (z+1)^3 ------------------------------------------------------- (z+0.2047) (z-0.9947) (z-0.998) (z^2 - 1.572z + 0.6291) Sample time: 0.05 seconds Discrete-time zero/pole/gain model.
which shows that Hd2 is the same as Hd.
The second issue is the Simulink implementation. In Simulink, there is no need to implement the closed loop system with a single block. Just draw the block digram using one block for the plant and one for the controller. Connect the output of the latter to the input of the former and then implement the feedback loop using a Sum or Subtract block. The plant and controller can each be implemented in an LTI System block. That way you can implement the plant using C or Cd, and the control using G or Gd, depending on what you're really trying to model.
  2 个评论
Maarten
Maarten 2021-12-16
Wow, I had no idea zpk was beter numerically! I was always taught to use tf, so I never considered that zpk might give more accurate answers in this case. Thank you, so much!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Classical Control Design 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by