Halved current during field weakening

User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

Results from test.
Currents on left axis, voltages on right axis
Currents on left axis, voltages on right axis
Id, Iq, Ifw left, idc right
Id, Iq, Ifw left, idc right
No really difference. Ifw seem to not autozoom the plot axis so hard to see what its doing exactly.
johu wrote: Fri Jun 18, 2021 11:28 am
bexander wrote: Fri Jun 18, 2021 9:36 am I'm I missunderstanding, but if you calculate Id and Iq from MTPA and then if Iq isn't reached it adds further to Id, without decreasing Iq? That would result in the square sum of Iq and Id are larger than square of Is. If so it makes sens that the Id bottoms out, or runs out of voltage if you will.
Yes and no. Id request always has priority over iq request. So if we run out of voltage iq will be reduced first. That said there are probably better ways to do field weakening just not quite as universal.
Looks like Id somehow runs out first in the plot.

Also, a quick look what going on at low speed.
Id, Iq, Ifw left, idc, fstat right, fwkp = -100
Id, Iq, Ifw left, idc, fstat right, fwkp = -100
Id, Iq, Ifw left, idc, fstat right, fwkp = 0
Id, Iq, Ifw left, idc, fstat right, fwkp = 0
Ifw definitely seem to interfere at low speeds? The inverter should not be out of voltage at this point?
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

Found this paper on how to measure motor parameters.
Measure Ld and Lq.pdf
(2.25 MiB) Downloaded 151 times
Doesn't seem impossible to measure but I will at least need to sort out a current probe.
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

What does this line of code equal to?

Code: Select all

static const int32_t modMax = FP_DIV(FP_FROMINT(2U), sqrt3);
2(unsigned) / square root of 3 = 1.15 and when put into an int it becomes 1? Makes no sens in the rest of the program so I'm clearly missing something.
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

Looking at today test, it is a bit odd that Ud hits its limit some time before Id colapses. If the voltage limit causes this, shouldn't Id colapse at the same instance as Ud max is reached?
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Halved current during field weakening

Post by celeron55 »

bexander wrote: Sat Jun 19, 2021 4:43 am No really difference. Ifw seem to not autozoom the plot axis so hard to see what its doing exactly.
Are you sure it isn't limited to -100A? It will be limited to -50% of the throtcur value. Do you have throtcur set to 200A? In that case throtcur has to be increased or this code modified to allow more FW:

Code: Select all

   fwController.SetMinMaxY(-50 * Param::Get(Param::throtcur), 0); //allow 50% of max current for extra field weakening
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

bexander wrote: Sat Jun 19, 2021 6:32 pm What does this line of code equal to?

Code: Select all

static const int32_t modMax = FP_DIV(FP_FROMINT(2U), sqrt3);
2(unsigned) / square root of 3 = 1.15 and when put into an int it becomes 1? Makes no sens in the rest of the program so I'm clearly missing something.
Spelled out this would be ((2U << 15) << 15) / (sqrt(3) * 1 << 15) = 37837
<<15 because CST_DIGITS is defined as 15 before including my_fp.h
This is the extra amplitude gained through space vector modulation (+15%)
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

celeron55: Yes, I agree, ifw is limited so never goes below -100.

johu: Ok, that makes sens with the rest of the sw.

Regarding this plot from yesterday.
Currents on left axis, voltages on right axis
Currents on left axis, voltages on right axis
When looking closely one can see that Ud reaches its limit before the Id colapses. On other plots in this thread also the opposite appears, Ud reaches its limit after Id colapses. However, Uq always rises the exact moment Id colapses, which I think is a bit strange.
Another question is why there are no step in Iq, but still a step in Uq. To my understanding, Uq is calculated from Iq, so this does not add up.
Changing the syncadv factor increased torque and power delivery but still shows the same behavior regarding Id colapsing and a large step in Uq.
This really is strange to me.

Would be very interesting to see similar plots from other motor/inverter combinations to find out if this only happends to the MGR or to other motors as well. The MGR does not have very much power so might be why it becomes very noticable for this motor.

Just for the fun of it I made some crude measured of the motor parameters as per previously posted document. I used a 50A current transducer and put my low resolution scope probe directly on it. Would proably be better if I used a amplifier in between.
Anyway, the results:
Winding resistance for one leg: 75mohm
Ld = 2,15mH
Lq = 6,33mH
Flux linkage = 0,108 Weber
This results in LqminusLq = 4,18mH
Looking at the Id/Iq distribution from these and it is almost identical as with the parameters used by the SW so thats great.

