From b3a04cc19b8700c22bddc027a38e68272621de73 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Mon, 26 Dec 2016 20:53:37 +1100 Subject: [PATCH] Expose some pieces of flex info to TunerStudio --- comms.ino | 4 +++- corrections.ino | 4 +++- globals.h | 1 + reference/speeduino.ini | 13 ++++++++----- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/comms.ino b/comms.ino index 8e29f61..b5e76a1 100644 --- a/comms.ino +++ b/comms.ino @@ -258,7 +258,9 @@ void sendValues(int packetlength, byte portNum) response[32] = highByte(currentStatus.rpmDOT); response[33] = currentStatus.ethanolPct; //Flex sensor value (or 0 if not used) - response[34] = getNextError(); + response[34] = currentStatus.flexCorrection; //Flex fuel correction (% above or below 100) + response[35] = currentStatus.flexIgnCorrection; //Ignition correction (Increased degrees of advance) for flex fuel + response[36] = getNextError(); //cli(); if (portNum == 0) { Serial.write(response, (size_t)packetlength); } diff --git a/corrections.ino b/corrections.ino index c91d177..29a41dd 100644 --- a/corrections.ino +++ b/corrections.ino @@ -22,6 +22,7 @@ PID egoPID(&PID_O2, &PID_output, &PID_AFRTarget, configPage3.egoKP, configPage3. void initialiseCorrections() { egoPID.SetMode(AUTOMATIC); //Turn O2 PID on + currentStatus.flexIgnCorrection = 0; } /* @@ -344,7 +345,8 @@ static inline byte correctionsFlexTiming(byte advance) { if(!configPage1.flexEnabled) { return advance; } //Check for flex being enabled byte flexRange = configPage1.flexAdvHigh - configPage1.flexAdvLow; - return advance + percentage(currentStatus.ethanolPct, flexRange); + currentStatus.flexIgnCorrection = percentage(currentStatus.ethanolPct, flexRange); + return advance + currentStatus.flexIgnCorrection; } static inline byte correctionsIATretard(byte advance) diff --git a/globals.h b/globals.h index 7bf2721..6a74db9 100644 --- a/globals.h +++ b/globals.h @@ -143,6 +143,7 @@ struct statuses { byte iatCorrection; //The amount of inlet air temperature adjustment currently being applied byte launchCorrection; //The amount of correction being applied if launch control is active byte flexCorrection; //Amount of correction being applied to compensate for ethanol content + byte flexIgnCorrection; //Amount of additional advance being applied based on flex byte afrTarget; byte idleDuty; bool fanOn; //Whether or not the fan is turned on diff --git a/reference/speeduino.ini b/reference/speeduino.ini index 689df56..c1a0e6b 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -1393,7 +1393,8 @@ menuDialog = main cltGauge = coolant, "Coolant Temp", "TEMP", -40, 215, 0, 30, 200, 220, 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, + advanceGauge = advance, "Spark Advance", "deg BTDC", 50, -10, 0, 0, 35, 45, 0, 0 + flexGauge = flex, "Flex sensor", "%", 0, 100, -1, -1, 999, 999, 0, 0 gaugeCategory = "Other" clockGauge = secl, "Clock", "Seconds", 0, 255, 10, 10, 245, 245, 0, 0 @@ -1524,7 +1525,7 @@ menuDialog = main ochGetCommand = "A" - ochBlockSize = 35 + ochBlockSize = 37 secl = scalar, U08, 0, "sec", 1.000, 0.000 squirt = scalar, U08, 1, "bits", 1.000, 0.000 @@ -1580,9 +1581,11 @@ menuDialog = main afr2 = scalar, U08, 30, "O2", 0.100, 0.000 rpmDOT = scalar, S16, 31, "rpm/s", 1.000, 0.000 flex = scalar, U08, 33, "%", 1.000, 0.000 - errors = scalar, U08, 34, "bits", 1.000, 0.000 - errorNum = bits, U08, 34, [0:1] - currentError = bits, U08, 34, [2:7] + flexFuelCor = scalar, U08, 34, "%", 1.000, 0.000 + flexIgnCor = scalar, U08, 35, "deg", 1.000, 0.000 + errors = scalar, U08, 36, "bits", 1.000, 0.000 + errorNum = bits, U08, 36, [0:1] + currentError = bits, U08, 36, [2:7] ; Computed output channels. See "megatuneExamples.ini" for all the ; pre-defined variables, search for "???" and you'll see them.