mirror of https://github.com/rusefi/speeduino.git
Actually use the dwell correction curve in the code
This commit is contained in:
parent
666da25d06
commit
128942aca6
|
@ -120,7 +120,7 @@ This function returns the current values of a fixed group of variables
|
|||
*/
|
||||
void sendValues(int length)
|
||||
{
|
||||
byte packetSize = 29;
|
||||
byte packetSize = 30;
|
||||
byte response[packetSize];
|
||||
|
||||
response[0] = currentStatus.secl; //secl is simply a counter that increments each second. Used to track unexpected resets (Which will reset this count to 0)
|
||||
|
@ -157,6 +157,7 @@ void sendValues(int length)
|
|||
response[27] = lowByte(currentStatus.freeRAM);
|
||||
|
||||
response[28] = currentStatus.batCorrection; //Battery voltage correction (%)
|
||||
response[29] = (byte)(currentStatus.dwell / 100);
|
||||
|
||||
|
||||
Serial.write(response, (size_t)packetSize);
|
||||
|
|
21
globals.h
21
globals.h
|
@ -61,6 +61,7 @@ struct statuses {
|
|||
int batADC;
|
||||
int O2ADC;
|
||||
int dwell;
|
||||
byte dwellCorrection; //The amount of correction being applied to the dwell time.
|
||||
byte battery10; //The current BRV in volts (multiplied by 10. Eg 12.5V = 125)
|
||||
byte advance;
|
||||
byte corrections;
|
||||
|
@ -225,24 +226,8 @@ struct config3 {
|
|||
byte egoLoadMin; //Load (TPS or MAP) must be above this for closed loop to function
|
||||
byte voltageCorrectionBins[6]; //X axis bins for voltage correction tables
|
||||
byte injVoltageCorrectionValues[6]; //Correction table for injector PW vs battery voltage
|
||||
byte unused107;
|
||||
byte unused108;
|
||||
byte unused109;
|
||||
byte unused110;
|
||||
byte unused111;
|
||||
byte unused112;
|
||||
byte unused113;
|
||||
byte unused114;
|
||||
byte unused115;
|
||||
byte unused116;
|
||||
byte unused117;
|
||||
byte unused118;
|
||||
byte unused119;
|
||||
byte unused120;
|
||||
byte unused121;
|
||||
byte unused122;
|
||||
byte unused123;
|
||||
byte unused124;
|
||||
byte airDenBins[9];
|
||||
byte airDenRates[9];
|
||||
byte unused125;
|
||||
byte unused126;
|
||||
byte unused127;
|
||||
|
|
|
@ -82,7 +82,7 @@ page = 1
|
|||
#elif ALPHA_N
|
||||
tpsBins = array, U08, 72, [ 8], "TPS", 1.0, 0.0, 0.0, 255.0, 0
|
||||
#elif AIR_FLOW_METER
|
||||
#error "MSnS does not support MAF"
|
||||
#error "Speeduino does not support MAF"
|
||||
;#exit
|
||||
#endif
|
||||
crankCold = scalar, U08, 80, "ms", 0.1, 0.0, 0.0, 25.5, 1
|
||||
|
@ -238,40 +238,24 @@ page = 3
|
|||
egoKI = scalar, U08, 82, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
|
||||
egoKD = scalar, U08, 83, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
|
||||
#if CELSIUS
|
||||
egoTemp = scalar, U08, 84, "°C", 0.555, -72, -40, 102.0, 0
|
||||
egoTemp = scalar, U08, 84, "°C", 0.555, -72, -40, 102.0, 0
|
||||
#else
|
||||
egoTemp = scalar, U08, 84, "°F", 1.0, -40, -40, 215.0, 0
|
||||
egoTemp = scalar, U08, 84, "°F", 1.0, -40, -40, 215.0, 0
|
||||
#endif
|
||||
egoCount = scalar, U08, 85, "", 4.0, 0.0, 4.0, 255.0, 0 ; * ( 1 byte)
|
||||
egoDelta = scalar, U08, 86, "%", 1.0, 0.0, 0.0, 255.0, 0 ; * ( 1 byte)
|
||||
egoLimit = scalar, U08, 87, "", 1, 0, 0, 16, 0
|
||||
ego_min = scalar, U08, 88, "AFR", 0.1, 0.0, 7, 25, 1
|
||||
ego_max = scalar, U08, 89, "AFR", 0.1, 0.0, 7, 25, 1
|
||||
ego_sdelay = scalar, U08, 90, "sec", 1, 0, 0, 120, 0
|
||||
egoRPM = scalar, U08, 91, "rpm", 100, 0.0, 100, 25500, 0
|
||||
egoTPSMax = scalar, U08, 92, "%", 1, 0, 0, 120, 0
|
||||
egoLoadMax = scalar, U08, 93, "%", 1, 0, 0, 120, 0
|
||||
egoLoadMin = scalar, U08, 94, "%", 1, 0, 0, 120, 0
|
||||
brvBins = array, U08, 95, [6], "V", 0.1, 0, 6, 24, 1 ; Bins for the battery reference voltage
|
||||
injBatRates = array, U08, 101,[6], "%", 1, 0.0, 0.00, 255.0, 0 ;Values for injector pulsewidth vs voltage
|
||||
;unused107 = scalar, U08, 107, "none", 0, 0, 0, 0, 0
|
||||
;unused108 = scalar, U08, 108, "none", 0, 0, 0, 0, 0
|
||||
; unused109 = scalar, U08, 109, "none", 0, 0, 0, 0, 0
|
||||
;unused110 = scalar, U08, 110, "none", 0, 0, 0, 0, 0
|
||||
;unused111 = scalar, U08, 111, "none", 0, 0, 0, 0, 0
|
||||
;unused112 = scalar, U08, 112, "none", 0, 0, 0, 0, 0
|
||||
;unused113 = scalar, U08, 113, "none", 0, 0, 0, 0, 0
|
||||
;unused114 = scalar, U08, 114, "none", 0, 0, 0, 0, 0
|
||||
;unused115 = scalar, U08, 115, "none", 0, 0, 0, 0, 0
|
||||
; unused116 = scalar, U08, 116, "none", 0, 0, 0, 0, 0
|
||||
;unused117 = scalar, U08, 117, "none", 0, 0, 0, 0, 0
|
||||
;unused118 = scalar, U08, 118, "none", 0, 0, 0, 0, 0
|
||||
;unused119 = scalar, U08, 119, "none", 0, 0, 0, 0, 0
|
||||
;unused120 = scalar, U08, 120, "none", 0, 0, 0, 0, 0
|
||||
; unused121 = scalar, U08, 121, "none", 0, 0, 0, 0, 0
|
||||
;unused122 = scalar, U08, 122, "none", 0, 0, 0, 0, 0
|
||||
;unused123 = scalar, U08, 123, "none", 0, 0, 0, 0, 0
|
||||
;unused124 = scalar, U08, 124, "none", 0, 0, 0, 0, 0
|
||||
egoLimit = scalar, U08, 87, "", 1, 0, 0, 16, 0
|
||||
ego_min = scalar, U08, 88, "AFR", 0.1, 0.0, 7, 25, 1
|
||||
ego_max = scalar, U08, 89, "AFR", 0.1, 0.0, 7, 25, 1
|
||||
ego_sdelay = scalar, U08, 90, "sec", 1, 0, 0, 120, 0
|
||||
egoRPM = scalar, U08, 91, "rpm", 100, 0.0, 100, 25500, 0
|
||||
egoTPSMax = scalar, U08, 92, "%", 1, 0, 0, 120, 0
|
||||
egoLoadMax = scalar, U08, 93, "%", 1, 0, 0, 120, 0
|
||||
egoLoadMin = scalar, U08, 94, "%", 1, 0, 0, 120, 0
|
||||
brvBins = array, U08, 95, [6], "V", 0.1, 0, 6, 24, 1 ; Bins for the battery reference voltage
|
||||
injBatRates = array, U08, 101,[6], "%", 1, 0, 0, 255, 0 ;Values for injector pulsewidth vs voltage
|
||||
airDenBins = array, U08, 107,[9], "C", 1.0, -40, -40, 215, 0 ; Bins for the air density correction curve
|
||||
airDenRates = array, U08, 116,[9], "%", 1.0, 0.0, 0, 255, 0 ; Values for the air density correction curve
|
||||
;unused125 = scalar, U08, 125, "none", 0, 0, 0, 0, 0
|
||||
;unused126 = scalar, U08, 126, "none", 0, 0, 0, 0, 0
|
||||
;unused127 = scalar, U08, 127, "none", 0, 0, 0, 0, 0
|
||||
|
@ -315,6 +299,7 @@ page = 3
|
|||
subMenu = injChars, "Injector Characteristics"
|
||||
subMenu = triggerSettings, "&Trigger Setup"
|
||||
subMenu = OLED, "OLED Setup"
|
||||
subMenu = airdensity_curve, "IAT Density"
|
||||
|
||||
menu = "&Tuning"
|
||||
subMenu = std_realtime, "&Realtime Display"
|
||||
|
@ -641,7 +626,16 @@ help = helpEnrichments, "Enrichments Help"
|
|||
xBins = brvBins, batteryVoltage
|
||||
yBins = injBatRates
|
||||
|
||||
|
||||
|
||||
|
||||
; Correction curve for Air Density vs temperature
|
||||
curve = airdensity_curve, "IAT density correction"
|
||||
columnLabel = "Air Temperature", "C"
|
||||
xAxis = -40, 215, 6
|
||||
yAxis = 0, 255, 6
|
||||
xBins = airDenBins, iat
|
||||
yBins = airDenRates
|
||||
|
||||
[TableEditor]
|
||||
; table_id, map3d_id, "title", page
|
||||
table = veTable1Tbl, veTable1Map, "VE Table", 1
|
||||
|
@ -757,10 +751,10 @@ help = helpEnrichments, "Enrichments Help"
|
|||
|
||||
#if CELSIUS
|
||||
cltGauge = coolant, "Coolant Temp", "TEMP", -40, 120, -15, 0, 95, 105, 0, 0
|
||||
matGauge = mat, "Manifold Air Temp", "TEMP", -40, 110, -15, 0, 95, 100, 0, 0
|
||||
iatGauge = iat, "Inlet Air Temp", "TEMP", -40, 110, -15, 0, 95, 100, 0, 0
|
||||
#else
|
||||
cltGauge = coolant, "Coolant Temp", "TEMP", -40, 250, 0, 30, 200, 220, 0, 0
|
||||
matGauge = mat, "Manifold Air Temp", "TEMP", -40, 215, 0, 30, 200, 210, 0, 0
|
||||
iatGauge = iat, "Inlet Air Temp", "TEMP", -40, 215, 0, 30, 200, 210, 0, 0
|
||||
#endif
|
||||
advanceGauge = advance, "Spark Advance", "deg BTDC", 50, -10, 0, 0, 35, 45, 0,
|
||||
loopGauge = loopsPerSecond,"Main loop speed", "Loops/S" , 0, 20000, -1, 500,1800, 4000, 0, 0
|
||||
|
@ -791,7 +785,7 @@ help = helpEnrichments, "Enrichments Help"
|
|||
gauge3 = pulseWidthGauge
|
||||
gauge4 = dutyCycleGauge
|
||||
gauge5 = mapGauge
|
||||
gauge6 = matGauge
|
||||
gauge6 = iatGauge
|
||||
gauge7 = cltGauge
|
||||
gauge8 = gammaEnrichGauge
|
||||
|
||||
|
@ -897,7 +891,7 @@ help = helpEnrichments, "Enrichments Help"
|
|||
|
||||
ochGetCommand = "A"
|
||||
|
||||
ochBlockSize = 29
|
||||
ochBlockSize = 30
|
||||
|
||||
secl = scalar, U08, 0, "sec", 1.000, 0.000
|
||||
squirt = scalar, U08, 1, "bits", 1.000, 0.000
|
||||
|
@ -912,13 +906,11 @@ help = helpEnrichments, "Enrichments Help"
|
|||
mapaccden = bits, U08, 2, [7:7]
|
||||
baroADC = scalar, U08, 3, "ADC", 1.000, 0.000
|
||||
mapADC = scalar, U08, 4, "ADC", 1.000, 0.000
|
||||
#matADC = scalar, U08, 5, "ADC", 1.000, 0.000
|
||||
#cltADC = scalar, U08, 6, "ADC", 1.000, 0.000
|
||||
#if CELSIUS
|
||||
matRaw = scalar, U08, 5, "°C", 1.000, 0.000
|
||||
iatRaw = scalar, U08, 5, "°C", 1.000, 0.000
|
||||
coolantRaw = scalar, U08, 6, "°C", 1.000, 0.000
|
||||
#else
|
||||
matRaw = scalar, U08, 5, "°F", 1.000, 0.000
|
||||
iatRaw = scalar, U08, 5, "°F", 1.000, 0.000
|
||||
coolantRaw = scalar, U08, 6, "°F", 1.000, 0.000
|
||||
#endif
|
||||
tpsADC = scalar, U08, 7, "ADC", 1.000, 0.000
|
||||
|
@ -934,25 +926,23 @@ help = helpEnrichments, "Enrichments Help"
|
|||
gammaEnrich = scalar, U08, 17, "%", 1.000, 0.000
|
||||
veCurr = scalar, U08, 18, "%", 1.000, 0.000
|
||||
afrTarget = scalar, U08, 19 "O2", 0.100, 0.000
|
||||
#blank2 = scalar, U08, 20
|
||||
pulseWidth = scalar, U08, 20, "ms", 0.1, 0.000
|
||||
pulseWidth = scalar, U08, 20, "ms", 0.1, 0.000
|
||||
TPSdot = scalar, U08, 21, "%/s", 10.00, 0.000
|
||||
advance = scalar, U08, 22, "deg", 1.000, 0.000
|
||||
tps = scalar, U08, 23, "%", 1.000, 0.000
|
||||
loopsPerSecond = scalar, S16, 24, "loops", 1.000, 0.000
|
||||
freeRAM = scalar, S16, 26, "bytes", 1.000, 0.000
|
||||
batCorrection = scalar, U08, 28, "%", 1.000, 0.000
|
||||
dwell = scalar, U08, 29, "ms", 0.1, 0.000
|
||||
|
||||
; Computed output channels. See "megatuneExamples.ini" for all the
|
||||
; pre-defined variables, search for "???" and you'll see them.
|
||||
|
||||
accDecEnrich = { accelEnrich + ((engine & 0b00100000) ? tdePct : 100) }
|
||||
;batteryVoltage = { batADC / 255.0 * 30.0 } ; Current MS power supply voltage.
|
||||
coolant = { coolantRaw - 40 } ; Coolant sensor temperature in user units.
|
||||
mat = { matRaw - 40 } ; Manifold temperature in user units.
|
||||
iat = { iatRaw - 40 } ; Manifold temperature in user units.
|
||||
; egoVoltage = { egoADC / 255.0 * 5.0 } ; EGO sensor voltage.
|
||||
time = { timeNow } ; "timeNow" is a parameterless built-in function.
|
||||
;loopsPerSecond = { loopsPerSecond10*10 } ; True number of mainloops per second
|
||||
seconds = { secl };
|
||||
|
||||
afrtarget = { 0 }
|
||||
|
@ -1025,8 +1015,8 @@ help = helpEnrichments, "Enrichments Help"
|
|||
entry = tpsADC, "tpsADC", int, "%d"
|
||||
entry = tps, "TPS", int, "%d"
|
||||
entry = afr, "O2", float, "%.3f"
|
||||
entry = mat, "MAT", float, "%.1f"
|
||||
entry = coolant, "CLT", float, "%.1f"
|
||||
entry = iat, "IAT", int, "%d"
|
||||
entry = coolant, "CLT", int, "%d"
|
||||
entry = engine, "Engine", int, "%d"
|
||||
entry = squirt, "Squirt", int, "%d"
|
||||
entry = egoCorrection, "Gego", int, "%d"
|
||||
|
|
|
@ -309,8 +309,7 @@ void loop()
|
|||
{
|
||||
currentStatus.TPSlast = currentStatus.TPS;
|
||||
currentStatus.TPSlast_time = currentStatus.TPS_time;
|
||||
//currentStatus.tpsADC = map(analogRead(pinTPS), 0, 1023, 0, 255); //Get the current raw TPS ADC value and map it into a byte
|
||||
currentStatus.tpsADC = fastMap1023toX(analogRead(pinTPS), 0, 1023, 0, 255); //Same as above line, but using optimised map function
|
||||
currentStatus.tpsADC = fastMap1023toX(analogRead(pinTPS), 0, 1023, 0, 255); //Get the current raw TPS ADC value and map it into a byte
|
||||
currentStatus.TPS = map(currentStatus.tpsADC, configPage1.tpsMin, configPage1.tpsMax, 0, 100); //Take the raw TPS ADC value and convert it into a TPS% based on the calibrated values
|
||||
currentStatus.TPS_time = currentLoopTime;
|
||||
}
|
||||
|
@ -437,7 +436,10 @@ void loop()
|
|||
//Dwell is stored as ms * 10. ie Dwell of 4.3ms would be 43 in configPage2. This number therefore needs to be multiplied by 100 to get dwell in uS
|
||||
if ( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) ) { currentStatus.dwell = (configPage2.dwellCrank * 100); }
|
||||
else { currentStatus.dwell = (configPage2.dwellRun * 100); }
|
||||
int dwellAngle = (div(currentStatus.dwell, timePerDegree).quot );
|
||||
//Pull battery voltage based dwell correction and apply if needed
|
||||
currentStatus.dwellCorrection = table2D_getValue(dwellVCorrectionTable, currentStatus.battery10);
|
||||
if (currentStatus.dwellCorrection != 100) { currentStatus.dwell = divs100(currentStatus.dwell) * currentStatus.dwellCorrection; }
|
||||
int dwellAngle = (div(currentStatus.dwell, timePerDegree).quot ); //Convert the dwell time to dwell angle based on the current engine speed
|
||||
|
||||
//Calculate start angle for each channel
|
||||
//1
|
||||
|
|
Loading…
Reference in New Issue