-
-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
13 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,13 +106,22 @@ void VvtController::setOutput(expected<percent_t> outputValue) { | |
&& engine->rpmCalculator.getSecondsSinceEngineStart(getTimeNowNt()) > engineConfiguration->vvtActivationDelayMs / MS_PER_SECOND | ||
; | ||
|
||
vvtOutput = outputValue.value_or(0); | ||
|
||
if (outputValue && enabled) { | ||
m_pwm->setSimplePwmDutyCycle(PERCENT_TO_DUTY(outputValue.Value)); | ||
float vvtPct = outputValue.Value; | ||
|
||
// Compensate for battery voltage so that the % output is actually % solenoid current normalized | ||
// to a 14v supply (boost duty when battery is low, etc) | ||
float voltageRatio = 14 / Sensor::get(SensorType::BatteryVoltage).value_or(14); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
nmschulte
Contributor
|
||
vvtPct *= voltageRatio; | ||
|
||
vvtOutput = vvtPct; | ||
|
||
m_pwm->setSimplePwmDutyCycle(PERCENT_TO_DUTY(vvtPct)); | ||
} else { | ||
m_pwm->setSimplePwmDutyCycle(0); | ||
|
||
vvtOutput = 0; | ||
|
||
// we need to avoid accumulating iTerm while engine is not running | ||
m_pid.reset(); | ||
} | ||
|
https://maximilianocontieri.com/code-smell-02-constants-and-magic-numbers