Skip to content

Commit

Permalink
Added regen ramp to FOC (again). Fixed q voltage limiter
Browse files Browse the repository at this point in the history
  • Loading branch information
jsphuebner committed Sep 27, 2019
1 parent 5be35cf commit 94c46f6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/project/pwmgeneration-foc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ void PwmGeneration::Run()
ProcessCurrents(id, iq);

int32_t ud = dController.Run(id);
int32_t uq = qController.Run(iq);
int32_t qlimit = FOC::GetQLimit(maxVd);
int32_t qlimit = FOC::GetQLimit(ud);
qController.SetMinMaxY(-qlimit, qlimit);
int32_t uq = qController.Run(iq);
FOC::InvParkClarke(ud, uq, angle);

s32fp idc = (iq * uq) / FOC::GetMaximumModulationIndex();
Expand Down Expand Up @@ -133,6 +133,13 @@ void PwmGeneration::Run()

void PwmGeneration::SetTorquePercent(s32fp torquePercent)
{
s32fp brkrampstr = Param::Get(Param::brkrampstr);

if (frq < brkrampstr && torquePercent < 0)
{
torquePercent = FP_MUL(FP_DIV(frq, brkrampstr), torquePercent);
}

s32fp id = FP_MUL(Param::Get(Param::throtid), ABS(torquePercent));
s32fp iq = FP_MUL(Param::Get(Param::throtiq), Param::GetInt(Param::dir) * torquePercent);

Expand Down

0 comments on commit 94c46f6

Please sign in to comment.