Skip to content

Commit

Permalink
Don't apply backwards regen if motor is already turning backwards
Browse files Browse the repository at this point in the history
  • Loading branch information
catphish committed Jan 10, 2023
1 parent 8867d55 commit 12f483b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pwmgeneration-sine.cpp
Expand Up @@ -121,6 +121,12 @@ void PwmGeneration::SetTorquePercent(float torque)
fslipspnt = fslipmin + roundingError;
}
}
else if (Encoder::GetRotorDirection() != Param::GetInt(Param::dir))
{
// Do not apply negative torque if we are already traveling backwards.
fslipspnt = 0;
ampnomLocal = 0;
}
else
{
ampnomLocal = -torque;
Expand Down

0 comments on commit 12f483b

Please sign in to comment.