Project - Position control of mass spring damper system
1)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.
Ans: The Transfer function for spring mass damper system is X(s)/F(s)=1/ms^2+cs+k where X(s) is displacement of the position wrt the force acting on the mass. F(s) is the force applied on the mass.m is mass=3.6kg, c=damping constant=100Ns/m, Spring constant=400 N/m.
To control the displaced position of the mass after the force acting on it, we have to use PID controller. Here zeta value=1.001(critically damped condition) is considered by using zeta value Poles(P1,P2) are calculated and then Calculate kp (Proportionality constant),Kd (differntial constant) by using the place command. Ki value is manually modified to control the output wrt input.
Here input is pulse generated signal with amplitude of 1 and period of 10. as given in qusn.
The script file written to find the poles , kd and kp value is below.

Simulink model is built based on the transfer function equation. and PID controller is added before the plant transfer function. Pass the m,c ,k,kp and kd values to the model blocks and change the ki values from 0 and observe the output wrt input.

Here error signal is generated by taking the feedback output and given to the comparator to compare with the refernce signal(Pulse generator) each time then given output to PID controller, and the PID controller output is given to Plant(Spring mass damper) transfer function. Like this the output is rectified with error changing the values of ki manually.
The first value of ki is taken as ki=0;

For Ki value=5

For ki value=10

For ki value=20

For ki value=50

For ki value=100

For ki=200

For ki=500

For Ki value=1000

For ki=1010

For ki=1020

Output is modified to match with input by varying ki value from 0 to 1020. But still there are few overshoots and undershoots are observed. We can give a try reduce that by manually changing the values of kp and kd slightly. We already have kp and kd values but slightly modifying the values near to the current values.
Actual kd value from place(A,B,P) is kp approximately equal to '0' now change it 2. keep ki=1000, kd =-24(as same from place command).

kp=5

Kp=10

So like wise we can control the position of the spring mass damper system wrt input signal.
Matlab Script file, Simulink model file are attched here.