Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regen Brake Light Fix #119

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 7 additions & 21 deletions src/stm32_vcu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -546,30 +546,16 @@ static void Ms10Task(void)

selectedInverter->SetTorque(torquePercent);

//Brake light based on regen being below the set threshold !! this logic needs verifying
if(Param::GetInt(Param::reversemotor) == 0)

if(Param::GetInt(Param::potnom) < Param::GetInt(Param::RegenBrakeLight))
{
if((torquePercent * requestedDirection) < Param::GetFloat(Param::RegenBrakeLight))//if reverse we flip signs of torque, so multiply by direction- reverse is -1
{
//enable Brake Light Ouput
IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Set();
}
else
{
IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Clear();
}
Param::SetInt(Param::BrkVacVal,torquePercent*requestedDirection*-1);
//enable Brake Light Ouput
IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Set();
}
else //Motor torques flipped so need to flip again
else
{
if((torquePercent * requestedDirection) < Param::GetFloat(Param::RegenBrakeLight))//if reverse we flip signs of torque, so multiply by direction- reverse is -1, reversed again for MotRev
{
//enable Brake Light Ouput
IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Set();
}
else
{
IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Clear();
}
IOMatrix::GetPin(IOMatrix::BRAKELIGHT)->Clear();
}

//speed = ABS(selectedInverter->GetMotorSpeed());//set motor rpm on interface NO ABS allowed on speed as we need to know direction
Expand Down
Loading