Some base work for the knock control
This commit is contained in:
parent
765e52fce5
commit
26773ba41d
|
@ -34,5 +34,9 @@ static inline int8_t correctionKnock(int8_t);
|
|||
uint16_t correctionsDwell(uint16_t dwell);
|
||||
|
||||
uint16_t AFRnextCycle;
|
||||
unsigned long knockStartTime;
|
||||
byte lastKnockCount;
|
||||
int16_t knockWindowMin; //The current minimum crank angle for a knock pulse to be valid
|
||||
int16_t knockWindowMax;//The current maximum crank angle for a knock pulse to be valid
|
||||
|
||||
#endif // CORRECTIONS_H
|
||||
|
|
|
@ -29,6 +29,7 @@ void initialiseCorrections()
|
|||
currentStatus.flexIgnCorrection = 0;
|
||||
currentStatus.egoCorrection = 100; //Default value of no adjustment must be set to avoid randomness on first correction cycle after startup
|
||||
AFRnextCycle = 0;
|
||||
currentStatus.knockActive = false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -511,8 +512,31 @@ static inline int8_t correctionKnock(int8_t advance)
|
|||
{
|
||||
byte knockRetard = 0;
|
||||
|
||||
if( (configPage10.knock_mode > 0) && (knockCounter > 0) )
|
||||
//First check is to do the window calculations (ASsuming knock is enabled)
|
||||
if( configPage10.knock_mode != KNOCK_MODE_OFF )
|
||||
{
|
||||
knockWindowMin = table2D_getValue(&knockWindowStartTable, currentStatus.RPM);
|
||||
knockWindowMax = knockWindowMin + table2D_getValue(&knockWindowDurationTable, currentStatus.RPM);
|
||||
}
|
||||
|
||||
|
||||
if( (configPage10.knock_mode == KNOCK_MODE_DIGITAL) )
|
||||
{
|
||||
//
|
||||
if(knockCounter > configPage10.knock_count)
|
||||
{
|
||||
if(currentStatus.knockActive == true)
|
||||
{
|
||||
//Knock retard is currently
|
||||
}
|
||||
else
|
||||
{
|
||||
//Knock needs to be activated
|
||||
lastKnockCount = knockCounter;
|
||||
knockStartTime = micros();
|
||||
knockRetard = configPage10.knock_firstStep;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -170,6 +170,10 @@
|
|||
#define NITROUS_STAGE1 1
|
||||
#define NITROUS_STAGE2 2
|
||||
|
||||
#define KNOCK_MODE_OFF 0
|
||||
#define KNOCK_MODE_DIGITAL 1
|
||||
#define KNOCK_MODE_ANALOG 2
|
||||
|
||||
#define RESET_CONTROL_DISABLED 0
|
||||
#define RESET_CONTROL_PREVENT_WHEN_RUNNING 1
|
||||
#define RESET_CONTROL_PREVENT_ALWAYS 2
|
||||
|
@ -221,6 +225,8 @@ struct table2D rotarySplitTable; //8 bin ignition split curve for rotary leading
|
|||
struct table2D flexFuelTable; //6 bin flex fuel correction table for fuel adjustments (2D)
|
||||
struct table2D flexAdvTable; //6 bin flex fuel correction table for timing advance (2D)
|
||||
struct table2D flexBoostTable; //6 bin flex fuel correction table for boost adjustments (2D)
|
||||
struct table2D knockWindowStartTable;
|
||||
struct table2D knockWindowDurationTable;
|
||||
|
||||
//These are for the direct port manipulation of the injectors, coils and aux outputs
|
||||
volatile byte *inj1_pin_port;
|
||||
|
@ -393,6 +399,7 @@ struct statuses {
|
|||
bool fuelPumpOn; //The current status of the fuel pump
|
||||
byte syncLossCounter;
|
||||
byte knockRetard;
|
||||
bool knockActive;
|
||||
|
||||
//Helpful bitwise operations:
|
||||
//Useful reference: http://playground.arduino.cc/Code/BitMath
|
||||
|
|
|
@ -1184,8 +1184,8 @@ static inline void ignitionSchedule1Interrupt() //Most ARM chips can simply call
|
|||
}
|
||||
else if (ignitionSchedule1.Status == RUNNING)
|
||||
{
|
||||
//ignitionSchedule1.EndCallback();
|
||||
*ign1_pin_port &= ~(ign1_pin_mask);
|
||||
ignitionSchedule1.EndCallback();
|
||||
//*ign1_pin_port &= ~(ign1_pin_mask);
|
||||
ignitionSchedule1.Status = OFF; //Turn off the schedule
|
||||
ignitionSchedule1.schedulesSet = 0;
|
||||
ignitionSchedule1.hasNextSchedule = false;
|
||||
|
|
|
@ -353,9 +353,11 @@ void flexPulse()
|
|||
*/
|
||||
void knockPulse()
|
||||
{
|
||||
//Check if this the start of a knock.
|
||||
if(knockCounter == 0)
|
||||
{
|
||||
//knockAngle = crankAngle + fastTimeToAngle( (micros() - lastCrankAngleCalc) );
|
||||
knockStartTime = micros();
|
||||
knockCounter = 1;
|
||||
}
|
||||
else { ++knockCounter; } //Knock has already started, so just increment the counter for this
|
||||
|
|
Loading…
Reference in New Issue