these are my functions Ramp.m function [PLRAMP] = Ramp(PL, PL0, T1, PLPRE, CONTROL) %…
- User
these are my functions
Ramp.m
function [PL_RAMP] = Ramp(PL, PL_0, T1, PL_PRE, CONTROL)
% Define the step size for changing the pressure PLINE_STEP = 0.2;
% Pressure Adjustment Based on Control Flag % CONTROL = 1: Increase Pressure % CONTROL = -1: Decrease Pressure % CONTROL = 0: Maintain Current Pressure if CONTROL == 1 PL_RAMP = PL_PRE + PLINE_STEP; % Increase pressure by PLINE_STEP elseif CONTROL == -1 PL_RAMP = PL_PRE - PLINE_STEP; % Decrease pressure by PLINE_STEP elseif CONTROL == 0 PL_RAMP = PL_PRE; % Keep pressure constant end
% Initial Time Condition Check % If T1 is 0 (start of simulation), set pressure to initial value PL_0 if T1 == 0 PL_RAMP = PL_0; end
% Pressure Boundary Conditions % Ensure PL_RAMP does not exceed maximum pressure PL % Ensure PL_RAMP does not fall below zero if PL_RAMP > PL PL_RAMP = PL; elseif PL_RAMP < 0 PL_RAMP = 0; end
end
tiremodel.m
function [FX] = tiremodel(I, N, MU_MAX)
% Tire Slip Ratio vs. Normalized Force Lookup Table % Column 1: Slip ratio (I) % Column 2: Corresponding normalized force TIRE_W = [0 0; -0.05 0.6; -0.1 0.8; -0.15 0.95; -0.2 1; -0.25 0.97; -0.3 0.94; -0.4 0.87; -0.6 0.8; -0.8 0.75; -1 0.7];
% Longitudinal Force Calculation (FX) % Interpolate the normalized force from the lookup table based on the slip ratio (I) % Multiply the interpolated value by the normal force (N) and the maximum friction coefficient (MU_MAX) FX = N * (interp1(TIRE_W(:,1), TIRE_W(:,2), I)) * MU_MAX;
end
slip.m
function [FB_S, SKID] = slip(FB, N, MU_MAX, MU_S)
% Checking Skid Condition Based on Applied Braking Force and Maximum Frictional Force % FB: Applied Braking Force % N: Normal Force % MU_MAX: Maximum Friction Coefficient % MU_S: Static Friction Coefficient
% Determine if Tire is Skidding if FB <= MU_MAX * N % No Skid: Effective Braking Force equals Applied Force FB_S = FB; SKID = ‘NO’; % Set SKID status to ‘NO’ indicating no skidding else % Skid: Effective Braking Force limited by Static Frictional Force FB_S = MU_S * N; SKID = ‘YES’; % Set SKID status to ‘YES’ indicating skidding end
end
Braking_torque.m
function [T_f, T_r] = Braking_torque(Pl, Af, Ar, mu_f, mu_r, N_f, Rmean_f, Rmean_r) FRIC_F = Pl * Af * mu_f * N_f; FRIC_R = Pl * Ar * mu_r * N_f; TFRIC_F = FRIC_F * Rmean_f; TFRIC_R = FRIC_R * Rmean_r; T_f = TFRIC_F; T_r = TFRIC_R; end
ABScycle.m
function [control] = ABScycle(a1, a2, a3, a4, aw, aw_pre)
% Determine the direction of change in angular acceleration if (aw - aw_pre) <= 0 slope = -1; % Negative slope indicates deceleration else slope = 1; % Positive slope indicates acceleration end
% ABS logic based on current angular acceleration (aw) and its change (slope) if aw <= 0 % If angular acceleration is negative or zero (decelerating wheel) if aw > a1 % If angular acceleration is greater than threshold a1 if slope == -1 control = 1; % Increase brake pressure elseif slope == 1 control = 0; % Hold brake pressure end elseif aw <= a1 % If angular acceleration is less than or equal to threshold a1 if slope == -1 control = -1; % Decrease brake pressure elseif slope == 1 control = 0; % Hold brake pressure end end else % If angular acceleration is positive (accelerating wheel) if aw <= a4 % If angular acceleration is less than or equal to threshold a4 if slope == 1 control = 0; % Hold brake pressure elseif slope == -1 % If the wheel is starting to decelerate if aw >= a3 control = 0; % Hold brake pressure else control = 1; % Increase brake pressure end end elseif aw > a4 % If angular acceleration is greater than threshold a4 control = 1; % Increase brake pressure end end end
- Assistant