Page 1 of 2

Inverter Firmware v5.05.R

Posted: Sun May 09, 2021 5:48 pm
by johu
There is a new and strongly recommended release of the inverter FOC firmware. It fixes an issue with the PI controllers that could cause the car to switch to uncontrolled strong regen when deep in the field weakening range and coming off the accelerator. It will be tested more, but basically there was a large scaling error in the anti-windup code that would cause to not really work. So the controller did wind up and failed to react appropriately to setpoint changes. There are also more fixes:
  • Fixed anti-windup issue, this could cause very strong unwanted regen in the upper speed range - SAFETY CRITICAL!
  • Improved idc filtering for smoother DC current limiting
  • add a parameter 'sincosofs' - this is the midpoint reading of a sin/cos encoder output, removing the requirement for a precise 1.65V midpoint and resistor divider if using, for example, a sin/cos chip that doesn't work on 3.3V VCC (MLX91204 requires 5V)
  • Obey DC voltage limit in boost mode
  • Disallowed saving parameters in run mode
  • Added support for BMW i3 gate driver board SPI ADC
  • Changed ADC sample time to 7.5 clocks
  • Taking 8 samples from last PWM period instead of 3
  • Rotor movement compensation becomes active above 10 Hz
  • Auto-detect flash size and write parameters to according address
I will release only the FOC software at this point because the sine-software is not tested on a vehicle. It is attached for testing volunteers.
The release is here: https://github.com/jsphuebner/stm32-sin ... ag/v5.05.R

EDIT: the first bullet point affects FOC only
EDIT2: uncontrolled high rpm regen still not fixed, be careful.

Re: Inverter Firmware v5.05.R

Posted: Sun May 09, 2021 6:07 pm
by arber333
johu wrote: Sun May 09, 2021 5:48 pm I will release only the FOC software at this point because the sine-software is not tested on a vehicle. It is attached for testing volunteers.
So what exactly does the sine version improve?
I will try it, but i would like to know what to observe.

tnx

Re: Inverter Firmware v5.05.R

Posted: Sun May 09, 2021 7:49 pm
by Boxster EV
Disallowing saving params in run mode is a good shout. That caught me out once when increasing RPM idle setting whilst outside the car (accidently left car in D). I've never moved so fast in my life. :-)

Also, will you keep the fweak calculation mod that Jon Volk introduced to v4.97r?

Re: Inverter Firmware v5.05.R

Posted: Sun May 09, 2021 9:25 pm
by johu
@arber: The changes don't affect the core control of sine firmware. You'd just need to make a regression test.
@boxter: the Jon Volk mod is not yet in there. I was gonna include it but resolving the FOC windup issue made me release it ASAP

Re: Inverter Firmware v5.05.R

Posted: Mon May 10, 2021 6:04 pm
by bexander
Excellent!
Maybe put this thread under "Announcements"?

Re: Inverter Firmware v5.05.R

Posted: Mon May 10, 2021 10:25 pm
by johu
Oh, yes just did :)

Tested a bit more today and still hit over current when coming off throttle at 7500 rpm. It could be my parameters: throtcur 5.5A, ocurlim=900A. This means theoretically up to 550A + 225A (throtcur*100/2) field weakening can be commanded. That is 1160A peak!
At least the horrible unwanted regen has not occurred again.

Re: Inverter Firmware v5.05.R

Posted: Tue May 11, 2021 12:31 pm
by johu
I tested more today. The only way to mitigate the problem is to completely turn off regen when coming off throttle. The way I have it set up in my VCU is 4 regen levels, where level 1 completely disables off-throttle regen but brings in regen proportional to brake pedal pressure. So now I can quickly release throttle at 7500 rpm and then step on the brake to bring in regen.

So a quick work around would be a little wait time where torque is commanded=0 and then regen is ramped up. Only above a certain motor speed or field weakening current.

Re: Inverter Firmware v5.05.R

Posted: Wed May 12, 2021 1:03 am
by ZooKeeper
johu wrote: Tue May 11, 2021 12:31 pm .... The only way to mitigate the problem is to completely turn off regen when coming off throttle. The way I have it set up in my VCU is 4 regen levels, where level 1 completely disables off-throttle regen but brings in regen proportional to brake pedal pressure. So now I can quickly release throttle at 7500 rpm and then step on the brake to bring in regen.
Optimal! Coasting "saves" more energy than regen can recoup, BUT it takes discipline ;)

Re: Inverter Firmware v5.05.R

