mirror of https://github.com/FOME-Tech/fome-fw.git
voltage compensated vvt #209
This commit is contained in:
parent
229a9d99dc
commit
c7a7f7467c
|
@ -31,6 +31,7 @@ Release template (copy/paste this for new release):
|
|||
### Added
|
||||
- Log per-cylinder true ignition timing (includes trim, knock retard, etc) #76
|
||||
- Add mode for CLT/IAT sensors that are installed "high side" instead of typical "low side" #116
|
||||
- Automatic supply voltage compensation for VVT solenoids, giving more stable control as battery voltage changes #209
|
||||
|
||||
### Fixed
|
||||
- Improved bench test resolution (more usable for testing injectors, dwell, etc)
|
||||
|
|
|
@ -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);
|
||||
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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue