solution

ME 481 – H14
Name ________________________
1) Copy the MATLAB files "ode_smd.m" and "ode_yd_smd.m" below into two separate M files
in your working directory. Use the exact file names. Run "ode_smd.m" to provide a forward
dynamic simulation of a spring-mass-damper. Provide MATLAB plots of position and velocity
as a function of time and a MATLAB plot of time step as a function of time.
viscous damping
0.1
1.5
0.05
Velocity [m/sec]
Position [m]
x0
xn
0
-0.05
-0.1
0
1
2
Time [sec]
3
4
1
0.5
0
-0.5
-1
-1.5
0
1
2
Time [sec]
3
4
Time step [msec]
25
20
15
mean time step = 17.05 msec
CPU time = 0.0466 sec
10
5
0
0
1
2
Time [sec]
3
4
2) Compute damping ratio ζ based on spring-mass-damper coefficients in file "ode_smd.m" and
using log-decrement methods from the decay envelope in your simulation data. Show your
work.
0.0796
ζCOEFF ________________
0.0802
ζLOG-DEC ________________
spring-mass-damper coefficients
m = 1 kg, k = 157.9 N/m, c = 2 N.sec/m
k
 157.9 N  1  kg.m 

= 
= 12.56 rad/sec

2 
m
 m  1 kg  N. sec 
ωn = 2 π fn fn = 2 Hz T = 0.5 sec
c
c
 1  2 N. sec  1  sec  kg.m 

ζ=
=
=  


 = 0.0796
c CR 2 m ω n  2  m  1 kg  12.56rad  N. sec 2 
ωn =
log-decrement
n = 3, x0 = 0.06031 m, xn = 0.01323 m
δ=
1  x0
ln
n  x n

 = 0.50567

ζ=
δ
4π + δ 2
2
= 0.0802
ME 481 – H14
Name ________________________
3) Modify "ode_yd_smd.m" for pure Coulomb friction equal to 0.5 Newtons and viscous
damping c = 0. Provide MATLAB plots of position and velocity as a function of time and a
MATLAB plot of time step as a function of time. Provide a listing of your code. Comment on
the differences from part 1) above. Specifically address time step and CPU time.
simple Coulomb friction – friction force = - f * sign(velocity)
x0
1.5
xn
0.05
Velocity [m/sec]
Position [m]
0.1
0
-0.05
-0.1
0
1
2
Time [sec]
3
4
1
0.5
0
-0.5
-1
-1.5
1
0
2
Time [sec]
3
4
Time step [msec]
40
30
mean time step = 9.4787 msec
CPU time = 0.2339 sec
20
10
0
0
1
2
Time [sec]
3
4
a) linear decay envelope for Coulomb versus exponential decay envelope for viscous
b) time step gets VERY small at velocity reversal, mean time step is about 1/2 for viscous, CPU
time about 5 times slower
4) Compute Coulomb friction based on the decay envelope in your simulation data from part 3).
Show your work
0.509 N
fCOULOMB ________________
n = 3, x0 = 0.08703 m, xn = 0.04837 m
f=
s=
x0 − xn
= 0.02577 m/sec
nT
π k s π  157.9 N  0.02577 m  sec 
= 
 = 0.509 N


2 ω n 2  m 
sec
 12.56rad 
ME 481 – H14
f =
Name ________________________
k ( x 0 − x n )  157.9 N  0.08703m − 0.04837 m 
 = 0.509 N
=

4n
4(3)
 m 

