You are on page 1of 9

CM: 1277

Lab 2 memo
Team name: 3

To: Dr. Cornwell

From: Ryan Tarr, Albert Li, Josh Krsek

Due date: March 18, 2019

Re: Mass-spring-damper system identification from data and model refinement

In this lab we compared the response of a spring-mass-damper system using Simulink and Matlab with
experimental data. The experimental data for the step response of the system is shown in Figure 1. Using
these data, we determined performance values of the response as shown in Table 1. The performance
values reported in Table 1 were used to compute the standard form 2 nd order system parameters given in
Table 2.

Figure 1. Experimental step response of a spring-mass-damper system.

Table 1. Data extracted from the experimental response plot and arrays for a given step
force.

First peak value, Steady-state Input force, 𝐹in


Peak time, 𝑡p (s)
𝑥p (cm) value, 𝑥ss (cm) (N)

1.782 0.110 0.972 8.00


Table 2. Standard form parameters calculated from the experimental response data for a
given step force.

Natural frequency, Damping ratio, 𝜁 Static gain, 𝐾 Input force, 𝐹in


𝜔n (rad/s) (unitless) (cm/N) (N)

28.61 0.058 0.1215 8.00

A comparison of our model using the parameters in Table 2 and our experimental data is shown in Figure
2. The peak time, peak value, frequency of oscillation, and steady-state value are identical between our
model and our experimental data because we extracted those values from our experiment. The settling
time of the model is larger than that of the experiment. This larger settling time is due to the model
neglecting other forms of energy loss besides viscous damping.

Figure 2. Comparison of experimental step response to simulation results for a


spring-mass-damper system.

Using the performance values in Table 2, we were able to determine the physical parameters for our
spring-mass-damper model, as shown in Table 3. These parameters were computed by equating
coefficients of the model to the standard form 2nd order DE.
Table 3. Calculated system parameters for a simulated step response including and not
including Coulomb friction.

Viscous Spring Coulomb


Case Mass, 𝑚 (kg) damping, 𝑐 stiffness, 𝑘 damping, 𝜇 SEE (cm)
(N.s/m) (N/m) (unitless)
Original
1.005 3.335 822.9 N/A 0.0919
model

Refined model 1.060 2.620 822.9 0.009 0.0436

To quantify the difference between the model and the data we used a standard error estimate (SEE)

2
∑ 𝑛𝑖 = 1(𝑥model,𝑖 − 𝑥data,𝑖 )
SEE = √ (1)
𝑛−2

where 𝑛 is the number of data points. To refine the model the Coulomb damping and other parameter
values reported in Table 3 were varied iteratively to minimize the SEE. The updated values are also
shown in Table 3. By refining our model, we reduced the SEE by 52.54%.

Figure 3 shows a comparison of simulation results of the refined model (including Coulomb friction) to
the results of the original model (not including Coulomb friction) and the experimental response of a
spring-mass-damper system. The peak time and peak value are approximately the same for the model
and the experimental data for the first three cycles because we used nearly identical system parameters
for the simulation. Figure 3 matches the trend of the experimental data for a longer than Figure 2. This
improvement is due to the inclusion of Coulomb friction and optimization of system parameters in the
refined model in Figure 3 resulting in a better representation of reality. Despite the improvements of the
refined model in Figure 3, the model has a smaller settling time than the experimental data. The
difference in the settling time of the refined model and the experimental data is due to excessive energy
loss.
Figure 3. Comparison of simulation results of the refined model to the results
of the original model and experimental and experimental response
of a spring-mass-damper system.

Attached to this document are a printout of the Simulink model and the Matlab m-file used to run the
simulation.
Simulink diagram (original)

Simulink diagram (refined)


Matlab m-file
%**************************************************************************
% lab_2_code.m
%
% This code utilizes simulink to simulate the displacement of a mass
% in a mass-spring-damper system. We were given a set of data and we
% plotted the simulated results against the data. We used information
% in the data to calculate the spring-mass-damper coefficients. We
% then modified the simulink model to include coulomb friction to
% better match reality. Then, we used loops to make the values m,c,k,
% and mu better match the data (by minimizing the SEE).
%
% Written by: Ryan Tarr, Albert Bowen, Josh Krsek
% 3/17/2019
%**************************************************************************
clc
clear variables
close all

% data

load('Lab2_data')
npts=1250;
tdata=data(1,1:npts)'; % time in s
xdata=data(2,1:npts)'; % displacement in cm

plot(tdata,xdata,'.')
xlabel('Time (s)')
ylabel('Displacement (m)')

% data calculations

% xp, tp, xss