The Id/Iq distribution seem to be correct and not really have anything to do with the Id colapse.

Will keep looking for more clues to this, any pointer much appreciated.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Just did a log, couldn't go full throttle as the data logger would be too slow, but still.
It's acceleration from 0-7500 rpm and regen back down. ud also maxes out, so most of the ifw command will have no effect. But certainly id can be maintained and doesn't collapse like in your log
Attachments
Screenshot_2021-06-20-21-28-26.png
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

johu: Thank you! Very good to have something "normal" to compare to.

Looks like setting fwkp to 0 should be ok for testing as both in mine and johu plots it seem to be acting to late, when Ud already is maxed out. Just to exclude things.
The more I think about it the stranger it is that Uq makes a step to hit its limit. The only input to the qController is the Iq and I can't see any step in Iq. The gains are the same for both dController and qController.
One idea is to test with decreased curkifrqgain, to see if that changes anything.
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Halved current during field weakening

Post by celeron55 »

I think we should ask the question: What exactly does the field look like to the MGR before and after the tipping point with syncadv=20, compared to syncadv=10?

The motor is spinning at about 2300rpm and has 4 pole pairs. That's frq=153Hz.

This normally gives us syncadv = (frq - 20) * 10 = 1330.

In "syncadv=20" case it gives us syncadv = (frq - 20) * 20 = 2660, which is 1330 more than usual. The unit here is angles from 0...65535, meaning this is 7.3 degrees advanced. That's the only change this hack does, so it's very useful. (giving you guys aren't willing to mess with the MTPA values... yet)

Looking from bexander's 2021-06-19 graph, we can see before the collapse we have roughly the values:
idc=40
id=-50
iq=70
ifw=-10
ud=-35000
uq=3000

After collapse:
idc=15
id=-10
iq=60
ifw=-50
ud=-35000
uq=13000

This roughly matches with some of the previous graphs. However, the inverter might not be outputting the same field (in its viewpoint) when configured with syncadv=20, thus we'll look at bexander's 2021-06-12 graph. Before collapse:
idc=45
id=-60
iq=80
ud=-35000
uq=3000

After collapse:
idc=30
id=-30
iq=65
ud=-35000
uq=13000

We can see the "before collapse" values are basically the same so it doesn't matter which ones we use for this calculation.

Now, the motor is seeing this advanced by 7.5 degrees.

The current vector (id=-60, iq=80) has an angle of 126.9 degrees.

Advancing it by 7.5 degrees we get 134.4 degrees, which is vector (id=-70, iq=71). That's what the motor sees before the collapsing current in the syncadv=20 case.

The before-collapse field looking the same to the inverter with or without syncadv modification means we already calculated the field angle for syncadv=10: it's vector (id=-60, iq=80) or 126.9 degrees. Taken from the 2021-06-19 graph it's 126 degrees (id=-50, iq=70).

By this calculation we can see the motor performs better (current collapses less) with an id=iq split compared to a split with about id=71%*iq.

Can we just get testing going with the crazy MTPA values? Based on this I'm 100% sure they'll give more performance. For some reason that I don't understand it seems the motor wants more Id before it's actually needed, otherwise it's game over when the need actually comes. This is how it behaves, just cater to it.
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Halved current during field weakening

Post by celeron55 »

I think the reason for this actually is that this motor has to go so extremely far into the FW region at these voltages that it's not yet been done with openinverter. This is from another world compared to johu's Leaf graph for example. Maybe this is more like a permanent magnet assisted synchronous reluctance motor or something equally crazy? You need to build up the field weakening in advance in order to kill the back EMF eating up your room to create more field weakening. Once back EMF kills your field weakening, you're done, you're pulled completely back from FW, thus the halving of idc. If you maintain enough field weakening to keep the back EMF down, you should be able to keep going higher. Of course limited by how the magnets and steel in the rotor were designed. But we'll find out...

You can actually see in bexander's graphs that id starts dropping way before the collapse. Once it starts happening, Openinverter behaves completely wrongly: It lets RPM increase while maintaining the id:iq ratio. Shortly afterwards iq starts dropping. This happens because back EMF increases with RPM and id isn't increased to counter it - there's no room in the remaining voltage ((remaining voltage) = (battery voltage) - (back EMF))) to generate current anymore. That's the last chance to start shifting current from iq into id, to maintain lower back EMF. Soon after this id drops out - it looks like a collapse because literally FW collapses - once id isn't enough to maintain low enough back EMF, back EMF starts eating the voltage, and that makes it impossible to generate enough id. It's like you're fighting a bear and you're using the bear's weight to hold the bear down.

There are many ways to fix this, one of which is to modify the MTPA parameters, but I feel that's not ideal, mostly because it's controlled by throttle and this should mostly be controlled mostly by speed. If this is to be automated, the FW controller has to "wake up" sooner. Currently it wakes up once id has already collapsed, or actually at the exact moment it collapses. The chance to add id to maintain FW is before id collapses, not when or after it collapses.

I think the way to do this would be to know how much id there needs to be at each rpm in order to not collapse the FW, and maintain it at minimum. Maybe it could be configured simply as a linear value as id relative to speed (A/Hz). In this case it would be something like 70A/150Hz = 0.47A/Hz or more. Maybe even disable the id PID controller and simply add this speed-based amount?

Ok so I'd like bexander (or someone else with a running car with the Q211 MGR) to try this:

Code: Select all

diff --git a/src/pwmgeneration-foc.cpp b/src/pwmgeneration-foc.cpp
index 084365a..ea5eea6 100644
--- a/src/pwmgeneration-foc.cpp
+++ b/src/pwmgeneration-foc.cpp
@@ -69,7 +69,7 @@ void PwmGeneration::Run()
 
       if (opmode == MOD_RUN && initwait == 0)
       {
-         s32fp fwIdRef = idref <= 0 ? fwController.RunProportionalOnly(iq) : 0;
+         s32fp fwIdRef = idref <= 0 ? -FP_MUL(frq, FP_FROMFLT(0.47)) : 0;
          dController.SetRef(idref + fwIdRef);
          Param::SetFlt(Param::ifw, fwIdRef);
       }
That is, replace

Code: Select all

s32fp fwIdRef = idref <= 0 ? fwController.RunProportionalOnly(iq) : 0;
with

Code: Select all

s32fp fwIdRef = idref <= 0 ? - FP_MUL(frq, FP_FROMFLT(0.5)) : 0;
Or if you'd like to leave the controller in you can do this. This might be better actually.

Code: Select all

s32fp fwIdRef = idref <= 0 ? fwController.RunProportionalOnly(iq) -FP_MUL(frq, FP_FROMFLT(0.47)) : 0;
This will cause additional id to be controlled directly based on speed instead of the iq-based controller.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Worth a shot :)
It's the variant without controller
Attachments
stm32_foc.bin
(42.15 KiB) Downloaded 94 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

