Halved current during field weakening

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'm playing with the MTPA calculation in LibreOffice and it looks like you can make a 10x adjustment and it only makes a 2x difference in output. So going really wild with these will make sense. Something along the lines of 10x IqminusId or 0.1x fluxLinkage will definitely cause more Id than Iq. But 2x or 0.5x respectively might have no discernable effect.
Attachments
mtpa1.ods
(25.72 KiB) Downloaded 105 times
tscrot-2021-06-13_12-53-55.png
tscrot-2021-06-13_12-51-37.png
tscrot-2021-06-13_12-51-19.png
tscrot-2021-06-13_12-50-55.png
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Halved current during field weakening

Post by johu »

celeron55 wrote: Sun Jun 13, 2021 9:08 am

Code: Select all

static const s32fp lqminusldSquaredBs10 = FP_FROMFLT(0.01722); //additional 10-bit left shift because otherwise it can't be represented
static const s32fp lqminusld = FP_FROMFLT(0.0058);
Why isn't lqminusldSquaredBs10 = lqminusld^2? It seems to be the value of lqminusld^2 / 2, i.e. half the correct value. My calculator is telling me lqminusldSquaredBs10 should be 0.03445, not 0.01722. 10-bit left shift equals multiplying by 1024, right?
Oh, well that's not intended, I think.
celeron55 wrote: Sun Jun 13, 2021 9:59 am I'm playing with the MTPA calculation in LibreOffice and it looks like you can make a 10x adjustment and it only makes a 2x difference in output. So going really wild with these will make sense. Something along the lines of 10x IqminusId or 0.1x fluxLinkage will definitely cause more Id than Iq. But 2x or 0.5x respectively might have no discernable effect.
Yes that's exactly why I didn't make these parameters let alone auto-tuning.
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 »

I'm still stuck at the syncadv calculation.
If the sample/calculation time is always 80us, in my mind that then concludes to syncadv = frq * 5,24; based on that 80us at 400 Hz is 80us/(1/400) * 65536 = 2097 bits and syncadv/frq is 2097/400 = 5,24.
To my understanding, theoretically syncadv should start from 0 rpm and should increas linearly with increased speed.
On thing here is that fstat or frq starts at 2,8 * polePairRatio so there will be a jump from 0 to 5,6Hz in my case.
Does it always take 80us and how was this time measured?

Something seem to be out of sync as changing syncadv clearly have an effect on motor/inverter behaviour.
How hard is it to measure motor parameters? Can it be done or is the only possibility to test random values and see what works best?
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 a thought, this 80us delay, what exactly is using most of the time? ADC, calculations, or output?
Is it possible that before FW this time is 80us and during FW this time increases due to different operations being performed?
Seem unlikely though, that there should be that large difference in these delays so that different syncadv should be required in different regions of operation.
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 »

Syncadv is working fine. What you're seeing is just the ability of wrong syncadv (your edited value) to change the timing towards Id.

It's the wrong way to change the timing though, syncadv is not meant for doing this. If I were you I'd move to editing the IqminusId and fluxLinkage values which are actually meant for adjusting the Id/Iq ratio. See my previous post where I tested how much they have to be changed (a lot) in order for there to be a large enough effect.
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Halved current during field weakening

Post by johu »

bexander wrote: Mon Jun 14, 2021 5:20 am Just a thought, this 80us delay, what exactly is using most of the time? ADC, calculations, or output?
Is it possible that before FW this time is 80us and during FW this time increases due to different operations being performed?
Seem unlikely though, that there should be that large difference in these delays so that different syncadv should be required in different regions of operation.
Basically At cycle n-1 the resolver exciter pin is toggled and 40us later the resolver return is read. Another 113-40us=73us later we use this resolver return for our calculations.


More precisely, the actual delay between toggling the pin and seeing that actual change on the return lines is 113+40us (measured with a scope). That is mainly caused by the low pass filter that converts rectangle to sine. So when the exciter swings positive, we know this is caused by the exciter PIN going negative in cycle n-2. This doesn't affect the "age" of the reading though!
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: Ok, so the total delay is then 153us and that results in the factor of 10 in the syncadv calculation. Great!

celeron55:
Since I'm experiencing some low speed stuttering and this got worse when I increased syncadv I'm interested in fully understanding this.