ME 481 – H14
%
%
%
%
%
%
%
Name ________________________
ode_smd.m - example use of ODE solver for spring-mass-damper
HJSIII, 11.03.11
ODE coded in file ode_yd_smd.m
{y} = { x }
{ xd }
-
m*xdd + c*xd + k*x = Fext
{yd} = { xd } = [ 0
{ xdd }
[ -k/m
1
] {y}
-c/m ]
clear
global m
%
%
%
%
m
k
c
k
c
physical constants
x [m]
xd [m/sec]
xdd [m/sec^2]
= 1;
% mass [kg]
= 157.9;
% spring [N/m] - causes wn=2Hz
= 2;
% viscous [N.sec/m] - causes 4 sec exp decay
% initial conditions
y0 = [ 0.1 0 ]';
% free release
% time range
tspan = [ 0 4 ];
% measure CPU time
tic;
[ t, y ] = ode23( 'ode_yd_smd', tspan, y0 );
t_exe = toc
% time step
delta_t = 1000 * diff(t);
% units [msec]
delta_t = [ delta_t ; delta_t(end) ];
% repeat last value
n_time_steps = length(t)
ave_time_step = mean( delta_t )
% time domain results
figure( 1 )
subplot( 2, 2, 1 )
plot( t,y(:,1) )
xlabel( 'Time [sec]' )
ylabel( 'Position [m]' )
axis( [ 0 4 -0.1 0.1 ] )
subplot( 2, 2, 2 )
plot( t,y(:,2) )
xlabel( 'Time [sec]' )
ylabel( 'Velocity [m/sec]' )
axis( [ 0 4 -1.5 1.5 ] )
subplot( 2, 2, 3 )
plot( t,delta_t )
xlabel( 'Time [sec]' )
ylabel( 'Time step [msec]' )
% compute A(linear) over all t
n = length( t );
Y = y';
Ydot = [];
for j = 1:n,
tval = t(j);
yval = y(j,:)';
Ydot = [ Ydot ode_yd_smd( tval, yval ) ];
end
% compare linear model to actual model
A_smd = [ 0
1
;
-k/m -c/m ]
A_linear = Ydot * Y' * inv( Y * Y' )
% frequencies
ME 481 – H14
Name ________________________
[ modes, wn ] = eig( A_linear );
wn = diag( wn );
fn = imag(wn) /2 /pi
% bottom of ode_smd
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function yd = ode_yd_smd( t, y )
% spring-mass-damper
%
m*xddot + c*xdot + k*x = Fext
%
called by ode_smd.m
% HJSIII, 11.03.11
global m
k
c
% free motion
Fext = 0;
% individual terms
x = y(1);
xd = y(2);
xdd = ( -k*x -c*xd +Fext ) / m;
% return values
yd(1,1) = xd;
yd(2,1) = xdd;
% use linear ODE with constant coefficients
%Asmd = [ 0
1
;
%
-k/m -c/m ];
%yd = A * y;
% bottom of ode_yd_smd
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function yd = ode_yd_smd( t, y )
% called by ode_smd.m – spring-mass-Coulomb friction
% HJSIII, 11.04.05
global m
k
c
% free motion
Fext = 0;
% Coulomb friction
f = 0.5;
% [N]
% individual terms
x = y(1);
xd = y(2);
% spring force
Fspr = -k*x;
% friction force - simple model
Ff = -f*sign(xd);
%xdd = ( -k*x -c*xd +Fext ) / m;
xdd = ( +Fspr +Ff +Fext ) / m;
% return values
yd(1,1) = xd;
yd(2,1) = xdd;
% viscous
% Coulomb
ME 481 – H14
% bottom of ode_yd_smd
Name ________________________
ME 481 – H14
Name ________________________
0.5
0.5
0.4
0.4
Velocity [m/sec]
Position [m]
5) Modify your MATLAB code to simulate the stick-slip drag-sled from HW12 part 2). Provide
MATLAB plots of position, velocity and acceleration of the drag-sled as a function of time and a
MATLAB plot of time step as a function of time. Provide a listing of your code. Comment on
the differences from HW12.
0.3
0.2
0.1
0
5
10
Time [sec]
0.1
15
Acceleration [m/s/s]
Time step [msec]
0.2
0
0
1500
1000
500
0
0.3
0
5
10
Time [sec]
15
0
5
10
Time [sec]
15
0
5
10
Time [sec]
15
2
0
-2
a) very similar curves
b) MATLAB
WM
about 3.5 sec apart
about 3.5 sec apart
max velocity ≈ 0.42 mps
max velocity ≈ 0.45 mps
c) time step gets VERY small during slip
max accel ≈ 2.95 mps2
max accel ≈ 2.95 mps2
ME 481 – H14
%
%
%
%
%
%
%
Name ________________________
ode_stick_slip.m - ODE solver for stick-slip spring-mass
HJSIII, 11.04.05
ODE coded in file ode_yd_stick_slip.m
{y} = { x }
{ xd }
{yd} = { xd }
{ xdd }
clear
global m
k
mu_s
mu_d
% physical constants
m = 12.5;
%
k = 742.5;
%
mu_s = 0.9;
%
mu_d = 0.6;
%
g = 9.81;
%
v_driver = 0.034; %
eps = 1e-7;
%
g
v_driver
eps
mass [kg]
spring [N/m]
static coefficient of friction
dynamic coefficient of friction
gravity [mpss]
driver velocity [mps]
very small value
disp( ' ' )
disp( 'Stick-slip drag-sled' )
% initial conditions
y0 = [ 0 0 ]';
% time range
tmax = 16;
tspan = [ 0 tmax ];
% call ODE solver
[ t, y ] = ode23( 'ode_yd_stick_slip', tspan, y0 );
% time step
delta_t = diff(t);
% units [sec]
delta_t = [ delta_t ; delta_t(end) ];
% repeat last value
% approximate acceleration
x = y(:,1);
xd = y(:,2);
delta_xd = diff(xd);
delta_xd = [ delta_xd ; delta_xd(end) ];
xdd = delta_xd ./ delta_t;
n_time_steps = length(t)
ave_time_step = mean( delta_t )
% time domain results
figure( 1 )
clf
subplot( 2, 2, 1 )
plot( t,x )
xlabel( 'Time [sec]' )
ylabel( 'Position [m]' )
axis( [ 0 tmax -0.05 0.5 ] )
subplot( 2, 2, 2 )
plot( t,xd )
xlabel( 'Time [sec]' )
ylabel( 'Velocity [m/sec]' )
axis( [ 0 tmax -0.05 0.5 ] )
subplot( 2, 2, 3 )
plot( t,delta_t*1000 )
xlabel( 'Time [sec]' )
ylabel( 'Time step [msec]' )
axis( [ 0 tmax 0 1800 ] )
subplot( 2, 2, 4 )
ME 481 – H14
Name ________________________
plot( t,xdd )
xlabel( 'Time [sec]' )
ylabel( 'Acceleration [m/s/s]' )
axis( [ 0 tmax -3.5 3.5 ] )
% bottom of ode_stick_slip
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function yd = ode_yd_stick_slip( t, y )
%
called by ode_stick_slip.m
% HJSIII, 11.04.05
global m
k
mu_s
mu_d
g
v_driver
eps
% individual terms
x = y(1);
xd = y(2);
% spring force
x_driver = v_driver * t;
Fspr = k * ( x_driver - x );
% friction force - simple model
Ff = -mu_d * m * g * sign(xd);
% special handling for zero velocity - need for stick-slip
if abs(xd) < eps,
Ff = -Fspr;
if abs(Ff) > (mu_s*m*g) ,
Ff = -mu_s * m * g * sign(Fspr);
end
end
% ODE
xdd = ( +Fspr +Ff ) / m;
% return values
yd(1,1) = xd;
yd(2,1) = xdd;
% bottom of ode_yd_stick_slip
ME 481 – H14
Name ________________________
EXTRA CREDIT
Modify your pendulum from H13 using “Script Pin Friction” with “Pin Radius = 0.25 inch” and
“Friction Coefficient = 0.1” for ±10 degrees of motion. Attach a screen shot of your mechanism.
Provide a phase plane plot and estimate joint friction torque from the time decay envelope.
Tf = µ r m g = (0.1) (0.25 inch) (0.46 lbf) = 0.0115 in.lbf
Tf =
m g a (θ 0 − θ n )
4n
Tf =
(0.46 lbf )(3.7 inch )(10.02° − 2.337°)  π rad  = 0.01141 in.lbf


