A bunch of setup work for MAE

This commit is contained in:
Josh Stewart 2019-05-22 07:47:09 +10:00
parent 2ac3d0c457
commit 105eeba8aa
9 changed files with 114 additions and 54 deletions

View File

@ -204,19 +204,20 @@
;Page 1 is all general settings. Note that some of these (algorithm and ignAlgorithm) MUST come before their use in the bitStringValue() calls in the fuel and ignition tables
;--------------------------------------------------
page = 1
unused2-1 = scalar, S08, 0, "kPa", 1.0, 0.0, -127, 127, 0
unused2-2 = scalar, U08, 1, "kPa", 1.0, 0.0, 0.0, 255, 0
unused2-3 = scalar, U08, 2, "%", 1.0, 0.0, 0.0, 95.0, 0 ;This used to be asePct
unused2-4 = scalar, U08, 3, "s", 1.0, 0.0, 0.0, 255, 0 ;This used to be aseCount
unused1-0 = scalar, S08, 0, "kPa", 1.0, 0.0, -127, 127, 0
unused1-1 = scalar, U08, 1, "kPa", 1.0, 0.0, 0.0, 255, 0
unused1-2 = scalar, U08, 2, "%", 1.0, 0.0, 0.0, 95.0, 0 ;This used to be asePct
aeMode = bits, U08, 3, [0:1], "TPS", "MAP", "INVALID", "INVALID"
unused1-3c = bits, U08, 3, [2:7], "MAP", "TPS", "INVALID", "INVALID"
wueRates = array, U08, 4, [10], "%", 1.0, 0.0, 0.0, 255, 0
crankingPct = scalar, U08, 14, "%", 1.0, 0.0, 0.0, 255, 0
pinLayout = bits, U08, 15, [0:7], "Speeduino v0.1", "Speeduino v0.2", "Speeduino v0.3", "Speeduino v0.4", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "NA6 MX5 PNP", "Turtana PCB", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "Plazomat I/O 0.1", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "Daz V6 Shield 0.1", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "NO2C", "UA4C", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "dvjcodec Teensy RevA", "dvjcodec Teensy RevB", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
tachoPin = bits, U08, 16, [0:5], "Board Default", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
tachoDiv = bits, U08, 16, [6:7], "Normal", "Half", "INVALID", "INVALID"
tachoDuration = scalar, U08, 17, "ms", 1.0, 0.0, 1.0, 6.0, 0
unused2-18 = scalar, U08, 18, "ms", 0.1, 0.0, 0.0, 25.5, 1
tpsThresh = scalar, U08, 19, "%/s", 1.0, 0.0, 0.0, 255, 0
taeTime = scalar, U08, 20, "ms", 10, 0.0, 0.0, 2550, 0
maeThresh = scalar, U08, 18, "kPa/s", 1.0, 0.0, 0.0, 255, 0 ;MAP threshold for triggering AE
taeThresh = scalar, U08, 19, "%/s", 1.0, 0.0, 0.0, 255, 0 ;TPS threshold for triggering AE
aeTime = scalar, U08, 20, "ms", 10, 0.0, 0.0, 2550, 0
; Display (Options for what the display is showing)
display = bits, U08, 21, [0:2], "Unused", "Adafruit 128x32", "Generic 128x32", "Adafruit 128x64", "Generic 128x64", "INVALID", "INVALID", "INVALID"
@ -284,8 +285,8 @@ page = 1
idleUpPolarity= bits, U08, 57, [6:6], "Normal", "Inverted"
idleUpEnabled = bits, U08, 57, [7:7], "Off", "On"
idleUpAdder = scalar, U08, 58, "% / Steps" 1.0, 0.0, 0.0, 250.0, 0
taeTaperMin = scalar, U08, 59, "RPM", 100, 0.0, 1000, 10000, 0
taeTaperMax = scalar, U08, 60, "RPM", 100, 0.0, 2000, 10000, 0
aeTaperMin = scalar, U08, 59, "RPM", 100, 0.0, 1000, 10000, 0
aeTaperMax = scalar, U08, 60, "RPM", 100, 0.0, 2000, 10000, 0
iacCLminDuty = scalar, U08, 61, "%", 1.0, 0.0, 0.0, 100.0, 0 ; Minimum and maximum duty cycles when using closed loop idle
iacCLmaxDuty = scalar, U08, 62, "%", 1.0, 0.0, 0.0, 100.0, 0
@ -430,7 +431,11 @@ page = 4
#endif
cltAdvValues = array, S08, 77, [ 6], "deg", 0.1, 0.0, -12.7, 12.7, 1
unused4-64 = array, U08, 83, [45], "%", 1.0, 0.0, 0.0, 255, 0
;MAP based acceleration enrichment
maeBins = array, U08, 83, [ 4], "kpa/s", 10.0, 0.0, 0.00, 2550.0, 0
maeRates = array, U08, 87, [ 4], "%", 1.0, 0.0, 0.00, 255.0, 0 ; 4 bytes
unused4-64 = array, U08, 91, [37], "%", 1.0, 0.0, 0.0, 255, 0
;--------------------------------------------------
;Start AFR page
@ -1105,8 +1110,9 @@ page = 11
defaultValue = lnchCtrlTPS, 0
defaultValue = resetControl, 0
defaultValue = bootloaderCaps, 0
defaultValue = taeTaperMin, 1000
defaultValue = taeTaperMax, 5000
defaultValue = aeTaperMin, 1000
defaultValue = aeTaperMax, 5000
defaultValue = aeMode, 0 ;Set aeMode to TPS
; defaultValue = obd_address, 0
;Default pins
@ -1336,7 +1342,7 @@ menuDialog = main
fanInv = ""
fanHyster = "The number of degrees of hysteresis to be used in controlling the fan. Recommended values are between 2 and 5"
taeTime = "The duration of the acceleration enrichment"
aeTime = "The duration of the acceleration enrichment"
iacChannels = "The number of output channels used for PWM valves. Select 1 for 2-wire valves or 2 for 3-wire valves."
iacStepTime = "Pause time between each step. Values that are too low can cause the motor to behave erratically or not at all"
@ -1641,11 +1647,13 @@ menuDialog = main
field = "Output speed", tachoDiv
field = "Pulse duration", tachoDuration
dialog = accelEnrichments_center, ""
field = "TPSdot Threshold", tpsThresh
field = "Accel Time", taeTime
field = "Taper Start RPM", taeTaperMin
field = "Taper End RPM", taeTaperMax
dialog = accelEnrichments_center, "Acceleration Enrichment"
field = "Enrichment mode", aeMode
field = "TPSdot Threshold", taeThresh, { aeMode == 0 }
field = "MAPdot Threshold", maeThresh, { aeMode == 1 }
field = "Accel Time", aeTime
field = "Taper Start RPM", aeTaperMin
field = "Taper End RPM", aeTaperMax
dialog = accelEnrichments_south, "Decelleration Fuel Cutoff (DFCO)"
field = "Enabled", dfcoEnabled
@ -1657,9 +1665,11 @@ menuDialog = main
liveGraph = pump_ae_Graph, "AE Graph"
graphLine = afr
graphLine = TPSdot, "%", -2000, 2000, auto, auto
graphLine = MAPdot, "%", -2000, 2000, auto, auto
dialog = accelEnrichments_north, "", xAxis
panel = time_accel_tpsdot_curve
panel = time_accel_tpsdot_curve, { aeMode == 0 }
panel = time_accel_mapdot_curve, { aeMode == 1 }
dialog = accelEnrichments, "Acceleration Enrichment"
topicHelp = "http://speeduino.com/wiki/index.php/Acceleration_Wizard"
@ -2712,14 +2722,21 @@ cmdtestspk450dc = "E\x03\x0C"
[CurveEditor]
;time-based accel enrichment
;tps-based accel enrichment
curve = time_accel_tpsdot_curve, "TPS based AE"
columnLabel = "TPSdot", "Added"
xAxis = 0, 1200, 6
yAxis = 0, 250, 4
xBins = taeBins, TPSdot
yBins = taeRates
;gauge = cltGauge
;map-based accel enrichment
curve = time_accel_mapdot_curve, "MAP based AE"
columnLabel = "MAPdot", "Added"
xAxis = 0, 1200, 6
yAxis = 0, 250, 4
xBins = maeBins, MAPdot
yBins = maeRates
; Correction curve for dwell vs battery voltage
curve = dwell_correction_curve, "Dwell voltage correction"
@ -3096,6 +3113,7 @@ cmdtestspk450dc = "E\x03\x0C"
mapGauge_psi = map_psi, "Engine MAP (PSI)", "PSI", -15, 100, 0, 20, 200, 245, 0, 0
mapGauge_bar = map_bar, "Engine MAP (BAR)", "Bar", -1, 3, -1, -1, 5, 5, 2, 2
mapGauge_vacBoost = map_vacboost, "Engine MAP (in-Hg/PSI)", "in-Hg/PSI", -30, 30, -30, -30, 30, 30, 1, 1
baroGauge = baro, "Baro Pressure", "kPa", 0, 255, 0, 20, 200, 245, 0, 0
batteryVoltage = batteryVoltage,"Battery Voltage", "volts", 0, 25, 8, 9, 15, 16, 2, 2
tpsADCGauge = tpsADC, "TPS ADC", "", 0, 255, -1, -1, 256, 256, 0, 0
@ -3192,7 +3210,7 @@ cmdtestspk450dc = "E\x03\x0C"
; you change it.
ochGetCommand = "r\$tsCanId\x30%2o%2c"
ochBlockSize = 92
ochBlockSize = 93
secl = scalar, U08, 0, "sec", 1.000, 0.000
status1 = scalar, U08, 1, "bits", 1.000, 0.000
@ -3292,7 +3310,7 @@ cmdtestspk450dc = "E\x03\x0C"
ignLoad = scalar, S16, 87, { bitStringValue( algorithmUnits , ignAlgorithm ) }, 1.000, 0.000
dwell = scalar, U16, 89, "ms", 0.001, 0.000
CLIdleTarget = scalar, U08, 91, "RPM", 10.00, 0.000
MAPdot = scalar, U08, 92, "kPa/s", 10.00, 0.000
#if CELSIUS
coolant = { coolantRaw - 40 } ; Temperature readings are offset by 40 to allow for negatives