Ok, will test this when possible.

Is what I should expect a ifw starting from 0 and increase negatively with increased speed as long as id is negative?
I never really understood this line in the original code either...
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

I could not resist so squeezed in a quick test but that got a bit scary... As roads are full of traffic I made a short test in the neighborhood. I think the speed was up to 50km/h when I let go but the inverter gave me more torque, not less or regen so had to brake very hard to decelerate and stop.
Currents left, voltage right
Currents left, voltage right
I think the collapse happend later, at around 45km/h. But it also pulled hard, resulting in some wheelspin. I set throtcur to 1 before I did the test so should be the same as with other tests but iq is a lot higher in this one.

I think if this is going to work one needs to more precise measure the motor parameters.
Calculate base speed with:
image_2021-06-21_175021.png
image_2021-06-21_175021.png (3.27 KiB) Viewed 3908 times
Use MTPA up to base speed and then above base speed voltage and current limited maximum torque control (VCLMT).
image_2021-06-21_175153.png
image_2021-06-21_175153.png (8.39 KiB) Viewed 3908 times
All copied from
https://se.mathworks.com/help/mcb/ref/m ... rence.html

But this will be not at all universal but might work for the MGR. However requires programing and a couple of new parameters. I can not implement this as I lack the skills needed. Would it even be worth the trouble for one specific motor?

EDIT: added my comments to the test after the first graph.
User avatar
ZooKeeper
Posts: 507
Joined: Mon Mar 30, 2020 10:23 pm
Location: USA

Re: Halved current during field weakening

Post by ZooKeeper »

bexander wrote: Mon Jun 21, 2021 3:54 pm But this will be not at all universal but might work for the MGR. However requires programing and a couple of new parameters. I can not implement this as I lack the skills needed. Would it even be worth the trouble for one specific motor?
To induce wheel-spin, I would say YES! 8-)
Huebner VCU controlling a Gen2 Prius Inverter powering an MGR
"Talent is equally distributed but opportunity is not." - Leila Janah
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Interesting :)
So there definitely is more in it. With the regular firmware you should tune syncofs and syncadv. I can make it a parameter again. You need to make sure when only commanding manualid the motor coasts down. I think what we are seeing is misalignment, the controller thinks it is generating id but actually creates a considerable iq along with it.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
celeron55
Posts: 774
Joined: Thu Jul 04, 2019 3:04 pm
Location: Finland
Has thanked: 27 times
Been thanked: 110 times
Contact:

