From dc7b789a4e9c1dc124d5134bdf8b920ddd9599f4 Mon Sep 17 00:00:00 2001 From: Josh Stewart Date: Tue, 16 Apr 2019 23:20:42 +1000 Subject: [PATCH] Add idle rpm target, delta, idle on statuses. Closes #215 --- reference/speeduino.ini | 19 ++++++----- speeduino/comms.h | 2 +- speeduino/comms.ino | 1 + speeduino/globals.h | 70 ++++++++++++++++++++++------------------- speeduino/idle.ino | 22 +++++++++++-- 5 files changed, 70 insertions(+), 44 deletions(-) diff --git a/reference/speeduino.ini b/reference/speeduino.ini index a28f8d5b..3736d7f6 100644 --- a/reference/speeduino.ini +++ b/reference/speeduino.ini @@ -3222,7 +3222,7 @@ cmdtestspk450dc = "E\x03\x0C" ; you change it. ochGetCommand = "r\$tsCanId\x30%2o%2c" - ochBlockSize = 91 + ochBlockSize = 92 secl = scalar, U08, 0, "sec", 1.000, 0.000 status1 = scalar, U08, 1, "bits", 1.000, 0.000 @@ -3321,7 +3321,7 @@ cmdtestspk450dc = "E\x03\x0C" fuelLoad = scalar, S16, 85, { bitStringValue( algorithmUnits , algorithm ) }, 1.000, 0.000 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 #if CELSIUS @@ -3364,6 +3364,8 @@ cmdtestspk450dc = "E\x03\x0C" boostTableLimit = { boostType == 0 ? 100 : 511 } ;The maximum value allowed in the boost table. 100 is used for duty cycle, 511 for kpa + CLIdleDelta = { CLIdleTarget - rpm } + ;------------------------------------------------------------------------------- [Datalog] @@ -3394,7 +3396,7 @@ cmdtestspk450dc = "E\x03\x0C" entry = iat, "IAT", int, "%d" entry = coolant, "CLT", int, "%d" entry = engine, "Engine", int, "%d" - entry = DFCOOn, "DFCO", int, "%d" + entry = DFCOOn, "DFCO", int, "onOff" entry = egoCorrection, "Gego", int, "%d" entry = airCorrection, "Gair", int, "%d" entry = batCorrection, "Gbattery", int, "%d" @@ -3419,12 +3421,15 @@ cmdtestspk450dc = "E\x03\x0C" entry = map_psi, "Boost PSI", float, "%.1f" entry = boostTarget, "Boost Target", int, "%d", { boostEnabled } entry = boostDuty, "Boost Duty", int, "%d", { boostEnabled } - entry = boostCutOut , "Boost cut", int, "%d" - entry = launchHard , "Launch Hard", int, "%d" - entry = hardLimitOn , "Hard Limiter", int, "%d" + entry = boostCutOut , "Boost cut", int, "onOff" + entry = launchHard , "Hard Launch", int, "onOff" + entry = hardLimitOn , "Hard Limiter", int, "onOff" + entry = idleControlOn, "Idle Control", int, "onOff" entry = idleLoad, "IAC value", int, "%d" + entry = CLIdleTarget, "Idle Target RPM", int, "%%d", { iacAlgorithm == 3 || iacAlgorithm == 5 } ;Only show for closed loop idle modes + entry = CLIdleDelta, "Idle RPM Delta", int, "%d", { iacAlgorithm == 3 || iacAlgorithm == 5 } ;Only show for closed loop idle modes entry = baro, "Baro Pressure",int, "%d" - entry = nitrousOn, "Nitrous On", int, "%d", { n2o_enable > 0 } + entry = nitrousOn, "Nitrous", int, "onOff", { n2o_enable > 0 } entry = syncLossCounter, "Sync Loss #", int, "%d" entry = auxin_gauge0, "AuxIn CH0", int, "%d" diff --git a/speeduino/comms.h b/speeduino/comms.h index 3376cfe2..ae16c948 100644 --- a/speeduino/comms.h +++ b/speeduino/comms.h @@ -22,7 +22,7 @@ #define warmupPage 10 //Config Page 10 #define fuelMap2Page 11 -#define SERIAL_PACKET_SIZE 91 /**< The size of the live data packet. This MUST match ochBlockSize setting in the ini file */ +#define SERIAL_PACKET_SIZE 92 /**< The size of the live data packet. This MUST match ochBlockSize setting in the ini file */ byte currentPage = 1;//Not the same as the speeduino config page numbers bool isMap = true; /**< Whether or not the currentPage contains only a 3D map that would require translation */ diff --git a/speeduino/comms.ino b/speeduino/comms.ino index c5dc7ae1..7498ad74 100644 --- a/speeduino/comms.ino +++ b/speeduino/comms.ino @@ -592,6 +592,7 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum) fullStatus[88] = highByte(currentStatus.ignLoad); fullStatus[89] = lowByte(currentStatus.dwell); fullStatus[90] = highByte(currentStatus.dwell); + fullStatus[91] = currentStatus.CLIdleTarget; for(byte x=0; x> 1; //Current step count (Divided by 2 for byte) } + //Set or clear the idle active flag + if(idleStepper.targetIdleStep != idleStepper.curIdleStep) { BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); } + else { BIT_CLEAR(currentStatus.spark, BIT_SPARK_IDLE); } break; case IAC_ALGORITHM_STEP_CL: //Case 5 is closed loop stepper control @@ -279,7 +291,8 @@ void idleControl() iacCoolTime = configPage9.iacCoolTime * 1000; } - idle_cl_target_rpm = table2D_getValue(&iacClosedLoopTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET) * 10; //All temps are offset by 40 degrees + currentStatus.CLIdleTarget = (byte)table2D_getValue(&iacClosedLoopTable, currentStatus.coolant + CALIBRATION_TEMPERATURE_OFFSET); //All temps are offset by 40 degrees + idle_cl_target_rpm = (uint16_t)currentStatus.CLIdleTarget * 10; //All temps are offset by 40 degrees if(currentStatus.idleUpActive == true) { idle_pid_target_value += configPage2.idleUpAdder; } //Add Idle Up amount if active idlePID.Compute(); idleStepper.targetIdleStep = idle_pid_target_value; @@ -288,6 +301,9 @@ void idleControl() currentStatus.idleLoad = idleStepper.curIdleStep >> 1; //Current step count (Divided by 2 for byte) idleCounter++; } + //Set or clear the idle active flag + if(idleStepper.targetIdleStep != idleStepper.curIdleStep) { BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); } + else { BIT_CLEAR(currentStatus.spark, BIT_SPARK_IDLE); } break; default: