Need help with car suspension dampening, current code is exp growing.

4 ビュー (過去 30 日間)
Levi Mikesell
Levi Mikesell 2022 年 12 月 2 日
コメント済み: Chris 2022 年 12 月 2 日
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

回答 (1 件)

Chris
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)
  2 件のコメント
Levi Mikesell
Levi Mikesell 2022 年 12 月 2 日
Thank you so much!
Chris
Chris 2022 年 12 月 2 日
No problem :)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMultibody Modeling についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by