fix smooth retard functionality #5611

This commit is contained in:
kifir 2024-05-27 15:18:24 +03:00 committed by rusefillc
parent 9011ed2e91
commit 6464d4dc7b
3 changed files with 19 additions and 8 deletions

View File

@ -104,15 +104,16 @@ angle_t getRunningAdvance(int rpm, float engineLoad) {
#endif #endif
#if EFI_LAUNCH_CONTROL #if EFI_LAUNCH_CONTROL
if (engine->launchController.isLaunchCondition && engineConfiguration->enableLaunchRetard) { if (engine->launchController.isSmoothRetardCondition && engineConfiguration->enableLaunchRetard) {
const float launchAngle = engineConfiguration->launchTimingRetard;
if (engineConfiguration->launchSmoothRetard) { if (engineConfiguration->launchSmoothRetard) {
float launchAngle = engineConfiguration->launchTimingRetard; const int launchRpm = engineConfiguration->launchRpm;
int launchRpm = engineConfiguration->launchRpm; const int smoothRetardStartRpm = (launchRpm - engineConfiguration->launchRpmWindow);
int launchRpmWithTimingRange = launchRpm + engineConfiguration->launchRpmWindow; const int smoothRetardEndRpm = (launchRpm - engineConfiguration->smoothRetardEndRpm);
// interpolate timing from rpm at launch triggered to full retard at launch launchRpm + launchTimingRpmRange // https://github.com/rusefi/rusefi/issues/5611#issuecomment-2130431696
return interpolateClamped(launchRpm, advanceAngle, launchRpmWithTimingRange, launchAngle, rpm); return interpolateClamped(smoothRetardStartRpm, advanceAngle, smoothRetardEndRpm, launchAngle, rpm);
} else { } else {
return engineConfiguration->launchTimingRetard; return launchAngle;
} }
} }
#endif /* EFI_LAUNCH_CONTROL */ #endif /* EFI_LAUNCH_CONTROL */

View File

@ -119,6 +119,7 @@ LaunchControlBase::LaunchControlBase() {
launchActivatePinState = false; launchActivatePinState = false;
isLaunchPreCondition = false; isLaunchPreCondition = false;
isLaunchCondition = false; isLaunchCondition = false;
isSmoothRetardCondition = false;
} }
float LaunchControlBase::getFuelCoefficient() const { float LaunchControlBase::getFuelCoefficient() const {
@ -130,7 +131,7 @@ void LaunchControlBase::update() {
return; return;
} }
int rpm = Sensor::getOrZero(SensorType::Rpm); const int rpm = Sensor::getOrZero(SensorType::Rpm);
combinedConditions = isLaunchConditionMet(rpm); combinedConditions = isLaunchConditionMet(rpm);
//and still recalculate in case user changed the values //and still recalculate in case user changed the values
@ -150,6 +151,8 @@ void LaunchControlBase::update() {
// If conditions are met... // If conditions are met...
isLaunchCondition = m_launchTimer.hasElapsedSec(engineConfiguration->launchActivateDelay); isLaunchCondition = m_launchTimer.hasElapsedSec(engineConfiguration->launchActivateDelay);
} }
isSmoothRetardCondition = isSmoothRetardRpmCondition(rpm);
} }
bool LaunchControlBase::isLaunchRpmRetardCondition() const { bool LaunchControlBase::isLaunchRpmRetardCondition() const {
@ -160,6 +163,12 @@ bool LaunchControlBase::isLaunchSparkRpmRetardCondition() const {
return isLaunchRpmRetardCondition() && engineConfiguration->launchSparkCutEnable; return isLaunchRpmRetardCondition() && engineConfiguration->launchSparkCutEnable;
} }
bool LaunchControlBase::isSmoothRetardRpmCondition(const int rpm) const {
const int smoothRetardStartRpm = engineConfiguration->launchRpm - engineConfiguration->launchRpmWindow;
const int smoothRetardEndRpm = engineConfiguration->launchRpm - engineConfiguration->smoothRetardEndRpm;
return (smoothRetardStartRpm <= rpm) && (rpm <= smoothRetardEndRpm);
}
bool LaunchControlBase::isLaunchFuelRpmRetardCondition() const { bool LaunchControlBase::isLaunchFuelRpmRetardCondition() const {
return isLaunchRpmRetardCondition() && engineConfiguration->launchFuelCutEnable; return isLaunchRpmRetardCondition() && engineConfiguration->launchFuelCutEnable;
} }

View File

@ -37,6 +37,7 @@ public:
private: private:
bool isLaunchRpmRetardCondition() const; bool isLaunchRpmRetardCondition() const;
bool isSmoothRetardRpmCondition(int rpm) const;
Timer m_launchTimer; Timer m_launchTimer;
}; };