xss=xdata(end); % cm
[xp,xp_index]=max(xdata); % xmax in cm
tp=tdata(xp_index); % s

% std form parameters

Fin=8; % N

delta=2*log(xss/(xp-xss)); % log decrement


zeta=delta/sqrt((delta^2)+4*pi^2); % damping ratio
wd=pi/tp; % rad/s
wn=wd/sqrt(1-zeta^2); % rad/s
K=(xss/Fin); % cm/N

% determining m, c, and k

k=(1/K)*100; % N/m (subject to change)


k1=(1/K)*100; %N/m (original k value)
m=k/(wn^2); %kg (subject to change)
m1=k/(wn^2); %kg (original m value)
c=2*zeta*k/wn; % N*s/m (subject to change)
c1=2*zeta*k/wn; %N*s/m (original c value)

% simulation (w/o coulomb friction)


maxstep=0.001;
tol=1e-6;

tf=tdata(end); % s
x0=0; % m
v0=0; % m/s

sim('lab_2_sim1')

x_sim_cm = x_sim * 100; % cm

% plot of model (w/o coulomb) vs. data

figure
plot(t_sim,x_sim_cm,'k-',tdata,xdata,'b.')
xlabel('Time (s)')
ylabel('Displacement (cm)')
legend('Model','Data')
set(gcf,'color','w')

% model with coulomb friction

mu=0;
g=9.81; %m/s^2

sim('lab_2_sim2')
x_sim_cm1=x_sim1*100;

x_int=interp1(t_sim1,x_sim_cm1,tdata);

figure
plot(t_sim1,x_sim_cm1)

% computing SEE

SEE_bad=sqrt(sum((x_int-xdata).^2)/(length(x_int)-2)); % SEE (w/o adjusting


% values)

% finding mu to reduce SEE

i=0;
for n=0:0.001:0.05
i=i+1;
mu=n;
sim('lab_2_sim2')
x_sim_cm1=x_sim1*100;
x_int=interp1(t_sim1,x_sim_cm1,tdata);
SEE(i)=sqrt(sum((x_int-xdata).^2)/(length(x_int)-2));
mu_adj(i)=mu;
end

% plotting SEE against mu

figure
plot(mu_adj,SEE)

[SEE_min_mu_adj,mu_index]=min(SEE);
best_mu=mu_adj(mu_index);
mu=best_mu;

% finding m to reduce SEE

counter=0;
for n=0.5:0.01:1.5
m=n;
counter=counter+1;
sim('lab_2_sim2')
x_sim_cm1=x_sim1*100;
x_int=interp1(t_sim1,x_sim_cm1,tdata);
m_adj(counter)=m;
SEE(counter)=sqrt(sum((x_int-xdata).^2)/(length(x_int)-2));
end

% plot of SEE against m

figure
plot(m_adj,SEE)

[SEE_min_m_adj,m_index]=min(SEE);
best_m=m_adj(m_index);

m=best_m;

% finding c to reduce SEE

i=0;
for n=2:0.01:3
i=i+1;
c=n;
sim('lab_2_sim2')
x_sim_cm1=x_sim1*100;
x_int=interp1(t_sim1,x_sim_cm1,tdata);
x_best(i,:)=x_sim_cm1;
t_best(i,:)=t_sim1;
SEE1(i)=sqrt(sum((x_int-xdata).^2)/(length(x_int)-2));
c_adj(i)=c;
end

% plot of SEE against c

figure
plot(c_adj,SEE1)

[SEE_min_c_adj,c_index]=min(SEE1);
best_c=c_adj(c_index);

SEE_best = SEE_min_c_adj;

% plot of adjusted model and data

figure
plot(t_best(c_index,:),x_best(c_index,:),'r-',tdata,xdata,'b.')
xlabel('Time(s)')
ylabel('Displacement (cm)')
legend('Model','Data')
% reduction in the SEE
SEE_reduction = ((SEE_bad-SEE_best)/(SEE_bad))*100;

% We tried to run a for loop to find the optimal k that reduces the SEE
% even more, but after trying this, the SEE value remained the same.

% c=best_c

% finding k to reduce SEE


%
% i=0;
% for n=822:0.01:823
% i=i+1
% k=n;
% sim('lab_2_sim2')
% x_sim_cm1=x_sim1*100;
% x_int=interp1(t_sim1,x_sim_cm1,tdata);
% SEE2(i)=sqrt(sum((x_int-xdata).^2)/(length(x_int)-2));
% k_adj(i)=k;
% end
%
% plot of SEE against k

% figure
% plot(k_adj,SEE2)
%
% [SEE_min_k_adj,k_index]=min(SEE2);
% best_k=k_adj(k_index);

You might also like