Project - Position control of mass spring damper system
Aim:-
Obtain the transfer function of a mass spring damper system and use it in the model. Add a PID controller to adjust the force on mass so that its position follows a reference signal.
Take m = 3.6; %kg k = 400; %N/m c = 100; %Ns/m
The reference signal is shown in the following figure.

Result:-
First need to find out the K by pole placement method to get the kp and kd.
%Given parameters m = 3.6 kg, k = 400 N/m, c= 100 Ns/m.
m = 3.6;
k = 400; %spring constant
c = 100; %damping ratio
%Transfer function for a spring mass damper system is 1 / ( m * s^2 + c* s + k )
fn=1;
wn = sqrt(k/m);
%let take zeta = 0.9;
zeta = 0.9;
%poles
p1 = -zeta * wn + wn * sqrt(zeta^2-1);
p2 = -zeta * wn - wn * sqrt(zeta^2-1);
P = [p1;p2];
%A & B matrices
A = [0 1;-k/m c/m];
B = [0;1/m];
%Poles placement design
K = place (A,B,P);

From the m script we got,
kp = -1.0232e-13 and kd = 168.3052.

First created the model of mass spring damper system with kp and kd as obtained by keeping the ki as zero.

Here the reference signal is provided as pulse signal.

The output is obtained as ;

The yellow line is the reference signal and the blue line is the output from the system. We can see that the system not following the reference signal so we need to change the parameters.

In the above table we can see that rise time decrease by increasing the kp and overshoot decrease by increasing the kd. So by trail and error I have set the kp as 650 and kd as 260.
Now the issue is with steady state error. So I tried to change the ki value to adjest the steady state error.
first I put the ki as 50,


Here we need to decrease the steady state error some more. So we are increasing the ki value again.
Lets add 200 to ki and make it as 250 then observe the response,

Here we can see that the steady state error needs to eliminate some more, so finally we are going to set the value of ki as 500 and observe the result.


Here we can see the output of the system is following the reference signal with a rise time of almoost one second and no overshoot and steady state error. So we can say that the system is settled and stabled.
The parameters are obtained by the trail and error method are;
kp = 650
kd = 260
ki = 500
Conclusion:-
Our aim is to obtain the transfer function of a mass spring damper system and use it in the model. Add a PID controller to adjust the force on mass so that its position follows a reference signal.
So with the help of PID controllers we have successfully positioned the spring mass damper system.
(The model and script file are attached below)