mirror of https://github.com/rusefi/rusefi.git
Launch control code rework
This commit is contained in:
parent
a787fac690
commit
2d21796e59
|
@ -104,15 +104,16 @@ static angle_t getRunningAdvance(int rpm, float engineLoad) {
|
|||
#endif
|
||||
|
||||
#if EFI_LAUNCH_CONTROL
|
||||
if (engine->launchController.isLaunchCondition && engineConfiguration->enableLaunchRetard) {
|
||||
if (engineConfiguration->launchSmoothRetard) {
|
||||
if (engineConfiguration->enableLaunchRetard) {
|
||||
if (engine->launchController.isLaunchPreCondition && engineConfiguration->launchSmoothRetard) {
|
||||
float launchAngle = engineConfiguration->launchTimingRetard;
|
||||
int launchRpm = engineConfiguration->launchRpm;
|
||||
int launchRpmWithTimingRange = launchRpm + engineConfiguration->launchRpmWindow;
|
||||
// interpolate timing from rpm at launch triggered to full retard at launch launchRpm + launchTimingRpmRange
|
||||
return interpolateClamped(launchRpm, advanceAngle, launchRpmWithTimingRange, launchAngle, rpm);
|
||||
} else {
|
||||
return engineConfiguration->launchTimingRetard;
|
||||
int launchRpmWithTimingWindow = launchRpm - engineConfiguration->launchRpmWindow;
|
||||
// interpolate timing from rpm at launch triggered to full retard at launch launchRpm
|
||||
float launchTimingInterpolated = interpolateClamped(launchRpmWithTimingWindow, advanceAngle, launchRpm, advanceAngle - launchAngle, rpm);
|
||||
return launchTimingInterpolated;
|
||||
} else if (engine->launchController.isLaunchCondition) {
|
||||
return advanceAngle - engineConfiguration->launchTimingRetard;
|
||||
}
|
||||
}
|
||||
#endif /* EFI_LAUNCH_CONTROL */
|
||||
|
|
|
@ -77,8 +77,16 @@ bool LaunchControlBase::isInsideTpsCondition() const {
|
|||
* Condition is true as soon as we are above LaunchRpm
|
||||
*/
|
||||
LaunchCondition LaunchControlBase::isInsideRPMCondition(int rpm) const {
|
||||
int launchRpm = engineConfiguration->launchRpm;
|
||||
return (launchRpm < rpm) ? LaunchCondition::Launch : LaunchCondition::NotMet;
|
||||
auto launchRpm = engineConfiguration->launchRpm;
|
||||
auto preLaunchRpm = launchRpm - engineConfiguration->launchRpmWindow;
|
||||
|
||||
if (rpm >= launchRpm) {
|
||||
return LaunchCondition::Launch;
|
||||
} else if ((rpm >= preLaunchRpm) && (rpm < launchRpm)) {
|
||||
return LaunchCondition::PreLaunch;
|
||||
} else {
|
||||
return LaunchCondition::NotMet;
|
||||
}
|
||||
}
|
||||
|
||||
LaunchCondition LaunchControlBase::isLaunchConditionMet(int rpm) {
|
||||
|
@ -110,13 +118,7 @@ void LaunchControlBase::update() {
|
|||
combinedConditions = isLaunchConditionMet(rpm) == LaunchCondition::Launch;
|
||||
|
||||
//and still recalculate in case user changed the values
|
||||
retardThresholdRpm = engineConfiguration->launchRpm
|
||||
/*
|
||||
we never had UI for 'launchAdvanceRpmRange' so it was always zero. are we supposed to forget about this dead line
|
||||
or it is supposed to be referencing 'launchTimingRpmRange'?
|
||||
+ (engineConfiguration->enableLaunchRetard ? engineConfiguration->launchAdvanceRpmRange : 0)
|
||||
*/
|
||||
+ engineConfiguration->launchRpmWindow;
|
||||
retardThresholdRpm = engineConfiguration->launchRpm - (engineConfiguration->enableLaunchRetard ? engineConfiguration->launchRpmWindow : 0);
|
||||
|
||||
if (!combinedConditions) {
|
||||
// conditions not met, reset timer
|
||||
|
@ -126,10 +128,29 @@ void LaunchControlBase::update() {
|
|||
// If conditions are met...
|
||||
isLaunchCondition = m_launchTimer.hasElapsedSec(engineConfiguration->launchActivateDelay);
|
||||
}
|
||||
|
||||
isLaunchPreCondition = combinedConditions = (isLaunchConditionMet(rpm) == LaunchCondition::PreLaunch);;
|
||||
int targetLaunchSparkSkipPercent = engineConfiguration->launchSparkSkipPercent;
|
||||
if (isLaunchPreCondition) {
|
||||
m_preLaunchSparkSkipArmed = false;
|
||||
|
||||
if (targetLaunchSparkSkipPercent > 0) {
|
||||
int launchRpm = engineConfiguration->launchRpm;
|
||||
int launchRpmWithWindow = launchRpm - engineConfiguration->launchRpmWindow;
|
||||
int launchSparkSkipInterpolated = interpolateClamped(launchRpmWithWindow, 0, launchRpm, targetLaunchSparkSkipPercent, rpm);
|
||||
float launchSparkSkip = ((float)launchSparkSkipInterpolated) / 100.0f;
|
||||
engine->hardSparkLimiter.setTargetSkipRatio(launchSparkSkip);
|
||||
}
|
||||
} else {
|
||||
if (m_preLaunchSparkSkipArmed == false) {
|
||||
engine->hardSparkLimiter.setTargetSkipRatio(0);
|
||||
m_preLaunchSparkSkipArmed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool LaunchControlBase::isLaunchRpmRetardCondition() const {
|
||||
return isLaunchCondition && (retardThresholdRpm < Sensor::getOrZero(SensorType::Rpm));
|
||||
return (isLaunchCondition || isLaunchPreCondition) && (retardThresholdRpm < Sensor::getOrZero(SensorType::Rpm));
|
||||
}
|
||||
|
||||
bool LaunchControlBase::isLaunchSparkRpmRetardCondition() const {
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
void initLaunchControl();
|
||||
|
||||
enum class LaunchCondition {
|
||||
PreLaunch,
|
||||
Launch,
|
||||
NotMet
|
||||
};
|
||||
|
@ -37,6 +38,7 @@ private:
|
|||
bool isLaunchRpmRetardCondition() const;
|
||||
|
||||
Timer m_launchTimer;
|
||||
bool m_preLaunchSparkSkipArmed = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -49,6 +51,7 @@ public:
|
|||
* targetSkipRatio of '0' means 'do not skip', would always return false
|
||||
*/
|
||||
void setTargetSkipRatio(float targetSkipRatio);
|
||||
float getTargetSkipRatio() { return targetSkipRatio; };
|
||||
|
||||
bool shouldSkip();
|
||||
private:
|
||||
|
|
|
@ -4672,14 +4672,16 @@ dialog = tcuControls, "Transmission Settings"
|
|||
field = ""
|
||||
field = "Launch RPM", launchRpm, {launchControlEnabled == 1}
|
||||
field = "Launch Control Window", launchRpmWindow, {launchControlEnabled == 1}
|
||||
;field = "Boost Solenoid Duty", launchBoostDuty, {launchControlEnabled == 1}
|
||||
field = "TPS Threshold", launchTpsThreshold, {launchControlEnabled == 1}
|
||||
field = "Ignition Retard enable", enableLaunchRetard, {launchControlEnabled == 1}
|
||||
field = "Ignition Retard", launchTimingRetard, {launchControlEnabled == 1 && enableLaunchRetard == 1}
|
||||
field = "Fuel Added %", launchFuelAdderPercent, {launchControlEnabled == 1}
|
||||
field = "Smooth Retard Mode", launchSmoothRetard, {launchControlEnabled == 1 && enableLaunchRetard == 1}
|
||||
field = "Hard Cut Mode"
|
||||
field = "Ignition Cut", launchSparkCutEnable, {launchControlEnabled == 1}
|
||||
field = "Fuel Cut", launchFuelCutEnable, {launchControlEnabled == 1}
|
||||
field = "Ignition Cut", launchSparkCutEnable, {launchControlEnabled == 1}
|
||||
field = "Spark Skip Transition Target %", launchSparkSkipPercent, {launchControlEnabled == 1}
|
||||
|
||||
|
||||
dialog = smLaunchControl, "", border
|
||||
|
|
Loading…
Reference in New Issue