celeron55 wrote: ↑Fri Sep 09, 2022 1:47 pm
Not that I understand even half of this, but now it's again sounding like something that mirrors what I found when playing with syncadv on the MGR.
Do you agree syncadv can be used to compensate some of this, but with the downside of reduced low speed torque? Because that's what I found to be the case.
It's vary hard to predict the effect that syncadv has (I'm still guessing most of the time which is why it worries me when I lose confidence in the simulator). This is partly as the impact of syncadv changes with speed and partly because errors in it cause requested Id at the controller to be seen as Iq by the motor and vice versa. Combined these can have all sorts of odd effects. When you combine that with field weakening, Mtpa, measurement noise, etc, there are lots and lots and lots of ways for it to go wrong.
I would agree that if you use the adjustments like syncadv to optimise for one area it is highly likely to adversely affect performance somewhere else.
johu wrote: ↑Fri Sep 09, 2022 1:55 pm
Well then here is something for you to test. Best run yet
Parameters
curkp 50
curki 35000
curkifrqgain 0
fwkp 5
fwki 50
fwmargin 4500
syncofs 1000
syncadv 0.5
ldminuslq 1
fluxlinkage 90
Still somewhat shaky but drivable, no unwanted regen, no trips.
I have increased S&H time to 7.5 clocks again because I was seeing like 70A spikes in il1/il2! They were gone then.
Next I found that increasing curki improves stability. It is now at 35000 for my Leaf motor. So a good deal of shakiness is now gone, I think with a bit more tuning it could be eliminated. Throttle reacts a bit weird once entering field weakening, you suddenly get more acceleration but you can always compensate that by coming off throttle. It never accelerates on its own. I think that can be tuned out as well. I didn't have the patience now.
That's looking good

Not too keen on the way that Ifw comes in in lumps and then is pulled out too much at a time though. I'll put it into the simulator now to see what it looks like.
Any chance that you could try a couple of things?
First a mod to repurpose syncadv temporarily to see whether sync compensation does have the effect of the logged data that I'm hoping for
Code: Select all
in foc.c
void FOC::SetAngle(uint16_t angle, uint16_t syncadv)
{
sin = SineCore::Sine(angle + syncadv);
cos = SineCore::Cosine(angle + syncadv);
}
inpwmgeneration-foc.c
at the top
CalcNextAngleSync(dir);
FOC::SetAngle(angle, 0);
and lower down
s32fp syncadv = FP_MUL(frqFiltered, Param::Get(Param::syncadv));
syncadv = MAX(0, syncadv);
FOC::SetAngle(angle, FP_TOINT(dir * syncadv));
FOC::InvParkClarke(ud, uq);
A syncadv value of 12 should then compensate for the pwm timer loading delay.
And second a custom PI controller for the field weakening (I know the coding is a bit hacky but just as a test):
Code: Select all
int32_t PiController::RunDebug(s32fp curVal)
{
s32fp err = refVal - curVal;
if(err > 100)
err = 100;
if(err < -2000)
err = -2000;
s32fp esumTemp = esum + err;
if((kp != 0) || (ki != 0))
{
int32_t y = FP_TOINT(err * kp + (esumTemp / frequency) * ki);
int32_t ylim = MAX(y, minY);
ylim = MIN(ylim, maxY);
if ((ylim == y) || (ABS(esumTemp) < ABS(esum)))
{
esum = esumTemp; //anti windup, only integrate when not saturated or if will reduce saturation
}
return ylim;
}
return minY;
}
EDIT2 - Just simulated this PI controller mod and it doesn't seem to give the benefit that I previously saw when using you ki and kps so probably not worth trying after all.
Thanks
EDIT - forgot - also need to disable the old syncadv functionality:
Code: Select all
//Compensate rotor movement that happened between sampling and processing
//syncOfs += FP_TOINT(dir * syncadv);