Complete (untested) flat shift

This commit is contained in:
Josh Stewart 2017-01-17 15:09:41 +11:00
parent 109f64f342
commit 9d7ca71e3f
3 changed files with 30 additions and 7 deletions

View File

@ -26,6 +26,7 @@ static inline byte correctionFlexTiming(byte);
static inline byte correctionIATretard(byte);
static inline byte correctionSoftRevLimit(byte);
static inline byte correctionSoftLaunch(byte);
static inline byte correctionSoftFlatShift(byte);
#endif // CORRECTIONS_H

View File

@ -52,6 +52,16 @@ const int map_page_size = 288;
#define BIT_SPARK_IDLE 6 // idle on
#define BIT_SPARK_SYNC 7 // Whether engine has sync or not
#define BIT_SPARK2_FLATSH 0 //Flat shift hard cut
#define BIT_SPARK2_FLATSS 1 //Flat shift soft cut
#define BIT_SPARK2_UNUSED3 2
#define BIT_SPARK2_UNUSED4 3
#define BIT_SPARK2_UNUSED5 4
#define BIT_SPARK2_UNUSED6 5
#define BIT_SPARK2_UNUSED7 6
#define BIT_SPARK2_UNUSED8 7
#define VALID_MAP_MAX 1022 //The largest ADC value that is valid for the MAP sensor
#define VALID_MAP_MIN 2 //The smallest ADC value that is valid for the MAP sensor
@ -153,6 +163,7 @@ struct statuses {
unsigned long TAEEndTime; //The target end time used whenever TAE is turned on
volatile byte squirt;
volatile byte spark;
volatile byte spark2;
byte engine;
unsigned int PW1; //In uS
unsigned int PW2; //In uS
@ -164,6 +175,8 @@ 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;
bool flatShiftingHard;
//Helpful bitwise operations:
//Useful reference: http://playground.arduino.cc/Code/BitMath

View File

@ -118,6 +118,9 @@ byte deltaToothCount = 0; //The last tooth that was used with the deltaV calc
int rpmDelta;
byte ignitionCount;
byte fixedCrankingOverride = 0;
bool clutchTrigger;
bool previousClutchTrigger;
unsigned long secCounter; //The next time to incremen 'runSecs' counter.
unsigned long MAX_STALL_TIME = 500000UL; //The maximum time (in uS) that the system will continue to function before the engine is considered stalled/stopped. This is unique to each decoder, depending on the number of teeth etc. 500000 (half a second) is used as the default value, most decoders will be much less.
int channel1IgnDegrees; //The number of crank degrees until cylinder 1 is at TDC (This is obviously 0 for virtually ALL engines, but there's some weird ones)
@ -276,6 +279,8 @@ void setup()
currentStatus.hasSync = false;
currentStatus.runSecs = 0;
currentStatus.secl = 0;
currentStatus.flatShiftingHard = false;
currentStatus.launchingHard = false;
triggerFilterTime = 0; //Trigger filter time is the shortest possible time (in uS) that there can be between crank teeth (ie at max RPM). Any pulses that occur faster than this time will be disgarded as noise. This is simply a default value, the actual values are set in the setup() functinos of each decoder
switch (pinTrigger) {
@ -869,14 +874,18 @@ void loop()
readTPS();
//Check for launching (clutch) can be done around here too
bool launchTrigger;
if(configPage3.launchHiLo) { launchTrigger = digitalRead(pinLaunch); }
else { launchTrigger = !digitalRead(pinLaunch); }
if (configPage3.launchEnabled && launchTrigger && (currentStatus.RPM > ((unsigned int)(configPage3.lnchSoftLim) * 100)) ) { currentStatus.launchingSoft = true; BIT_SET(currentStatus.spark, BIT_SPARK_SLAUNCH); } //SoftCut rev limit for 2-step launch control.
else { currentStatus.launchingSoft = false; BIT_CLEAR(currentStatus.spark, BIT_SPARK_SLAUNCH); }
if (configPage3.launchEnabled && launchTrigger && (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.
previousClutchTrigger = clutchTrigger;
if(configPage3.launchHiLo) { clutchTrigger = digitalRead(pinLaunch); }
else { clutchTrigger = !digitalRead(pinLaunch); }
if(previousClutchTrigger != clutchTrigger) { currentStatus.flatShiftRPM = 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.
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; }
else { currentStatus.flatShiftingHard = false; }
//Boost cutoff is very similar to launchControl, but with a check against MAP rather than a switch
if(configPage3.boostCutType && currentStatus.MAP > (configPage3.boostLimit * 2) ) //The boost limit is divided by 2 to allow a limit up to 511kPa
{
@ -1348,7 +1357,7 @@ void loop()
//Perform an initial check to see if the ignition is turned on (Ignition only turns on after a preset number of cranking revolutions and:
//Check for hard cut rev limit (If we're above the hardcut limit, we simply don't set a spark schedule)
if(ignitionOn && !currentStatus.launchingHard && !BIT_CHECK(currentStatus.spark, BIT_SPARK_BOOSTCUT) && !BIT_CHECK(currentStatus.spark, BIT_SPARK_HRDLIM))
if(ignitionOn && !currentStatus.launchingHard && !BIT_CHECK(currentStatus.spark, BIT_SPARK_BOOSTCUT) && !BIT_CHECK(currentStatus.spark, BIT_SPARK_HRDLIM) && !currentStatus.flatShiftingHard)
{
//if (ignition1StartAngle <= crankAngle && ignition1.schedulesSet == 0) { ignition1StartAngle += CRANK_ANGLE_MAX_IGN; }