From 7171c12a6a80ea23a7265fb66eb04377d9daef07 Mon Sep 17 00:00:00 2001 From: "Vitor Moreno B. Sales" Date: Sun, 31 May 2020 05:35:25 -0300 Subject: [PATCH 1/3] Fix bu introduced on last commit (#394) --- speeduino/corrections.h | 1 + speeduino/corrections.ino | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/speeduino/corrections.h b/speeduino/corrections.h index 5365bc43..a2547ad9 100644 --- a/speeduino/corrections.h +++ b/speeduino/corrections.h @@ -41,6 +41,7 @@ extern unsigned long knockStartTime; extern byte lastKnockCount; extern int16_t knockWindowMin; //The current minimum crank angle for a knock pulse to be valid extern int16_t knockWindowMax;//The current maximum crank angle for a knock pulse to be valid +extern uint16_t aseTaperStart; extern uint16_t dfcoStart; #endif // CORRECTIONS_H diff --git a/speeduino/corrections.ino b/speeduino/corrections.ino index e7dca660..385834fa 100644 --- a/speeduino/corrections.ino +++ b/speeduino/corrections.ino @@ -29,6 +29,7 @@ unsigned long knockStartTime; byte lastKnockCount; int16_t knockWindowMin; //The current minimum crank angle for a knock pulse to be valid int16_t knockWindowMax;//The current maximum crank angle for a knock pulse to be valid +uint16_t aseTaperStart; uint16_t dfcoStart; void initialiseCorrections() @@ -220,13 +221,14 @@ byte correctionASE() { BIT_SET(currentStatus.engine, BIT_ENGINE_ASE); //Mark ASE as active. ASEValue = 100 + table2D_getValue(&ASETable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); + aseTaperStart = runSecsX10; } else { - if ( (!BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK)) && (runSecsX10 < configPage2.aseTaperTime) ) //Cranking check needs to be here also, so cranking and afterstart enrichments won't run simultaneously + if ( (!BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK)) && ((runSecsX10 - aseTaperStart) < configPage2.aseTaperTime) ) //Cranking check needs to be here also, so cranking and afterstart enrichments won't run simultaneously { BIT_SET(currentStatus.engine, BIT_ENGINE_ASE); //Mark ASE as active. - ASEValue = 100 + map(runSecsX10, 0, configPage2.aseTaperTime,\ + ASEValue = 100 + map((runSecsX10 - aseTaperStart), 0, configPage2.aseTaperTime,\ table2D_getValue(&ASETable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET), 0); } else From c3291e876857bf924b3e9aaae05ce5b32696238a Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Fri, 5 Jun 2020 09:30:06 +1000 Subject: [PATCH 2/3] Minor corrections on HW test modes --- speeduino/TS_CommandButtonHandler.ino | 110 +++++++++++++++----------- speeduino/globals.h | 18 +++++ speeduino/timers.ino | 32 ++++---- 3 files changed, 96 insertions(+), 64 deletions(-) diff --git a/speeduino/TS_CommandButtonHandler.ino b/speeduino/TS_CommandButtonHandler.ino index 48db7455..f99d27a6 100644 --- a/speeduino/TS_CommandButtonHandler.ino +++ b/speeduino/TS_CommandButtonHandler.ino @@ -31,6 +31,20 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) endCoil2Charge(); endCoil3Charge(); endCoil4Charge(); + #if IGN_CHANNELS >= 5 + endCoil5Charge(); + #endif + #if IGN_CHANNELS >= 6 + endCoil6Charge(); + #endif + #if IGN_CHANNELS >= 7 + endCoil7Charge(); + #endif + #if IGN_CHANNELS >= 8 + endCoil8Charge(); + #endif + + closeInjector1(); closeInjector2(); closeInjector3(); @@ -62,12 +76,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_INJ1_OFF: // cmd group is for injector1 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector1(); BIT_CLEAR(HWTest_INJ_50pc, 1); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector1(); BIT_CLEAR(HWTest_INJ_50pc, INJ1_CMD_BIT); } break; case TS_CMD_INJ1_50PC: // cmd group is for injector1 50% dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, 1); } - if(!BIT_CHECK(HWTest_INJ_50pc, 1)) { closeInjector1(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, INJ1_CMD_BIT); } + if(!BIT_CHECK(HWTest_INJ_50pc, INJ1_CMD_BIT)) { closeInjector1(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_INJ2_ON: // cmd group is for injector2 on actions @@ -75,12 +89,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_INJ2_OFF: // cmd group is for injector2 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector2(); BIT_CLEAR(HWTest_INJ_50pc, 2); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector2(); BIT_CLEAR(HWTest_INJ_50pc, INJ2_CMD_BIT); } break; case TS_CMD_INJ2_50PC: // cmd group is for injector2 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, 2); } - if(!BIT_CHECK(HWTest_INJ_50pc, 2)) { closeInjector2(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, INJ2_CMD_BIT); } + if(!BIT_CHECK(HWTest_INJ_50pc, INJ2_CMD_BIT)) { closeInjector2(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_INJ3_ON: // cmd group is for injector3 on actions @@ -88,12 +102,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_INJ3_OFF: // cmd group is for injector3 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector3(); BIT_CLEAR(HWTest_INJ_50pc, 3); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector3(); BIT_CLEAR(HWTest_INJ_50pc, INJ3_CMD_BIT); } break; case TS_CMD_INJ3_50PC: // cmd group is for injector3 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, 3); } - if(!BIT_CHECK(HWTest_INJ_50pc, 3)) { closeInjector3(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, INJ3_CMD_BIT); } + if(!BIT_CHECK(HWTest_INJ_50pc, INJ3_CMD_BIT)) { closeInjector3(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_INJ4_ON: // cmd group is for injector4 on actions @@ -101,12 +115,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_INJ4_OFF: // cmd group is for injector4 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector4(); BIT_CLEAR(HWTest_INJ_50pc, 4); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector4(); BIT_CLEAR(HWTest_INJ_50pc, INJ4_CMD_BIT); } break; case TS_CMD_INJ4_50PC: // cmd group is for injector4 50% dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, 4); } - if(!BIT_CHECK(HWTest_INJ_50pc, 4)) { closeInjector4(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, INJ4_CMD_BIT); } + if(!BIT_CHECK(HWTest_INJ_50pc, INJ4_CMD_BIT)) { closeInjector4(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_INJ5_ON: // cmd group is for injector5 on actions @@ -114,12 +128,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_INJ5_OFF: // cmd group is for injector5 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector5(); BIT_CLEAR(HWTest_INJ_50pc, 5); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector5(); BIT_CLEAR(HWTest_INJ_50pc, INJ5_CMD_BIT); } break; case TS_CMD_INJ5_50PC: // cmd group is for injector5 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, 5); } - if(!BIT_CHECK(HWTest_INJ_50pc, 5)) { closeInjector5(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, INJ5_CMD_BIT); } + if(!BIT_CHECK(HWTest_INJ_50pc, INJ5_CMD_BIT)) { closeInjector5(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_INJ6_ON: // cmd group is for injector6 on actions @@ -127,12 +141,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_INJ6_OFF: // cmd group is for injector6 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector6(); BIT_CLEAR(HWTest_INJ_50pc, 6); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector6(); BIT_CLEAR(HWTest_INJ_50pc, INJ6_CMD_BIT); } break; case TS_CMD_INJ6_50PC: // cmd group is for injector6 50% dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, 6); } - if(!BIT_CHECK(HWTest_INJ_50pc, 6)) { closeInjector6(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, INJ6_CMD_BIT); } + if(!BIT_CHECK(HWTest_INJ_50pc, INJ6_CMD_BIT)) { closeInjector6(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_INJ7_ON: // cmd group is for injector7 on actions @@ -140,12 +154,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_INJ7_OFF: // cmd group is for injector7 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector7(); BIT_CLEAR(HWTest_INJ_50pc, 7); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector7(); BIT_CLEAR(HWTest_INJ_50pc, INJ7_CMD_BIT); } break; case TS_CMD_INJ7_50PC: // cmd group is for injector7 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, 7); } - if(!BIT_CHECK(HWTest_INJ_50pc, 7)) { closeInjector7(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, INJ7_CMD_BIT); } + if(!BIT_CHECK(HWTest_INJ_50pc, INJ7_CMD_BIT)) { closeInjector7(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_INJ8_ON: // cmd group is for injector8 on actions @@ -153,12 +167,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_INJ8_OFF: // cmd group is for injector8 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector8(); BIT_CLEAR(HWTest_INJ_50pc, 8); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ){ closeInjector8(); BIT_CLEAR(HWTest_INJ_50pc, INJ8_CMD_BIT); } break; case TS_CMD_INJ8_50PC: // cmd group is for injector8 50% dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, 8); } - if(!BIT_CHECK(HWTest_INJ_50pc, 8)) { closeInjector8(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_INJ_50pc, INJ8_CMD_BIT); } + if(!BIT_CHECK(HWTest_INJ_50pc, INJ8_CMD_BIT)) { closeInjector8(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_IGN1_ON: // cmd group is for spark1 on actions @@ -166,12 +180,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_IGN1_OFF: // cmd group is for spark1 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil1Charge(); BIT_CLEAR(HWTest_IGN_50pc, 1); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil1Charge(); BIT_CLEAR(HWTest_IGN_50pc, IGN1_CMD_BIT); } break; case TS_CMD_IGN1_50PC: // cmd group is for spark1 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, 1); } - if(!BIT_CHECK(HWTest_IGN_50pc, 1)) { coil1Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, IGN1_CMD_BIT); } + if(!BIT_CHECK(HWTest_IGN_50pc, IGN1_CMD_BIT)) { coil1Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_IGN2_ON: // cmd group is for spark2 on actions @@ -179,12 +193,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_IGN2_OFF: // cmd group is for spark2 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil2Charge(); BIT_CLEAR(HWTest_IGN_50pc, 2); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil2Charge(); BIT_CLEAR(HWTest_IGN_50pc, IGN2_CMD_BIT); } break; case TS_CMD_IGN2_50PC: // cmd group is for spark2 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, 2); } - if(!BIT_CHECK(HWTest_IGN_50pc, 2)) { coil2Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, IGN2_CMD_BIT); } + if(!BIT_CHECK(HWTest_IGN_50pc, IGN2_CMD_BIT)) { coil2Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_IGN3_ON: // cmd group is for spark3 on actions @@ -192,12 +206,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_IGN3_OFF: // cmd group is for spark3 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil3Charge(); BIT_CLEAR(HWTest_IGN_50pc, 3); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil3Charge(); BIT_CLEAR(HWTest_IGN_50pc, IGN3_CMD_BIT); } break; case TS_CMD_IGN3_50PC: // cmd group is for spark3 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, 3); } - if(!BIT_CHECK(HWTest_IGN_50pc, 3)) { coil3Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, IGN3_CMD_BIT); } + if(!BIT_CHECK(HWTest_IGN_50pc, IGN3_CMD_BIT)) { coil3Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_IGN4_ON: // cmd group is for spark4 on actions @@ -205,12 +219,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_IGN4_OFF: // cmd group is for spark4 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil4Charge(); BIT_CLEAR(HWTest_IGN_50pc, 4); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil4Charge(); BIT_CLEAR(HWTest_IGN_50pc, IGN4_CMD_BIT); } break; case TS_CMD_IGN4_50PC: // cmd group is for spark4 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, 4); } - if(!BIT_CHECK(HWTest_IGN_50pc, 4)) { coil4Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, IGN4_CMD_BIT); } + if(!BIT_CHECK(HWTest_IGN_50pc, IGN4_CMD_BIT)) { coil4Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_IGN5_ON: // cmd group is for spark5 on actions @@ -218,12 +232,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_IGN5_OFF: // cmd group is for spark5 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil5Charge(); BIT_CLEAR(HWTest_IGN_50pc, 5); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil5Charge(); BIT_CLEAR(HWTest_IGN_50pc, IGN5_CMD_BIT); } break; case TS_CMD_IGN5_50PC: // cmd group is for spark4 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, 5); } - if(!BIT_CHECK(HWTest_IGN_50pc, 5)) { coil5Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, IGN5_CMD_BIT); } + if(!BIT_CHECK(HWTest_IGN_50pc, IGN5_CMD_BIT)) { coil5Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_IGN6_ON: // cmd group is for spark6 on actions @@ -231,12 +245,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_IGN6_OFF: // cmd group is for spark6 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil6Charge(); BIT_CLEAR(HWTest_IGN_50pc, 6); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil6Charge(); BIT_CLEAR(HWTest_IGN_50pc, IGN6_CMD_BIT); } break; case TS_CMD_IGN6_50PC: // cmd group is for spark6 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, 6); } - if(!BIT_CHECK(HWTest_IGN_50pc, 6)) { coil6Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, IGN6_CMD_BIT); } + if(!BIT_CHECK(HWTest_IGN_50pc, IGN6_CMD_BIT)) { coil6Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_IGN7_ON: // cmd group is for spark7 on actions @@ -244,12 +258,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_IGN7_OFF: // cmd group is for spark7 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil7Charge(); BIT_CLEAR(HWTest_IGN_50pc, 7); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil7Charge(); BIT_CLEAR(HWTest_IGN_50pc, IGN7_CMD_BIT); } break; case TS_CMD_IGN7_50PC: // cmd group is for spark7 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, 7); } - if(!BIT_CHECK(HWTest_IGN_50pc, 7)) { coil7Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, IGN7_CMD_BIT); } + if(!BIT_CHECK(HWTest_IGN_50pc, IGN7_CMD_BIT)) { coil7Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; case TS_CMD_IGN8_ON: // cmd group is for spark8 on actions @@ -257,12 +271,12 @@ uint16_t TS_CommandButtonsHandler(int buttonCommand) break; case TS_CMD_IGN8_OFF: // cmd group is for spark8 off actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil8Charge(); BIT_CLEAR(HWTest_IGN_50pc, 8); } + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { endCoil8Charge(); BIT_CLEAR(HWTest_IGN_50pc, IGN8_CMD_BIT); } break; case TS_CMD_IGN8_50PC: // cmd group is for spark8 50%dc actions - if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, 8); } - if(!BIT_CHECK(HWTest_IGN_50pc, 8)) { coil8Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) + if( BIT_CHECK(currentStatus.testOutputs, 1) ) { BIT_TOGGLE(HWTest_IGN_50pc, IGN8_CMD_BIT); } + if(!BIT_CHECK(HWTest_IGN_50pc, IGN8_CMD_BIT)) { coil8Low(); } //Ensure this output is turned off (Otherwise the output may stay on permanently) break; //VSS Calibration routines diff --git a/speeduino/globals.h b/speeduino/globals.h index 456f32a1..807a5818 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -270,6 +270,24 @@ #define BATTV_COR_MODE_WHOLE 0 #define BATTV_COR_MODE_OPENTIME 1 +#define INJ1_CMD_BIT 0 +#define INJ2_CMD_BIT 1 +#define INJ3_CMD_BIT 2 +#define INJ4_CMD_BIT 3 +#define INJ5_CMD_BIT 4 +#define INJ6_CMD_BIT 5 +#define INJ7_CMD_BIT 6 +#define INJ8_CMD_BIT 7 + +#define IGN1_CMD_BIT 0 +#define IGN2_CMD_BIT 1 +#define IGN3_CMD_BIT 2 +#define IGN4_CMD_BIT 3 +#define IGN5_CMD_BIT 4 +#define IGN6_CMD_BIT 5 +#define IGN7_CMD_BIT 6 +#define IGN8_CMD_BIT 7 + //Table sizes #define CALIBRATION_TABLE_SIZE 512 #define CALIBRATION_TEMPERATURE_OFFSET 40 // All temperature measurements are stored offset by 40 degrees. This is so we can use an unsigned byte (0-255) to represent temperature ranges from -40 to 215 diff --git a/speeduino/timers.ino b/speeduino/timers.ino index 72e250c6..761c5c5b 100644 --- a/speeduino/timers.ino +++ b/speeduino/timers.ino @@ -233,24 +233,24 @@ void oneMSInterval() //Most ARM chips can simply call a function //Check whether any of the fuel outputs is on //Check for injector outputs on 50% - if(BIT_CHECK(HWTest_INJ_50pc, 1)) { injector1Toggle(); } - if(BIT_CHECK(HWTest_INJ_50pc, 2)) { injector2Toggle(); } - if(BIT_CHECK(HWTest_INJ_50pc, 3)) { injector3Toggle(); } - if(BIT_CHECK(HWTest_INJ_50pc, 4)) { injector4Toggle(); } - if(BIT_CHECK(HWTest_INJ_50pc, 5)) { injector5Toggle(); } - if(BIT_CHECK(HWTest_INJ_50pc, 6)) { injector6Toggle(); } - if(BIT_CHECK(HWTest_INJ_50pc, 7)) { injector7Toggle(); } - if(BIT_CHECK(HWTest_INJ_50pc, 8)) { injector8Toggle(); } + if(BIT_CHECK(HWTest_INJ_50pc, INJ1_CMD_BIT)) { injector1Toggle(); } + if(BIT_CHECK(HWTest_INJ_50pc, INJ2_CMD_BIT)) { injector2Toggle(); } + if(BIT_CHECK(HWTest_INJ_50pc, INJ3_CMD_BIT)) { injector3Toggle(); } + if(BIT_CHECK(HWTest_INJ_50pc, INJ4_CMD_BIT)) { injector4Toggle(); } + if(BIT_CHECK(HWTest_INJ_50pc, INJ5_CMD_BIT)) { injector5Toggle(); } + if(BIT_CHECK(HWTest_INJ_50pc, INJ6_CMD_BIT)) { injector6Toggle(); } + if(BIT_CHECK(HWTest_INJ_50pc, INJ7_CMD_BIT)) { injector7Toggle(); } + if(BIT_CHECK(HWTest_INJ_50pc, INJ8_CMD_BIT)) { injector8Toggle(); } //Check for ignition outputs on 50% - if(BIT_CHECK(HWTest_IGN_50pc, 1)) { coil1Toggle(); } - if(BIT_CHECK(HWTest_IGN_50pc, 2)) { coil2Toggle(); } - if(BIT_CHECK(HWTest_IGN_50pc, 3)) { coil3Toggle(); } - if(BIT_CHECK(HWTest_IGN_50pc, 4)) { coil4Toggle(); } - if(BIT_CHECK(HWTest_IGN_50pc, 5)) { coil5Toggle(); } - if(BIT_CHECK(HWTest_IGN_50pc, 6)) { coil6Toggle(); } - if(BIT_CHECK(HWTest_IGN_50pc, 7)) { coil7Toggle(); } - if(BIT_CHECK(HWTest_IGN_50pc, 8)) { coil8Toggle(); } + if(BIT_CHECK(HWTest_IGN_50pc, IGN1_CMD_BIT)) { coil1Toggle(); } + if(BIT_CHECK(HWTest_IGN_50pc, IGN2_CMD_BIT)) { coil2Toggle(); } + if(BIT_CHECK(HWTest_IGN_50pc, IGN3_CMD_BIT)) { coil3Toggle(); } + if(BIT_CHECK(HWTest_IGN_50pc, IGN4_CMD_BIT)) { coil4Toggle(); } + if(BIT_CHECK(HWTest_IGN_50pc, IGN5_CMD_BIT)) { coil5Toggle(); } + if(BIT_CHECK(HWTest_IGN_50pc, IGN6_CMD_BIT)) { coil6Toggle(); } + if(BIT_CHECK(HWTest_IGN_50pc, IGN7_CMD_BIT)) { coil7Toggle(); } + if(BIT_CHECK(HWTest_IGN_50pc, IGN8_CMD_BIT)) { coil8Toggle(); } } } From 940a6826b52b3393bfa730c9e9ef64000bb77246 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Sat, 6 Jun 2020 10:52:27 +1000 Subject: [PATCH 3/3] Initial work on engine protection system --- reference/speeduino.ini | 44 ++++++++++++++++---- speeduino/comms.ino | 3 +- speeduino/corrections.ino | 4 +- speeduino/engineProtection.h | 8 ++++ speeduino/engineProtection.ino | 75 ++++++++++++++++++++++++++++++++++ speeduino/globals.h | 20 +++++++-- speeduino/globals.ino | 1 + speeduino/init.ino | 9 +++- speeduino/speeduino.ino | 35 ++-------------- 9 files changed, 151 insertions(+), 48 deletions(-) create mode 100644 speeduino/engineProtection.h create mode 100644 speeduino/engineProtection.ino diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 10ff8dd6..08c137a2 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -500,7 +500,9 @@ page = 4 idleAdvBins = array, U08, 108, [6], "RPM", 10.0, -50, -500, 500, 0 idleAdvValues = array, U08, 114, [6], "deg", 1.0, -15, -15, 50, 0 - unused4-120 = array, U08, 120, [8], "%", 1.0, 0.0, 0.0, 255, 0 + engineProtectMaxRPM = scalar, U08, 120, "rpm", 100, 0.0, 100, 25500, 0 + + unused4-120 = array, U08, 121, [7], "%", 1.0, 0.0, 0.0, 255, 0 ;-------------------------------------------------- ;Start AFR page @@ -524,7 +526,7 @@ page = 6 egoType = bits , U08, 0, [2:3], "Disabled", "Narrow Band", "Wide Band", "INVALID" ; egoOption boostEnabled = bits, U08, 0, [4:4], "Off", "On" vvtEnabled = bits, U08, 0, [5:5], "Off", "On" - boostCutType = bits, U08, 0, [6:7], "Off", "Spark Only", "Fuel Only","Both" + engineProtectType = bits, U08, 0, [6:7], "Off", "Spark Only", "Fuel Only","Both" egoKP = scalar, U08, 1, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte) egoKI = scalar, U08, 2, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte) @@ -1031,17 +1033,20 @@ page = 10 ;Pressure transducers fuelPressureEnable = bits, U08, 135, [0:0], "Off", "On" oilPressureEnable = bits, U08, 135, [1:1], "Off", "On" + oilPressureProtEnbl = bits, U08, 135, [2:2], "Off", "On" fuelPressurePin = bits, U08, 136, [0:3], "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A8", "A10", "A11", "A12", "A13", "A14", "A15" oilPressurePin = bits, U08, 136, [4:7], "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A8", "A10", "A11", "A12", "A13", "A14", "A15" - fuelPressureMin = scalar, S08, 137, "kpa", 1.0, 0.0, -100, 127, 0 ;Note signed int - fuelPressureMax = scalar, U08, 138, "kpa", 1.0, 0.0, 0.0, 255, 0 - oilPressureMin = scalar, S08, 139, "kpa", 1.0, 0.0, -100, 127, 0 ;Note signed int - oilPressureMax = scalar, U08, 140, "kpa", 1.0, 0.0, 0.0, 255, 0 + fuelPressureMin = scalar, S08, 137, "psi", 1.0, 0.0, -100, 127, 0 ;Note signed int + fuelPressureMax = scalar, U08, 138, "psi", 1.0, 0.0, 0.0, 255, 0 + oilPressureMin = scalar, S08, 139, "psi", 1.0, 0.0, -100, 127, 0 ;Note signed int + oilPressureMax = scalar, U08, 140, "psi", 1.0, 0.0, 0.0, 255, 0 + + oilPressureProtRPM = array, U08, 141, [ 4], "RPM", 100.0, 0.0, 100.0, 25500, 0 + oilPressureProtMins = array, U08, 145, [ 4], "psi", 1.0, 0.0, 0.0, 255, 0 - unused11_135_191 = array, U08, 141, [50], "RPM", 100.0, 0.0, 100, 25500, 0 - ;unused11_135_191 = array, U08, 135, [56], "RPM", 100.0, 0.0, 100, 25500, 0 + unused11_135_191 = array, U08, 149, [42], "RPM", 100.0, 0.0, 100, 25500, 0 ;Page 11 is the fuel map and axis bins only page = 11 @@ -2477,6 +2482,8 @@ menuDialog = main settingOption = "0-150 PSI", oilPressureMin=-18, oilPressureMax=168 ; Vout = VCC x (P x 0.8 / 150 + 0.1) https://aftermarketindustries.com.au/image/cache/data/aftermarket%20industries%20fuel%20pressure%20sensor%20data%202-500x500.png field = "Pressure at 0v", oilPressureMin, { oilPressureEnable } field = "Pressure at 5v", oilPressureMax, { oilPressureEnable } + field = "Oil Pressure Protection", oilPressureProtEnbl, { oilPressureEnable } + panel = oil_pressure_prot_curve, { oilPressureEnable } dialog = oilPressureDialog, "Oil Pressure", xAxis gauge = oilPressureGauge @@ -3530,6 +3537,15 @@ cmdVSSratio6 = "E\x99\x06" yBins = knock_window_dur size = 400, 200 +; Oil Pressure protection curve + curve = oil_pressure_prot_curve, "Oil Pressure Protection" + columnLabel = "RPM", "Minimum PSI" + xAxis = 0, 8000, 9 + yAxis = 0, 150, 3 + xBins = oilPressureProtRPM, rpm + yBins = oilPressureProtMins + size = 400, 200 + ; Warmup enrichment VEAL AFR adjustment curves curve = warmup_afr_curve, "Target Adjustment" columnLabel = "Coolant", "Offset" @@ -3815,6 +3831,12 @@ cmdVSSratio6 = "E\x99\x06" indicator = { resetLockOn }, "Reset Lock OFF","Reset Lock ON", red, black, green, black indicator = { bootloaderCaps > 0 }, "Std. Boot", "Custom Boot", white, black, white, black indicator = { nitrousOn }, "Nitrous Off", "Nitrous On", white, black, red, black + ;Engine Protection status indicators + indicator = { engineProtectStatus}, "Engine Protect OFF", "Engine Protect ON", white, black, red, black + indicator = { engineProtectRPM }, "Rev Limiter Off", "Rev Limiter ON", white, black, red, black + indicator = { engineProtectMAP }, "Boost Limit OFF", "Boost Limit ON", white, black, red, black + indicator = { engineProtectOil }, "Oil Pres. Protect OFF","Oil Pres. Protect ON",white, black, red, black + indicator = { engineProtectAFR }, "AFR Protect OFF", "AFR Protect ON", white, black, red, black ;------------------------------------------------------------------------------- @@ -3920,6 +3942,12 @@ cmdVSSratio6 = "E\x99\x06" vssRefresh = bits, U08, 83, [3:3] unused81_4 = bits, U08, 83, [4:4] nSquirts = bits, U08, 83, [5:7] + engineProtectStatus = scalar, U08, 84, "bits", 1.000, 0.000 + engineProtectRPM = bits, U08, 84, [0:0] + engineProtectMAP = bits, U08, 84, [1:1] + engineProtectOil = bits, U08, 84, [2:2] + engineProtectAFR = bits, U08, 84, [3:3] + engineProtectOth = bits, U08, 84, [4:7] ; Unused for now unused1 = scalar, U08, 84, "ADC",1.000, 0.000 fuelLoad = scalar, S16, 85, { bitStringValue( algorithmUnits , algorithm ) }, 1.000, 0.000 ignLoad = scalar, S16, 87, { bitStringValue( algorithmUnits , ignAlgorithm ) }, 1.000, 0.000 diff --git a/speeduino/comms.ino b/speeduino/comms.ino index 1bf0b7d2..a9994e49 100644 --- a/speeduino/comms.ino +++ b/speeduino/comms.ino @@ -629,8 +629,7 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum) fullStatus[82] = highByte(currentStatus.PW4); //Pulsewidth 4 multiplied by 10 in ms. Have to convert from uS to mS. fullStatus[83] = currentStatus.status3; - - fullStatus[84] = currentStatus.nChannels; //THIS IS CURRENTLY UNUSED! + fullStatus[84] = currentStatus.engineProtectStatus; fullStatus[85] = lowByte(currentStatus.fuelLoad); fullStatus[86] = highByte(currentStatus.fuelLoad); fullStatus[87] = lowByte(currentStatus.ignLoad); diff --git a/speeduino/corrections.ino b/speeduino/corrections.ino index 385834fa..f91244cc 100644 --- a/speeduino/corrections.ino +++ b/speeduino/corrections.ino @@ -773,8 +773,8 @@ int8_t correctionKnock(int8_t advance) //First check is to do the window calculations (ASsuming knock is enabled) if( configPage10.knock_mode != KNOCK_MODE_OFF ) { - knockWindowMin = table2D_getValue(&knockWindowStartTable, currentStatus.RPM); - knockWindowMax = knockWindowMin + table2D_getValue(&knockWindowDurationTable, currentStatus.RPM); + knockWindowMin = table2D_getValue(&knockWindowStartTable, currentStatus.RPMdiv100); + knockWindowMax = knockWindowMin + table2D_getValue(&knockWindowDurationTable, currentStatus.RPMdiv100); } diff --git a/speeduino/engineProtection.h b/speeduino/engineProtection.h new file mode 100644 index 00000000..a39878b1 --- /dev/null +++ b/speeduino/engineProtection.h @@ -0,0 +1,8 @@ + + + + +byte checkEngineProtect(); +byte checkBoostLimit(); +byte checkOilPressureLimit(); +byte checkAFRLimit(); \ No newline at end of file diff --git a/speeduino/engineProtection.ino b/speeduino/engineProtection.ino new file mode 100644 index 00000000..874f5f57 --- /dev/null +++ b/speeduino/engineProtection.ino @@ -0,0 +1,75 @@ + +#include "globals.h" +#include "engineProtection.h" + +byte checkEngineProtect() +{ + byte protectActive = 0; + if(checkBoostLimit() || checkOilPressureLimit() || checkAFRLimit()) + { + if(currentStatus.RPM > (configPage4.engineProtectMaxRPM*100U)) { protectActive = 1; } + } + + return protectActive; +} + +byte checkBoostLimit() +{ + byte boostLimitActive = 0; + //Boost cutoff is very similar to launchControl, but with a check against MAP rather than a switch + if( (configPage6.boostCutType > 0) && (currentStatus.MAP > (configPage6.boostLimit * 2)) ) //The boost limit is divided by 2 to allow a limit up to 511kPa + { + boostLimitActive = 1; + switch(configPage6.boostCutType) + { + case 1: + BIT_SET(currentStatus.spark, BIT_SPARK_BOOSTCUT); + BIT_CLEAR(currentStatus.status1, BIT_STATUS1_BOOSTCUT); + BIT_SET(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_MAP); + break; + case 2: + BIT_SET(currentStatus.status1, BIT_STATUS1_BOOSTCUT); + BIT_CLEAR(currentStatus.spark, BIT_SPARK_BOOSTCUT); + break; + case 3: + BIT_SET(currentStatus.spark, BIT_SPARK_BOOSTCUT); + BIT_SET(currentStatus.status1, BIT_STATUS1_BOOSTCUT); + break; + default: + //Shouldn't ever happen, but just in case, disable all cuts + BIT_CLEAR(currentStatus.status1, BIT_STATUS1_BOOSTCUT); + BIT_CLEAR(currentStatus.spark, BIT_SPARK_BOOSTCUT); + } + } + else + { + BIT_CLEAR(currentStatus.spark, BIT_SPARK_BOOSTCUT); + BIT_CLEAR(currentStatus.status1, BIT_STATUS1_BOOSTCUT); + } + + return boostLimitActive; +} + +byte checkOilPressureLimit() +{ + byte oilProtectActive = 0; + BIT_CLEAR(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_OIL); //Will be set true below if required + + if(configPage10.oilPressureProtEnbl == true) + { + byte oilLimit = table2D_getValue(&oilPressureProtectTable, currentStatus.RPMdiv100); + if(currentStatus.oilPressure < oilLimit) + { + BIT_SET(currentStatus.engineProtectStatus, ENGINE_PROTECT_BIT_OIL); + oilProtectActive = 1; + } + } + + return oilProtectActive; +} + +byte checkAFRLimit() +{ + +} + diff --git a/speeduino/globals.h b/speeduino/globals.h index 51b3fd50..e8f3ee1a 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -288,6 +288,11 @@ #define IGN7_CMD_BIT 6 #define IGN8_CMD_BIT 7 +#define ENGINE_PROTECT_BIT_RPM 0 +#define ENGINE_PROTECT_BIT_MAP 1 +#define ENGINE_PROTECT_BIT_OIL 2 +#define ENGINE_PROTECT_BIT_AFR 3 + //Table sizes #define CALIBRATION_TABLE_SIZE 512 #define CALIBRATION_TEMPERATURE_OFFSET 40 // All temperature measurements are stored offset by 40 degrees. This is so we can use an unsigned byte (0-255) to represent temperature ranges from -40 to 215 @@ -339,6 +344,7 @@ extern struct table2D flexAdvTable; //6 bin flex fuel correction table for tim extern struct table2D flexBoostTable; //6 bin flex fuel correction table for boost adjustments (2D) extern struct table2D knockWindowStartTable; extern struct table2D knockWindowDurationTable; +extern struct table2D oilPressureProtectTable; //These are for the direct port manipulation of the injectors, coils and aux outputs extern volatile PORT_TYPE *inj1_pin_port; @@ -460,6 +466,7 @@ extern volatile byte LOOP_TIMER; struct statuses { volatile bool hasSync; uint16_t RPM; + byte RPMdiv100; long longRPM; int mapADC; int baroADC; @@ -559,6 +566,7 @@ struct statuses { byte gear; /**< Current gear (Calculated from vss) */ byte fuelPressure; /**< Fuel pressure in PSI */ byte oilPressure; /**< Oil pressure in PSI */ + byte engineProtectStatus; }; /** @@ -791,7 +799,9 @@ struct config4 { byte idleAdvBins[6]; byte idleAdvValues[6]; - byte unused4_120[8]; + byte engineProtectMaxRPM; + + byte unused4_120[7]; #if defined(CORE_AVR) }; @@ -1088,7 +1098,8 @@ struct config10 { byte fuelPressureEnable : 1; byte oilPressureEnable : 1; - byte unused10_135 : 6; + byte oilPressureProtEnbl : 1; + byte unused10_135 : 5; byte fuelPressurePin : 4; byte oilPressurePin : 4; @@ -1098,7 +1109,10 @@ struct config10 { int8_t oilPressureMin; byte oilPressureMax; - byte unused11_135_191[51]; //Bytes 135-191 + byte oilPressureProtRPM[4]; + byte oilPressureProtMins[4]; + + byte unused11_135_191[43]; //Bytes 135-191 #if defined(CORE_AVR) }; diff --git a/speeduino/globals.ino b/speeduino/globals.ino index c190aa62..a4764493 100644 --- a/speeduino/globals.ino +++ b/speeduino/globals.ino @@ -38,6 +38,7 @@ struct table2D flexAdvTable; //6 bin flex fuel correction table for timing adv struct table2D flexBoostTable; //6 bin flex fuel correction table for boost adjustments (2D) struct table2D knockWindowStartTable; struct table2D knockWindowDurationTable; +struct table2D oilPressureProtectTable; //These are for the direct port manipulation of the injectors, coils and aux outputs volatile PORT_TYPE *inj1_pin_port; diff --git a/speeduino/init.ino b/speeduino/init.ino index 2ceecf81..0c4e3604 100644 --- a/speeduino/init.ino +++ b/speeduino/init.ino @@ -182,6 +182,12 @@ void initialiseAll() knockWindowDurationTable.values = configPage10.knock_window_dur; knockWindowDurationTable.axisX = configPage10.knock_window_rpms; + oilPressureProtectTable.valueSize = SIZE_BYTE; + oilPressureProtectTable.axisSize = SIZE_BYTE; //Set this table to use byte axis bins + oilPressureProtectTable.xSize = 4; + oilPressureProtectTable.values = configPage10.oilPressureProtMins; + oilPressureProtectTable.axisX = configPage10.oilPressureProtRPM; + //Setup the calibration tables loadCalibration(); @@ -316,6 +322,7 @@ void initialiseAll() currentStatus.launchingHard = false; currentStatus.crankRPM = ((unsigned int)configPage4.crankRPM * 10); //Crank RPM limit (Saves us calculating this over and over again. It's updated once per second in timers.ino) currentStatus.fuelPumpOn = false; + currentStatus.engineProtectStatus = 0; 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 dwellLimit_uS = (1000 * configPage4.dwellLimit); currentStatus.nChannels = ((uint8_t)INJ_CHANNELS << 4) + IGN_CHANNELS; //First 4 bits store the number of injection channels, 2nd 4 store the number of ignition channels @@ -325,7 +332,7 @@ void initialiseAll() timer5_overflow_count = 0; toothHistoryIndex = 0; toothHistorySerialIndex = 0; - + noInterrupts(); initialiseTriggers(); diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index 4fb6966d..9d304d77 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -35,6 +35,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "storage.h" #include "crankMaths.h" #include "init.h" +#include "engineProtection.h" #include BOARD_H //Note that this is not a real file, it is defined in globals.h. int ignition1StartAngle = 0; @@ -145,6 +146,7 @@ void loop() { currentStatus.longRPM = getRPM(); //Long RPM is included here currentStatus.RPM = currentStatus.longRPM; + currentStatus.RPMdiv100 = currentStatus.RPM / 100; FUEL_PUMP_ON(); currentStatus.fuelPumpOn = true; //Not sure if this is needed. } @@ -228,37 +230,6 @@ void loop() else { currentStatus.flatShiftingHard = false; } } - - - //Boost cutoff is very similar to launchControl, but with a check against MAP rather than a switch - if( (configPage6.boostCutType > 0) && (currentStatus.MAP > (configPage6.boostLimit * 2)) ) //The boost limit is divided by 2 to allow a limit up to 511kPa - { - switch(configPage6.boostCutType) - { - case 1: - BIT_SET(currentStatus.spark, BIT_SPARK_BOOSTCUT); - BIT_CLEAR(currentStatus.status1, BIT_STATUS1_BOOSTCUT); - break; - case 2: - BIT_SET(currentStatus.status1, BIT_STATUS1_BOOSTCUT); - BIT_CLEAR(currentStatus.spark, BIT_SPARK_BOOSTCUT); - break; - case 3: - BIT_SET(currentStatus.spark, BIT_SPARK_BOOSTCUT); - BIT_SET(currentStatus.status1, BIT_STATUS1_BOOSTCUT); - break; - default: - //Shouldn't ever happen, but just in case, disable all cuts - BIT_CLEAR(currentStatus.status1, BIT_STATUS1_BOOSTCUT); - BIT_CLEAR(currentStatus.spark, BIT_SPARK_BOOSTCUT); - } - } - else - { - BIT_CLEAR(currentStatus.spark, BIT_SPARK_BOOSTCUT); - BIT_CLEAR(currentStatus.status1, BIT_STATUS1_BOOSTCUT); - } - //And check whether the tooth log buffer is ready if(toothHistoryIndex > TOOTH_LOG_SIZE) { BIT_SET(currentStatus.status1, BIT_STATUS1_TOOTHLOG1READY); } @@ -932,7 +903,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 any of the hard cut rev limits being on - if(currentStatus.launchingHard || BIT_CHECK(currentStatus.spark, BIT_SPARK_BOOSTCUT) || BIT_CHECK(currentStatus.spark, BIT_SPARK_HRDLIM) || currentStatus.flatShiftingHard) + if(checkEngineProtect() || currentStatus.launchingHard || BIT_CHECK(currentStatus.spark, BIT_SPARK_HRDLIM) || currentStatus.flatShiftingHard) { if(configPage2.hardCutType == HARD_CUT_FULL) { ignitionOn = false; } else