Need help with car suspension dampening, current code is exp growing.
조회 수: 4 (최근 30일)
이전 댓글 표시
Currently trying to model a cars suspension as it runs over a bump, however, my current code is actually growing intstead of dampening. Below are the assignment details as well, my current code:
clear
Mc = 401; %Weight
Mw = 48; %Wheel Mass
Ds = 2300; % Susp Damping Coef
Cs = 230000; % Susp Spring Coef
Cw = 250000; %Wheel Spring Coef
Wact = 0.001; % WActuator Time Const
t = 0; %intial Time
dt = 0.001;
Zc = 0; % Displacement Chass
Zw = 0; % Displacement Wheel
Zr = 0; %Disp Road
Vw = 0; %intial speed wheel vertical
Vc = 0; %intial speed Chassis Vertical
U=0;
alp = 0;
bet = 0;
u = U*exp(-alp*(t(end)-t(1)))*cos(2*pi*bet*(t(end)-t(1)));
Fs = 0; %leaving as 0 until we figure out the non-damp force graphing
Fs(end+1) = Fs(end) + ((Fs(end)/Wact)+(1/Wact)*u)*dt; %Damp force
Aw = 0; %intial Wheel Acc
Ac = 0; %intial Chassis Acc
while t(end) < 5
if t(end) > 1 && t(end) < 1.11
Zr = -0.5;
Aw(end+1) = -(1/Mw)*((Cw+Cs)*Zw(end) + Cs*Zc(end) + Ds*(Vc(end) - Vw(end)) + Cw*Zr(end)-Fs(end));
Vw(end+1) = Vw(end) + Aw(end)*dt;
Zw(end+1) = Zw(end) + Vw(end)*dt;
Ac(end+1) = (1/Mc)*(Cs*(Zw(end)-Zc(end))+Ds*(Vw(end)-Vc(end))+Fs(end));
Vc(end+1) = Vc(end) + Ac(end)*dt;
Zc(end+1) = Zc(end) + Vc(end)*dt;
t(end+1) = t(end) + dt;
else
Zr = 0;
Aw(end+1) = -(1/Mw)*((Cw+Cs)*Zw(end) + Cs*Zc(end) + Ds*(Vc(end) - Vw(end)) + Cw*Zr(end)-Fs(end));
Vw(end+1) = Vw(end) + Aw(end)*dt;
Zw(end+1) = Zw(end) + Vw(end)*dt;
Ac(end+1) = (1/Mc)*(Cs*(Zw(end)-Zc(end))+Ds*(Vw(end)-Vc(end))+Fs(end));
Vc(end+1) = Vc(end) + Ac(end)*dt;
Zc(end+1) = Zc(end) + Vc(end)*dt;
t(end+1) = t(end) + dt;
end
end
plot(t,Zc)
% position, velocity, acceleration of the wheel/chass
댓글 수: 0
답변 (1개)
Chris
2022년 12월 2일
Looking at the image, a_w and a_c are independent of previous acceleration values.
Aw(end+1) = -(1/Mw)*((Cw+Cs)*Zw(end) + Cs*Zc(end) + Ds*(Vc(end) - Vw(end)) + Cw*Zr(end)-Fs(end));
Ac(end+1) = (1/Mc)*(Cs*(Zw(end)-Zc(end))+Ds*(Vw(end)-Vc(end))+Fs(end));
You also have pulled a minus sign to the front, when it should only apply to the first term.
Aw(end+1) = (1/Mw)*(-(Cw+Cs)*Zw(end) + Cs*Zc(end) + Ds*(Vc(end) - Vw(end)) + Cw*Zr(end)-Fs(end));
I offer no guarantees on the validity of the rest of your code.
clear
Mc = 401; %Weight
Mw = 48; %Wheel Mass
Ds = 2300; % Susp Damping Coef
Cs = 230000; % Susp Spring Coef
Cw = 250000; %Wheel Spring Coef
Wact = 0.001; % WActuator Time Const
t = 0; %intial Time
dt = 0.001;
Zc = 0; % Displacement Chass
Zw = 0; % Displacement Wheel
Zr = 0; %Disp Road
Vw = 0; %intial speed wheel vertical
Vc = 0; %intial speed Chassis Vertical
U=0;
alp = 0;
bet = 0;
u = U*exp(-alp*(t(end)-t(1)))*cos(2*pi*bet*(t(end)-t(1)));
Fs = 0; %leaving as 0 until we figure out the non-damp force graphing
Fs(end+1) = Fs(end) + ((Fs(end)/Wact)+(1/Wact)*u)*dt; %Damp force
Aw = 0; %intial Wheel Acc
Ac = 0; %intial Chassis Acc
while t(end) < 5
if t(end) > 1 && t(end) < 1.11
Zr = -0.5;
Aw(end+1) = (1/Mw)*(-(Cw+Cs)*Zw(end) + Cs*Zc(end) + Ds*(Vc(end) - Vw(end)) + Cw*Zr(end)-Fs(end));
Vw(end+1) = Vw(end) + Aw(end)*dt;
Zw(end+1) = Zw(end) + Vw(end)*dt;
Ac(end+1) = (1/Mc)*(Cs*(Zw(end)-Zc(end))+Ds*(Vw(end)-Vc(end))+Fs(end));
Vc(end+1) = Vc(end) + Ac(end)*dt;
Zc(end+1) = Zc(end) + Vc(end)*dt;
t(end+1) = t(end) + dt;
else
Zr = 0;
Aw(end+1) = (1/Mw)*(-(Cw+Cs)*Zw(end) + Cs*Zc(end) + Ds*(Vc(end) - Vw(end)) + Cw*Zr(end)-Fs(end));
Vw(end+1) = Vw(end) + Aw(end)*dt;
Zw(end+1) = Zw(end) + Vw(end)*dt;
Ac(end+1) = (1/Mc)*(Cs*(Zw(end)-Zc(end))+Ds*(Vw(end)-Vc(end))+Fs(end));
Vc(end+1) = Vc(end) + Ac(end)*dt;
Zc(end+1) = Zc(end) + Vc(end)*dt;
t(end+1) = t(end) + dt;
end
end
plot(t,Zc)
참고 항목
카테고리
Help Center 및 File Exchange에서 Multibody Modeling에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!