Discrete transfer function implementation on hardware explodes to infinity
5 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a very simple transfer function model that works well in Matlab/Simulink. However, when I try to implement it on my actual hardware, the output quickly explodes to infinity.
I'm trying to deploy this model to a PLC running Twincat. Twincat has its own implementation of transfer functions which I have faith it is bug free. I have double checked my calls and I don't believe there is anything wrong (famous last words!).
Could this numeric instability be due to the way that matlab/simulink implements the calculation versus the way that Twincat does it?
Or could it be something related to the type/order of the model? Would state space offer any advantage in terms of numeric stability?
Thanks
#Matlab code
sys = tf([0 0.0611], [1 2.05 0])
sys =
0.0611
------------
s^2 + 2.05 s
Continuous-time transfer function.
sysd = c2d(sys, 0.002)
sysd =
1.22e-07 z + 1.219e-07
----------------------
z^2 - 1.996 z + 0.9959
Sample time: 0.002 seconds
Discrete-time transfer function.
5 个评论
Mathieu NOE
2022-11-8
That sounds ok to me
make sure the a and b coefficients are passed in the right order (usual error is when copy paste from ascending vs descending power of z formalism)
回答(1 个)
Bora Eryilmaz
2022-12-7
编辑:Bora Eryilmaz
2022-12-7
Your discrete transfer function has poles (almost) right on the unit circle:
sys = tf([0 0.0611], [1 2.05 0]);
sysd = c2d(sys, 0.002);
pzmap(sysd)
Any slight perturbation of your model coefficients when it is implemented using fixed-point numbers on the PLC would likely make your transfer function unstable.
Also, your model has an integrator (1/s term). So its simulation would go to infinity anyway.
step(sys)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Control System Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!