Vous êtes sur la page 1sur 3

sim_qcar.

m
% Simulate and animate quarter-car suspension model. Model used originally % for an optimization demonstration in ME 149, Engineering System Design % Optimization, a graduate course taught at Tufts University in the % Mechanical Engineering Department. A corresponding video is available at: % % http://www.youtube.com/watch?v=_jKceIHn6tc % % The model is based on the electric vehicle design case study found in the % dissertation by James T. Allison: % % http://deepblue.lib.umich.edu/handle/2027.42/58449 % % Author: James T. Allison, Assistant Professor, University of Illinois at % Urbana-Champaign % Date: 3/4/12

% Clear workspace and set plotting flags clear; ploton1 = 1; ploton2 = 2; % animate qcar response % plot response

% Initialize vehicle parameters: C = 2; switch C case 1 k = 500.4; c = 24.67; case 2 k = 505.33; c = 1897.9; case 3 k = 1000; c = 1000; end % not optimal % tuned for handling % tuned for comfort % specify suspension design case

ms = 325; mus = 65; kus = 232.5e3; grav = 9.81; v = 10; dt = 0.005;

% 1/4 sprung mass (kg) % 1/4 unsprung mass (kg) % tire stiffness (N/m) % acceleration of gravity (m/s^2) % vehicle velocity (m/s) % simulation time step

% Construct linear state space model Aqcar = [0 1 0 0;-kus/mus -c/mus k/mus c/mus;0 -1 0 1;0 c/ms -k/ms -c/ms]; Bqcar = [-1 0 0 0]'; Cqcar = [1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 1; 0 -1 0 1]; Dqcar = 0; qcar = ss(Aqcar,Bqcar,Cqcar,Dqcar);

% note: y(:,1-4) = x, y(:,5) = d/dt susp stroke (i.e., x3dot) % Definition of System States: % x(1) = z1-z0 = L1 % x(2) = z1dot % x(3) = z2-z1 = L2 % x(4) = z2dot tire deflection wheel cm velocity suspension stroke (deflection) sprung mass velocity

% Initialize simulation x0 = [0 0 0 0]'; load IRI_737b dx = road_x(2) - road_x(1); dt2 = dx/v; z0dot = [0 diff(road_z)/dt]; tmax = 5; t = 0:dt:tmax; x = v*t; u = interp1(road_x,z0dot,x);umf = 3; % initial state % road profile data % spacial step for input data % time step for input data % road profile velocity % simulation time length % time/space steps to record output % prepare simulation input

% Simulate quarter car model y = lsim(qcar,u*umf,t,x0); deltamaxf = max(abs(y(:,1))); z2dotdot = [0 diff(y(:,4))'/dt2]; % max x3 amplitude % sprung mass acceleration

% animate response if ploton1

z0 = interp1(road_x,road_z,x)'*umf; % road elevation z1 = z0 + y(:,1); z2 = z1 + y(:,3); zmf = 3; % wheel cm position % sprung mass position

% exaggerate response for better visualization

for i=1:length(t) plotsusp([z0(i), z1(i)*zmf, z2(i)*zmf, t(i)],road_x,road_z,x(i),umf); refresh end end

% plot response if ploton2 figure(2);clf plot(t,y(:,3),'r-',t,y(:,5),'k-'); hold on plot(t,u*umf); plot(t,z2dotdot,'g-') legend('stroke','stroke velocity', ... 'road input velocity','sprung mass accel') end