View File

@ -165,7 +165,7 @@ void sendcanValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portTy
fullStatus[13] = currentStatus.wueCorrection; //Warmup enrichment (%)
fullStatus[14] = lowByte(currentStatus.RPM); //rpm HB
fullStatus[15] = highByte(currentStatus.RPM); //rpm LB
fullStatus[16] = currentStatus.TAEamount; //acceleration enrichment (%)
fullStatus[16] = currentStatus.AEamount; //acceleration enrichment (%)
fullStatus[17] = currentStatus.corrections; //Total GammaE (%)
fullStatus[18] = currentStatus.VE; //Current VE 1 (%)
fullStatus[19] = currentStatus.afrTarget;

View File

@ -513,7 +513,7 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum)
fullStatus[13] = currentStatus.wueCorrection; //Warmup enrichment (%)
fullStatus[14] = lowByte(currentStatus.RPM); //rpm HB
fullStatus[15] = highByte(currentStatus.RPM); //rpm LB
fullStatus[16] = (byte)(currentStatus.TAEamount >> 1); //TPS acceleration enrichment (%) divided by 2 (Can exceed 255)
fullStatus[16] = (byte)(currentStatus.AEamount >> 1); //TPS acceleration enrichment (%) divided by 2 (Can exceed 255)
fullStatus[17] = currentStatus.corrections; //Total GammaE (%)
fullStatus[18] = currentStatus.VE; //Current VE 1 (%)
fullStatus[19] = currentStatus.afrTarget;

