MATLAB: Discrete time simulation error in Simulink

Control System Toolboxdiscrete time simulationpid controllersimulinkSimulink Control Designsisotool

Hello,
I am using PID controller block of Simulink library to control a dynamical system which is represented by a transfer function in simulink. For continuous time simulations; when I substitute the PID parameters designed in SISO Design Tool into the PID block, I get the same results as what SISOtool gives.However in discrete time, I cannot get the same results as the one created in design tool. For example I generate a PID code in an Embedded Matlab Function block and when I enter the parameters designed in sisotool, it does not work.
A related and more interesting problem also occurs in a simpler application. A discretized (using d2c(myfunction,Ts,'tustin')) open loop transfer function gives different responses to a step reference in simulink and when I write
>>step(myfunction)
in command window. In the first case, some steady state error occurs but in the second case no steady state error occurs as expected.
I want to note also that, I tried to change configuration parameters (change solver, change sampling time…) in simulation but it did not work.
I think the two problems may be related in the sense of discrete time simulation in simulink and I hope I have explained the problem clearly. This is a serious problem since I need to design a number of PID controllers for a complex-nonlinear system. Any assistance would be greatly appreciated.
Thank you,
Tugba

Best Answer

I realized that matlab rounds the coefficients when I run c2d function and entering these parameters as discrete time transfer function coefficients makes huge difference between the actual parameters. I could not imagine that, difference at 10^-10 digits make such a big steady state error but it does.
So, I guess discretization problem is solved.
Related Question