Page 1 of 2

Overcurrent at high RPMs when regen engages?

Posted: Thu Jan 27, 2022 2:02 pm
by janosch
I think this deserves its own thread so it is easier to find in the future:
1) my first post about this
2) zapatero and johu discussing it
janosch wrote: Mon Jan 24, 2022 3:37 pm ...
We tripped the overcurrent limit at 65mph today when removing foot from the throttle.
Got -180A, thats -64kW of braking @ 356V!
ChaDeMo is -50kW I suppose, so we are vaguely within battery params, but I would like to reign it in regardless.
...
johu wrote: Tue Jan 25, 2022 10:30 pm What rpm are you running at said speed?

I'd reduce regenramp to 0.3 and also choose a slow throtramp. Like 4 or less.
...
I see, I thought I had it start at 3% but it's 5. Of course the comment is wrong, it starts slow ramping below 5 or whatever you put into the preceding if statement.
Ok I just ran the code locally & made a plot to make sure I understand what is going on.

I just compiled 5.17R and we will try it out. I am not sure if changing 5 to 10 will make much difference, as the inflection point is firmly in the throttle region already like this, but we will try it, as well as regenRamp=0.1 instead of 0.3, which I have higher hopes for.

I now wonder how OEMs initiate regen smoothly at high speeds! A delicate operation.

Re: Overcurrent at high RPMs when regen engages?

Posted: Thu Jan 27, 2022 4:52 pm
by johu
Maybe worthwhile posting my plot of the event here:
Image

and the text
johu wrote: Thu Jan 06, 2022 5:39 pm During the test drive I had completely disabled regen, so it's pure "phantom" braking. At least the plot now shows what I expected: excessive negative q-current of -550A (0A is control target!). The FW controller tried to counteract by commanding -280A field weakening current on top of the MTPA current. Indeed id reaches -400A but apparently that is not helpful. Remembering that mystery post that was deleted after a few hours, too much id might actually no longer result in field weakening.

fwkp was at -300.

The idea is: if I slowly come off throttle all is good. That's what I want to mimic.

Re: Overcurrent at high RPMs when regen engages?

Posted: Tue Feb 15, 2022 11:50 am
by janosch
Problem still occurs with 5.17R-foc and the settings below @ ~65mph

Let me know what changes you want us to try, I can change params & try again, as well as make small code changes.

Re: Overcurrent at high RPMs when regen engages?

Posted: Tue Feb 15, 2022 12:41 pm
by johu
Yes, can you try with regenramp << 1? like 0.3 or 0.1 even. Perhaps also change the start of the slow downramp in throttle.cpp to 10% or so.

Re: Overcurrent at high RPMs when regen engages?

Posted: Sun Mar 06, 2022 11:48 am
by Zapatero
For me it doesn't matter how i set the values, it always occurs. On my EV86 it happens above 7000 RPM. The issue for me is: in 4th gear i don't have to rev so high but the car is rather sluggish, in 3th gear it would be perfect but i keep hitting the range above 7000 RPM all the time on the highway.

Re: Overcurrent at high RPMs when regen engages?

Posted: Sun Mar 06, 2022 10:31 pm
by arber333
johu wrote: Tue Feb 15, 2022 12:41 pm Yes, can you try with regenramp << 1? like 0.3 or 0.1 even. Perhaps also change the start of the slow downramp in throttle.cpp to 10% or so.
Just a repost...
My Lebowski controler has a setting that is called acceleration limiter. This limits acceleration to a band of say 7k - 10k eRPM/s which would account to somewhere at 1000rpm/s for 8 pole motor.

Could there be a function to limit acceleration/deceleration to some humane value above 7000rpm? Maybe that would solve that issue.

Re: Overcurrent at high RPMs when regen engages?

Posted: Tue Apr 05, 2022 8:39 am
by janosch
Hello,

this previously happened at 60mph for us, now yesterday it only happened at 80mph, info from the test drive:
RegenRamp at 0.1%

