Filter löschen
Filter löschen

Discrete transfer function implementation on hardware explodes to infinity

4 Ansichten (letzte 30 Tage)
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 Kommentare
Felipe
Felipe am 8 Nov. 2022
Hi Mathie, thanks for your reply!
I did not know that. The transfer function I'm trying to implement has 2 poles and 2 zeros. The API I'm using, implements the model in this form:
Mathieu NOE
Mathieu NOE am 8 Nov. 2022
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)

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Bora Eryilmaz
Bora Eryilmaz am 7 Dez. 2022
Bearbeitet: Bora Eryilmaz am 7 Dez. 2022
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)

Kategorien

Mehr zu PLC Code Generation Basics finden Sie in Help Center und File Exchange

Produkte


Version

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by