Allow spark advance values below 0 in the main table
This commit is contained in:
parent
db147b5ccb
commit
04a6866115
|
@ -230,7 +230,7 @@ page = 2
|
|||
;Start Ignition table (Page 3)
|
||||
;--------------------------------------------------
|
||||
page = 3
|
||||
advTable1 = array, U08, 0,[16x16], "deg", 1.0, 0.0, 0.0, 255.0, 0
|
||||
advTable1 = array, U08, 0,[16x16], "deg", 1.0, -40, -40, 215.0, 0
|
||||
rpmBins2 = array, U08, 256,[ 16], "RPM", 100.0, 0.0, 100, 25500, 0
|
||||
|
||||
#if SPEED_DENSITY
|
||||
|
|
|
@ -20,14 +20,14 @@ static inline byte correctionIATDensity(); //Inlet temp density correction
|
|||
static inline byte correctionLaunch(); //Launch control correction
|
||||
static inline bool correctionDFCO(); //Decelleration fuel cutoff
|
||||
|
||||
byte correctionsIgn(byte advance);
|
||||
static inline byte correctionFixedTiming(byte);
|
||||
static inline byte correctionCrankingFixedTiming(byte);
|
||||
static inline byte correctionFlexTiming(byte);
|
||||
static inline byte correctionIATretard(byte);
|
||||
static inline byte correctionSoftRevLimit(byte);
|
||||
static inline byte correctionSoftLaunch(byte);
|
||||
static inline byte correctionSoftFlatShift(byte);
|
||||
int8_t correctionsIgn(int8_t advance);
|
||||
static inline int8_t correctionFixedTiming(int8_t);
|
||||
static inline int8_t correctionCrankingFixedTiming(int8_t);
|
||||
static inline int8_t correctionFlexTiming(int8_t);
|
||||
static inline int8_t correctionIATretard(int8_t);
|
||||
static inline int8_t correctionSoftRevLimit(int8_t);
|
||||
static inline int8_t correctionSoftLaunch(int8_t);
|
||||
static inline int8_t correctionSoftFlatShift(int8_t);
|
||||
|
||||
uint16_t correctionsDwell(uint16_t dwell);
|
||||
|
||||
|
|
|
@ -314,7 +314,7 @@ static inline byte correctionAFRClosedLoop()
|
|||
|
||||
//******************************** IGNITION ADVANCE CORRECTIONS ********************************
|
||||
|
||||
byte correctionsIgn(byte advance)
|
||||
int8_t correctionsIgn(int8_t advance)
|
||||
{
|
||||
|
||||
advance = correctionFlexTiming(advance);
|
||||
|
@ -329,19 +329,19 @@ byte correctionsIgn(byte advance)
|
|||
return advance;
|
||||
}
|
||||
|
||||
static inline byte correctionFixedTiming(byte advance)
|
||||
static inline int8_t correctionFixedTiming(int8_t advance)
|
||||
{
|
||||
if (configPage2.FixAng != 0) { return configPage2.FixAng; } //Check whether the user has set a fixed timing angle
|
||||
return advance;
|
||||
}
|
||||
|
||||
static inline byte correctionCrankingFixedTiming(byte advance)
|
||||
static inline int8_t correctionCrankingFixedTiming(int8_t advance)
|
||||
{
|
||||
if ( BIT_CHECK(currentStatus.engine, BIT_ENGINE_CRANK) ) { return configPage2.CrankAng; } //Use the fixed cranking ignition angle
|
||||
return advance;
|
||||
}
|
||||
|
||||
static inline byte correctionFlexTiming(byte advance)
|
||||
static inline int8_t correctionFlexTiming(int8_t advance)
|
||||
{
|
||||
if(!configPage1.flexEnabled) { return advance; } //Check for flex being enabled
|
||||
byte flexRange = configPage1.flexAdvHigh - configPage1.flexAdvLow;
|
||||
|
@ -352,22 +352,22 @@ static inline byte correctionFlexTiming(byte advance)
|
|||
return advance + currentStatus.flexIgnCorrection;
|
||||
}
|
||||
|
||||
static inline byte correctionIATretard(byte advance)
|
||||
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
|
||||
byte advanceIATadjust = table2D_getValue(&IATRetardTable, currentStatus.IAT);
|
||||
int8_t advanceIATadjust = table2D_getValue(&IATRetardTable, currentStatus.IAT);
|
||||
if (advanceIATadjust <= advance) { return (advance - advanceIATadjust); }
|
||||
else { return 0; }
|
||||
}
|
||||
|
||||
static inline byte correctionSoftRevLimit(byte advance)
|
||||
static inline int8_t correctionSoftRevLimit(int8_t advance)
|
||||
{
|
||||
BIT_CLEAR(currentStatus.spark, BIT_SPARK_SFTLIM);
|
||||
if (currentStatus.RPM > ((unsigned int)(configPage2.SoftRevLim) * 100) ) { BIT_SET(currentStatus.spark, BIT_SPARK_SFTLIM); return configPage2.SoftLimRetard; } //Softcut RPM limit (If we're above softcut limit, delay timing by configured number of degrees)
|
||||
return advance;
|
||||
}
|
||||
|
||||
static inline byte correctionSoftLaunch(byte advance)
|
||||
static inline int8_t correctionSoftLaunch(int8_t advance)
|
||||
{
|
||||
//SoftCut rev limit for 2-step launch control.
|
||||
if (configPage3.launchEnabled && clutchTrigger && (currentStatus.clutchEngagedRPM < ((unsigned int)(configPage3.flatSArm) * 100)) && (currentStatus.RPM > ((unsigned int)(configPage3.lnchSoftLim) * 100)) )
|
||||
|
@ -382,7 +382,7 @@ static inline byte correctionSoftLaunch(byte advance)
|
|||
return advance;
|
||||
}
|
||||
|
||||
static inline byte correctionSoftFlatShift(byte advance)
|
||||
static inline int8_t correctionSoftFlatShift(int8_t advance)
|
||||
{
|
||||
if(configPage3.flatSEnable && clutchTrigger && (currentStatus.clutchEngagedRPM > ((unsigned int)(configPage3.flatSArm) * 100)) && (currentStatus.RPM > (currentStatus.clutchEngagedRPM-configPage3.flatSSoftWin) ) )
|
||||
{
|
||||
|
@ -404,7 +404,7 @@ uint16_t correctionsDwell(uint16_t dwell)
|
|||
|
||||
//Dwell limiter
|
||||
uint16_t dwellPerRevolution = dwell + (uint16_t)(configPage2.sparkDur * 100); //Spark duration is in mS*10. Multiple it by 100 to get spark duration in uS
|
||||
byte pulsesPerRevolution = 1;
|
||||
int8_t pulsesPerRevolution = 1;
|
||||
//Single channel spark mode is the only time there will be more than 1 pulse per revolution on any given output
|
||||
if(configPage2.sparkMode == IGN_MODE_SINGLE && configPage1.nCylinders > 1) //No point in running this for 1 cylinder engines
|
||||
{
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
#define CALIBRATION_TABLE_SIZE 512
|
||||
#define CALIBRATION_TEMPERATURE_OFFSET 40 // All temperature measurements are stored offset by 40 degrees. This is so we can use an unsigned byte (0-255) to represent temperature ranges from -40 to 215
|
||||
#define OFFSET_FUELTRIM 127 //The fuel trim tables are offset by 128 to allow for -128 to +128 values
|
||||
#define OFFSET_IGNITION 40 //Ignition values from the main spark table are offset 40 degrees downards to allow for negative spark timing
|
||||
|
||||
#define SERIAL_BUFFER_THRESHOLD 32 // When the serial buffer is filled to greater than this threshold value, the serial processing operations will be performed more urgently in order to avoid it overflowing. Serial buffer is 64 bytes long, so the threshold is set at half this as a reasonable figure
|
||||
|
||||
|
@ -225,7 +226,7 @@ struct statuses {
|
|||
byte idleLoad; //Either the current steps or current duty cycle for the idle control.
|
||||
int canin[9]; //16bit raw value of selected canin data for channel 1-8
|
||||
uint8_t current_caninchannel = 0; //start off at channel 0
|
||||
|
||||
|
||||
//Helpful bitwise operations:
|
||||
//Useful reference: http://playground.arduino.cc/Code/BitMath
|
||||
// y = (x >> n) & 1; // n=0..15. stores nth bit of x in y. y becomes 0 or 1.
|
||||
|
|
|
@ -997,14 +997,14 @@ void loop()
|
|||
//Speed Density
|
||||
currentStatus.VE = get3DTableValue(&fuelTable, currentStatus.MAP, currentStatus.RPM); //Perform lookup into fuel map for RPM vs MAP value
|
||||
currentStatus.PW1 = PW_SD(req_fuel_uS, currentStatus.VE, currentStatus.MAP, currentStatus.corrections, inj_opentime_uS);
|
||||
currentStatus.advance = get3DTableValue(&ignitionTable, currentStatus.MAP, currentStatus.RPM); //As above, but for ignition advance
|
||||
currentStatus.advance = get3DTableValue(&ignitionTable, currentStatus.MAP, currentStatus.RPM) - OFFSET_IGNITION; //As above, but for ignition advance
|
||||
}
|
||||
else
|
||||
{
|
||||
//Alpha-N
|
||||
currentStatus.VE = get3DTableValue(&fuelTable, currentStatus.TPS, currentStatus.RPM); //Perform lookup into fuel map for RPM vs TPS value
|
||||
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); //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);
|
||||
|
|
Loading…
Reference in New Issue