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.
Model: the transfer function for the mass spring damper system is
T/F = X(s)/F(S) = 1/(m*s^2+c*s+k)
= 1/m/(s^2+c/m*s+k/m)
= k/(s^2+2*zeta*wn*s+wn^2)
where c/m = 2*zeta*wn
k = 1/m
k/m = wn^2
model

clc
clear all
% parameter that given in question
m = 3.6; % mass in kg
k = 400; % stiffness or spring constant in N/m
c = 100; % dashpot or damper in Ns/m
% A & B matrices
A = [0,1;111.11,27.79];
B = [0;0.27];
% definig wn
fn = 1.0; % 1 hz natural frequency
wn = 2*pi*fn; % natural frequency rad/sec
% Design parameter
zeta = 0.5; % damping co-efficient
% Desired poles
p1 = -zeta*wn+wn*sqrt(zeta^2-1);
p2 = -zeta*wn-wn*sqrt(zeta^2-1);
p = [p1;p2];
% pole placement design
k = place(A,B,p);
% Defining kp,kd &ki from k
kp = k(1)
kd = k(2)
ki = 1000
Command for the transfer function for the mass spring damper system
% transfer function for spring mass damper
m = 3.6; %mass in kg
k = 400; % stiffness or spring constant in N/m
c = 100; % dashpot or damper in N/m
% defining wn
fn = 1.0; % 1 hz natural frequency
wn = 2*pi*fn; % natural frequency rad/sec
% design parameter
zeta = 0.5; % damped co-efficient
% transfer function
s = tf('s');
s = 1/m/(s^2+2*zeta*wn*s+wn^2);
% transfer function for spring mass damper
kp
kp =
557.7349
>> kd
kd =
126.1970
spring_mass
>> s
s =
0.2778
---------------------
s^2 + 6.283 s + 39.48
Continuous-time transfer function.


