Project - Position control of mass spring damper system
AIM
To Design the transfer function of a spring mass damper system using PID
Description
Spring Mass Damper
Governing Equation

The free-body diagram for this system is shown below. The spring force is proportional to the displacement of the mass, and the viscous damping force is proportional to the velocity of the mass, Both forces oppose the motion of the mass and are, therefore, shown in the negative -direction. Note also that this corresponds to the position of the mass when the spring is unstretched.
`F=ma+cu+kx`
Transfer function
`(x(s))/(F(s)) = 1/(m*s^2 + d*s + k)`
PID

changing equation to PID model
`x=-k/m+1/m(k_p(x_(ref)-x)+k_i(intx_(ref)-x)dt-k_d x`
MATLAB CODE
Main Code
%%%code by Jagaveerapandiyan.S
%%%Design Parameter
clear all;
close all;
clc;
m = 3.6; %kg
k = 400; %N/m
c = 100; %Ns/m
%% Requirement of requirement responce
wn=sqrt(k/m);
fn=wn/2*pi;
zeta=0.9;
p1=-zeta*wn+wn*sqrt(zeta^2-1);
p2=-zeta*wn-wn*sqrt(zeta^2-1);
P=[p1;p2];
A=[0 1;-k/m -c/m];
B=[0;1/m];
%pole placement Design
K=place(A,B,P);
kp=K(1);
kd=K(2);
ki=750;
err=out.x-out.x_ref % almost need to zero
Simulink
Plot code
%plot
subplot(311)
plot(out.time,out.x,'b')
hold on
plot(out.time,out.x_ref,'r-')
legend('x','x_(referance)')
xlabel('time')
ylabel('x')
subplot(312)
plot(out.time,out.u,'b')
xlabel('time')
ylabel('displacemenr')
subplot(313)
plot(out.time,out.a,'b')
xlabel('time')
ylabel('acceleration')
Plot
ki-0

there is no variation & is almost zero the system at rest state inputs are not taken into consideration
ki-500

system is undergoes process but there is error to the input
ki-1000

result of displacement & input value is obtained almost constant so ki=1000 is best to choose
ki-1100

result started overshoot
INFERENCE
PID transfer function of a mass spring damper system is Designed
ki-1000 with a zeta value 0.9 are suitable system design for spring mass damper system with lesser numerical error