managed to get to stall around 80mph once, couldn't seem to recreate, but not sure I got up to 80mph again. The plot attached is trying to get it to stall, but not the actual stall.

It's not great to drive when regen ramp is this low, eg. press the brake and nothing happens for a couple seconds, then it kicks in. I think I will try again tomorrow but with 0.3% regenramp. I suspect it will be slightly easier to stall it with that.

I also want to get a plot of when the throttle vibrates at low throttle position, from just a glimpse it looked like a few weird things were going on with the plot.
This is with 5.17 & the throttle.cpp:132 modification:

Code: Select all

 else if (potnom < throttleRamped && throttleRamped > 10)
(stalling = ocurlim hit)

Re: Overcurrent at high RPMs when regen engages?

Posted: Tue Apr 05, 2022 8:57 am
by johu
I'm thinking this throttle.cpp modification does not help since Zapatero reported that even coming off throttle slowly can trigger the error. So you can revert this back to 3 or 5% for better drivability.

What does it do for you when you increase curkp to 50?

Re: Overcurrent at high RPMs when regen engages?

Posted: Tue Apr 05, 2022 11:00 am
by johu
Went out for another test drive with alternative FW controller, source code here:
https://github.com/jsphuebner/stm32-sin ... fw-control

It can do weird stuff when badly configured, so be careful. Make sure to apply attached parameters as a base, some parameters were added, fwkp has changed signs!
My new testing strategy is to dial down throtcur (3) and ocurlim (500) so when things go wrong it's not as harsh.

So I could accelerate happily into the rev limiter (7500 rpm) but as soon as I came of throttle, same old old I'd think: id shoots up from -100A to almost -500A, PI controller tries to counteract by pulling ud to full positive and that's it, over current. Maybe with higher ocurlim it would have resulted in uncontrolled regen, I don't know. It seems to happen at the moment that iq crosses 0. Why oh why?

Re: Overcurrent at high RPMs when regen engages?

Posted: Tue Apr 05, 2022 12:50 pm
by johu
Reading, reading: https://mdpi-res.com/d_attachment/energ ... -04526.pdf

Indeed ud = −ωe x Lq x iq

-> sign change of iq means sign change of ud

Re: Overcurrent at high RPMs when regen engages?

Posted: Tue Apr 05, 2022 5:28 pm
by johu
And progress!
https://github.com/jsphuebner/stm32-sin ... fw-control
Not perfect, but getting there. As a consequence of the above finding I now preload the d-current integrator with its negative value when direction of torque changes. This means it no longer takes perhaps many 100 cycles to integrate from +35000 to -35000 but it is sent to -35000 instantly. It is much smoother now in the upper rev range but regen is still stronger than requested. May be a matter of tuning now.

While coasting to a stop on a downhill at about 6500 rpm with the inverter OFF I could see about 20 kW going into the battery. So that's the pure back-EMF that is "passively" generated. I don't think the software really "sees" this current yet, maybe syncadv is wrong and it is not correctly showing up on iq.

Anyway, please test this one starting with the attached parameters (and you custom throtcur and ocurlim of course)

Re: Overcurrent at high RPMs when regen engages?

Posted: Wed Apr 06, 2022 11:58 am
by janosch
Very nice, thank you! We will give that a whirl in a few days.

Re: Overcurrent at high RPMs when regen engages?

Posted: Mon Apr 11, 2022 2:38 pm
by Zapatero
i just tested this and unfortunately for me it did not work. Only when i use your settings then it does work. But the power is less than what i had before. Everytime i set syncadv to 14 or more it will block the wheels and the inverter turns off. That's such a shame, as exactly syncadv obviousely is the setting that would make it powerful. Also if i turn up fwkp to 200 / 300 the car would drive better, but then the overcurrent problem is there, too.

So for me this didn't make anything better

Re: Overcurrent at high RPMs when regen engages?