Posted: Wed May 12, 2021 7:39 am
by Hans Gustafsson
johu wrote: Tue May 11, 2021 12:31 pm I tested more today. The only way to mitigate the problem is to completely turn off regen when coming off throttle. The way I have it set up in my VCU is 4 regen levels, where level 1 completely disables off-throttle regen but brings in regen proportional to brake pedal pressure. So now I can quickly release throttle at 7500 rpm and then step on the brake to bring in regen.

So a quick work around would be a little wait time where torque is commanded=0 and then regen is ramped up. Only above a certain motor speed or field weakening current.
As an old chassis engineer, it's the right way to go, even from road safety. For best tire grip in a turn, the wheels should be as free-rolling as possible. This is very important on winter roads, but can be a problem on gravel and aspalt as well, if you drive hard. A mechanical freewheel or clutch would have been prefered , but an electric freewheel may be good enough. I have a BMW engine in my prodjekt and it has pretty good "freewheeling properties" to be a permanent magnet motor and no coincidence BMW engineers got it that way.

Re: Inverter Firmware v5.05.R

Posted: Wed May 12, 2021 9:51 am
by johu
Well I like both, in city driving or on hilly roads I enjoy strong regen. So I ultimately want it to be fully usable.
I tested the field weakening controller today. At around 5500 rpm and full throttle it starts to command a current. With light throttle at 7000 rpm it commands no current. So I'm thinking to turn off regen while field weakening current is still above a certain threshold. So when you come off throttle it will taper off and then regen can come back in.
Still gives you the liberty to turn it off.

Re: Inverter Firmware v5.05.R

