## Controller design - transfer function producing different response from numerical model

on 31 Oct 2012

### Arkadiy Turevskiy (view profile)

I'm producing different results when I use built-in Simulink blocks such as Transfer Function and PID Controller as compared to explicitly describing the system using Derivative, Integrator, Sum blocks etc. I believe it has something to do with the way MATLAB linearises the models in Simulink and other tools like SISOTool.
As an example, I have a simple linear model of the form
x'' = u/1.54
with u as the input and x as the state. Applying a PD controller to this:
u = (2 + 5*s)*e
gives the closed loop TF
x(s)/r(s) = (5*s + 2) / (1.54*s^2 + 5*s + 2)
Comparing the response of this TF to a step input to the explicitly stated model produces different outputs, as seen in the images. Does anyone know the cause of this? They should be identical, but MATLAB seems to be solving one model incorrectly. To reiterate, I get the first response when using PID Control or Transfer Functions blocks or the MATLAB functions "Step" and SISOTool. The second response is obtained from the model with the double integrator.
Cheers,
Murray

### Arkadiy Turevskiy (view profile)

on 31 Oct 2012
Edited by Arkadiy Turevskiy

### Arkadiy Turevskiy (view profile)

on 2 Nov 2012

I agree with the recommendation not to use pure derivative from the previous answer. Derivative block is causing problems in the simulation. To implement a PD controller in real life, you wouldn't use pure derivative anyway. Real signals are always noisy, and pure derivative amplifies high frequency noise.
Use a PID Controller block from Continuous library instead. Set I gain to zero. You can make N (filter coefficient) very high if you want to closely approximate pure derivative. If you look under block mask you will see the block implements a derivative action using an integrator. This is exactly what the doc for derivative block recommends.
If you do that, and also add a gain of 1/1.54 (looks like you forgot it in the lower branch of your model), you will get the same results.
Also easy to do in MATLAB:
s=tf('s');
G=1/(s^2*1.54);
C=pid(2,0,5);
step(feedback(C*G,1))
HTH.

Murray

### Murray (view profile)

on 1 Nov 2012
Thanks for the answer, seems to make sense using the integrator for derivative action. Do you have any suggestion as to how rate feedback would be used in the controller, rather than derivative action on the error? I found using rate feedback produced the same response as using the derivative block.
Thanks, Murray