Outlander VCU - Rear inverter, Charger and BMS
- aot93
- Posts: 212
- Joined: Mon Feb 15, 2021 5:45 pm
- Location: UK, West Sussex
- Has thanked: 8 times
- Been thanked: 48 times
Re: Outlander VCU - Rear inverter, Charger and BMS
BMS_packvoltage is voltage as read from the BMS.
No the VCU will not go in error state if pre-charge conditions are not met, in fact there is currently no max pre-charge time so it will just sit there waiting for the conditions to be met.
The only exception here is if pre charge happens too quickly then I flash my red LED after as a warning.
If there was a battery fault it's the BMS job to detect it and report it on the CAN bus, if the VCU sees the BMS in an error state the VCU will also go to error state.
No the VCU will not go in error state if pre-charge conditions are not met, in fact there is currently no max pre-charge time so it will just sit there waiting for the conditions to be met.
The only exception here is if pre charge happens too quickly then I flash my red LED after as a warning.
If there was a battery fault it's the BMS job to detect it and report it on the CAN bus, if the VCU sees the BMS in an error state the VCU will also go to error state.
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
OK i have to put my battery in the car to test this functionality. Grear job on making this a fluid VCU.
There is one thing i noticed. It may be connected to my battery being outside of the car on long 6mm2 cables

My max torque is set to 60Nm, maybe that is too little, but would that really trip the torque limiter to drop the torque to 0?
Another thing i am looking for is rev limiter. Yesterday i ran the motor to 10000rpm forward which is 160km/h on ground! Great!
But i could do the same in reverse! No inhibitor there... What would you suggest i do? I would like to have maybe 30km/h in reverse, about 1900RPM (better make it 2000). That should be plenty.
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
Did anyone use rev limiter code with Outlander inverter/motor VCU code?
- aot93
- Posts: 212
- Joined: Mon Feb 15, 2021 5:45 pm
- Location: UK, West Sussex
- Has thanked: 8 times
- Been thanked: 48 times
Re: Outlander VCU - Rear inverter, Charger and BMS
I limit speed in reverse by setting torque request to 0 when in reverse this works well for me but not exactly smooth.
In all cases if torque goes outside of the accepted norms ( -+200nm) then we set torque request to zero
There is also a crude step down in torque request if we are over the BMS discharge limit.
If you want something more aggressive you could pull RSDN high or set the inverterFunction to 0 (0x287 b6)
As for the cutting out with wheels on the ground it could be many things, I would check to see how much torque the VCU is requesting and also if that 0x287b6 is changing from 0x03.
Code: Select all
if (motorRPM < -2000)
{
torqueRequest = 0;
}
}
There is also a crude step down in torque request if we are over the BMS discharge limit.
Code: Select all
if (torqueRequest > (2000))
{
torqueRequest = 0;
Serial.println("--!OVER TORQUE!--");
}inverterFunction
if (torqueRequest < (-1000))
{
torqueRequest = 0;
Serial.println("--!UNDER TORQUE!--");
}
torqueRequest += 10000;
if (BMS_discurrent < currentact) // Decrease torque if we are over current - Crude needs work..
{
torqueRequest -= 20;
Serial.println("--!OVER CURRENT!--");
if (torqueRequest < 0)
{
torqueRequest = 0;
}
}
If you want something more aggressive you could pull RSDN high or set the inverterFunction to 0 (0x287 b6)
As for the cutting out with wheels on the ground it could be many things, I would check to see how much torque the VCU is requesting and also if that 0x287b6 is changing from 0x03.
- marcexec
- Posts: 169
- Joined: Tue May 14, 2019 12:52 pm
- Location: Dublin, Ireland
- Has thanked: 742 times
- Been thanked: 67 times
Re: Outlander VCU - Rear inverter, Charger and BMS
Is that a hard limit (i.e. the OEM inverter ignores it) or just to stay in spec?
A motorcyclist is never late, Frodo Baggins. Nor is he early. He arrives precisely when he means to.
Getting started guide for Celeron55's iPDM56
My Suzuki RF400 build @ES
Honda IMA & Lebowski howto

Getting started guide for Celeron55's iPDM56
My Suzuki RF400 build @ES
Honda IMA & Lebowski howto

