Project - Position control of mass spring damper system
Consider a spring-mass damper system of mass 'm', spring constant 'k', damping coefficient 'c'.
The force applied to the system is F(t) and the displacement is x.
The equation of motion of the system is;
m*x_dot_dot = c*x_dot = k*x = F(t)
Applying Laplace transform on both side of this equation;
X(s) = [F(s)+ms*x(0) = c*x_dot(0)] / [ms^2 + c*s + k]
Where X(s) is the laplace transform of x and F(s) is the laplace transform of F(t).
The transfer function of the system can be defined as the ratio of laplace transforn of the output to the laplace transform of the input.
ie. G(s) = X(s)/F(s)
G(s) = 1/(ms^2 + cs + k)
Built a simulink model with a TRANSFER FUNCTION using this equation.

The reference signal is a pulse signal and the PID controller is integrated using Kp, Kd and Ki gains. The Kp is directly connected to the feedback signal and the Kd is connected to the derivative block to get the derivative of x and Ki is connected to the integratior to get the integral value of x.
The value of Kp and Kd is calculated using the pole placement command in MATLAB.

The value of Ki is finalised to 900 by trying out different values and select the one which has minimal over-shoot.

After runnig the model, we obtaine the response signal. From the graph we can see that the value of x starts from 0 and settle to the reference signal with an over-shoot.
After 5 seconds, when the reference signal fall to 0, the value of x also fall to 0 with some over-shoot and settled and so on the value of x follows the reference signal.

An another way for approaching the question is by using the PID controller block which is available in the simulink library.
Created a similink model with the PID controller block.

The Kp, Kd and Ki values are obtained using the tunr option in the PID controller.


After running the sumulation the response is generted in the scope block

From the graph we can see that the value of x follows the referance signal with with sone over-shoot and settling down to the reference signal.
Since the value of Kp, Kd and Ki is automatically determined by the simulink, the values as more accurate and precise compared to the first one and this methos is also time saving.