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.
Take m = 3.6; %kg k = 400; %N/m c = 100; %Ns/m
The reference signal is shown in the following figure.

Blocks Used:
Clock The Clock block outputs the current simulation time at each simulation step.
To Workspace The To Workspace block logs the data connected to its input port to a workspace from a Simulink model.
Scope The Scope is a Sink block used to display a signal much like an oscilloscope.
Pulse The Pulse Generator block generates square wave pulses at regular intervals.
Add/Subtract The Sum block performs addition or subtraction on its inputs.
Gain The Gain block multiplies the input by a constant value (gain).
Integrator The Integrator block outputs the integral of its input at the current time step.
Derivative The Derivative block approximates the derivative of the input signal u with respect to the simulation time t.
Transfer Function The Transfer Function block modifies its input signal and outputs a new signal on a line to the Scope.
Model:

Matlab Workspace:

Output:
The position control of mass spring damper system is done. We have got a good tracking response through the model.