- aot93
- Posts: 212
- Joined: Mon Feb 15, 2021 5:45 pm
- Location: UK, West Sussex
- Has thanked: 8 times
- Been thanked: 48 times
Re: Outlander VCU - Rear inverter, Charger and BMS
I actually don't know, I've not really tried to exceed the published torque.
It's more than I need in my application.
It's more than I need in my application.
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
Now that is a revelation!
it makes sense to me now that when i wanted to drive into the garage torque would cut off. It will only cutoff in forward direction.
My motor is installed in reverse

thank you.
- midway
- Posts: 89
- Joined: Mon Feb 15, 2021 3:52 pm
- Location: Ural
- Has thanked: 9 times
- Been thanked: 12 times
Re: Outlander VCU - Rear inverter, Charger and BMS
My engine is also installed in the opposite direction. Everything works fine. When I changed the direction of rotation, my engine stopped accelerating spontaneously.
- aot93
- Posts: 212
- Joined: Mon Feb 15, 2021 5:45 pm
- Location: UK, West Sussex
- Has thanked: 8 times
- Been thanked: 48 times
Re: Outlander VCU - Rear inverter, Charger and BMS
Small but very important detail, this is all coded for normal oem orientation.
Rather than reversing all the code it might be worth just inverting the incoming RPM messages
This should work then inverting the final torque request in inverterComms()
The only other part i can think needs changing would be the hardcoded rev limit in reverse to be a positive value
Rather than reversing all the code it might be worth just inverting the incoming RPM messages
Code: Select all
void canRX_289(const CAN_message_t &msg)
{
motorTorque = ((((msg.buf[0] * 256) + msg.buf[1]) - 10000) / 10); // Motor Torque -200 / + 200nm
motorRPM = (msg.buf[2] * 256 + msg.buf[3] - 20000);
motorRPM = motorRPM * -1;
The only other part i can think needs changing would be the hardcoded rev limit in reverse to be a positive value
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
A question there... what would happen if i would set
Code: Select all
minTorque = 0;
Code: Select all
minTorque = -10;
How do you set
Code: Select all
torqueIncrement = 10;
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
Update because of connecting HV battery
The car moves rather well out and into the garage. No more shutoffs. Tomorrow i will go to drive on the road
.
There is another issue i noticed. Charger temp function... rather temp function in general.
void tempCheck() requests fan (OUT6 output) to turn on when various devices temperatures are more than fanOnTemp.
When i left my charger ON to its own devices it went to temperature above 50deg and still tempCheck() wouldnt turn the fan outpout on.
What could be the problem? When i observe status report in serial everything is shown as it is.
tempCheck(); is called in loop() function
The car moves rather well out and into the garage. No more shutoffs. Tomorrow i will go to drive on the road

There is another issue i noticed. Charger temp function... rather temp function in general.
void tempCheck() requests fan (OUT6 output) to turn on when various devices temperatures are more than fanOnTemp.
When i left my charger ON to its own devices it went to temperature above 50deg and still tempCheck() wouldnt turn the fan outpout on.
What could be the problem? When i observe status report in serial everything is shown as it is.
tempCheck(); is called in loop() function
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
ok now... i managed to go for a roll
. Motor can pull the car just fine. However starting torque is a bit lame.
But the most problematic is constant torque block. It felt like i couldnt get the VCU to accept throttle value more than 50%...
I calinrated throttle so when released it showed 0. I tested variuous torque increments from 10 to 100. This torque block felt worse when in map3!
Another issue i observed is the constance of torque. If i would remove throttle pedal command motor would still feel like steady speed even a bit uphill. It felt kind of having cruise control on... Any thoughts?
Also i havent felt any regen when i lifted my foot off the throttle. Shoiuld i be thinking about putting (-1) to regen values?
My system does not report battery current as i dont use ISA shunt or Outlander shunt yet. In any case i have analog current display and SOC meter which is sufficient for now. Do you think code absolutely needs a current report?

But the most problematic is constant torque block. It felt like i couldnt get the VCU to accept throttle value more than 50%...
I calinrated throttle so when released it showed 0. I tested variuous torque increments from 10 to 100. This torque block felt worse when in map3!
Another issue i observed is the constance of torque. If i would remove throttle pedal command motor would still feel like steady speed even a bit uphill. It felt kind of having cruise control on... Any thoughts?
Also i havent felt any regen when i lifted my foot off the throttle. Shoiuld i be thinking about putting (-1) to regen values?
My system does not report battery current as i dont use ISA shunt or Outlander shunt yet. In any case i have analog current display and SOC meter which is sufficient for now. Do you think code absolutely needs a current report?
- aot93
- Posts: 212
- Joined: Mon Feb 15, 2021 5:45 pm
- Location: UK, West Sussex
- Has thanked: 8 times
- Been thanked: 48 times
Re: Outlander VCU - Rear inverter, Charger and BMS
MinTorque is not used in the code.
Not sure on why the fan is not turning on, does it work using the test options.
Well the you could be getting de-ratted as there is no specific values for max discharge.
There should not be a condition where the motor 'sticks' i suspect something do with the mounting being in reverse but the code is assuming forward.
I think your code has quite a few changes now, if you can post it i can take a look, otherwise it's hard to know exactly what's going on.
Not sure on why the fan is not turning on, does it work using the test options.
Well the you could be getting de-ratted as there is no specific values for max discharge.
There should not be a condition where the motor 'sticks' i suspect something do with the mounting being in reverse but the code is assuming forward.
I think your code has quite a few changes now, if you can post it i can take a look, otherwise it's hard to know exactly what's going on.
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
YAY! I think i solved the first part of my torque blocking...
I found this code for overcurrent which deals with BMS repported torque. Guess what i am not using any current reporting...
Code: Select all
/* if (BMS_discurrent < currentact) // Decrese tourque if we are over current - Crude needs work..
{
torqueRequest -= 20;
Serial.println("--!OVER CURRENT!--");
if (torqueRequest < 0)
{
torqueRequest = 0;
}
} */
I tried to replace value regenRequest
Code: Select all
regenRequest -= 5;
EDIT: Should i be asserting positive increment to regen in the code where it is now negative increment?
Code: Select all
if (regenTarget < regenRequest) // increment Regen
{
regenRequest -= Regen;
torqueRequest = regenRequest;
// Serial.println("Regen inc.");
}
https://github.com/arber333/Mini-E-VCU
Re: Outlander VCU - Rear inverter, Charger and BMS
Hi aot93,
I would be most grateful to acquire your latest PCBs if you have any available
Many thanks
MArk
I would be most grateful to acquire your latest PCBs if you have any available
Many thanks
MArk
- aot93
- Posts: 212
- Joined: Mon Feb 15, 2021 5:45 pm
- Location: UK, West Sussex
- Has thanked: 8 times
- Been thanked: 48 times
Re: Outlander VCU - Rear inverter, Charger and BMS
Hi Arber,
I will take a look at your code and report back if i spot anything.
As for the regen, the basic idea is a regen value is acquired from the map using throttle position and speed.
There are some delays and everything gets incremented to ensure smooth driving.
I found all the above necessary in a light car, in a heavier vehicle it's probably not needed.
When it it's well setup i get quite close to one pedal driving.
I will take a look at your code and report back if i spot anything.
As for the regen, the basic idea is a regen value is acquired from the map using throttle position and speed.
There are some delays and everything gets incremented to ensure smooth driving.
I found all the above necessary in a light car, in a heavier vehicle it's probably not needed.
When it it's well setup i get quite close to one pedal driving.
- aot93
- Posts: 212
- Joined: Mon Feb 15, 2021 5:45 pm
- Location: UK, West Sussex
- Has thanked: 8 times
- Been thanked: 48 times
Re: Outlander VCU - Rear inverter, Charger and BMS
Hi Mark,
drop me a PM with your details, I have VCU boards but no BMS ones..I would be most grateful to acquire your latest PCBs if you have any available
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
Yes, yes! That is my goal. I still have to connect my wattmeter device - display above the left dial. This will show me how much regen is there at all.
Does the code take into account brake pedal as well? In my experience brake pedal regen is undesirable in snow or icing conditions. I would much rather use throttle pedal regen AND mechanical braking.
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
Well i closed up my front box and relay box. I added my watt meter sensor and went for a ride....
Several rides into this showed results...
Inverter at start pulled 115A for acceleration. I consider this rather slow in comparison with my ACIM motor before. That was on NORMAL mode. When motor develops rpm it goes really good, however takeoff from 0 leaves a lot to be desired. I even managed to trip out during takeoff. I guess this would be torque increment protection?
When on SPORT mode acceleration was much better with 180A up to 80km/h and 220A up to 120Km/h. I ran out of straight road to go faster.
Tommorow in daylight i will test 0 to 100kn/h acceleration and report further.
There was NO NOTICABLE regen when i removed throttle or used the brake. No regen effect at all.
@aot93 can you tell me your setting for torqueIncrement please? What would be a sensible value?
Also how would i resolve regen?
tnx
Several rides into this showed results...
Inverter at start pulled 115A for acceleration. I consider this rather slow in comparison with my ACIM motor before. That was on NORMAL mode. When motor develops rpm it goes really good, however takeoff from 0 leaves a lot to be desired. I even managed to trip out during takeoff. I guess this would be torque increment protection?
When on SPORT mode acceleration was much better with 180A up to 80km/h and 220A up to 120Km/h. I ran out of straight road to go faster.
Tommorow in daylight i will test 0 to 100kn/h acceleration and report further.
There was NO NOTICABLE regen when i removed throttle or used the brake. No regen effect at all.
@aot93 can you tell me your setting for torqueIncrement please? What would be a sensible value?
Also how would i resolve regen?
tnx
- aot93
- Posts: 212
- Joined: Mon Feb 15, 2021 5:45 pm
- Location: UK, West Sussex
- Has thanked: 8 times
- Been thanked: 48 times
Re: Outlander VCU - Rear inverter, Charger and BMS
Hi Arber,
Good to hear you are driving.
For the low power in the different modes you should play with the maps to get the response you want. I would suggest using all 1's in map 3 this will give a straight mapping of pedal position to torque, ie 50% pedal 100nm torque.
To note there is also no torque incrementing in map3
As for the increment setting this something you can play with to get the feel right 20 is a good place to start, use map 3 to get an idea of what no increment is like.
As I say it may not be needed at all in a heavier car.
As for no regen, I took a look at your code, i think the issue may be here
Specifically
I think we need to flip this as the numbers in the map are already negative, which in your case is forward.
This would also explain the 'hold' you were experiencing.
As always with regen test this carefully as it could result in undesired torque request.
I also not your new var 'Regen' has a default value of 100 this might be a bit high.
Need to come up with a nicer way of dealing with rotated installations.
Brake pedal is not considered in regen until motor drops bellow some small value (100?) then we inhibit the inverter and reset everything as we should be almost stopped by this point.
Good to hear you are driving.
For the low power in the different modes you should play with the maps to get the response you want. I would suggest using all 1's in map 3 this will give a straight mapping of pedal position to torque, ie 50% pedal 100nm torque.
To note there is also no torque incrementing in map3
As for the increment setting this something you can play with to get the feel right 20 is a good place to start, use map 3 to get an idea of what no increment is like.
As I say it may not be needed at all in a heavier car.
As for no regen, I took a look at your code, i think the issue may be here
Code: Select all
if (pedal_offset < 0)
{
inverterFunction = 0x03;
regenState = 1;
regenTarget = pedal_offset * 2;
if (brake_pedal == 1 && brakeDelay == 0)
{
brakeDelay = millis();
}
if (brake_pedal == 1 && brakeDelay + 1000 < millis() && regenRequest < -9)
{
digitalWrite(OUT4, HIGH);
brakeDelay = 0;
}
}
Code: Select all
regenTarget = pedal_offset * 2;
This would also explain the 'hold' you were experiencing.
As always with regen test this carefully as it could result in undesired torque request.
I also not your new var 'Regen' has a default value of 100 this might be a bit high.
Need to come up with a nicer way of dealing with rotated installations.
Brake pedal is not considered in regen until motor drops bellow some small value (100?) then we inhibit the inverter and reset everything as we should be almost stopped by this point.
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
There is another issue i noticed.
Whenever i removed power from VCU it wouldnt load EEPROM values! This means that if i reset VCU somehow i may get stuck with throttle way out of calibration. Is there a solution for that maybe?
Or would i need to install EEPROM chip on my teensy board? I dont have eeprom installed now. I thought native flash would serve in stead of eeprom there.
tnx
Whenever i removed power from VCU it wouldnt load EEPROM values! This means that if i reset VCU somehow i may get stuck with throttle way out of calibration. Is there a solution for that maybe?
Or would i need to install EEPROM chip on my teensy board? I dont have eeprom installed now. I thought native flash would serve in stead of eeprom there.
tnx
- aot93
- Posts: 212
- Joined: Mon Feb 15, 2021 5:45 pm
- Location: UK, West Sussex
- Has thanked: 8 times
- Been thanked: 48 times
Re: Outlander VCU - Rear inverter, Charger and BMS
That's odd.. the built in flash is all I've ever used.
Could be a library mis match or something, if I get a chance I'll try building your code here to see if I can replicate.
Could be a library mis match or something, if I get a chance I'll try building your code here to see if I can replicate.
Re: Outlander VCU - Rear inverter, Charger and BMS
chentron wrote: ↑Wed Nov 15, 2023 7:13 pm
I am not programmer but i imagine will write lot of "#" anywhere i see the word BMS in main.cpp file...
I'm not a programmer either, I'm trying to start an electric motor for a boat, it would be great for me to have a simplified control program, without BMS. Please, tell me what is my problem when compiling the project? : https://github.com/aot93/Mini-E-VCU
c:/users/mikhail/.platformio/packages/toolchain-gccarmnoneeabi-teensy/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio\build\teensy41\src\main.cpp.o: in function `_GLOBAL__sub_I__ZN8ADC_util20getConversionEnumStrEN12ADC_settings20ADC_CONVERSION_SPEEDE':
main.cpp:(.text.startup._GLOBAL__sub_I__ZN8ADC_util20getConversionEnumStrEN12ADC_settings20ADC_CONVERSION_SPEEDE+0x176): undefined reference to `FilterOnePole::FilterOnePole(FILTER_TYPE, float, float)'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\teensy41\firmware.elf] Error 1
I am not programmer but i imagine will write lot of "#" anywhere i see the word BMS in main.cpp file...
I'm not a programmer either, I'm trying to start an electric motor for a boat, it would be great for me to have a simplified control program, without BMS. Please, tell me what is my problem when compiling the project? : https://github.com/aot93/Mini-E-VCU
c:/users/mikhail/.platformio/packages/toolchain-gccarmnoneeabi-teensy/bin/../lib/gcc/arm-none-eabi/11.3.1/../../../../arm-none-eabi/bin/ld.exe: .pio\build\teensy41\src\main.cpp.o: in function `_GLOBAL__sub_I__ZN8ADC_util20getConversionEnumStrEN12ADC_settings20ADC_CONVERSION_SPEEDE':
main.cpp:(.text.startup._GLOBAL__sub_I__ZN8ADC_util20getConversionEnumStrEN12ADC_settings20ADC_CONVERSION_SPEEDE+0x176): undefined reference to `FilterOnePole::FilterOnePole(FILTER_TYPE, float, float)'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\teensy41\firmware.elf] Error 1
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
Exactly! I found in code were a lot of int declaration for EEPROM items. I had to change them to uint8_t on smaller values and uint16_t for larger values like tpshighOffset. Now values were holding after reset albeit like 339 instead of 340...
I also raised tpslowOffset value to 1800 as my sensor showed about 1400 at 0 pedal.
When i did that i immediately got better torque response and lo and behold - 30A regen!!!
Now i still need to investigate that behaviour... on each start from 0 the motor would strike back (say 20km/h) and then roll out. I noticed similar behaviour during regenon at low incline. At certain speed a reverse strike would happen and then subside. It is not comfortable and i am worried about driveshafts... Any idea what would cause that reverse strikes?
I am also thinking of using Map3 as default and redo code so as it will work without regen in map1. Regen is quite good and i feel concern it can cause trouble in snow... SPORT switch will be good to select this function...
-
- Posts: 3554
- Joined: Mon Dec 24, 2018 1:37 pm
- Location: Slovenia
- Has thanked: 131 times
- Been thanked: 330 times
- Contact:
Re: Outlander VCU - Rear inverter, Charger and BMS
My iteration of program works without BMS at this time. You can get it here:
https://github.com/arber333/Mini-E-VCU