Professional Documents
Culture Documents
Lab 2 memo
Team name: 3
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.
Table 1. Data extracted from the experimental response plot and arrays for a given step
force.
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.
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.
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)
% 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
xss=xdata(end); % cm
[xp,xp_index]=max(xdata); % xmax in cm
tp=tdata(xp_index); % s
Fin=8; % N
% determining m, c, and k
tf=tdata(end); % s
x0=0; % m
v0=0; % m/s
sim('lab_2_sim1')
figure
plot(t_sim,x_sim_cm,'k-',tdata,xdata,'b.')
xlabel('Time (s)')
ylabel('Displacement (cm)')
legend('Model','Data')
set(gcf,'color','w')
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
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
figure
plot(mu_adj,SEE)
[SEE_min_mu_adj,mu_index]=min(SEE);
best_mu=mu_adj(mu_index);
mu=best_mu;
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
figure
plot(m_adj,SEE)
[SEE_min_m_adj,m_index]=min(SEE);
best_m=m_adj(m_index);
m=best_m;
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
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;
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
% figure
% plot(k_adj,SEE2)
%
% [SEE_min_k_adj,k_index]=min(SEE2);
% best_k=k_adj(k_index);