Slightly improved flat shift / launch logic

This commit is contained in:
Josh Stewart 2017-01-18 13:20:04 +11:00
parent da3f460152
commit 4c1c9a051e
4 changed files with 30 additions and 8 deletions

View File

@ -256,7 +256,7 @@ static inline byte correctionAFRClosedLoop()
currentStatus.afrTarget = currentStatus.O2; //Catch all incase the below doesn't run. This prevents the Include AFR option from doing crazy things if the AFR target conditions aren't met. This value is changed again below if all conditions are met.
//Check the ignition count to see whether the next step is required
if( (ignitionCount & (configPage3.egoCount - 1)) == 1 ) //This is the equivalent of ( (ignitionCount % configPage3.egoCount) == 0 ) but without the expensive modulus operation. ie It results in True every <egoCount> ignition loops. Note that it only works for power of two vlaues for egoCount
//if( (ignitionCount & (configPage3.egoCount - 1)) == 1 ) //This is the equivalent of ( (ignitionCount % configPage3.egoCount) == 0 ) but without the expensive modulus operation. ie It results in True every <egoCount> ignition loops. Note that it only works for power of two vlaues for egoCount
{
//Determine whether the Y axis of the AFR target table tshould be MAP (Speed-Density) or TPS (Alpha-N)
byte yValue;
@ -321,6 +321,7 @@ byte correctionsIgn(byte advance)
advance = correctionIATretard(advance);
advance = correctionSoftRevLimit(advance);
advance = correctionSoftLaunch(advance);
advance = correctionSoftFlatShift(advance);
//Fixed timing check must go last
advance = correctionFixedTiming(advance);
advance = correctionCrankingFixedTiming(advance); //This overrrides the regular fixed timing, must come last
@ -368,7 +369,28 @@ static inline byte correctionSoftRevLimit(byte advance)
static inline byte correctionSoftLaunch(byte advance)
{
if (currentStatus.launchingSoft) { return configPage3.lnchRetard; } //SoftCut rev limit for 2-step launch control
//SoftCut rev limit for 2-step launch control.
if (configPage3.launchEnabled && clutchTrigger && (currentStatus.clutchEngagedRPM < ((unsigned int)(configPage3.flatSArm) * 100)) && (currentStatus.RPM > ((unsigned int)(configPage3.lnchSoftLim) * 100)) )
{
currentStatus.launchingSoft = true;
BIT_SET(currentStatus.spark, BIT_SPARK_SLAUNCH);
return configPage3.lnchRetard;
}
currentStatus.launchingSoft = false;
BIT_CLEAR(currentStatus.spark, BIT_SPARK_SLAUNCH);
return advance;
}
static inline byte correctionSoftFlatShift(byte advance)
{
if(configPage3.flatSEnable && clutchTrigger && (currentStatus.clutchEngagedRPM > ((unsigned int)(configPage3.flatSArm) * 100)) && (currentStatus.RPM > (currentStatus.clutchEngagedRPM-configPage3.flatSSoftWin) ) )
{
BIT_SET(currentStatus.spark2, BIT_SPARK2_FLATSS);
return configPage3.flatSRetard;
}
BIT_CLEAR(currentStatus.spark2, BIT_SPARK2_FLATSS);
return advance;
}

View File

@ -175,7 +175,7 @@ struct statuses {
boolean launchingSoft; //True when in launch control soft limit mode
boolean launchingHard; //True when in launch control hard limit mode
int freeRAM;
unsigned int flatShiftRPM;
unsigned int clutchEngagedRPM;
bool flatShiftingHard;
//Helpful bitwise operations:

View File

@ -738,7 +738,7 @@ menuDialog = main
flexAdvLow = "Additional advance (in degrees) at lowest ethanol reading (Typically 0)"
flexAdvHigh = "Additional advance (in degrees) at highest ethanol reading (Typically 10-20 degrees)"
flatSArm = "The RPM above which an active clutch input will be considered a flat shift (instead of launch). This must be at least several hundred RPM above idle"
flatSArm = "The RPM switch point that determines whether an eganged clutch is for launch control or flat shift. Below this figure, an engaged clutch is considered to be for launch, above this figure an active clutch input will be considered a flat shift. This should be set at least several hundred RPM above idle"
flatSSoftWin= "The number of RPM below the flat shift point where the softlimit will be applied (aka Soft limit window). Recommended values are 200-1000"
flatSRetard = "The absolute timing (BTDC) that will be used when within the soft limit window"
@ -1022,6 +1022,7 @@ menuDialog = main
field = "Clutch Input Pin", launchPin, { launchEnable || flatSEnable }
field = "Clutch enabled when signal is",launchHiLo, { launchEnable || flatSEnable }
field = "Clutch Pullup Resistor", lnchPullRes, { launchEnable || flatSEnable }
field = "Launch / Flat Shift switch RPM",flatSArm, { launchEnable || flatSEnable }
dialog = LaunchControl, "Launch Control / Flat shift", 6
topicHelp = Fhelp7
@ -1037,7 +1038,6 @@ menuDialog = main
; Flat shift
field = "Flat Shift"
field = "Enable flat shift", flatSEnable
field = "Flat Shift above", flatSArm, { flatSEnable }
field = "Soft rev window", flatSSoftWin, { flatSEnable }
field = "Soft limit absolute timing", flatSRetard, { flatSEnable }

View File

@ -878,12 +878,12 @@ void loop()
if(configPage3.launchHiLo) { clutchTrigger = digitalRead(pinLaunch); }
else { clutchTrigger = !digitalRead(pinLaunch); }
if(previousClutchTrigger != clutchTrigger) { currentStatus.flatShiftRPM = currentStatus.RPM; }
if(previousClutchTrigger != clutchTrigger) { currentStatus.clutchEngagedRPM = currentStatus.RPM; }
if (configPage3.launchEnabled && clutchTrigger && (currentStatus.RPM > ((unsigned int)(configPage3.lnchHardLim) * 100)) ) { currentStatus.launchingHard = true; BIT_SET(currentStatus.spark, BIT_SPARK_HLAUNCH); } //HardCut rev limit for 2-step launch control.
if (configPage3.launchEnabled && clutchTrigger && (currentStatus.clutchEngagedRPM < ((unsigned int)(configPage3.flatSArm) * 100)) && (currentStatus.RPM > ((unsigned int)(configPage3.lnchHardLim) * 100)) ) { currentStatus.launchingHard = true; BIT_SET(currentStatus.spark, BIT_SPARK_HLAUNCH); } //HardCut rev limit for 2-step launch control.
else { currentStatus.launchingHard = false; BIT_CLEAR(currentStatus.spark, BIT_SPARK_HLAUNCH); }
if(configPage3.flatSEnable && clutchTrigger && (currentStatus.RPM > ((unsigned int)(configPage3.flatSArm) * 100)) && (currentStatus.RPM > currentStatus.flatShiftRPM) ) { currentStatus.flatShiftingHard = true; }
if(configPage3.flatSEnable && clutchTrigger && (currentStatus.RPM > ((unsigned int)(configPage3.flatSArm) * 100)) && (currentStatus.RPM > currentStatus.clutchEngagedRPM) ) { currentStatus.flatShiftingHard = true; }
else { currentStatus.flatShiftingHard = false; }
//Boost cutoff is very similar to launchControl, but with a check against MAP rather than a switch