Posted: Mon Apr 11, 2022 3:04 pm
by EV_Builder
Zapatero wrote: Mon Apr 11, 2022 2:38 pm i just tested this and unfortunately for me it did not work. Only when i use your settings then it does work. But the power is less than what i had before. Everytime i set syncadv to 14 or more it will block the wheels and the inverter turns off. That's such a shame, as exactly syncadv obviousely is the setting that would make it powerful. Also if i turn up fwkp to 200 / 300 the car would drive better, but then the overcurrent problem is there, too.

So for me this didn't make anything better
How high is the setting? You have a graph of more parameters?incl. Voltage?

Re: Overcurrent at high RPMs when regen engages?

Posted: Mon Apr 11, 2022 3:19 pm
by johu
Too bad. Thing with syncadv is it is not meant to make more power but to keep track of id/iq and any rpm. By increasing it more id is generated "by accident" which might make the motor more powerful but also makes unwanted regen stronger.
Apparently the MTPA constants in software don't match the Leaf motor, thats why unmatching syncadv gives more power. Does the problem get less pronounced with syncadv turned back?

Re: Overcurrent at high RPMs when regen engages?

Posted: Mon Apr 11, 2022 5:43 pm
by EV_Builder
johu wrote: Mon Apr 11, 2022 3:19 pm Too bad. Thing with syncadv is it is not meant to make more power but to keep track of id/iq and any rpm. By increasing it more id is generated "by accident" which might make the motor more powerful but also makes unwanted regen stronger.
Apparently the MTPA constants in software don't match the Leaf motor, thats why unmatching syncadv gives more power. Does the problem get less pronounced with syncadv turned back?
Basically we want to see a graph of actual current vs current commanded? If we tune that parameter to perfecti it's swing and delta is small?

Re: Overcurrent at high RPMs when regen engages?

Posted: Wed Apr 13, 2022 6:44 am
by johu
EV_Builder wrote: Mon Apr 11, 2022 5:43 pm Basically we want to see a graph of actual current vs current commanded? If we tune that parameter to perfecti it's swing and delta is small?
Not quite, basically I think the Clarke-transformation delivers incorrect iq/id in the first place because it works with the wrong rotor angle. With well-tuned syncofs it delivers correct values at standstill. Then as rpm increases, the angle becomes “outdated“ because it had been measured a few 10 us before. Then iq/id split is off, not sure in which direction though.
Syncadv compensates for this lag but if set too high it can over-compensate

By my calculations it should be around 8

I'm away for a few days, so may not reply until Friday

Re: Overcurrent at high RPMs when regen engages?

Posted: Wed Apr 13, 2022 11:01 am
by EV_Builder
Ahh ok gotcha

Re: Overcurrent at high RPMs when regen engages?

Posted: Sat Apr 16, 2022 4:49 pm
by LeonB
johu wrote: Mon Apr 11, 2022 3:19 pm Apparently the MTPA constants in software don't match the Leaf motor, thats why unmatching syncadv gives more power.
I am currently experiencing the same effect with my Prius Gen3 motor, whereas power increases when increasing syncadv. Albeit unwanted regen decreases at the same time, but at >6000rpm the car starts to accelerate on its own.
Are fluxlinkage and lqminusld the only constants that need to be changed or are there other motor-specific constants? I have already found some sources online that note different values for the prius compared to the firmware (fluxlinkage=0.124Wb (firmware: 0.09) and lqminusld≈0.0008H (firmware: 0.0058)).

Re: Overcurrent at high RPMs when regen engages?

Posted: Sat Apr 16, 2022 5:05 pm
by johu
Oh that sounds exciting as well. Will test myself once the drive shafts for the Audi arrive. And will do more testing in Touran when it is not needed.
Yes those are the only constants that need to be changed.

Re: Overcurrent at high RPMs when regen engages?

Posted: Tue Aug 09, 2022 2:34 pm
by johu
So I have almost watched the entire series of Dave Wilsons "Teaching old motors new tricks" on youtube. It confirms that many things are done right in the openinverter firmware and some are not:
  1. P and I controller gains are sort of randomly tuned, transient response could be better by tuning them depending on real motor resistance and inductance
  2. Since IPM motors have different q and d axis inductances the two controllers would also end up with different gains
  3. There is no d/q decoupling term, so if the q-current is changed this will have a transient, unwanted effect on the d-current and vice versa
  4. il1, il2, resolver_sin and cos are not sampled simultaneously. That is of course a hardware limit as we only have one ADC
