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
|
#endif
|
||||||
|
|
||||||
#if EFI_LAUNCH_CONTROL
|
#if EFI_LAUNCH_CONTROL
|
||||||
if (engine->launchController.isLaunchCondition && engineConfiguration->enableLaunchRetard) {
|
if (engineConfiguration->enableLaunchRetard) {
|
||||||
if (engineConfiguration->launchSmoothRetard) {
|
if (engine->launchController.isLaunchPreCondition && engineConfiguration->launchSmoothRetard) {
|
||||||
float launchAngle = engineConfiguration->launchTimingRetard;
|
float launchAngle = engineConfiguration->launchTimingRetard;
|
||||||
int launchRpm = engineConfiguration->launchRpm;
|
int launchRpm = engineConfiguration->launchRpm;
|
||||||
int launchRpmWithTimingRange = launchRpm + engineConfiguration->launchRpmWindow;
|
int launchRpmWithTimingWindow = launchRpm - engineConfiguration->launchRpmWindow;
|
||||||
// interpolate timing from rpm at launch triggered to full retard at launch launchRpm + launchTimingRpmRange
|
// interpolate timing from rpm at launch triggered to full retard at launch launchRpm
|
||||||
return interpolateClamped(launchRpm, advanceAngle, launchRpmWithTimingRange, launchAngle, rpm);
|
float launchTimingInterpolated = interpolateClamped(launchRpmWithTimingWindow, advanceAngle, launchRpm, advanceAngle - launchAngle, rpm);
|
||||||
} else {
|
return launchTimingInterpolated;
|
||||||
return engineConfiguration->launchTimingRetard;
|
} else if (engine->launchController.isLaunchCondition) {
|
||||||
|
return advanceAngle - engineConfiguration->launchTimingRetard;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* EFI_LAUNCH_CONTROL */
|
#endif /* EFI_LAUNCH_CONTROL */
|
||||||
|
|
|
@ -77,8 +77,16 @@ bool LaunchControlBase::isInsideTpsCondition() const {
|
||||||
* Condition is true as soon as we are above LaunchRpm
|
* Condition is true as soon as we are above LaunchRpm
|
||||||
*/
|
*/
|
||||||
LaunchCondition LaunchControlBase::isInsideRPMCondition(int rpm) const {
|
LaunchCondition LaunchControlBase::isInsideRPMCondition(int rpm) const {
|
||||||
int launchRpm = engineConfiguration->launchRpm;
|
auto launchRpm = engineConfiguration->launchRpm;
|
||||||
return (launchRpm < rpm) ? LaunchCondition::Launch : LaunchCondition::NotMet;
|
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) {
|
LaunchCondition LaunchControlBase::isLaunchConditionMet(int rpm) {
|
||||||
|
@ -110,13 +118,7 @@ void LaunchControlBase::update() {
|
||||||
combinedConditions = isLaunchConditionMet(rpm) == LaunchCondition::Launch;
|
combinedConditions = isLaunchConditionMet(rpm) == LaunchCondition::Launch;
|
||||||
|
|
||||||
//and still recalculate in case user changed the values
|
//and still recalculate in case user changed the values
|
||||||
retardThresholdRpm = engineConfiguration->launchRpm
|
retardThresholdRpm = engineConfiguration->launchRpm - (engineConfiguration->enableLaunchRetard ? engineConfiguration->launchRpmWindow : 0);
|
||||||
/*
|
|
||||||
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;
|
|
||||||
|
|
||||||
if (!combinedConditions) {
|
if (!combinedConditions) {
|
||||||
// conditions not met, reset timer
|
// conditions not met, reset timer
|
||||||
|
@ -126,10 +128,29 @@ void LaunchControlBase::update() {
|
||||||
// If conditions are met...
|
// If conditions are met...
|
||||||
isLaunchCondition = m_launchTimer.hasElapsedSec(engineConfiguration->launchActivateDelay);
|
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 {
|
bool LaunchControlBase::isLaunchRpmRetardCondition() const {
|
||||||
return isLaunchCondition && (retardThresholdRpm < Sensor::getOrZero(SensorType::Rpm));
|
return (isLaunchCondition || isLaunchPreCondition) && (retardThresholdRpm < Sensor::getOrZero(SensorType::Rpm));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LaunchControlBase::isLaunchSparkRpmRetardCondition() const {
|
bool LaunchControlBase::isLaunchSparkRpmRetardCondition() const {
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
void initLaunchControl();
|
void initLaunchControl();
|
||||||
|
|
||||||
enum class LaunchCondition {
|
enum class LaunchCondition {
|
||||||
|
PreLaunch,
|
||||||
Launch,
|
Launch,
|
||||||
NotMet
|
NotMet
|
||||||
};
|
};
|
||||||
|
@ -23,7 +24,7 @@ public:
|
||||||
// Update the state of the launch control system
|
// Update the state of the launch control system
|
||||||
void update();
|
void update();
|
||||||
|
|
||||||
float getFuelCoefficient() const;
|
float getFuelCoefficient() const;
|
||||||
bool isInsideSpeedCondition() const;
|
bool isInsideSpeedCondition() const;
|
||||||
bool isInsideTpsCondition() const;
|
bool isInsideTpsCondition() const;
|
||||||
bool isInsideSwitchCondition();
|
bool isInsideSwitchCondition();
|
||||||
|
@ -37,6 +38,7 @@ private:
|
||||||
bool isLaunchRpmRetardCondition() const;
|
bool isLaunchRpmRetardCondition() const;
|
||||||
|
|
||||||
Timer m_launchTimer;
|
Timer m_launchTimer;
|
||||||
|
bool m_preLaunchSparkSkipArmed = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,6 +51,7 @@ public:
|
||||||
* targetSkipRatio of '0' means 'do not skip', would always return false
|
* targetSkipRatio of '0' means 'do not skip', would always return false
|
||||||
*/
|
*/
|
||||||
void setTargetSkipRatio(float targetSkipRatio);
|
void setTargetSkipRatio(float targetSkipRatio);
|
||||||
|
float getTargetSkipRatio() { return targetSkipRatio; };
|
||||||
|
|
||||||
bool shouldSkip();
|
bool shouldSkip();
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -4668,18 +4668,20 @@ dialog = tcuControls, "Transmission Settings"
|
||||||
field = ""
|
field = ""
|
||||||
|
|
||||||
; dead code field = "Rpm Threshold", launchRpmThreshold, {launchControlEnabled == 1}
|
; dead code field = "Rpm Threshold", launchRpmThreshold, {launchControlEnabled == 1}
|
||||||
field = "Speed Threshold", launchSpeedThreshold, {launchControlEnabled == 1}
|
field = "Speed Threshold", launchSpeedThreshold, {launchControlEnabled == 1}
|
||||||
field = ""
|
field = ""
|
||||||
field = "Launch RPM", launchRpm, {launchControlEnabled == 1}
|
field = "Launch RPM", launchRpm, {launchControlEnabled == 1}
|
||||||
field = "Launch Control Window", launchRpmWindow, {launchControlEnabled == 1}
|
field = "Launch Control Window", launchRpmWindow, {launchControlEnabled == 1}
|
||||||
field = "TPS Threshold", launchTpsThreshold, {launchControlEnabled == 1}
|
;field = "Boost Solenoid Duty", launchBoostDuty, {launchControlEnabled == 1}
|
||||||
field = "Ignition Retard enable", enableLaunchRetard, {launchControlEnabled == 1}
|
field = "TPS Threshold", launchTpsThreshold, {launchControlEnabled == 1}
|
||||||
|
field = "Ignition Retard enable", enableLaunchRetard, {launchControlEnabled == 1}
|
||||||
field = "Ignition Retard", launchTimingRetard, {launchControlEnabled == 1 && enableLaunchRetard == 1}
|
field = "Ignition Retard", launchTimingRetard, {launchControlEnabled == 1 && enableLaunchRetard == 1}
|
||||||
field = "Fuel Added %", launchFuelAdderPercent, {launchControlEnabled == 1}
|
field = "Fuel Added %", launchFuelAdderPercent, {launchControlEnabled == 1}
|
||||||
field = "Smooth Retard Mode", launchSmoothRetard, {launchControlEnabled == 1 && enableLaunchRetard == 1}
|
field = "Smooth Retard Mode", launchSmoothRetard, {launchControlEnabled == 1 && enableLaunchRetard == 1}
|
||||||
field = "Hard Cut Mode"
|
field = "Hard Cut Mode"
|
||||||
field = "Ignition Cut", launchSparkCutEnable, {launchControlEnabled == 1}
|
|
||||||
field = "Fuel Cut", launchFuelCutEnable, {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
|
dialog = smLaunchControl, "", border
|
||||||
|
|
Loading…
Reference in New Issue