Final cleanup and comments
This commit is contained in:
parent
ce95b49861
commit
482f2364e8
|
@ -942,11 +942,17 @@ uint16_t correctionsDwell(uint16_t dwell)
|
||||||
{
|
{
|
||||||
uint16_t tempDwell = dwell;
|
uint16_t tempDwell = dwell;
|
||||||
uint16_t sparkDur_uS = (configPage4.sparkDur * 100); //Spark duration is in mS*10. Multiple it by 100 to get spark duration in uS
|
uint16_t sparkDur_uS = (configPage4.sparkDur * 100); //Spark duration is in mS*10. Multiple it by 100 to get spark duration in uS
|
||||||
|
if(currentStatus.actualDwell == 0) { currentStatus.actualDwell = tempDwell; } //Initialise the actualDwell value if this is the first time being called
|
||||||
|
|
||||||
|
//**************************************************************************************************************************
|
||||||
//Pull battery voltage based dwell correction and apply if needed
|
//Pull battery voltage based dwell correction and apply if needed
|
||||||
currentStatus.dwellCorrection = table2D_getValue(&dwellVCorrectionTable, currentStatus.battery10);
|
currentStatus.dwellCorrection = table2D_getValue(&dwellVCorrectionTable, currentStatus.battery10);
|
||||||
if (currentStatus.dwellCorrection != 100) { tempDwell = div100(dwell) * currentStatus.dwellCorrection; }
|
if (currentStatus.dwellCorrection != 100) { tempDwell = div100(dwell) * currentStatus.dwellCorrection; }
|
||||||
|
|
||||||
//Dwell correction is a basic closed loop to keep the dwell time consistent even when adjusting its end time for the per tooth timing
|
|
||||||
|
//**************************************************************************************************************************
|
||||||
|
//Dwell error correction is a basic closed loop to keep the dwell time consistent even when adjusting its end time for the per tooth timing.
|
||||||
|
//This is mostly of benefit to low resolution triggers at low rpm (<1500)
|
||||||
if( (configPage2.perToothIgn == true) && (configPage4.dwellErrCorrect == 1) )
|
if( (configPage2.perToothIgn == true) && (configPage4.dwellErrCorrect == 1) )
|
||||||
{
|
{
|
||||||
int16_t error = tempDwell - currentStatus.actualDwell;
|
int16_t error = tempDwell - currentStatus.actualDwell;
|
||||||
|
@ -955,17 +961,20 @@ uint16_t correctionsDwell(uint16_t dwell)
|
||||||
if(error > 0) { tempDwell += error; }
|
if(error > 0) { tempDwell += error; }
|
||||||
}
|
}
|
||||||
|
|
||||||
//Dwell limiter
|
//**************************************************************************************************************************
|
||||||
|
/*
|
||||||
|
Dwell limiter - If the total required dwell time per revolution is longer than the maximum time available at the current RPM, reduce dwell. This can occur if there are multiple sparks per revolution
|
||||||
|
This only times this can occur are:
|
||||||
|
1. Single channel spark mode where there will be nCylinders/2 sparks per revolution
|
||||||
|
2. Rotary ignition in wasted spark configuration (FC/FD), results in 2 pulses per rev. RX-8 is fully sequential resulting in 1 pulse, so not required
|
||||||
|
*/
|
||||||
uint16_t dwellPerRevolution = tempDwell + sparkDur_uS;
|
uint16_t dwellPerRevolution = tempDwell + sparkDur_uS;
|
||||||
int8_t 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
|
|
||||||
//For rotary ignition this also holds true in wasted spark configuration (FC/FD) resulting in 2 pulses. RX-8 however is fully sequential resulting in 1 pulse
|
|
||||||
if( ( (configPage4.sparkMode == IGN_MODE_SINGLE) || ((configPage4.sparkMode == IGN_MODE_ROTARY) && (configPage10.rotaryType != ROTARY_IGN_RX8)) ) && (configPage2.nCylinders > 1) ) //No point in running this for 1 cylinder engines
|
if( ( (configPage4.sparkMode == IGN_MODE_SINGLE) || ((configPage4.sparkMode == IGN_MODE_ROTARY) && (configPage10.rotaryType != ROTARY_IGN_RX8)) ) && (configPage2.nCylinders > 1) ) //No point in running this for 1 cylinder engines
|
||||||
{
|
{
|
||||||
pulsesPerRevolution = (configPage2.nCylinders >> 1);
|
pulsesPerRevolution = (configPage2.nCylinders >> 1);
|
||||||
dwellPerRevolution = dwellPerRevolution * pulsesPerRevolution;
|
dwellPerRevolution = dwellPerRevolution * pulsesPerRevolution;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(dwellPerRevolution > revolutionTime)
|
if(dwellPerRevolution > revolutionTime)
|
||||||
{
|
{
|
||||||
//Possibly need some method of reducing spark duration here as well, but this is a start
|
//Possibly need some method of reducing spark duration here as well, but this is a start
|
||||||
|
@ -973,7 +982,5 @@ uint16_t correctionsDwell(uint16_t dwell)
|
||||||
tempDwell = (revolutionTime / pulsesPerRevolution) - adjustedSparkDur;
|
tempDwell = (revolutionTime / pulsesPerRevolution) - adjustedSparkDur;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentStatus.actualDwell == 0) { currentStatus.actualDwell = tempDwell; } //Initialise the actualDwell value if this is the first time being called
|
|
||||||
|
|
||||||
return tempDwell;
|
return tempDwell;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ See page 136 of the processors datasheet: http://www.atmel.com/Images/doc2549.pd
|
||||||
|
|
||||||
#define DWELL_AVERAGE_ALPHA 30
|
#define DWELL_AVERAGE_ALPHA 30
|
||||||
#define DWELL_AVERAGE(input) (((long)input * (256 - DWELL_AVERAGE_ALPHA) + ((long)currentStatus.actualDwell * DWELL_AVERAGE_ALPHA))) >> 8
|
#define DWELL_AVERAGE(input) (((long)input * (256 - DWELL_AVERAGE_ALPHA) + ((long)currentStatus.actualDwell * DWELL_AVERAGE_ALPHA))) >> 8
|
||||||
//#define DWELL_AVERAGE(input) (currentStatus.dwell)
|
//#define DWELL_AVERAGE(input) (currentStatus.dwell) //Can be use to disable the above for testing
|
||||||
|
|
||||||
extern void (*inj1StartFunction)(void);
|
extern void (*inj1StartFunction)(void);
|
||||||
extern void (*inj1EndFunction)(void);
|
extern void (*inj1EndFunction)(void);
|
||||||
|
|
Loading…
Reference in New Issue