4(5)
 180° 
θ 0 =10.02°
θ 5 =2.337°
n=5
(m g) = 0.46 lbf
a = 3.7 inch
ME 481 – H14
Name ________________________
Simple pendulum - small angle
x0
Angle [deg]
10
xn
0
Ang acc [rad/s/s]
Ang vel [rad/s]
-10
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
0
0.5
1
1.5
2
2.5
3
3.5
4
4.5
5
0
0.5
1
1.5
2
2.5
3
Time [sec]
3.5
4
4.5
5
6
8
10
2
0
-2
20
0
-20
Simple pendulum - small angle
2
1.5
Ang vel [rad/s]
1
0.5
0
-0.5
-1
-1.5
-2
-10
-8
-6
-4
-2
0
2
Angle [deg]
4
ME 481 – H14
% h14_ec.m - ME 481 HW03 - read WM data for pendulum
% HJSIII, 13.04.06
% general constants
d2r = pi / 180;
% pendulum constants
m = 0.46;
% [lbm]
a = 3.7;
% [in]
JG = 1.5;
% [lbm.in.in]
g = 386;
% [ips2]
tau = sqrt( 4*pi*pi*( JG + m*a*a ) / ( m * g * a ) )
fn = 1 / tau
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% load WM data for pendulum with small angle
load h14_ec_cut.txt;
t = h14_ec_cut(:,1);
th = h14_ec_cut(:,2);
phi_deg = th/d2r + 90;
phid = h14_ec_cut(:,3);
phidd = h14_ec_cut(:,4);
% plot small angle results
figure( 1 )
clf
subplot( 3, 1, 1 )
plot( t,phi_deg,'b' )
axis( [ 0 5 -12 12 ] )
ylabel( 'Angle [deg]' )
title( 'Simple pendulum - small angle' )
subplot( 3, 1, 2 )
plot( t,phid,'b' )
axis( [ 0 5 -2 2 ] )
ylabel( 'Ang vel [rad/s]' )
subplot( 3, 1, 3 )
plot( t,phidd,'b' )
axis( [ 0 5 -20 20 ] )
xlabel( 'Time [sec]' )
ylabel( 'Ang acc [rad/s/s]' )
figure( 2 )
clf
plot( phi_deg, phid, 'b' )
axis( [ -10 10 -2 2 ] )
xlabel( 'Angle [deg]' )
ylabel( 'Ang vel [rad/s]' )
title( 'Simple pendulum - small angle' )
Name ________________________