He also stressed again the danger of using field weakening. As soon as your field collapses the motor will just produce the voltage it naturally produces and that creates a current only limited by motor resistance, cable resistance, internal battery resistance and finally the pack fuse. So whenever testing high rpm it is advised to take it slowly. If 6000 rpm is base speed then take it to 7000 rpm (noting that "base speed" drops as your battery voltage decreases). Only if you're super comfortable, take it to 7500 rpm or so. Don't go to 10000 rpm straight away!

The field weakening approach he introduces is pretty much identical to my last "alternative" field weakening branch where field weakening current depends on the remaining q-axis amplitude.

I think #4 is the most pressing issue as the other 3 "only" effect transient responses which are pretty much in check with all the ramping. I still have hopes that with the correct value of syncadv the ill effects of not sampling those quantities simultaneously can be compensated. So that's what the focus should be on.
So what we want to find is a value for syncadv so that commanding any magnitude of d-current, at any speed, will not generate ANY torque.

I wouldn't advise testing this on an idle motor as there is no natural speed limit when doing field weakening.

The most obvious and most dangerous way to find out is sitting in your car, put the inverter in manual mode, command some q-current to get moving, then when at speed at negative d-current and take away q-current. You should feel the car coasting down, not regenning and not drawing any significant current from the battery.

A better approach would be a small test stand with another motor that simulates the vehicle on the road, but whos got time to build that? A Prius transaxle with dual controller would be a neat way though.

Finally one could try simulating but I certainly don't have the knowledge to do that. Anyone?

Re: Overcurrent at high RPMs when regen engages?

Posted: Tue Aug 09, 2022 3:27 pm
by Ev8
So at high revs lifting off the throttle and getting unwanted regen is too little syncadv, I currently am running 14 and still get some unwanted regen I tried upto 15 once and was convinced it wasn’t slowing down after lifting off but I’ll have to try it again and see if it was actually just coasting…

Re: Overcurrent at high RPMs when regen engages?

Posted: Tue Aug 09, 2022 3:42 pm
by EV_Builder
Another thing which came to my mind is that many times freq drives aren't outputting a nice sin wave. But it's like square waves. Now my question is albeit from a tech view it might feel that a bad job is done I was wondering if it would reduce power consumption or have other advantages? If the devices would be perfect sinus generators they could be used to generate a 3phs network at home but in practice because they aren't you can't. Hence my question.

Re: Overcurrent at high RPMs when regen engages?

Posted: Wed Aug 10, 2022 1:35 am
by johu
Ev8 wrote: Tue Aug 09, 2022 3:27 pm So at high revs lifting off the throttle and getting unwanted regen is too little syncadv, I currently am running 14 and still get some unwanted regen I tried upto 15 once and was convinced it wasn’t slowing down after lifting off but I’ll have to try it again and see if it was actually just coasting…
Yes I'm not expecting syncadv to make the problem go away just now. It is only a prerequisite to do meaningful field weakening.

Re: Overcurrent at high RPMs when regen engages?

Posted: Thu Aug 11, 2022 8:20 pm
by johu
Just took a bit of a history lesson. In my first road trip video when I test top speed I come off the throttle at 7200 rpm (regen disabled) in order to change to 5 th gear. Everything goes smooth! Hmm.


So one change a while ago was taking 8 samples of the two phase current instead of 3 and also I upped sample time from 1.5 to 7.5 clocks. Goal was to make vibration go away. It means current values were about 14us old on that version but are 53 us old on the newer versions. Or are they? I mean it is the average of the 8 last samples. How "old" is that?

Besides that syncadv is calculated with a heavily filtered frequency also to help smoothness.

Have these smoothness mods affected high speed performance?

If anyone wants to volunteer testing, here is a version with these two smoothness mods undone.