Project - Position control of mass spring damper system
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.

Solution
The given parameters:
m=3.6
k=400
c=100
consider a simple Spring-mass-Damper system:

Matlab Code:
m=3.6;%mass
k=400;%spring
c=100;%damper
wn=sqrt(k/m);%Natural frequency of the dynamic system
zeta=c/(2*wn*m);%Damping ratio
%To find the poles
p1=-zeta*wn+wn*sqrt(zeta^2-1);
p2=-zeta*wn-wn*sqrt(zeta^2-1);
P=[p1;p2];
%The state space equation is converted into matrices
A=[0 1;-k/m -c/m];
B=[0;1/m];
method = input('Enter 1 for pole placement method or 2 for direct control')
if method ==1
K=place(A,B,P);
%Propotional and derivative gain
Kp = K(1);
Kd = K(2);
else if method ==2
Kp=wn^2;
Kd=2*zeta*wn;
else
disp('Entered input is not valid enter 1 or 2')
end
end
Ki = 500;%To get a stable system
Parameters of Transfer function block:

Simulink Model:

Output:
The value of zeta became 1.3176.
According to reference and Ki=500,the response became near by the stable system.

Thus the transfer function of a mass spring damper system with a PID controller to adjust the force on mass so that its position followed by a reference signal analyzed and simulated successfully.