I do agree that changing syncadv will not solve the FW or id/iq problem. This will most likely require tuning of the parameters you mention.
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 wrote: Mon Jun 14, 2021 6:59 am Basically At cycle n-1 the resolver exciter pin is toggled and 40us later the resolver return is read. Another 113-40us=73us later we use this resolver return for our calculations.


More precisely, the actual delay between toggling the pin and seeing that actual change on the return lines is 113+40us (measured with a scope). That is mainly caused by the low pass filter that converts rectangle to sine. So when the exciter swings positive, we know this is caused by the exciter PIN going negative in cycle n-2. This doesn't affect the "age" of the reading though!
I thought the syncadv where to compensate the whole chain from rotor position measurement to change in winding produced flux, so that the flux change is in sync with the rotor position? Are there other parameters compensating for to later parts of the chain?

Anyway, if one starts to measure time from toggling the resolver exciter signal and most of the delay is due to the propagation time in the square-to-sine filter then I don't think the time will be correct? The delay time should be measured from when the actual position measurement is done.
If from toggling it takes 30us for the signal to get through the filter and then during the last 10us it goes through the exciter coil, sens coil and return signal filter back to the stm32. During the first 30us the motor will turn before its position is measured so the starting time of the delay time should be when the signal meets the resolver hence the time will be 10us and not 40us in this example. Then adding the wait time for the next cycle where calculation starts, 73us.
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 »

So testing something like this might be a good idea.

1) Start with setting lqminusldSquaredBs10 = 0.03445.

2) Test with FluxLinkage = 0.01.

3) FluxLinkade back to stock (0.09) and set lqminusld = 0.02 and lqminusldSquaredBs10 = 0.4096.

Any other ideas?
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 wrote: Sun Jun 13, 2021 9:08 am Why isn't lqminusldSquaredBs10 = lqminusld^2? It seems to be the value of lqminusld^2 / 2, i.e. half the correct value. My calculator is telling me lqminusldSquaredBs10 should be 0.03445, not 0.01722. 10-bit left shift equals multiplying by 1024, right?

Making that change will cause slightly less Id and slightly more Iq, so it obviously isn't a solution to this problem though.
I get different result when I tested in LibreOffice. I get increased Id and decreased Iq, which is what one would want, right?
Stock IdminusIqSquaredBs10 = 0.01722
Stock IdminusIqSquaredBs10 = 0.01722
Corrected IdminusIqSquaredBs10 = 0.03445
Corrected IdminusIqSquaredBs10 = 0.03445
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Halved current during field weakening

Post by johu »

with the "corrected" one it's a bit too much id for my taste. Didn't think this should ever exceed iq.
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 »

You can't argue with the motor. If it wants it, what can you do?

In my opinion this absolutely needs to be tested before people drop the Q211 MGR from their projects as underpowered at reasonable voltages.
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 »

My plan is to test this on Saturday morning.

To me this makes sense as you sacrifice Iq or torque to get speed during FW but tests will tell.
It is a bit strange that it effects the MGR so strongly. I would imagine the Leaf motor or any other motor for that matter to suffer from the same thing.
MattsAwesomeStuff
Posts: 871
Joined: Fri Apr 26, 2019 5:40 pm
Has thanked: 278 times
Been thanked: 165 times

Re: Halved current during field weakening

Post by MattsAwesomeStuff »

Have nothing to contribute other than general cheerleading. You guys are making great progress.
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Halved current during field weakening

Post by johu »

:)
I really need to find out why this is only 1/2 of what is expected. Maybe there is a /2 in the formula which I factored in.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
tom3141
Posts: 157
Joined: Sat Dec 22, 2018 2:29 pm
Location: North Yorkshire

Re: Halved current during field weakening

Post by tom3141 »

I have a charging issue with mine at the moment but I’m following this thread with interest. Great work so far!
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 think I agree with johu, Id should not be larger than Iq. That makes no sens.
Found this
https://se.mathworks.com/help/mcb/ref/m ... rence.html
When looking under Interior PMSM the equation is close but does the openinverter not use any of the FW stuff? Might perhaps explain why it is hard to get torque under FW.
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Halved current during field weakening

Post by johu »

Just found the original post: viewtopic.php?p=3519#p3519

Image