Posted: Thu May 13, 2021 5:36 am
by johu
Bad news: the problem with uncontrolled regen at high rpm can still occur :(
Was coasting down a steep decline at 130 km/h (7000 rpm) when a 100 limit came up. Regen was off, so I switched it back on. First nothing happened, then a huge jolt of regen, then, fortunately, overcurrent.

Re: Inverter Firmware v5.05.R

Posted: Thu May 13, 2021 6:30 am
by arber333
johu wrote: Thu May 13, 2021 5:36 am Bad news: the problem with uncontrolled regen at high rpm can still occur :(
Was coasting down a steep decline at 130 km/h (7000 rpm) when a 100 limit came up. Regen was off, so I switched it back on. First nothing happened, then a huge jolt of regen, then, fortunately, overcurrent.
Hm... can you use another "observer" in your code to monitor for each regen command and insert filter to ramp it up slowly or remove it alltogether?

Or is this regen only appearance and in truth you receive 100% current flow back throough reverse diodes? In that case you have sync issues not really regen. I think maybe it would be good to put an observer in the code that would tell you what kind of regen issue this is in the first place. That would not be meant for the regular code but rather for your experimenting. When you work it out you comment that observer out.

Re: Inverter Firmware v5.05.R

Posted: Thu May 13, 2021 1:16 pm
by johu
Yes still in the diagnosis stage on this one. Thought I had it nailed with that windup issue, but no. It seems to happen on prolonged downhills where regen in field weakening is sustained for longer time.

Could use a dyno, would make testing less scary.

Re: Inverter Firmware v5.05.R

Posted: Fri May 14, 2021 1:25 pm
by Boxster EV
Hans Gustafsson wrote: Wed May 12, 2021 7:39 am
johu wrote: Tue May 11, 2021 12:31 pm I tested more today. The only way to mitigate the problem is to completely turn off regen when coming off throttle. The way I have it set up in my VCU is 4 regen levels, where level 1 completely disables off-throttle regen but brings in regen proportional to brake pedal pressure. So now I can quickly release throttle at 7500 rpm and then step on the brake to bring in regen.

So a quick work around would be a little wait time where torque is commanded=0 and then regen is ramped up. Only above a certain motor speed or field weakening current.
As an old chassis engineer, it's the right way to go, even from road safety. For best tire grip in a turn, the wheels should be as free-rolling as possible. This is very important on winter roads, but can be a problem on gravel and aspalt as well, if you drive hard. A mechanical freewheel or clutch would have been prefered , but an electric freewheel may be good enough. I have a BMW engine in my prodjekt and it has pretty good "freewheeling properties" to be a permanent magnet motor and no coincidence BMW engineers got it that way.
I agree with your sentiment and drove with just brake induced regen for 6 months. However, traffic here is so heavy again (as pandemic subsides), driving with one pedal makes for a better experience.

Of course free wheeling is a far nicer driving experience if the roads are quiet.

Re: Inverter Firmware v5.05.R

Posted: Sun May 16, 2021 9:43 am
by johu
Did some testing today but could not provoke unintended regen or overcurrent shutdown. Probably because the battery is fully charged and not as much field weakening is needed. Still some interesting results:
ifw.png
Starting at around sample 37 you can see I'm coasting (downhill) at 7200 rpm. The field weakening (FW) controller commands about -50A as to not produce negative torque. Strangely though I could see about 4 kW going into the battery and also felt a braking force.
Now around sample 50 I step on the brake which commands 15% regen through the pressure sensor. Now I would expect the FW controller to stop commanding current because I WANT negative torque. But it actually commands like -250A FW current! I think that is a problem.

So I'm seeing two issues: FW controller not working as intended in high speed regen scenario and probably misalignment of actual rotor position and calculated rotor position. The latter can be attributed to bad tuning of syncadv, i.e. the factor that compensates the rotor movement between measuring and processing the position.

I will temporarily make syncadv a parameter again and go over the maths of the FW controller.

Re: Inverter Firmware v5.05.R

Posted: Sun May 16, 2021 1:36 pm
by johu
Had some success by limiting the maximum output of the d-current controller to (max-2000)/2. In normal operation it outputs a negative or slightly positive value but whenever I ran into an over current it was stuck at max-2000. This severely limits the output range of the q-controller which outputs a high positive value when regenning at high speed. I never ran into unwanted regen again.
I still ran into an over current issue when transitioning quickly from uphill full throttle at max rpm to uphill regen. Now in this case the q-controller was stuck at the negative-most value while in forward motion it never usually outputs negative values. In reverse it outputs only negative values.
Now I could also limit its output to negative only in reverse and positive only in forward. I think that would cure the over current events, even though it's a bit of a symptomatic fix.
I would rather like to know WHY it outputs negative. Maybe the integral gain is too much at 20000?

Also it seems operation is more stable with high values for fwkp, had set it to -150 and that alone cured many over current events without limiting controller output.

Re: Inverter Firmware v5.05.R

Posted: Sun May 16, 2021 2:17 pm
by johu
Ok, best test run yet.
I have limited q-controller output as described. That led to like 1s of unwanted strong regen. So I lowered curki=10000 and everything is smooth now. Can transition quickly between regen and accel both uphill and downhill.
I also think low speed stuttering is less pronounced.

Please try it and remember to lower curki.

Re: Inverter Firmware v5.05.R

Posted: Wed Jun 16, 2021 12:56 pm
by UStas
Yesterday uploaded to my Prius Gen3 inverter v5.06.R FOC firmware. Without any configuration became much better, on my Outlander rear transaxle.
But stiil some regen, not so thereble. As soon I can, I will play with options.

Re: Inverter Firmware v5.05.R

Posted: Wed Jun 16, 2021 7:37 pm
by Zapatero
I tried the firmware and my low speed stuttering is still pretty bad. In fact it's so strong i would be very happy to get rid of it! Any suggestions?

Re: Inverter Firmware v5.05.R

Posted: Wed Jun 16, 2021 9:23 pm
by johu
Version 5.06.R? Did you lower curki?
Just for testing, how is it with fwkp=0?

Re: Inverter Firmware v5.05.R

Posted: Tue Jun 22, 2021 4:11 pm
by UStas
I`ve tested with curki=10000 on outlander rear transaxle - it`s perfect. Up to 100 km/h no any shock. We have only soft regen.

Re: Inverter Firmware v5.05.R

Posted: Tue Jun 22, 2021 4:16 pm
by UStas
Zapatero wrote: Wed Jun 16, 2021 7:37 pm I tried the firmware and my low speed stuttering is still pretty bad. In fact it's so strong i would be very happy to get rid of it! Any suggestions?
Check thermal settings and inverter temperature it may be because derating accured.
Or Current exceeded.

Re: Inverter Firmware v5.05.R

Posted: Sun Jun 27, 2021 9:25 am
by speedy_gonzalez
.

Re: Inverter Firmware v5.05.R

Posted: Sun Jun 27, 2021 1:03 pm
by johu
That's an interesting one. Would that apply to all IPM motors?

Re: Inverter Firmware v5.05.R

Posted: Sun Jun 27, 2021 2:26 pm
by bexander
Interesting indeed.
Measuring the characteristic current as described seem like a real hassle. If the permanent magnet flux is the same as flux linkage it might be easier to measure this and Ld and calculate the value of the characteristic current. Might also be possible to set a value and then test and adjust.
I think this is similar to the "fancy equations" found here https://se.mathworks.com/help/mcb/ref/m ... rence.html for the Interior PMSM?