This commit is contained in:
rusefillc 2024-05-07 22:31:05 -05:00 committed by GitHub
commit 29c184a42a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 55 additions and 28 deletions

View File

@ -104,15 +104,16 @@ 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 */

View File

@ -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 {

View File

@ -13,6 +13,7 @@
void initLaunchControl();
enum class LaunchCondition {
PreLaunch,
Launch,
NotMet
};
@ -23,7 +24,7 @@ public:
// Update the state of the launch control system
void update();
float getFuelCoefficient() const;
float getFuelCoefficient() const;
bool isInsideSpeedCondition() const;
bool isInsideTpsCondition() const;
bool isInsideSwitchCondition();
@ -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:

View File

@ -982,7 +982,7 @@ bit verboseCan2,"Print all","Do not print";Print incoming and outgoing second bu
int launchSpeedThreshold;Launch disabled above this speed if setting is above zero;"Kph", 1, 0, 0, 300, 0
int launchRpmWindow;Starting Launch RPM window to activate (subtracts from Launch RPM);"RPM", 1, 0, 0, 8000, 0
int unusedHere12
int launchSparkSkipPercent;Spark Skip Transition Target;"%", 1, 0, 0, 100, 0
int unusedHere13
float magicNumberAvailableForDevTricks
float turbochargerFilter

View File

@ -4771,18 +4771,20 @@ dialog = tcuControls, "Transmission Settings"
field = ""
; dead code field = "Rpm Threshold", launchRpmThreshold, {launchControlEnabled == 1}
field = "Speed Threshold", launchSpeedThreshold, {launchControlEnabled == 1}
field = "Speed Threshold", launchSpeedThreshold, {launchControlEnabled == 1}
field = ""
field = "Launch RPM", launchRpm, {launchControlEnabled == 1}
field = "Launch RPM", launchRpm, {launchControlEnabled == 1}
field = "Launch Control Window", launchRpmWindow, {launchControlEnabled == 1}
field = "TPS Threshold", launchTpsThreshold, {launchControlEnabled == 1}
field = "Ignition Retard enable", enableLaunchRetard, {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 = "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

View File

@ -78,7 +78,7 @@ TEST(LaunchControl, RPMCondition) {
engineConfiguration->launchRpm = 3000;
EXPECT_EQ(dut.isInsideRPMCondition(2900), LaunchCondition::NotMet);
EXPECT_EQ(dut.isInsideRPMCondition(2900), LaunchCondition::PreLaunch);
EXPECT_EQ(dut.isInsideRPMCondition(3100), LaunchCondition::Launch);
}
@ -143,7 +143,7 @@ TEST(LaunchControl, CombinedCondition) {
EXPECT_EQ(dut.isLaunchConditionMet(1200), LaunchCondition::NotMet);
Sensor::setMockValue(SensorType::Rpm, 3200);
Sensor::setMockValue(SensorType::Rpm, 3200);
EXPECT_EQ(dut.isLaunchConditionMet(3200), LaunchCondition::Launch);
Sensor::setMockValue(SensorType::VehicleSpeed, 40.0);