I am simulating a simple closed loop speed controller for a DC motor in scilab/xcos.
I have a continuous PI controller working just fine.
I have then discretized the continuous controller and implemented it in two different, but equivalent ways, and it seems that the two discrete implementations provide different results, even though they are supposed to be equivalent.
Both discrete controllers are obtained by the same discretization method (Tustin), but one is implemented as a single DLR Xcos transfer function, whereas the other is implemented as a sum of the P and I parts individually.
The attached model contains all setup in the Context, and illustrates both the continuous controller as well as both of the discrete controllers.
The "componentwise discrete control" tracks the continuous controller reasonably well, whereas the "transfer function discrete control" is unstable.
The problem is resolved for shorter sample times, which puzzles me since the math governing the two discrete implementations is completely identical, and I would therefore expect the relative behaviour of the two discrete controllers should be the same no matter what sample time is used.
I would appreciate any input or explanation as to what I am doing wrong and why these two seemingly equivalent implementations differ.
The model is attached here:
https://www.dropbox.com/s/itudk4a1ooh6ncz/dc_motor_control.zcos?dl=0
Just add a sample-and-hold in the path of the (continous!) kp in the componentwise controller ;-) The kp "saves" your stability because its continous, though the integrator works discrete. But the embedded discrete controller works discrete with Ts entirely - that's too slow. If you add the discrete behaviour to the kp via sample-and-hold you achieve the same results.