Project - Position control of mass spring damper system
Mass spring damper system:
A spring-mass-damper system is a mechanical system that consists of a mass connected to a spring and a damper. It is commonly used in engineering to model various physical systems, such as the suspension in vehicles, buildings subjected to earthquakes, or vibrating structures.
General equation:
m(d²x/dt²) + c (dx/dt) + kx = F
Spring Damper Transfer function:

Where,
mass is denoted as m, spring constant as k and Damping coefficient as c.
Objective:
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.
Parameters given:
mass, m = 3.6 kg
spring constant, k = 400 N/m
Damping coefficient, c = 100 Ns/m
Thus, natural frequency, wn=sqrt(k/m)
Solution:
The reference signal can be made using a pulse signal generator

Stop Time=27.5 sec

Script file Name: Final_spring.m


Thus, initial gain values are
Kp=K(1)=0
Kd=K(2)=100
Ki=0
Simulink Model:
File name: Final.mdl

Scope result:

As the output signal shows lot of deviation from the refrence signal, we can change the value of Kp to get at value of 1.
(a)Let kp=10000

we can see a lot of change and the signal is becoming stable as compared to Kp=0 output signal.
Still we haven't got required signal output as rising time is more and there is overshoot.
(b) Kp=20000

The overshoot increased but Rise time decreased. Thus, we will increase Kp value further to get 1.
(c)Kp=40000

we got the value of 1, but there is ringing. To minimize ringing we will change Kd value.
(d) Kp=40000, Kd=200

Still there is overshoot.
(e)Kp=40000, Kd=400

Small overshoot is still seen.
(f)Kp=40000, Kd=600

Thus, we got PID controller values as Kp=40000, Kd=600 and Ki=0.
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ALTERNATIVE METHOD:
Instead of taking zeta and wn value using given m,k,c values
For underdamped condition we can get PID controller gain values:
zeta=0.5
Script file : Alternative.m

Scope result:

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Conclusion:
- Obtained the transfer function for the spring mass damper system and succesfully build a PID controlled spring mass damper system model.
- Created a refrence signal as provided.
- Understood how the Kp,Kd,Ki values affect the out signal.
- Was able to adjust the force on mass so that the output signals position follows a reference signal.