So there are indeed some factors in there that don't show up in code:

Code: Select all

   s32fp term1 = fpsqrt(fluxLinkage2 + ((lqminusldSquaredBs10 * isSquared) >> 10));
   idref = FP_TOINT(FP_DIV(fluxLinkage - term1, lqminusld));
Now keep in mind lqminusldSquaredBs10 is already lqminusld²/2. Someone mind hacking above formula into a spreadsheet?
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 »

The equation presented by johu is equal to the one I found and linked to in my above post.

Anyway, results
According to SW
According to SW
According to Equation
According to Equation
There are differences so I guess the SW can be adjusted.
Looking at the plot according to the equation, Id is always lower than Iq but compared to SW Id is increased.

EDIT: attached the spredsheet
IdIq.ods
(37.77 KiB) Downloaded 94 times
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 »

By the way, where does the value LdminusLq origin from? Do you have any values of Ld and Lq? Thinking that they are whats needed to calculate the base speed and idfw according to what I linked previously.
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 »

Quoting johu from the "FOC low speed stuttering" thread (viewtopic.php?p=28839#p28839):
johu wrote: Thu Jun 17, 2021 5:28 pm There are two sources for id. One is MTPA. The other is FW. The FW controller might be crude. If the iq control target can not be reached it will increase id. This id is added to the one already calculated by MTPA
Can it be explained in this case why the FW controller isn't increasing Id when the motor isn't accepting enough current? Is it hitting a configurable limit? If so, what does one need to change to allow it to go much higher than it currently does? Is the only limit the "50% of throtcur" and is the limit actually working as intended? Can the internal status of the controller be graphed?
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Halved current during field weakening

Post by johu »

bexander wrote: Fri Jun 18, 2021 7:07 am By the way, where does the value LdminusLq origin from? Do you have any values of Ld and Lq? Thinking that they are whats needed to calculate the base speed and idfw according to what I linked previously.
I found these in a paper about the Prius motor. Since the outcome of MTPA only varies slightly with changing inductance and fluxLinkage I decided to hard-code them.
I will fix the equation now and post software here.
celeron55 wrote: Fri Jun 18, 2021 7:31 am Can it be explained in this case why the FW controller isn't increasing Id when the motor isn't accepting enough current? Is it hitting a configurable limit? If so, what does one need to change to allow it to go much higher than it currently does? Is the only limit the "50% of throtcur" and is the limit actually working as intended? Can the internal status of the controller be graphed?
To me it looks like it is running out of voltage. The 5.05.R and upwards have a spot value "ifw" that outputs the request of the FW controller.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Halved current during field weakening

Post by johu »

This software has the correct formula.

Code: Select all

   //factor of 8 has been incorporated into the right shift (7 instead of 10)
   s32fp term1 = fpsqrt(fluxLinkage2 + ((lqminusldSquaredBs10 * isSquared) >> 7));
   idref = FP_TOINT(FP_DIV(fluxLinkage - term1, 4 * lqminusld));
Attachments
stm32_foc.bin
(42.2 KiB) Downloaded 86 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 »

celeron55 wrote: Fri Jun 18, 2021 7:31 am Quoting johu from the "FOC low speed stuttering" thread (viewtopic.php?p=28839#p28839):
johu wrote: Thu Jun 17, 2021 5:28 pm There are two sources for id. One is MTPA. The other is FW. The FW controller might be crude. If the iq control target can not be reached it will increase id. This id is added to the one already calculated by MTPA
Can it be explained in this case why the FW controller isn't increasing Id when the motor isn't accepting enough current? Is it hitting a configurable limit? If so, what does one need to change to allow it to go much higher than it currently does? Is the only limit the "50% of throtcur" and is the limit actually working as intended? Can the internal status of the controller be graphed?
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.

I think using this equation, found in the link I posted previously, for Id_fw is more refined but will require knowing Ld and Lq.
Id_fw.png
Id_fw.png (8.56 KiB) Viewed 3581 times
Are the Ld and Lq stated in that Prius paper?

Plan to test the new SW tomorrow morning and report back.
Will try to add Ifw to the plot as well.
User avatar
johu
Site Admin
Posts: 5682
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 153 times
Been thanked: 960 times
Contact:

Re: Halved current during field weakening

Post by johu »

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.
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
Post Reply