diff --git a/globals.h b/globals.h index 31a56f8..6c73dc3 100644 --- a/globals.h +++ b/globals.h @@ -222,7 +222,7 @@ struct config3 { byte floodClear; //TPS value that triggers flood clear mode (No fuel whilst cranking) byte egoLoadMax; //Load (TPS or MAP) must be below this for closed loop to function byte egoLoadMin; //Load (TPS or MAP) must be above this for closed loop to function - byte dwellCorrectionBins[6]; //Correction table for dwell vs battery voltage + byte voltageCorrectionBins[6]; //X axis bins for voltage correction tables byte injVoltageCorrectionBins[6]; //Correction table for injector PW vs battery voltage byte unused107; byte unused108; diff --git a/scheduler.h b/scheduler.h index d6257c0..2682694 100644 --- a/scheduler.h +++ b/scheduler.h @@ -25,8 +25,12 @@ See page 136 of the processors datasheet: http://www.atmel.com/Images/doc2549.pd #ifndef SCHEDULER_H #define SCHEDULER_H -#include -#include +#ifdef __SAM3X8E__ + //Do stuff for ARM based CPUs +#else + #include + #include +#endif void initialiseSchedulers(); void setFuelSchedule1(void (*startCallback)(), unsigned long timeout, unsigned long duration, void(*endCallback)()); diff --git a/speeduino.ino b/speeduino.ino index ec653b8..8362eef 100644 --- a/speeduino.ino +++ b/speeduino.ino @@ -54,6 +54,8 @@ struct table3D ignitionTable; //8x8 ignition map struct table3D afrTable; //8x8 afr target map struct table2D taeTable; //4 bin TPS Acceleration Enrichment map (2D) struct table2D WUETable; //10 bin Warm Up Enrichment map (2D) +struct table2D dwellVCorrectionTable; //6 bin dwell voltage correction (2D) +struct table2D injectorVCorrectionTable; //6 bin injector voltage correction (2D) byte cltCalibrationTable[CALIBRATION_TABLE_SIZE]; byte iatCalibrationTable[CALIBRATION_TABLE_SIZE]; byte o2CalibrationTable[CALIBRATION_TABLE_SIZE]; @@ -104,6 +106,7 @@ void setup() WUETable.xSize = 10; WUETable.values = configPage1.wueValues; WUETable.axisX = configPage2.wueBins; + //The WUE X axis values are hard coded (Don't ask, they just are) WUETable.axisX[0] = 0; WUETable.axisX[1] = 11; WUETable.axisX[2] = 22; @@ -115,6 +118,15 @@ void setup() WUETable.axisX[8] = 94; WUETable.axisX[9] = 111; + dwellVCorrectionTable.valueSize = SIZE_BYTE; + dwellVCorrectionTable.xSize = 6; + dwellVCorrectionTable.values = configPage2.dwellCorrectionValues; + dwellVCorrectionTable.axisX = configPage3.voltageCorrectionBins; + injectorVCorrectionTable.valueSize = SIZE_BYTE; + injectorVCorrectionTable.xSize = 6; + injectorVCorrectionTable.values = configPage3.injVoltageCorrectionBins; + injectorVCorrectionTable.axisX = configPage3.voltageCorrectionBins; + //Setup the calibration tables loadCalibration(); //Set the pin mappings @@ -560,6 +572,12 @@ void closeInjector4() { digitalWrite(pinInjector4, LOW); BIT_CLEAR(currentStatus void beginCoil4Charge() { digitalWrite(pinCoil4, coilHIGH); BIT_SET(currentStatus.spark, 3); } void endCoil4Charge() { digitalWrite(pinCoil4, coilLOW); BIT_CLEAR(currentStatus.spark, 3); } +//Combination functions for semi-sequential injection +void openInjector1and4() { digitalWrite(pinInjector1, HIGH); digitalWrite(pinInjector4, HIGH); BIT_SET(currentStatus.squirt, 0); } +void closeInjector1and4() { digitalWrite(pinInjector1, LOW); digitalWrite(pinInjector4, LOW);BIT_CLEAR(currentStatus.squirt, 0); } +void openInjector2and3() { digitalWrite(pinInjector2, HIGH); digitalWrite(pinInjector3, HIGH); BIT_SET(currentStatus.squirt, 1); } +void closeInjector2and3() { digitalWrite(pinInjector2, LOW); digitalWrite(pinInjector3, LOW); BIT_CLEAR(currentStatus.squirt, 1); } + //The trigger function is called everytime a crank tooth passes the sensor volatile unsigned long curTime; volatile unsigned int curGap;