Project - Position control of mass spring damper system
objective:
position control of the mass-spring-damper system for the mentioned reference signal:
the ref signal was found as a square pattern, accordingly, in the library, the input blocks found as
1." Signal Generator''.2.'' Pulse generator''
Exercise 1 : with signal generator:
the parameters settings are :
waveform: square
time: use simulation time
Amplitude: 1
frequency: 0.1 hertz,
we have to create the model by connecting this signal with the workspace & scope blocks :
Accordingly model was created as below :

we found the scope of the same as below:

findings:
the needed pattern of the ''square'' is found as ok, but values on the y-axis range from -1 to +1 which is not similar which ranges from 0 to 1
Exercise2: pulse generator :

the model is saved & run to get the scope :

by comparing with question:

conclusion: the suitable one is the'' pulse generator''
Findings:
Comparing the needed pattern is the same in all the ways and means.
Conclusion: we have selected the pulse generator signal as the input
The model designed to know this is :

Developing the model 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.
We know the general equation for mass spring damper system s given by
x_dot = Ax + Bu
So the state representation of our spring mass system can be given by
x1_dot = x2 --------------------------------------(1)
x2_dot = -(k/m) + (1/m)u ----------------------------------------(2)
We are using PID controller. So it has three gains Kp,Kd and Ki
So u = [Kp(x_ref – x1) – Kdx2 + Ki inte(x_ref – x1)]
Then the equation (2) becomes
x2_dot = -(k/m) + (1/m) [Kp(x_ref – x1) – Kdx2 + Ki inte(x_ref – x1)] ------------(3)
We have to design the model for equation(3)
Where
Kp – is proportional gain
Kd – is integral gain
Ki – is integral gain
m – is mass of the spring mass system
k – is a stiffness or spring constant
x2_dot – is accelaration
x1_dot = x2 – is a velocity
x1 – is displacement
The input to the model is given by the following MATLAB script
Script codes:.m.file
% Challenge10_project_codes__m file;
%c=2*zeta*wn
%for zeta=0.5, c=2*(0.5)*(6.2832),c=6.2832
%c=100 given on the question
m=3.6; % mass of the system
k=400.0; % spring constant
wn=sqrt(k/m);%Find out the wn value by using formula
% Angular frequency m=3.6; % mass of the system
k=400.0; % spring constant in rad/sec
fn=1; % fn=wn/(2*pi), Natural frequency in Hz
zeta=0.5; %Defining Zeta to 0.5 damping ratio
p1=-zeta*wn+wn*sqrt(zeta^2-1); % first pole of characteristic equation
p2=-zeta*wn-wn*sqrt(zeta^2-1); % second pole of the characteristic equation.
P=[p1;p2]; % P vector stores the two poles
% A and B matrices from state space representation
c=100;
A=[0 1;-k/m -c/m];
B=[0;1/m];
% Pole placement design using 'place' Command
K=place(A,B,P);
Kp = K(1); % Kp is a proportional gain
Kd = K(2); % Kd is a derivative gain
Ki=1000;
Model developed :
As per the mass spring damper formulae :

U values _ scope

finding out the best results with different values of ki:
case1:
For ki =100

For ki=500

For ki=1000

Ki=1400

For ki=1500;

Ki=1550

Ki=1600

u values scope :

Conclusion: based on the patterns we may conclude that the value of ki=1400 is optimal.