Re: Halved current during field weakening

Post by celeron55 »

Yes I should have mentioned be damn sure syncofs is correct. Otherwise the change definitely gives you auto-throttle, the more the faster you go. I don't know if it otherwise might also, I don't understand the effects of for example some kind of remaining magnetic field in the rotor that effectively would offset the magnets. :twisted:

By the way, it would be nice to have frq or speed in these graphs, whichever has the value to fit some axis best. Maybe frq to the left axis. Altough, in this specific graph we can see the speed directly in ifw.

EDIT: I think the thing to attempt now is to try to go as high as possible using syncadv. At least that way when you release the throttle the motor will always stop making torque. I don't think the fanciest formulas will give that much benefit here, altough graphing them and studuying what parameters they take and what they're doing with them is definitely educational.
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

Regarding syncofs, I have tuned it as best as I can using prescribed method. I do get a deadband, where the motor doesn't rotate and I have set the syncofs to the middle of this deadband. If there is anything else I can do to tune it better, let me know.

I can test advancing syncadv further. Would be very helpful if this is a parameter.
When testing with increased syncadv, should I disable regen completely?

Regarding the fancy equations, there are only Ld and Lq that are new parameters. Lamda pm is FluxLinkage. It is all explaned in the link.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Here you go, syncadv a parameter again and scary FW removed. syncadv still starts hardcoded at 20 Hz.
Attachments
stm32_foc.bin
(42.24 KiB) Downloaded 92 times
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

That's great johu!
Is the calulation still as below but with the factor 10 replaced by the parameter "syncadv". Just so I know what I'm changing.

Code: Select all

int syncadv = (frq - FP_FROMINT(20)) * 10;
Just to summarize what I should test.
Basically keep increasing syncadv until I get FW to fully work without Id collapsing.
Plot in same manner as before but also add fstat to get a speed reference.
Should I disable regen? Should be interesting to see how this behaves as long as I don't get positive torque.

Will test as soon as can when I have time and a decent traffic situation. Should be latest by Saturday morning.
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

I was thinking more along the lines of tuning it similar to syncofs but at speed. Which is challenging.
So syncofs is basically tuned at 0 rpm where syncadv must be tuned at, say, 1000 rpm. You need to find a syncadv that creates no torque at higher speed when commanding iq=0 and id<0.

Maybe jack up the wheels, put the car in gear, spin the motor up with iq, then add id and drop iq to 0. Now tune syncadv until the motor coasts down. When the motor spins up crazy high, hit the brake.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

Aha, ok, this could be interesting.
1000rpm, that is below FW which is desired?
Any idea of how much Id I should add while at speed?
If synofs is correct the motor woun't spin using only Iq, it will need some Id (0,1) as well, right?
So, set the inverter in manual run, command Iq and Id to spin it up to 1000rpm, drop Iq and tune syncadv.
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

Don't know what I'm doing wrong but I can't get any respons from inputing manual Id/Iq.
Works fine in 4.94 SW but not in 5.00 nor in 5.09.
Can it be I use some old web interface or something?

I start with the key, put in gear, throttle and the wheel spins.
Puts the inverter in manualRun via web interface.
Confirms in web interface I have forward direction.
Other parameters seem to work but no respons from manualId och Iq?
User avatar
johu
Site Admin
Posts: 5681
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 959 times
Contact:

Re: Halved current during field weakening

Post by johu »

Hmm, have I broken it? Are you getting anything on ud and uq?
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
bexander
Posts: 834
Joined: Tue Jun 16, 2020 6:00 pm
Location: Gothenburg, Sweden
Has thanked: 63 times
Been thanked: 89 times

Re: Halved current during field weakening

Post by bexander »

Just to be clear, it is not working in 5.00 so nothing induced by the latest change.
When setting any of the two, or both, I get no respons, no sound of PWM and no change in spot values. I have not checked Ud and Uq, do you want me to check them?
I'm thinking I'm doing something wrong as otherwise no one is able to do syncofs tuning with sw from 5.00 on? Nor extra requirements needed to be fulfilled for manual id/iq input to work?

With 4.94 it works directly, I set Id 3 and I get audible conformation as well as change in spot value after a refresh.
Post Reply