CJ125 heater zero PWM improvement

This commit is contained in:
rusefi 2019-02-01 22:20:15 -05:00
parent 905db38c17
commit 56f0260414
2 changed files with 9 additions and 3 deletions

View File

@ -75,6 +75,15 @@ void SimplePwm::setSimplePwmDutyCycle(float dutyCycle) {
warning(CUSTOM_ERR_6579, "spwd:dutyCycle %.2f", dutyCycle);
return;
}
if (dutyCycle == 0.0f)
/**
* set the pin low just to be super sure
* this custom handling of zero value comes from CJ125 heater code
* TODO: is this really needed? cover by unit test?
*/
stateChangeCallback(this, 0);
}
if (dutyCycle < ZERO_PWM_THRESHOLD) {
mode = PM_ZERO;
} else if (dutyCycle > FULL_PWM_THRESHOLD) {

View File

@ -384,9 +384,6 @@ static void cjSetHeater(float value DECLARE_ENGINE_PARAMETER_SUFFIX) {
// todo: this should be moved to wboHeaterControl.setPwmDutyCycle()
wboHeaterControl.setFrequency(heaterDuty == 0.0f ? NAN : CJ125_HEATER_PWM_FREQ);
wboHeaterControl.setSimplePwmDutyCycle(heaterDuty);
// This fixes pwm sticking to the last pin state
if (heaterDuty == 0.0f)
wboHeaterPin.setValue(false);
}
static void cjSetIdleHeater(DECLARE_ENGINE_PARAMETER_SIGNATURE) {