E-Turbo Controller Code

MkngStffAwesome

Active member
USE AT YOUR OWN RISK

Right i have created a Universal E-turbo controller below is not the complete code but my notes on it so you can see what it does ..
Please provide me with your feed back.

I DON'T like posting code because the internet is full of haters who always think they can do things better, which maybe the case but instead of talking about doing something i actually did it.

The only thing missing from this code is a screen which can be another Project ( that's alot of work TOO ! )

Below are a number of methods of controlling your E-Turbos Max Speed
1 Simple on off switch

2 Adjusting a Potentiometer (POT) AKA a "KNOB"

3 Via the cars Pedal Pressure

4 Via Engine RPM ( This Overrides 2 )

Soft Start to no overload your electrical system.



2-4 and be mix and matched. (The most restrictive one is the actual speed )

SO you can have just a simple Switch "1" OR a switch "1" and engine RPM (4) Or you could have 1,3,4



We then have 4 Out puts which can be used to control various external devices and a saftey feature.


USE AT YOUR OWN RISK
Download Code
USE AT YOUR OWN RISK
 
Last edited:
Code:
Author:     Michael Dixon Auckland New Zealand ( Ultrasonic2 from Making Stuff Awesome ).  All rights reserved.



    USE AT YOUR OWN RISK. I have no ability to know how this will work in all possible use cases or if it works in any cases at all.

    It is Probal that there will be some unknown bugs with this.
  

    This is intended for a Arduino 328P (5v) Nano and assumes yuor car is also 5V

    Please consider becoming a Patreon @ https:www.patreon.com/Ultrasonic2


    Known Issues:-

    Nothing known.

    If you have any issues please send me a copy of your debug with "EnableLog" set to 1


    Testing:-

    Only bench testing.

    Getting Engine RPM has not bee tested as i'd need to connect it to a real car for that, which has not been done yet.

 

Below are a number of methods of controlling your E-Turbos Max Speed

 1 Simple on off switch

 2 Adjusting a Potentiometer (POT) AKA a "KNOB"

 3 Via the cars Pedal Pressure

 4 Via Engine RPM ( This Overrides 2 )

 Soft Start to no overload your electrical system.




2-4 and be mix and matched. (The most restrictive one is the actual speed )

 SO you can have just a simple Switch "1" OR  a switch "1" and engine RPM (4) Or you could have 1,3,4



We then have 4 Out puts which can be used to control various external devices and a saftey feature.



 ++++++++++++++  DEBUG  ++++++++++++++

 debug mode ( out put everything over serial )

int EnableLog = 2; 0=debug disabled 1= enabled. 2= enabled only variables. 3= engine rpm only.DO NOT leave this enabled as it massively slows down the Arduino making rev up/down and engine RPM  jerky. !!!!!!!!!

int DebugSpeed = 500;   500 1/2 second update speeds.

To read the output you'll need to use an App like "Putty" and connect to it on 115200 baud.



 ++++++++++++++  SWITCH  ++++++++++++++

(Always Used / Required)

This is a simple switch that can be used to Start your E-Turbo . If this is the only option enabled then Max motor speed is defined by  "SetMaxSpeed" See below.

 If other options are enabled then this becomes an overriding On-Off switch

Trigger_PIN


 ++++++++++++++  KNOB  ++++++++++++++

 Use a Knob (Pot) to adjust max motor speed. Even with Knob disabled "SetMaxSpeed" is used to limit max motor speed!

bool UseKnobForMaxRpm = 0; 0= Pot disabled use FIXED max speed specified below. 1 = Use pot to very max RPM from 0 to Specified below

int SetMaxSpeed = 1000; 1000= 100.0% , 986 = 98.6%

int SetMaMinKnobSpeed = 500; = 50.0% knob goes from 50% to "SetMaxSpeed". Can be changed to go from 0 to 100% it's from 50% because 0=100  can be to sensitive.


 ++++++++++++++  SOFT START  ++++++++++++++

(Always used)

 Slow down the motors spinup to reduce spinup current and destroying ESC's

int SoftSartTime = 1000; ( time to slowly increase the ESC from 0 to 100%. 1000 = 1second)to "SetMaxSpeed". Max setting 30,000

float RevDownTime = 6000;  6000 = 6 seconds. Once you have decided the "Max motor speed" rev the motor and e-turbo to that and then time how long it takes to come to a complete stop.

 This is used to estimate motor speed and therefore how much of "SoftSartTime" to reapply between toggling the switch or getting off and on the gas (for gear changes)

int IdleSpeed = 200;  200 = 20.0% min Idle Speed with battery flat FROM a complete stop. YOU'LL need to test this to find out what this is by setting "SetMaxSpeed" to a low number. See Debug



 ++++++++++++++  PEDAL LIMITING ++++++++++++++
 Use the cars pedal

bool UsePedal = 0;  0= disabled h 1= use 5v from Pedal (car).

int UseMultiProfiles = 0;  0=No (first profile used), 1 = Yes Pin connected to ECU. 2= Yes with Pullup ( for external switch )

 Values are pulled from the pedal sensor ( see debug to know what to change them too "**CurrenCurrentPedal"). The below numbers are just made up.

 3 point pedal to rpm rev up.

 0 to StartIdlePressure. No motor speed

 StartIdlePressure to StartRevUpPressure. Motor is Fixt to "IdleSpeed". This done for 3 reasons. At this point it's not expected that any boost will be created.

    1 This is just meant to spin the motor slow enought as to NOT create a restriction.

    2 Getting Motor sync is actually a un known time and this therefore affects the Actual motor spin up time.. This is therefore a unknown additional time to "SoftSartTime " idling the motor prior thus removes this randomness, which can cause inconsistent Current pulled when spinning up.

    3 Starting a motor from "0%" and slowly adding power can cause motor screeching and erratic behavior at low speeds. This avoids this by YOU ensuring a "IdleSpeed" is set to a speed that the motor can at least Idle at when your Battery is flat FROM A STOP.


Below StartIdlePressure 0% speed

int StartIdlePressureA = 500;  Fixed IdleSpeed to StartRevUpPressure point

int StartRevUpPressureA = 700; IdleSpeed Raming to SetMaxSpeed

int FinishRevUpPressureA = 1000; SetMaxSpeed

Above FinishRevUpPressure speed = SetMaxSpeed




Profile 2 enabled by switch/ clutch switch. Intended for no engine load condition but could also be used as a difference config for different situations.

int StartIdlePressureB = 200;

int StartRevUpPressureB = 250;

int FinishRevUpPressureB = 300;




 ++++++++++++++  RPM LIMITING ++++++++++++++

This Overides "KNOB" settings

 Used to specify different RPM's and motor speeds at those points

bool EnableRPMLimiting = 1; 0= disable rpm limiting. 1= enable rpm based limiting

int PulsesPerRPM = 6;  10 is max. The number of on or offs per rotation.. (this is assumed that you're connected to the engines CAM sensor. if your rpm is to high or low try changing this.

engine rpm can be massively thrown out by DEBUGing being enabled.


 below RPM1 motorspeed is 0

int RPM1A = 2000;

int RPM2A = 2500;

int RPM3A = 3500;

int RPM4A = 4500;

int RPM5A = 5500;

 Above RPM5 motorspeed is = to RPM5speed



int RPM1speedA = 200;

int RPM2speedA = 250;

int RPM3speedA = 700;  700 = 70.0%

int RPM4speedA = 900;

int RPM5speedA = 950;




Profile 2 enabled by switch/ clutch switch. Intended for no engine load condition but could also be used as a difference config for different situations.

 Used to specify different RPM's and motor speeds at those points

int RPM1B = 2000;

int RPM2B = 2500;

int RPM3B = 3500;

int RPM4B = 4500;

int RPM5B = 5500;



int RPM1speedB = 0;

int RPM2speedB = 200;

int RPM3speedB = 700;  700 = 70.0%

int RPM4speedB = 900;

int RPM5speedB = 950;




 ++++++++++++++  BATTERY PROTECTION ++++++++++++++

int DisableMotorUnder = 0;  0= do not disable the E-Turbo under a certain voltage 1= disable under a certain voltage.

int Use12vSensor = 1; 0= Use the High voltage for disabling "ETurboVolt" .1= use the 12v battery ( for 12v e-turbos ) for disabling

int DisableMotorUnderVolt = 1200; 1200= 12.00v

float DisableMotorTime = 120000;  60,000= 1 minute disable more for...



 ++++++++++++++  EXTERNAL CONTROL SWITCHING ++++++++++++++


 ***There is a out put pin on "PIN_PowerOn" that will turn on when 12v voltage above "ChargeOverVolt" used to turn things on when the car is running. This can be used to power a Mosfet OR LOW power Relay

PIN_PowerOn



int MotorRunningSwitch = 0;  0=Off, 1=only when boosting (over Idle), 2= Idling and Boosting (over 0 % speed). this can be used to run loud cooling fans only when needed (When the motor is running).This can be used to power a Mosfet OR LOW power Relay

float MotorRunningSwitchContinueFor = 30000; 60000 = 1 minute. once the motor is off it will continue to run (cool) for a period of time.

PIN_MotorRunning



 These are the Resistor values for a Voltage Divider for the cars 12V voltage system (15v)

The Ardunio Nano can only handle 5v In put so a voltage divider must be used to reduce the voltage to between 0-5v Under no conceivable case should the out put of the divider be more than 5v.

once  you receive the resistors it's bet to check their values and enter those instead of the theoretical values.

 Note the "5v" of the Nano as a great impact on the accuracy of the calculated voltage. Use "Debug" to see what the result is.


https:ohmslawcalculator.com/voltage-divider-calculator

Suggestion for 15v

 RHigh12v = 12K ohms

 RLow12v = 6K Ohms


Suggestion for 30v

 RHigh12v = 30K ohms

 RLow12v = 6K Ohms


Suggestion for 60v

 RHigh12v = 70K ohms

 RLow12v = 6K Ohms


int RHigh12v = 12000;

int RLow12v = 6000;



 These are the Resistor values for a Voltage Devider for the E-turbos Battery Pack

int RHighETurboVolt = 70000;

int RLowETurboVolt = 6000;



int ChargingMode = 0;  0=Charging disabled, 1= charge only when motor off, 2= Also charge during motor idling..
int ChargeOverVolt = 1300; = 1300 = 13.00V only allow charging when the 12v system is above this voltage ( Car off it will stop charging )
PIN_Charging


Used for turning something on if the 12v falls below a voltage,Like back charging the 12v battery from the E-turbo battery.(you'll need a buck for this.)
int UnderVoltage = 1299;  will turn on below
PIN_UnderVoltage
 
Ok - I've had a chance to look at this, pulled out another arduino and... I confess I can't make heads or tails out of this. I'm not an arduino guru by any stretch - how do we implement this code?
 
Any of it. I have no idea what to do with it. I thought it was a sketch that I could just copy and paste and compile into an Arduino but I have no idea what it is.
 
Right i think i know what's going on..

Post one has a link to download the code. (you need to click on the link and download all of the code)
Post 2 only contains the instruction part of the code for reference here. I can not post all of the code here like i did in second post because you have a character limit on posts. My code is about 30,000 characters, not surprisingly is to large.

Is this the problem ?
 
That appears to be it. I couldn't download it on my computer but it looks like I can from my phone. I thought your second post was a copy of the ino file. Let me check it out and I'll let you know.
 
Ok, I was able to download it, but I got an error once it told me it needed to be in a folder and wanted to create that folder. So what I did is I opened the sketch in Windows Notepad, copied it all (ctrl+a), and pasted it back into the arduino software, and saved it with a different name - I added "Alex" to the end of it just so I know it's the one I've copied/pasted. Then it worked :) So now I just get a warning when I verify the sketch:

X:\CarVids\ArduinoStuff\ArduinoCodeV2\E_Turbo Controller\E_Turbo_ControllerAlex.ino\E_Turbo_ControllerAlex\E_Turbo_ControllerAlex.ino:196:23: warning: overflow in implicit constant conversion [-Woverflow]
int RHighETurboVolt = 70000;
^~~~~

Is that something to worry about? I'd like to make a video on how to use this (and give you credit and point to your channel, of course); any other tips before I start diving in?
 
The max value is 32,767
70k assumes you were trying to use a 70k resistor is this correct ?
You could...
1) Use resistors lower than or = to 32k
2) Divide both the Rhigh and RLow by 10 so 70k would become 7,000

What parts of the code are you intending on using ?
 
I'll probably just be using the pot to set max value while testing. But I'd like to put it through its paces to make sure anyone can replicate its uses. Honestly, I'm only finding scraps of time here and there to work on it (leaving right now to get more stuff out of my dad's house and stopping by mom's - it's her 80th birthday today; later I have some camera tests to run, and then I've got a bunch of shows to direct for NBC this week, and at the end of the week flying down to Florida to shoot a two seat top fuel dragster... you get the idea)

But soon enough my schedule should start to open up - the start of 2022 looks promising...
 
ok the rpm sensing is most likely to be problematic and may need a lot of work to actually work... i wasn't able to test this.. It might work though
 
I probably still have a distributor with a VR pickup kicking around somewhere - I could probably chuck that in a drill to test. Though a VR sensor's output needs a lot of conditioning to play nicely with a digital micro controller input. I'm wondering if a simple MOSFET (being a voltage triggered, rather than current triggered, device would be fit for the purpose). I'd have to find one that's got a huge Vgs range. That's the issue with VR sensors - at slow speeds, there's not much of a pulse; but at high speeds I bet the pulse gets into the 10-20 volt range.

There may even be a VR conditioning circuit online somewhere - I haven't looked. I'm going to spend some time tonight messing with this.

Wish me luck.
 
I probably still have a distributor with a VR pickup kicking around somewhere - I could probably chuck that in a drill to test. Though a VR sensor's output needs a lot of conditioning to play nicely with a digital micro controller input. I'm wondering if a simple MOSFET (being a voltage triggered, rather than current triggered, device would be fit for the purpose). I'd have to find one that's got a huge Vgs range. That's the issue with VR sensors - at slow speeds, there's not much of a pulse; but at high speeds I bet the pulse gets into the 10-20 volt range.

There may even be a VR conditioning circuit online somewhere - I haven't looked. I'm going to spend some time tonight messing with this.

Wish me luck.
i theory if you change the pulses in the code and you could get the count from the ignition coils firing but you'd need a voltage divider for that since they run at 12 volts...
 
Top