Page 14 of 19
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Thu Jan 18, 2024 2:19 pm
by aot93
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.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Thu Jan 18, 2024 5:13 pm
by arber333
aot93 wrote: ↑Thu Jan 18, 2024 2:19 pm
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.
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

. When wheels are in the air i can spin them smoothly and easily. Everything runs now including the speedo functionality. However when i put the wheels on the ground i can move the car by small throttle, any larger throttle movement stops inverter and 0torque. When i drove the car out for test i could slowly get over the step but to get back inside over this step i couldnt get torque to cooperate. Is there any limit as in torque limiter?
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.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Wed Jan 31, 2024 5:01 pm
by arber333
Did anyone use rev limiter code with Outlander inverter/motor VCU code?
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Fri Feb 02, 2024 12:59 pm
by aot93
I limit speed in reverse by setting torque request to 0 when in reverse this works well for me but not exactly smooth.
Code: Select all
if (motorRPM < -2000)
{
torqueRequest = 0;
}
}
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.
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.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Fri Feb 02, 2024 1:33 pm
by marcexec
aot93 wrote: ↑Fri Feb 02, 2024 12:59 pm
accepted norms ( -+200nm)
Is that a hard limit (i.e. the OEM inverter ignores it) or just to stay in spec?
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Fri Feb 02, 2024 7:07 pm
by aot93
I actually don't know, I've not really tried to exceed the published torque.
It's more than I need in my application.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Fri Feb 02, 2024 8:17 pm
by arber333
aot93 wrote: ↑Fri Feb 02, 2024 12:59 pm
I limit speed in reverse by setting torque request to 0 when in reverse this works well for me but not exactly smooth.
CODE: SELECT ALL
if (motorRPM < -2000)
{
torqueRequest = 0;
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

. This makes for opposite RPM reading... when i apply positive torque(fwd) i am actually applying negative torque and resulting rpm. This means all the sensor counting is reversed. I need to go through the code to find those readings...
thank you.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Sat Feb 03, 2024 11:32 am
by midway
My engine is also installed in the opposite direction. Everything works fine. When I changed the direction of rotation, my engine stopped accelerating spontaneously.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Sat Feb 03, 2024 12:12 pm
by aot93
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
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;
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
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Sat Feb 03, 2024 4:23 pm
by arber333
aot93 wrote: ↑Sat Feb 03, 2024 12:12 pm
This should work then inverting the final torque request in inverterComms()
A question there... what would happen if i would set
To a negative value?
Would that give a reasonable regen in case of released pedal up to the very low RPM? Or is this nor used?
How do you set
value? I am using 10Nm, should i reduce it?
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Sat Feb 03, 2024 6:47 pm
by arber333
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
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Sun Feb 04, 2024 3:56 pm
by arber333
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?
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Sun Feb 04, 2024 4:07 pm
by aot93
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.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Sun Feb 04, 2024 4:53 pm
by arber333
aot93 wrote: ↑Sun Feb 04, 2024 4:07 pm
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.
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;
}
} */
Also i cant seem to get any meaningfull regen.
I tried to replace value regenRequest
with Regen variable that i can set via serial and that way hopefully increase regen untill i am satisfied. So far no joy. Can you tell me more about regen logic? How is it triggered and what governs it?
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.");
}
My up to date code is posted on my github...
https://github.com/arber333/Mini-E-VCU
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Sun Feb 04, 2024 8:05 pm
by markc5442
Hi aot93,
I would be most grateful to acquire your latest PCBs if you have any available
Many thanks
MArk
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Tue Feb 06, 2024 1:44 pm
by aot93
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.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Tue Feb 06, 2024 1:52 pm
by aot93
Hi Mark,
I would be most grateful to acquire your latest PCBs if you have any available
drop me a PM with your details, I have VCU boards but no BMS ones..
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Tue Feb 06, 2024 2:14 pm
by arber333
aot93 wrote: ↑Tue Feb 06, 2024 1:44 pm
When it it's well setup i get quite close to one pedal driving.
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.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Thu Feb 08, 2024 6:26 pm
by arber333
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
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Thu Feb 08, 2024 8:28 pm
by aot93
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
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;
}
}
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.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Thu Feb 08, 2024 8:57 pm
by arber333
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
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Thu Feb 08, 2024 11:37 pm
by aot93
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.
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Fri Feb 09, 2024 2:53 pm
by mikkke
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
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Fri Feb 09, 2024 5:31 pm
by arber333
aot93 wrote: ↑Thu Feb 08, 2024 11:37 pm
Could be a library mis match or something
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...
Re: Outlander VCU - Rear inverter, Charger and BMS
Posted: Fri Feb 09, 2024 5:33 pm
by arber333
mikkke wrote: ↑Fri Feb 09, 2024 2:53 pm
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
My iteration of program works without BMS at this time. You can get it here:
https://github.com/arber333/Mini-E-VCU