Simulink : Unstable response for a stable system

I have modeled a spring mass damper system along with a compensator in simulink. The transfer function of the spring mass damper system goes like this 1/(Ms^2+bs+k) where m=5.2e-6 b=6.25e-5 k=70 Am getting a stable response when i actually code this in matlab.But in simulink using ode45 dormand-prince, am getting a unstable response. Pls help me out in this, as this is my fisrt step in modeling a micro accelerometer.

 Accepted Answer

Hello Omkar,
I investigated your system a little bit, and I think I can give you some answers. I think your problem is due to the numerical values of your system paramters. Since you are modelling a (mechnaical) spring mass damper system, the parameters can be interpreted as follows:
M: mass
b: (linear) friction
k: spring rate
With these parameters, you create a Model with transfer function G(s) = 1/(Ms^2 + bs + k). This is a LTI-Model, more precisely a so called PT2-System. The numerical values of the characteristic coefficients of this PT2-System are (based on the numerical values of your system parameters):
w0 = 3.6690e+003 (Eigenfrequency)
D = 0.0016 (Damping)
K = 0.0143 (Gain)
the two Eigenvalues of the corresponding System Matrix A = [0 1; -w0^2 -2*D*w0] are:
1.0e+003 *
-0.0060 + 3.6690i
-0.0060 - 3.6690i
--> Your System has complex Eigenvalues with small real parts and large imaginary parts (compared to each other). The consequence is that your system is a so called "stiff" system.
"explicit" solvers, as ode45 for example, have problems to solve stiff systems, respectively they are not designed to solve these problems. Therefore Simulink offers other solvers, especially designed to solve stiff systems. One of such a solver is ode15s for example. If I use this solver, I get the same results as when I simulate the step response with the "step" command offered by the control toolbox.
The solution for you may be, that you use a solver that fits your problem.
I hope this will help you...

4 Comments

That was very informative. Thank you.
And the values that i have mentioned is correct since am working on accelerometers at micro level. I usually simulate it for 1second and even that takes 20 min !
Simon, would it be possible to give ur email id so that i could attach my simulink file and send it to you.I had a doubt which i cant explain without showing my exact model.
Hello Omkar,
I have to excuse myself. I mixed up the two paramters b and k in my calculations. Because of that the numerical values of the coefficients w0, D and K were wrong and also my "extrem" long step response (in the simualtion results, not the computation time). I corrected the values, and the answer in the text above. Nonetheless the rest about stiff systems remains valid.
The results in simulink depend strongly on the parameters of the solver. Because your System is very "fast" (high eigenfrequnecy) you have to adpat the solver apprpriate to your system. I would even propose a smaller "max stepsize" than Arnaud did. I used "max stepsize = 1e-5" and "relative tolereance = 1e-6". This showed (physical) reasonable (and smooth) results. I believe much more in these results than those produced by the "step" command. I don't know how "step" works internally, but it seems that there are "missing" aobout 80% of the oscillations with "step". Compare it to the simulink results.
you can mail to me: strs@hs-furtwangen.de
I ran my model with values of max step and tolerance you gave.I got a fair enough response. Thanks for that.
could pls explain what exactly is relative tolerance?
+1 vote for a good answer, looking forward to see more answers from you Simon Stroebel

Sign in to comment.

More Answers (2)

Hello Omkar, it would be neccessary to know if you used the "Transfer Function" Block in your Simulink Model, or if you coded it via a "real" Block Diagramm, that means with Integrators, Gain and Sum Blocks. In the latter case, you probably may have mixed up the signs in the Sum Blocks? This is common mistake which leads to "unstable" system responses of stable systems.

1 Comment

Thnks for ur reply simon.
I used the transfer function block available in the simulink browser and then entered my num and den coefficients. I had also this with integrator blocks. Got the same unstable result for both. when i keep my M=1 , b=2, k=4, then am getting a stable response but not for the actual values i mentioned.

Sign in to comment.

I tried these values with the transfer function block in Simulink and a step input and I get a stable input if I use ode23t, ode23s or ode23tb, with a max step size of 0.01s. It is however, a marginally stable system. Consider increasing the damping to make the system less stiff. ode45 is not well suited for numerically stiff systems, as has been pointed out already.
HTH,
Arnaud

3 Comments

Thank you Arnaud. And the poles for the system i meantioned are at -6-j3.67e3 and -6+j3.67e3. So it is stable system. And since this is the mechanical part which is already fabricated at micro level, i cannot change the existing values.
And i got a stable response for the solvers u mentioned. But Except for the steady state value no other parameters such as overshoot, settling time are matching with the with one done using matlab code. I want to know how the matlab will solve when i actually code it and how it will solve when the same system in solved in simulink.
What MATLAB code are you using to solve the system? Make sure you are using the same solver if you use an ode solver. Using:
m=5.2e-6; b=6.25e-5; k=70;
msd = tf(1,[m b k]);
step(msd,10)
I get the same response.
i used the same code as u have mentioned. I get a response where the overshoot is 97.5% and settling time around 0.68s.
Now when i do this in simulink by having a transfer function block,
a step input, a scope and setting the solver to ode23s and running the simulation for 1s, i get same steady state value but the response is nowhere similar to one i get using code.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!