diff --git a/reference/speeduino.ini b/reference/speeduino.ini index d1a2017d..44c80a65 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -210,7 +210,8 @@ page = 1 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" + battVCorMode = bits, U08, 3, [2:2], "Whole PW", "Open Time only" + unused1-3c = bits, U08, 3, [3: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", "01-05 MX5 PNP", "INVALID", "96-97 MX5 PNP", "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", "DIY-EFI CORE4 v1.0", "INVALID", "INVALID", "INVALID", "INVALID", "dvjcodec Teensy RevA", "dvjcodec Teensy RevB", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "Black STM32F407VET6 V0.1", "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" @@ -1118,6 +1119,7 @@ page = 11 defaultValue = aeMode, 0 ;Set aeMode to TPS defaultValue = batVoltCorrect, 0 defaultValue = legacyMAP, 0 + defaultValue = battVCorMode, 1 ;Default pins defaultValue = fanPin, 0 @@ -1539,6 +1541,8 @@ menuDialog = main #endif resetControlPin = "The Arduino pin used to control resets." + battVCorMode = "The Battery Voltage Correction value from the table below can either be applied on the whole injection Pulse Width value, or only on the Open Time value." + [UserDefined] ; Enhanced TunerStudio dialogs can be defined here @@ -1728,6 +1732,7 @@ menuDialog = main field = "Channel 4", inj4Ang, { indInjAng && (nCylinders > 6 || ((nCylinders == 4) && (injLayout == 3))) } field = "Injector Duty Limit", dutyLim panel = injector_voltage_curve + field = "Battery Voltage Correction Mode", battVCorMode dialog = egoControl, "" topicHelp = "http://speeduino.com/wiki/index.php/AFR/O2" diff --git a/speeduino/corrections.ino b/speeduino/corrections.ino index 6578e95d..3e095554 100644 --- a/speeduino/corrections.ino +++ b/speeduino/corrections.ino @@ -310,7 +310,11 @@ Uses a 2D enrichment table (WUETable) where the X axis is engine temp and the Y static inline byte correctionBatVoltage() { byte batValue = 100; - batValue = table2D_getValue(&injectorVCorrectionTable, currentStatus.battery10); + if (configPage2.battVCorMode == BATTV_COR_MODE_WHOLE) + { + if (currentStatus.battery10 > (injectorVCorrectionTable.axisX[5])) { batValue = injectorVCorrectionTable.values[injectorVCorrectionTable.xSize-1]; } //This prevents us doing the 2D lookup if the voltage is above maximum + else { batValue = table2D_getValue(&injectorVCorrectionTable, currentStatus.battery10); } + } return batValue; } diff --git a/speeduino/globals.h b/speeduino/globals.h index 03d7407f..e1f92a1f 100644 --- a/speeduino/globals.h +++ b/speeduino/globals.h @@ -239,6 +239,9 @@ #define MAX_RPM 18000 //This is the maximum rpm that the ECU will attempt to run at. It is NOT related to the rev limiter, but is instead dictates how fast certain operations will be allowed to run. Lower number gives better performance +#define BATTV_COR_MODE_WHOLE 0 +#define BATTV_COR_MODE_OPENTIME 1 + //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 @@ -500,7 +503,8 @@ struct config2 { byte unused2_1; 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 battVCorMode : 1; + byte unused1_3c : 5; byte wueValues[10]; //Warm up enrichment array (10 bytes) byte crankingPct; //Cranking enrichment byte pinMapping; // The board / ping mapping to be used diff --git a/speeduino/speeduino.ino b/speeduino/speeduino.ino index e1611a2c..38f664a3 100644 --- a/speeduino/speeduino.ino +++ b/speeduino/speeduino.ino @@ -395,7 +395,12 @@ void loop() currentStatus.corrections = correctionsFuel(); currentStatus.advance = getAdvance(); - //currentStatus.PW1 = PW(req_fuel_uS, currentStatus.VE, currentStatus.MAP, currentStatus.corrections, inj_opentime_uS); + + if (configPage2.battVCorMode == BATTV_COR_MODE_OPENTIME) + { + inj_opentime_uS = configPage2.injOpen * table2D_getValue(&injectorVCorrectionTable, currentStatus.battery10); // Apply voltage correction to injector open time. + } + currentStatus.PW1 = PW(req_fuel_uS, currentStatus.VE, currentStatus.MAP, currentStatus.corrections, inj_opentime_uS); //Manual adder for nitrous. These are not in correctionsFuel() because they are direct adders to the ms value, not % based