Throttle Control Issue - Matlab Code Block in Simulink
Show older comments
I am currently trying to set up some logic to simulate how a throttle would be controlled in a vehicle that I am simulating in reference to the vehicle's velocity. I am having trouble coming up with how to correctly model the behaviour I require. Below is my current code.
function [Throttle, CurrentThrottle] = fcn(u1,u2)
Vmin = 15*0.445;
Vmax = 30*0.445;
if(u1 < Vmin)
Throttle = 1;
CurrentThrottle = 1;
elseif(u1 > Vmax)
Throttle = 0;
CurrentThrottle = 0;
elseif u1 > u2
Throttle = 1;
CurrentThrottle = 1;
elseif u1 < u2
Throttle = 0;
CurrentThrottle = 0;
else
Throttle = 0;
CurrentThrottle = 0;
end
CurrentThrottle was a reference value that I am no longer using. I am trying to apply the throttle up to Vmax, then let the vehicle coast (meaning 0 throttle) until I reach Vmin. Then if I drop below Vmin, I would like to accelerate again. This is my latest, and nearly functional model. Others before have been much too complex...
u1 is the velocity input from the system, and u2 is the last velocity input from the system. Essentially: u1 = V(i) & u2 = V(i-1). Below is a picture of the model for reference.

Any help would be greatly appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Programming in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!