Add idle rpm target, delta, idle on statuses. Closes #215
This commit is contained in:
parent
a582b3e291
commit
dc7b789a4e
|
@ -3222,7 +3222,7 @@ cmdtestspk450dc = "E\x03\x0C"
|
||||||
; you change it.
|
; you change it.
|
||||||
|
|
||||||
ochGetCommand = "r\$tsCanId\x30%2o%2c"
|
ochGetCommand = "r\$tsCanId\x30%2o%2c"
|
||||||
ochBlockSize = 91
|
ochBlockSize = 92
|
||||||
|
|
||||||
secl = scalar, U08, 0, "sec", 1.000, 0.000
|
secl = scalar, U08, 0, "sec", 1.000, 0.000
|
||||||
status1 = scalar, U08, 1, "bits", 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
|
fuelLoad = scalar, S16, 85, { bitStringValue( algorithmUnits , algorithm ) }, 1.000, 0.000
|
||||||
ignLoad = scalar, S16, 87, { bitStringValue( algorithmUnits , ignAlgorithm ) }, 1.000, 0.000
|
ignLoad = scalar, S16, 87, { bitStringValue( algorithmUnits , ignAlgorithm ) }, 1.000, 0.000
|
||||||
dwell = scalar, U16, 89, "ms", 0.001, 0.000
|
dwell = scalar, U16, 89, "ms", 0.001, 0.000
|
||||||
|
CLIdleTarget = scalar, U08, 91, "RPM", 10.00, 0.000
|
||||||
|
|
||||||
|
|
||||||
#if CELSIUS
|
#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
|
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]
|
[Datalog]
|
||||||
|
@ -3394,7 +3396,7 @@ cmdtestspk450dc = "E\x03\x0C"
|
||||||
entry = iat, "IAT", int, "%d"
|
entry = iat, "IAT", int, "%d"
|
||||||
entry = coolant, "CLT", int, "%d"
|
entry = coolant, "CLT", int, "%d"
|
||||||
entry = engine, "Engine", int, "%d"
|
entry = engine, "Engine", int, "%d"
|
||||||
entry = DFCOOn, "DFCO", int, "%d"
|
entry = DFCOOn, "DFCO", int, "onOff"
|
||||||
entry = egoCorrection, "Gego", int, "%d"
|
entry = egoCorrection, "Gego", int, "%d"
|
||||||
entry = airCorrection, "Gair", int, "%d"
|
entry = airCorrection, "Gair", int, "%d"
|
||||||
entry = batCorrection, "Gbattery", int, "%d"
|
entry = batCorrection, "Gbattery", int, "%d"
|
||||||
|
@ -3419,12 +3421,15 @@ cmdtestspk450dc = "E\x03\x0C"
|
||||||
entry = map_psi, "Boost PSI", float, "%.1f"
|
entry = map_psi, "Boost PSI", float, "%.1f"
|
||||||
entry = boostTarget, "Boost Target", int, "%d", { boostEnabled }
|
entry = boostTarget, "Boost Target", int, "%d", { boostEnabled }
|
||||||
entry = boostDuty, "Boost Duty", int, "%d", { boostEnabled }
|
entry = boostDuty, "Boost Duty", int, "%d", { boostEnabled }
|
||||||
entry = boostCutOut , "Boost cut", int, "%d"
|
entry = boostCutOut , "Boost cut", int, "onOff"
|
||||||
entry = launchHard , "Launch Hard", int, "%d"
|
entry = launchHard , "Hard Launch", int, "onOff"
|
||||||
entry = hardLimitOn , "Hard Limiter", int, "%d"
|
entry = hardLimitOn , "Hard Limiter", int, "onOff"
|
||||||
|
entry = idleControlOn, "Idle Control", int, "onOff"
|
||||||
entry = idleLoad, "IAC value", int, "%d"
|
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 = 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 = syncLossCounter, "Sync Loss #", int, "%d"
|
||||||
|
|
||||||
entry = auxin_gauge0, "AuxIn CH0", int, "%d"
|
entry = auxin_gauge0, "AuxIn CH0", int, "%d"
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#define warmupPage 10 //Config Page 10
|
#define warmupPage 10 //Config Page 10
|
||||||
#define fuelMap2Page 11
|
#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
|
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 */
|
bool isMap = true; /**< Whether or not the currentPage contains only a 3D map that would require translation */
|
||||||
|
|
|
@ -592,6 +592,7 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum)
|
||||||
fullStatus[88] = highByte(currentStatus.ignLoad);
|
fullStatus[88] = highByte(currentStatus.ignLoad);
|
||||||
fullStatus[89] = lowByte(currentStatus.dwell);
|
fullStatus[89] = lowByte(currentStatus.dwell);
|
||||||
fullStatus[90] = highByte(currentStatus.dwell);
|
fullStatus[90] = highByte(currentStatus.dwell);
|
||||||
|
fullStatus[91] = currentStatus.CLIdleTarget;
|
||||||
|
|
||||||
for(byte x=0; x<packetLength; x++)
|
for(byte x=0; x<packetLength; x++)
|
||||||
{
|
{
|
||||||
|
|
|
@ -381,24 +381,25 @@ struct statuses {
|
||||||
int O2ADC;
|
int O2ADC;
|
||||||
int O2_2ADC;
|
int O2_2ADC;
|
||||||
int dwell;
|
int dwell;
|
||||||
byte dwellCorrection; //The amount of correction being applied to the dwell time.
|
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 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)
|
int8_t advance; /**< Signed 8 bit as advance can now go negative (ATDC) */
|
||||||
byte corrections;
|
byte corrections; /**< The total current corrections % amount */
|
||||||
int16_t TAEamount; //The amount of accleration enrichment currently being applied
|
int16_t TAEamount; /**< The amount of accleration enrichment currently being applied */
|
||||||
byte egoCorrection; //The amount of closed loop AFR 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 wueCorrection; /**< The amount of warmup enrichment currently being applied */
|
||||||
byte batCorrection; //The amount of battery voltage enrichment currently being applied
|
byte batCorrection; /**< The amount of battery voltage enrichment currently being applied */
|
||||||
byte iatCorrection; //The amount of inlet air temperature adjustment currently being applied
|
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 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 flexCorrection; /**< Amount of correction being applied to compensate for ethanol content */
|
||||||
int8_t flexIgnCorrection; //Amount of additional advance being applied based on flex. Note the type as this allows for negative values
|
int8_t flexIgnCorrection; /**< Amount of additional advance being applied based on flex. Note the type as this allows for negative values */
|
||||||
byte afrTarget;
|
byte afrTarget;
|
||||||
byte idleDuty;
|
byte idleDuty; /**< The current idle duty cycle amount if PWM idle is selected and active */
|
||||||
bool idleUpActive;
|
byte CLIdleTarget; /**< The target idle RPM (when closed loop idle control is active) */
|
||||||
bool fanOn; //Whether or not the fan is turned on
|
bool idleUpActive; /**< Whether the externally controlled idle up is currently active */
|
||||||
volatile byte ethanolPct; //Ethanol reading (if enabled). 0 = No ethanol, 100 = pure ethanol. Eg E85 = 85.
|
bool fanOn; /**< Whether or not the fan is turned on */
|
||||||
unsigned long TAEEndTime; //The target end time used whenever TAE 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 */
|
||||||
volatile byte status1;
|
volatile byte status1;
|
||||||
volatile byte spark;
|
volatile byte spark;
|
||||||
volatile byte spark2;
|
volatile byte spark2;
|
||||||
|
@ -411,32 +412,31 @@ struct statuses {
|
||||||
unsigned int PW6; //In uS
|
unsigned int PW6; //In uS
|
||||||
unsigned int PW7; //In uS
|
unsigned int PW7; //In uS
|
||||||
unsigned int PW8; //In uS
|
unsigned int PW8; //In uS
|
||||||
volatile byte runSecs; //Counter of seconds since cranking commenced (overflows at 255 obviously)
|
volatile byte runSecs; /**< Counter of seconds since cranking commenced (overflows at 255 obviously) */
|
||||||
volatile byte secl; //Continous
|
volatile byte secl; /**< Counter incrementing once per second. Will overflow after 255 and begin again. This is used by TunerStudio to maintain comms sync */
|
||||||
//volatile unsigned int loopsPerSecond;
|
volatile uint32_t loopsPerSecond; /**< A performance indicator showing the number of main loops that are being executed each second */
|
||||||
volatile uint32_t loopsPerSecond;
|
bool launchingSoft; /**< Indicator showing whether soft launch control adjustments are active */
|
||||||
bool launchingSoft; //True when in launch control soft limit mode
|
bool launchingHard; /**< Indicator showing whether hard launch control adjustments are active */
|
||||||
bool launchingHard; //True when in launch control hard limit mode
|
|
||||||
uint16_t freeRAM;
|
uint16_t freeRAM;
|
||||||
unsigned int clutchEngagedRPM;
|
unsigned int clutchEngagedRPM; /**< The RPM at which the clutch was last depressed. Used for distinguishing between launch control and flat shift */
|
||||||
bool flatShiftingHard;
|
bool flatShiftingHard;
|
||||||
volatile uint32_t startRevolutions; //A counter for how many revolutions have been completed since sync was achieved.
|
volatile uint32_t startRevolutions; /**< A counter for how many revolutions have been completed since sync was achieved. */
|
||||||
uint16_t boostTarget;
|
uint16_t boostTarget;
|
||||||
byte testOutputs;
|
byte testOutputs;
|
||||||
bool testActive;
|
bool testActive;
|
||||||
uint16_t boostDuty; //Percentage value * 100 to give 2 points of precision
|
uint16_t boostDuty; //Percentage value * 100 to give 2 points of precision
|
||||||
byte idleLoad; //Either the current steps or current duty cycle for the idle control.
|
byte idleLoad; /**< Either the current steps or current duty cycle for the idle control. */
|
||||||
uint16_t canin[16]; //16bit raw value of selected canin data for channel 0-15
|
uint16_t canin[16]; //16bit raw value of selected canin data for channel 0-15
|
||||||
uint8_t current_caninchannel = 0; //start off at channel 0
|
uint8_t current_caninchannel = 0; /**< Current CAN channel, defaults to 0 */
|
||||||
uint16_t crankRPM = 400; //The actual cranking RPM limit. Saves us multiplying it everytime from the config page
|
uint16_t crankRPM = 400; /**< The actual cranking RPM limit. This is derived from the value in the config page, but saves us multiplying it everytime it's used (Config page value is stored divided by 10) */
|
||||||
volatile byte status3;
|
volatile byte status3;
|
||||||
int16_t flexBoostCorrection; //Amount of boost added based on flex
|
int16_t flexBoostCorrection; /**< Amount of boost added based on flex */
|
||||||
byte nitrous_status;
|
byte nitrous_status;
|
||||||
byte nSquirts;
|
byte nSquirts;
|
||||||
byte nChannels; //Number of fuel and ignition channels
|
byte nChannels; /**< Number of fuel and ignition channels. */
|
||||||
int16_t fuelLoad;
|
int16_t fuelLoad;
|
||||||
int16_t ignLoad;
|
int16_t ignLoad;
|
||||||
bool fuelPumpOn; //The current status of the fuel pump
|
bool fuelPumpOn; /**< Indicator showing the current status of the fuel pump */
|
||||||
byte syncLossCounter;
|
byte syncLossCounter;
|
||||||
byte knockRetard;
|
byte knockRetard;
|
||||||
bool knockActive;
|
bool knockActive;
|
||||||
|
@ -452,8 +452,12 @@ struct statuses {
|
||||||
};
|
};
|
||||||
struct statuses currentStatus; //The global status object
|
struct statuses currentStatus; //The global status object
|
||||||
|
|
||||||
//Page 1 of the config - See the ini file for further reference
|
/**
|
||||||
//This mostly covers off variables that are required for fuel
|
* @brief This mostly covers off variables that are required for fuel
|
||||||
|
*
|
||||||
|
* See the ini file for further reference
|
||||||
|
*
|
||||||
|
*/
|
||||||
struct config2 {
|
struct config2 {
|
||||||
|
|
||||||
byte unused2_1;
|
byte unused2_1;
|
||||||
|
|
|
@ -188,8 +188,14 @@ void idleControl()
|
||||||
{
|
{
|
||||||
digitalWrite(pinIdle1, HIGH);
|
digitalWrite(pinIdle1, HIGH);
|
||||||
idleOn = true;
|
idleOn = true;
|
||||||
|
BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag on
|
||||||
|
}
|
||||||
|
else if (idleOn)
|
||||||
|
{
|
||||||
|
digitalWrite(pinIdle1, LOW);
|
||||||
|
idleOn = false;
|
||||||
|
BIT_CLEAR(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag on
|
||||||
}
|
}
|
||||||
else if (idleOn) { digitalWrite(pinIdle1, LOW); idleOn = false; }
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IAC_ALGORITHM_PWM_OL: //Case 2 is PWM open loop
|
case IAC_ALGORITHM_PWM_OL: //Case 2 is PWM open loop
|
||||||
|
@ -209,6 +215,7 @@ void idleControl()
|
||||||
if( currentStatus.idleDuty == 0 )
|
if( currentStatus.idleDuty == 0 )
|
||||||
{
|
{
|
||||||
disableIdle();
|
disableIdle();
|
||||||
|
BIT_CLEAR(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag off
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag on
|
BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag on
|
||||||
|
@ -220,7 +227,8 @@ void idleControl()
|
||||||
|
|
||||||
case IAC_ALGORITHM_PWM_CL: //Case 3 is PWM closed loop
|
case IAC_ALGORITHM_PWM_CL: //Case 3 is PWM closed loop
|
||||||
//No cranking specific value for closed loop (yet?)
|
//No cranking specific value for closed loop (yet?)
|
||||||
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; //Multiply the byte target value back out by 10
|
||||||
if( (idleCounter & 31) == 1) { idlePID.SetTunings(configPage6.idleKP, configPage6.idleKI, configPage6.idleKD); } //This only needs to be run very infrequently, once every 32 calls to idleControl(). This is approx. once per second
|
if( (idleCounter & 31) == 1) { idlePID.SetTunings(configPage6.idleKP, configPage6.idleKI, configPage6.idleKD); } //This only needs to be run very infrequently, once every 32 calls to idleControl(). This is approx. once per second
|
||||||
|
|
||||||
idlePID.Compute();
|
idlePID.Compute();
|
||||||
|
@ -228,6 +236,7 @@ void idleControl()
|
||||||
if( idle_pwm_target_value == 0 )
|
if( idle_pwm_target_value == 0 )
|
||||||
{
|
{
|
||||||
disableIdle();
|
disableIdle();
|
||||||
|
BIT_CLEAR(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag off
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag on
|
BIT_SET(currentStatus.spark, BIT_SPARK_IDLE); //Turn the idle control flag on
|
||||||
|
@ -265,6 +274,9 @@ void idleControl()
|
||||||
}
|
}
|
||||||
currentStatus.idleLoad = idleStepper.curIdleStep >> 1; //Current step count (Divided by 2 for byte)
|
currentStatus.idleLoad = idleStepper.curIdleStep >> 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;
|
break;
|
||||||
|
|
||||||
case IAC_ALGORITHM_STEP_CL: //Case 5 is closed loop stepper control
|
case IAC_ALGORITHM_STEP_CL: //Case 5 is closed loop stepper control
|
||||||
|
@ -279,7 +291,8 @@ void idleControl()
|
||||||
iacCoolTime = configPage9.iacCoolTime * 1000;
|
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
|
if(currentStatus.idleUpActive == true) { idle_pid_target_value += configPage2.idleUpAdder; } //Add Idle Up amount if active
|
||||||
idlePID.Compute();
|
idlePID.Compute();
|
||||||
idleStepper.targetIdleStep = idle_pid_target_value;
|
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)
|
currentStatus.idleLoad = idleStepper.curIdleStep >> 1; //Current step count (Divided by 2 for byte)
|
||||||
idleCounter++;
|
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;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue