Quite a lot of code and test driving produced today.
Unfortunately I was able to trigger an over current event, I had set ocurlim to 600 and throtcur to 4:
Then I did a full acceleration run with ocurlim=900A and throtcur=5.5A
Acceleration drops off sharply at 4500 rpm. FW controller becomes active but there is no more amplitude left to follow its command. But thats because I'm stupid, d-controller is limited to maxAmplitude-2000 and I set fwMargin=2000 as well. So it kicks in way too late. Will correct that and try again tomorrow.
As for your syncadv theory we should keep it in the back of our head. Traditionally though you see the same angle going into the forward and reverse transformations.
EDIT: code is right on the master branch:
https://github.com/jsphuebner/stm32-sine
EDIT2: maybe I should dump the guts of the new FW controller here for your reference:
Code: Select all
void PwmGeneration::SetTorquePercent(float torquePercent)
{
float is = Param::GetFloat(Param::throtcur) * torquePercent;
float id, iq;
uint32_t amplitude = FOC::GetTotalVoltage(Param::GetInt(Param::ud), Param::GetInt(Param::uq));
float ifw = FP_TOFLOAT(fwController.Run(amplitude));
float maxIs = Param::GetFloat(Param::throtcur) * 100 - ifw;
Param::SetFloat(Param::ifw, ifw);
if (is > 0)
is = MIN(maxIs, is);
else
is = -MIN(maxIs, -is);
FOC::Mtpa(is, id, iq);
id += ifw;
qController.SetRef(FP_FROMFLT(iq));
idref = FP_FROMFLT(id);
}
"is" is limited to maximum motor current minus FW current.