Transfer function block doesn't work inside a subsystem

This has more to do with how the transfer function is discretized then floating vs. double point precision. The transfer function is discretized by default using Forward Euler when generating code in PLECS. This second order system is unstable with the default step size of 1e-4.

For this type of resonant transfer function, it is often better to explicitly discretize the system yourself. Attached is a model where I use the Octave controls toolbox to use the Tustin discretization method and Tustin with frequency prewarp. The prewarp assures the resonance is exactly at the desired frequency. I changed the sampling frequency (fe) to 1e3 to exaggerate the impact of the prewarp and highlight how the system is still stable even with the much smaller sampling frequency.

Transfer_sub_bl.plecs (24.7 KB)

2 Likes