View File

@ -53,8 +53,8 @@ static inline byte correctionsFuel()
if (result != 100) { sumCorrections = (sumCorrections * result); activeCorrections++; }
if (activeCorrections == 3) { sumCorrections = sumCorrections / powint(100,activeCorrections); activeCorrections = 0; } // Need to check this to ensure that sumCorrections doesn't overflow. Can occur when the number of corrections is greater than 3 (Which is 100^4) as 100^5 can overflow
currentStatus.TAEamount = correctionAccel();
if (currentStatus.TAEamount != 100) { sumCorrections = (sumCorrections * currentStatus.TAEamount); activeCorrections++; }
currentStatus.AEamount = correctionAccel();
if (currentStatus.AEamount != 100) { sumCorrections = (sumCorrections * currentStatus.AEamount); activeCorrections++; }
if (activeCorrections == 3) { sumCorrections = sumCorrections / powint(100,activeCorrections); activeCorrections = 0; }
result = correctionFloodClear();
@ -164,23 +164,23 @@ static inline int16_t correctionAccel()
if( BIT_CHECK(currentStatus.engine, BIT_ENGINE_ACC) )
{
//If it is currently running, check whether it should still be running or whether it's reached it's end time
if( micros_safe() >= currentStatus.TAEEndTime )
if( micros_safe() >= currentStatus.AEEndTime )
{
//Time to turn enrichment off
BIT_CLEAR(currentStatus.engine, BIT_ENGINE_ACC);
currentStatus.TAEamount = 0;
currentStatus.AEamount = 0;
accelValue = 100;
currentStatus.tpsDOT = 0;
}
else
{
//Enrichment still needs to keep running. Simply return the total TAE amount
accelValue = currentStatus.TAEamount;
accelValue = currentStatus.AEamount;
}
}
else
{
int8_t TPS_change = (currentStatus.TPS - currentStatus.TPSlast);
int8_t TPS_change = (currentStatus.TPS - TPSlast);
//Check for deceleration (Deceleration adjustment not yet supported)
//Also check for only very small movement (Movement less than or equal to 2% is ignored). This not only means we can skip the lookup, but helps reduce false triggering around 0-2% throttle openings
if (TPS_change <= 2)
@ -191,13 +191,13 @@ static inline int16_t correctionAccel()
else
{
//If TAE isn't currently turned on, need to check whether it needs to be turned on
int rateOfChange = ldiv(1000000, (currentStatus.TPS_time - currentStatus.TPSlast_time)).quot * TPS_change; //This is the % per second that the TPS has moved
int rateOfChange = ldiv(1000000, (TPS_time - TPSlast_time)).quot * TPS_change; //This is the % per second that the TPS has moved
currentStatus.tpsDOT = rateOfChange / 10; //The TAE bins are divided by 10 in order to allow them to be stored in a byte. Faster as this than divu10
if (rateOfChange > configPage2.tpsThresh)
if (rateOfChange > configPage2.taeThresh)
{
BIT_SET(currentStatus.engine, BIT_ENGINE_ACC); //Mark accleration enrichment as active.
currentStatus.TAEEndTime = micros_safe() + ((unsigned long)configPage2.aeTime * 10000); //Set the time in the future where the enrichment will be turned off. taeTime is stored as mS / 10, so multiply it by 100 to get it in uS
currentStatus.AEEndTime = micros_safe() + ((unsigned long)configPage2.aeTime * 10000); //Set the time in the future where the enrichment will be turned off. taeTime is stored as mS / 10, so multiply it by 100 to get it in uS
accelValue = table2D_getValue(&taeTable, currentStatus.tpsDOT);
//Apply the taper to the above

View File

@ -195,6 +195,9 @@
#define NITROUS_STAGE1 1
#define NITROUS_STAGE2 2
#define AE_MODE_TPS 0
#define AE_MODE_MAP 1
#define KNOCK_MODE_OFF 0
#define KNOCK_MODE_DIGITAL 1
#define KNOCK_MODE_ANALOG 2
@ -232,7 +235,7 @@ const char TSfirmwareVersion[] PROGMEM = "Speeduino";
const byte data_structure_version = 2; //This identifies the data structure when reading / writing.
#define NUM_PAGES 12
const uint16_t npage_size[NUM_PAGES] = {0,128,288,288,128,288,128,240,192,192,192,288};
const uint16_t npage_size[NUM_PAGES] = {0,128,288,288,128,288,128,240,192,192,192,288}; /**< This array stores the size (in bytes) of each configuration page */
#define MAP_PAGE_SIZE 288
struct table3D fuelTable; //16x16 fuel map
@ -247,6 +250,7 @@ struct table3D trim2Table; //6x6 Fuel trim 2 map
struct table3D trim3Table; //6x6 Fuel trim 3 map
struct table3D trim4Table; //6x6 Fuel trim 4 map
struct table2D taeTable; //4 bin TPS Acceleration Enrichment map (2D)
struct table2D maeTable;
struct table2D WUETable; //10 bin Warm Up Enrichment map (2D)
struct table2D ASETable; //4 bin After Start Enrichment map (2D)
struct table2D ASECountTable; //4 bin After Start duration map (2D)
@ -369,9 +373,6 @@ struct statuses {
int16_t EMAPADC;
byte baro; //Barometric pressure is simply the inital MAP reading, taken before the engine is running. Alternatively, can be taken from an external sensor
byte TPS; /**< The current TPS reading (0% - 100%). Is the tpsADC value after the calibration is applied */
byte TPSlast; /**< The previous TPS reading */
unsigned long TPS_time; //The time the TPS sample was taken
unsigned long TPSlast_time; //The time the previous TPS sample was taken
byte tpsADC; /**< 0-255 byte representation of the TPS. Downsampled from the original 10-bit reading, but before any calibration is applied */
byte tpsDOT; /**< TPS delta over time. Measures the % per second that the TPS is changing. Value is divided by 10 to be stored in a byte */
byte mapDOT; /**< MAP delta over time. Measures the kpa per second that the MAP is changing. Value is divided by 10 to be stored in a byte */
@ -392,7 +393,7 @@ struct statuses {
byte battery10; /**< The current BRV in volts (multiplied by 10. Eg 12.5V = 125) */
int8_t advance; /**< Signed 8 bit as advance can now go negative (ATDC) */
byte corrections; /**< The total current corrections % amount */
int16_t TAEamount; /**< The amount of accleration enrichment currently being applied */
int16_t AEamount; /**< The amount of accleration enrichment currently being applied */
byte egoCorrection; /**< The amount of closed loop AFR enrichment currently being applied */
byte wueCorrection; /**< The amount of warmup enrichment currently being applied */
byte batCorrection; /**< The amount of battery voltage enrichment currently being applied */
@ -406,7 +407,7 @@ struct statuses {
bool idleUpActive; /**< Whether the externally controlled idle up is currently active */
bool fanOn; /**< Whether or not the fan is turned on */
volatile byte ethanolPct; /**< Ethanol reading (if enabled). 0 = No ethanol, 100 = pure ethanol. Eg E85 = 85. */
unsigned long TAEEndTime; /**< The target end time used whenever TAE is turned on */
unsigned long AEEndTime; /**< The target end time used whenever AE is turned on */
volatile byte status1;
volatile byte spark;
volatile byte spark2;
@ -462,10 +463,11 @@ struct statuses currentStatus; //The global status object
*/
struct config2 {
byte unused2_0;
byte unused2_1;
byte unused2_2;
byte unused2_3; //Was ASE
byte unused2_4; //Was ASECount
byte unused2_2; //Was ASE
byte aeMode : 2; /**< Acceleration Enrichment mode. 0 = TPS, 1 = MAP. Values 2 and 3 reserved for potential future use (ie blended TPS / MAP) */
byte unused1_3c : 6;
byte wueValues[10]; //Warm up enrichment array (10 bytes)
byte crankingPct; //Cranking enrichment
byte pinMapping; // The board / ping mapping to be used
@ -473,7 +475,7 @@ struct config2 {
byte tachoDiv : 2; //Whether to change the tacho speed
byte tachoDuration; //The duration of the tacho pulse in mS
byte maeThresh; /**< The MAPdot threshold that must be exceeded before AE is engaged */
byte tpsThresh; /**< The TPSdot threshold that must be exceeded before AE is engaged */
byte taeThresh; /**< The TPSdot threshold that must be exceeded before AE is engaged */
byte aeTime;
//Display config bits
@ -984,17 +986,18 @@ extern struct table3D fuelTable; //16x16 fuel map
extern struct table3D ignitionTable; //16x16 ignition map
extern struct table3D afrTable; //16x16 afr target map
extern struct table3D stagingTable; //8x8 afr target map
extern struct table2D taeTable; //4 bin TPS Acceleration Enrichment map (2D)
extern struct table2D WUETable; //10 bin Warm Up Enrichment map (2D)
extern struct table2D crankingEnrichTable; //4 bin cranking Enrichment map (2D)
extern struct table2D taeTable; /**< 4 bin TPS Acceleration Enrichment curve (2D) */
extern struct table2D maeTable; /**< 4 bin MAP based Acceleration Enrichment curve (2D) */
extern struct table2D WUETable; /**< 10 bin Warm Up Enrichment curve (2D) */
extern struct table2D crankingEnrichTable; /**< 4 bin cranking Enrichment curve (2D) */
extern struct config2 configPage2;
extern struct config4 configPage4;
extern struct config6 configPage6;
extern struct config9 configPage9;
extern struct config10 configPage10;
extern unsigned long currentLoopTime; //The time the current loop started (uS)
extern unsigned long previousLoopTime; //The time the previous loop started (uS)
volatile uint16_t ignitionCount; //The count of ignition events that have taken place since the engine started
extern unsigned long currentLoopTime; /**< The time (in uS) that the current mainloop started */
extern unsigned long previousLoopTime; /**< The time (in uS) that the previous mainloop started */
volatile uint16_t ignitionCount; /**< The count of ignition events that have taken place since the engine started */
extern byte cltCalibrationTable[CALIBRATION_TABLE_SIZE];
extern byte iatCalibrationTable[CALIBRATION_TABLE_SIZE];
extern byte o2CalibrationTable[CALIBRATION_TABLE_SIZE];

View File

@ -60,6 +60,10 @@ void initialiseAll()
taeTable.xSize = 4;
taeTable.values = configPage4.taeValues;
taeTable.axisX = configPage4.taeBins;
maeTable.valueSize = SIZE_BYTE; //Set this table to use byte values
maeTable.xSize = 4;
maeTable.values = configPage4.maeRates;
maeTable.axisX = configPage4.maeBins;
WUETable.valueSize = SIZE_BYTE; //Set this table to use byte values
WUETable.xSize = 10;
WUETable.values = configPage2.wueValues;

View File

@ -36,6 +36,12 @@ unsigned long EMAPrunningValue; //As above but for EMAP
unsigned int MAPcount; //Number of samples taken in the current MAP cycle
uint32_t MAPcurRev; //Tracks which revolution we're sampling on
bool auxIsEnabled;
byte TPSlast; /**< The previous TPS reading */
unsigned long TPS_time; //The time the TPS sample was taken
unsigned long TPSlast_time; //The time the previous TPS sample was taken
byte MAPlast; /**< The previous MAP reading */
unsigned long MAP_time; //The time the MAP sample was taken
unsigned long MAPlast_time; //The time the previous MAP sample was taken
//These variables are used for tracking the number of running sensors values that appear to be errors. Once a threshold is reached, the sensor reading will go to default value and assume the sensor is faulty
byte mapErrorCount = 0;

View File

@ -120,6 +120,11 @@ void initialiseADC()
static inline void instanteneousMAPReading()
{
//Update the calculation times and last value. These are used by the MAP based Accel enrich
MAPlast = currentStatus.MAP;
MAPlast_time = MAP_time;
MAP_time = micros();
unsigned int tempReading;
//Instantaneous MAP readings
#if defined(ANALOG_ISR_MAP)
@ -196,6 +201,11 @@ static inline void readMAP()
//Sanity check
if( (MAPrunningValue != 0) && (MAPcount != 0) )
{
//Update the calculation times and last value. These are used by the MAP based Accel enrich
MAPlast = currentStatus.MAP;
MAPlast_time = MAP_time;
MAP_time = micros();
currentStatus.mapADC = ldiv(MAPrunningValue, MAPcount).quot;
currentStatus.MAP = fastMap10Bit(currentStatus.mapADC, configPage2.mapMin, configPage2.mapMax); //Get the current MAP value
if(currentStatus.MAP < 0) { currentStatus.MAP = 0; } //Sanity check
@ -240,6 +250,12 @@ static inline void readMAP()
else
{
//Reaching here means that the last cylce has completed and the MAP value should be calculated
//Update the calculation times and last value. These are used by the MAP based Accel enrich
MAPlast = currentStatus.MAP;
MAPlast_time = MAP_time;
MAP_time = micros();
currentStatus.mapADC = MAPrunningValue;
currentStatus.MAP = fastMap10Bit(currentStatus.mapADC, configPage2.mapMin, configPage2.mapMax); //Get the current MAP value
if(currentStatus.MAP < 0) { currentStatus.MAP = 0; } //Sanity check
@ -259,8 +275,8 @@ static inline void readMAP()
void readTPS()
{
currentStatus.TPSlast = currentStatus.TPS;
currentStatus.TPSlast_time = currentStatus.TPS_time;
TPSlast = currentStatus.TPS;
TPSlast_time = TPS_time;
#if defined(ANALOG_ISR)
byte tempTPS = fastMap1023toX(AnChannel[pinTPS-A0], 255); //Get the current raw TPS ADC value and map it into a byte
#else
@ -291,7 +307,7 @@ void readTPS()
currentStatus.TPS = map(tempADC, configPage2.tpsMax, configPage2.tpsMin, 0, 100);
}
currentStatus.TPS_time = micros();
TPS_time = micros();
}
void readCLT(bool useFilter)

View File

@ -167,7 +167,7 @@ void doUpdates()
if(EEPROM.read(EEPROM_DATA_VERSION) == 10)
{
//April 2019 version adds the use of a 2D table for the priming pulse rather than a single value.
//May 2019 version adds the use of a 2D table for the priming pulse rather than a single value.
//This sets all the values in the 2D table to be the same as the previous single value
configPage2.primePulse[0] = configPage2.unused2_39 / 5; //New priming pulse values are in the range 0-127.5 rather than 0-25.5 so they must be divided by 5
configPage2.primePulse[1] = configPage2.unused2_39 / 5; //New priming pulse values are in the range 0-127.5 rather than 0-25.5 so they must be divided by 5
@ -182,6 +182,19 @@ void doUpdates()
//March 19 added a tacho pulse duration that could default to stupidly high values. Check if this is the case and fix it if found. 6ms is tha maximum allowed value
if(configPage2.tachoDuration > 6) { configPage2.tachoDuration = 3; }
//MAP based AE was introduced, force the AE mode to be TPS for all existing tunes
configPage2.aeMode = AE_MODE_TPS;
//Set some sane values for the MAP AE curve
configPage4.maeRates[0] = 75;
configPage4.maeRates[2] = 75;
configPage4.maeRates[3] = 75;
configPage4.maeRates[4] = 75;
configPage4.maeBins[0] = 7;
configPage4.maeBins[1] = 12;
configPage4.maeBins[2] = 20;
configPage4.maeBins[3] = 40;
writeAllConfig();
EEPROM.write(EEPROM_DATA_VERSION, 11);
}