• Car Hybrid Basic e2 help
    4 replies, posted
Hi, i am new to e2 and tried making my first code, it only consists of a if, elseif and else statements so far. @name Hybrid Engine E2 @inputs Speed Active @outputs Electric Petrol @persist  @trigger Active if(Active == 1 & Speed<27){     Petrol = 0     Electric = 1} elseif  (Active ==1 & Speed >=27){       Petrol = 1       Electric = 0} else {     Petrol = 0     Electric = 0 } I am making a hybrid car with both ACF Electric motor to get it moving and a petrol engine to take over above a certain speed. Currently it does not do anything and neither engines are active when i sit in the seat and active == 1. Any help would be appreciated
Add speed as a trigger to your E2, and maybe condense your code to read this: if(Speed<27){ Petrol=0 Electric=Active }else{ Petrol=Active Electric=0 } This will set the "Petrol" value to whatever "Active" is if the speed is over 27, or do the same thing to the "Electric" value if the speed is under or at 27. If "Active" is 0, both values are o regardless of speed.
Thanks it seems to work, but do you know how i could add a short delay between where it changes? because in the time it takes to swap which engine is active, it slows below 27 and swaps back to electric, thanks alot
It might be worth keeping the electric motor on as you're engaging the petrol one. if(Speed<29){ Electric=Active }else{ Electric=0 } if(Speed>27){ Petrol=Active }else{ Petrol=0 } This way, between 27 and 29 indicated speed, both engines are going; the elctric one's been accelerating the vehicle to 27, then there's a 2 speed buffer to give the petrol engine time to ramp up and take over.
Wow, works perfectly, thanks alot, Ill use this knowledge in future builds, thanks again!
Sorry, you need to Log In to post a reply to this thread.