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.
Answer:
How to implement the equations of mass-spring-damper in Matlab Simulink?
Answer:
The equation shown below is implemented in Simulink as follows

The obtained equations of the mass-spring-damper system can be rearranged to obtain the state space equations of the system. With consideration of initial condition zero,

Now by creating a matrix of variables obtained above,

The assumed solution is,

For the case d=0 means damping is zero (un damped)

For critically damped system

And for underdamped system

What is 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. The proportional integral derivative controller produces an output, which is the combination of the outputs of proportional, integral, and derivative controllers. The feedback from the plant whichever is a controllable parameter is given as input to the PID controller and the processed error is minimized to get the desired output if tuning of the parameter is done optimally. The mathematically PID controller can be defined by the following equation where e(t) is the error signal with respect to time, Kp, Ki and KD are PID constants.
Increasing the proportional gain () has the effect of proportionally increasing the control signal for the same level of error. The fact that the controller will "push" harder for a given level of error tends to cause the closed-loop system to react more quickly, but also to overshoot more. Another effect of increasing is that it tends to reduce, but not eliminate, the steady-state error.
The addition of a derivative term to the controller () adds the ability of the controller to "anticipate" error. With simple proportional control, if is fixed, the only way that the control will increase is if the error increases. With derivative control, the control signal can become large if the error begins sloping upward, even while the magnitude of the error is still relatively small. This anticipation tends to add damping to the system, thereby decreasing overshoot. The addition of a derivative term, however, has no effect on the steady-state error.
The addition of an integral term to the controller () tends to help reduce steady-state error. If there is a persistent, steady error, the integrator builds and builds, thereby increasing the control signal and driving the error down. A drawback of the integral term, however, is that it can make the system more sluggish (and oscillatory) since when the error signal changes sign, it may take a while for the integrator to "unwind."
The general effects of each controller parameter (, , ) on a closed-loop system are summarized in the table below. Note, these guidelines hold in many cases, but not all. If you truly want to know the effect of tuning the individual gains, you will have to do more analysis, or will have to perform testing on the actual system.

Apply Laplace transform on both sides.


The parameter which is under control must have some properties or free from some properties such as rise time, settling time, overshoot and steady state error. The impact of PID parameters on such properties can be found in the below table.


Rise Time:

Rise time is defined as the time taken for a signal to cross from a specified low value to a specified high value. In analog and digital electronics, the specified lower value and specified higher value are 10% and 90% of the final or steady-state value. So, the rise time is typically defined as how long it takes for a signal to go from 10% to 90% of its final value.
Settling Time:

The settling time of a dynamic system is defined as the time required for the output to reach and steady within a given tolerance band. It is denoted as Ts. Settling time comprises propagation delay and time required to reach the region of its final value. It includes the time to recover the overload condition incorporated with slew and steady near to the tolerance band.
The tolerance band is a maximum allowable range in which the output can be settle. Generally, the tolerance bands are 2% or 5%.
Peak Over Shoot:

(MP) is defined as the deviation of the response at the peak time from the final value of the response. it is also called the maximum overshoot. We can write it as

Steady State Error:
Steady-state error is defined as the difference between the desired value and the actual value of a system output in the limit as time goes to infinity (i.e., when the response of the control system has reached steady-state).
Steady-state error is a property of the input/output response for a linear system. In general, a good control system will be one that has a low steady-state error.

Stability of the System
A system is stable if every bounded input yields a bounded output. We call this statement the bounded-input, bounded-output (BIBO) definition of stability.
The stability of a linear closed loop system can be determined from the locations of the closed loop poles in the s-plane.

The location of poles of the transfer function decides the stability of the system. Which is shown in the above figure for critically stable, unstable, and stable systems.
For our case, the transfer function is determined from the constants of motor and state space equations,
Simulink Modelling of Mass spring damper system modeling with PID Controller

configuration paremeters of project step time is 20sec and slover selection typeis fixed step

the solver settings are shown above
the reference speed is i am giving pluse generator input as shown below

Input pluse generatorgraph shown below
In above data is given for transfer function shown in the below
Take m = 3.6; %kg k = 400; %N/m c = 100; %Ns/m

In the sumlink control system PID Controller tuned and given parameter shown in below

output graph is shown in below and pid controller tuned pluse generator pid tuned in show

CONCLUSION: From the above results, we can infer that:
1. All values are displayed in the workspace and stored in the file z.mat