Page 1 of 1

Improving MTPA

Posted: Mon Aug 15, 2022 8:49 am
by Bigpie
Looking at the firmware, the MTPA seems to use some hardcoded values.

Code: Select all

static const s32fp fluxLinkage = FP_FROMFLT(0.09);
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);
....

void FOC::Mtpa(int32_t is, int32_t& idref, int32_t& iqref)
{
   int32_t isSquared = is * is;
   int32_t sign = is < 0 ? -1 : 1;
   s32fp term1 = fpsqrt(fluxLinkage2 + ((lqminusldSquaredBs10 * isSquared) >> 10));
   idref = FP_TOINT(FP_DIV(fluxLinkage - term1, lqminusld));
   iqref = sign * (int32_t)sqrt(isSquared - idref * idref);
}
https://hackaday.io/project/164932-axio ... -into-vesc
https://github.com/vedderb/bldc/pull/17 ... 103ae858b2

I can manage to make these values in to parameters, but I've not yet found a way to externally workout the flux linkage and the d q inductance difference for a specific motor.

Re: Improving MTPA

Posted: Mon Aug 15, 2022 12:05 pm
by johu
I think bexander worked out Rs, Lq and Ld for his MGR motor:
viewtopic.php?p=28905#p28905

There was also an attempt to make them parameters
viewtopic.php?t=2025

Re: Improving MTPA

Posted: Mon Aug 15, 2022 12:17 pm
by bexander
Here is the document I used as a guide to measure Rs, Lq and Ld.
Measure Ld and Lq.pdf
(2.25 MiB) Downloaded 102 times

Re: Improving MTPA

Posted: Mon Aug 15, 2022 1:07 pm
by Bigpie
Thanks, I was just reading that and following through your changes. Did you commit to a github fork?

Re: Improving MTPA

Posted: Mon Aug 15, 2022 7:33 pm
by bexander
Bigpie wrote: Mon Aug 15, 2022 1:07 pm Thanks, I was just reading that and following through your changes. Did you commit to a github fork?
No sorry, no github fork.

Re: Improving MTPA

Posted: Wed Aug 17, 2022 9:52 am
by Bigpie
No problem.

Still reading up at the moment. https://github.com/vedderb/bldc/ is a treasure trove, especially this commit https://github.com/vedderb/bldc/pull/179

"The only configuration parameter needed is the Lq-Ld difference which determines how "tilted" the MTPA trajectory is. Torque increase depends on Ldiff and flux linkage, in a motor with high saliency it can yield a 40+% torque increase (nissan leaf motor) and the % gets bigger with more amps." Some bold claims.

Re: Improving MTPA

Posted: Wed Aug 17, 2022 2:04 pm
by johu
Also found this paper that at least acknowledges the issue of phase delay between current and position measurement. Doesn't present a solution though...