Prevent the IAT retard curve from clobbering spark advance values below 0
This commit is contained in:
parent
cfebe84514
commit
7b13b8995c
|
@ -316,12 +316,12 @@ static inline byte correctionAFRClosedLoop()
|
||||||
|
|
||||||
int8_t correctionsIgn(int8_t advance)
|
int8_t correctionsIgn(int8_t advance)
|
||||||
{
|
{
|
||||||
|
|
||||||
advance = correctionFlexTiming(advance);
|
advance = correctionFlexTiming(advance);
|
||||||
advance = correctionIATretard(advance);
|
advance = correctionIATretard(advance);
|
||||||
advance = correctionSoftRevLimit(advance);
|
advance = correctionSoftRevLimit(advance);
|
||||||
advance = correctionSoftLaunch(advance);
|
advance = correctionSoftLaunch(advance);
|
||||||
advance = correctionSoftFlatShift(advance);
|
advance = correctionSoftFlatShift(advance);
|
||||||
|
|
||||||
//Fixed timing check must go last
|
//Fixed timing check must go last
|
||||||
advance = correctionFixedTiming(advance);
|
advance = correctionFixedTiming(advance);
|
||||||
advance = correctionCrankingFixedTiming(advance); //This overrrides the regular fixed timing, must come last
|
advance = correctionCrankingFixedTiming(advance); //This overrrides the regular fixed timing, must come last
|
||||||
|
@ -356,8 +356,9 @@ static inline int8_t correctionIATretard(int8_t advance)
|
||||||
{
|
{
|
||||||
//Adjust the advance based on IAT. If the adjustment amount is greater than the current advance, just set advance to 0
|
//Adjust the advance based on IAT. If the adjustment amount is greater than the current advance, just set advance to 0
|
||||||
int8_t advanceIATadjust = table2D_getValue(&IATRetardTable, currentStatus.IAT);
|
int8_t advanceIATadjust = table2D_getValue(&IATRetardTable, currentStatus.IAT);
|
||||||
if (advanceIATadjust <= advance) { return (advance - advanceIATadjust); }
|
int tempAdvance = (advance - advanceIATadjust);
|
||||||
else { return 0; }
|
if (tempAdvance >= -OFFSET_IGNITION) { return tempAdvance; }
|
||||||
|
else { return -OFFSET_IGNITION; }
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int8_t correctionSoftRevLimit(int8_t advance)
|
static inline int8_t correctionSoftRevLimit(int8_t advance)
|
||||||
|
|
|
@ -159,15 +159,15 @@ void setup()
|
||||||
if (configPage10.enable_canbus == 1) { Serial3.begin(115200); }
|
if (configPage10.enable_canbus == 1) { Serial3.begin(115200); }
|
||||||
#elif defined(CORE_STM32)
|
#elif defined(CORE_STM32)
|
||||||
if (configPage10.enable_canbus == 1) { Serial2.begin(115200); }
|
if (configPage10.enable_canbus == 1) { Serial2.begin(115200); }
|
||||||
else if (configPage10.enable_canbus == 2)
|
else if (configPage10.enable_canbus == 2)
|
||||||
{
|
{
|
||||||
//enable local can interface
|
//enable local can interface
|
||||||
}
|
}
|
||||||
#elif defined(CORE_TEESNY)
|
#elif defined(CORE_TEESNY)
|
||||||
if (configPage10.enable_canbus == 1) { Serial2.begin(115200); }
|
if (configPage10.enable_canbus == 1) { Serial2.begin(115200); }
|
||||||
else if (configPage10.enable_canbus == 2)
|
else if (configPage10.enable_canbus == 2)
|
||||||
{
|
{
|
||||||
//enable local can interface
|
//enable local can interface
|
||||||
FlexCAN CANbus0(2500000, 0); //setup can interface to 250k
|
FlexCAN CANbus0(2500000, 0); //setup can interface to 250k
|
||||||
static CAN_message_t txmsg,rxmsg;
|
static CAN_message_t txmsg,rxmsg;
|
||||||
CANbus0.begin();
|
CANbus0.begin();
|
||||||
|
@ -840,11 +840,11 @@ void loop()
|
||||||
command();
|
command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //ATmega2561 does not have Serial3
|
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) //ATmega2561 does not have Serial3
|
||||||
//if serial3 interface is enabled then check for serial3 requests.
|
//if serial3 interface is enabled then check for serial3 requests.
|
||||||
if (configPage10.enable_canbus == 1)
|
if (configPage10.enable_canbus == 1)
|
||||||
{
|
{
|
||||||
if ( ((mainLoopCount & 31) == 1) or (Serial3.available() > SERIAL_BUFFER_THRESHOLD) )
|
if ( ((mainLoopCount & 31) == 1) or (Serial3.available() > SERIAL_BUFFER_THRESHOLD) )
|
||||||
{
|
{
|
||||||
if (Serial3.available() > 0)
|
if (Serial3.available() > 0)
|
||||||
|
@ -865,11 +865,11 @@ void loop()
|
||||||
canCommand();
|
canCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (configPage10.enable_canbus == 2) // can module enabled
|
else if (configPage10.enable_canbus == 2) // can module enabled
|
||||||
{
|
{
|
||||||
//check local can module
|
//check local can module
|
||||||
}
|
}
|
||||||
#elif defined(CORE_TEENSY)
|
#elif defined(CORE_TEENSY)
|
||||||
//if can or secondary serial interface is enabled then check for requests.
|
//if can or secondary serial interface is enabled then check for requests.
|
||||||
if (configPage10.enable_canbus == 1) //secondary serial interface enabled
|
if (configPage10.enable_canbus == 1) //secondary serial interface enabled
|
||||||
|
@ -881,14 +881,14 @@ void loop()
|
||||||
canCommand();
|
canCommand();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (configPage10.enable_canbus == 2) // can module enabled
|
else if (configPage10.enable_canbus == 2) // can module enabled
|
||||||
{
|
{
|
||||||
//check local can module
|
//check local can module
|
||||||
// if ( ((mainLoopCount & 31) == 1) or (CANbus0.available())
|
// if ( ((mainLoopCount & 31) == 1) or (CANbus0.available())
|
||||||
// {
|
// {
|
||||||
// CANbus0.read(rx_msg);
|
// CANbus0.read(rx_msg);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1039,7 +1039,7 @@ void loop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
vvtControl();
|
vvtControl();
|
||||||
idleControl(); //Perform any idle related actions. Even at higher frequencies, running 4x per second is sufficient.
|
idleControl(); //Perform any idle related actions. Even at higher frequencies, running 4x per second is sufficient.
|
||||||
|
@ -1090,7 +1090,7 @@ void loop()
|
||||||
currentStatus.PW1 = PW_AN(req_fuel_uS, currentStatus.VE, currentStatus.TPS, currentStatus.corrections, inj_opentime_uS); //Calculate pulsewidth using the Alpha-N algorithm (in uS)
|
currentStatus.PW1 = PW_AN(req_fuel_uS, currentStatus.VE, currentStatus.TPS, currentStatus.corrections, inj_opentime_uS); //Calculate pulsewidth using the Alpha-N algorithm (in uS)
|
||||||
currentStatus.advance = get3DTableValue(&ignitionTable, currentStatus.TPS, currentStatus.RPM) - OFFSET_IGNITION; //As above, but for ignition advance
|
currentStatus.advance = get3DTableValue(&ignitionTable, currentStatus.TPS, currentStatus.RPM) - OFFSET_IGNITION; //As above, but for ignition advance
|
||||||
}
|
}
|
||||||
|
|
||||||
currentStatus.advance = correctionsIgn(currentStatus.advance);
|
currentStatus.advance = correctionsIgn(currentStatus.advance);
|
||||||
/*
|
/*
|
||||||
//Check for fixed ignition angles
|
//Check for fixed ignition angles
|
||||||
|
|
Loading…
Reference in New Issue