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.
Spring mass damper system
The mass-spring-damper model consists of discrete mass nodes distributed throughout an object and interconnected via a network of springs and dampers. This model is well-suited for modelling object with complex material properties such as nonlinearity and viscoelasticity. Packages such as MATLAB may be used to run simulations of such models. As well as engineering simulation, these systems have applications in computer graphics and computer animation.

To analyze the mass-spring-damper system it is a prerequisite to understanding how to model the equations of each component with the knowledge of Newton’s 2nd law of motion. Which are represented below.

With the following points of consideration, the modelling is done.
- Point masses are present only
- is resultant of all forces
- is absolute acceleration
- Linear force in direction is acting.

The following free body diagram (FBD) in a positive deflected state is presented.


The sum of all forces acting in a different direction is given as follows,

This is the equation of motion (EoM) and it is in the form of 2nd order ordinary differential equation (ODE), linear in nature, with constant coefficients and inhomogeneous.
The above equation was in the differential form we can convert it into the s domain or frequency domain which is represented as follows,

Finally, we can rearrange the equation to get the transfer function G(s) of this system. The definition of the transfer function of a control system is its outputs divided by its inputs. In this case, X(s) is the output, F(s) is the input, so we can get G(s) as follows:

The above-derived ODE can be converted to a single order equation by using a state-space representation of the mass-spring damper system. The Laplace transformation ignores the initial condition of the system.
PID controller
A proportional–integral–derivative controller (PID controller or three-term controller) is a control loop mechanism employing feedback that is widely used in industrial control systems and a variety of other applications requiring continuously modulated control. A PID controller continuously calculates an error value
as the difference between a desired setpoint (SP) and a measured process variable (PV) and applies a correction based on proportional, integral, and derivative terms (denoted P, I, and D respectively), hence the name.
In practical terms, PID automatically applies an accurate and responsive correction to a control function. An everyday example is the cruise control on a car, where ascending a hill would lower speed if constant engine power were applied. The controller's PID algorithm restores the measured speed to the desired speed with minimal delay and overshoot by increasing the power output of the engine in a controlled manner.

The overall control function �(�)=�p�(�)+�i∫0��(�)d�+�dd�(�)d�,
where �p
, �i
, and �d
, all non-negative, denote the coefficients for the proportional, integral, and derivative terms respectively (sometimes denoted P, I, and D).
Implementation of Spring mass system using PID controllers
The Simulink model of Spring mass damper system along with PID controller is shown below

Intial conditions are defined below








Conclusion
With the help of PID controllers we have successfully positioned the spring mass damper system.