Tweak trigger filter time to better value for 36-1

This commit is contained in:
Josh Stewart 2014-07-07 22:48:50 +10:00
parent 0ce155f7da
commit d306e8aee7
2 changed files with 15 additions and 2 deletions

View File

@ -212,6 +212,7 @@ ISR(TIMER3_COMPB_vect) //fuelSchedule2
}
ISR(TIMER3_COMPC_vect) //fuelSchedule3
{
noInterrupts();
if (fuelSchedule3.Status == PENDING) //Check to see if this schedule is turn on
{
fuelSchedule3.StartCallback();
@ -226,9 +227,11 @@ ISR(TIMER3_COMPC_vect) //fuelSchedule3
fuelSchedule3.Status = OFF; //Turn off the schedule
TIMSK3 &= ~(1 << OCIE3C); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
interrupts();
}
ISR(TIMER4_COMPB_vect) //fuelSchedule4
{
noInterrupts();
if (fuelSchedule4.Status == PENDING) //Check to see if this schedule is turn on
{
fuelSchedule4.StartCallback();
@ -243,9 +246,11 @@ ISR(TIMER4_COMPB_vect) //fuelSchedule4
fuelSchedule4.Status = OFF; //Turn off the schedule
TIMSK4 &= ~(1 << OCIE4B); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
interrupts();
}
ISR(TIMER5_COMPA_vect) //ignitionSchedule1
{
noInterrupts();
if (ignitionSchedule1.Status == PENDING) //Check to see if this schedule is turn on
{
ignitionSchedule1.StartCallback();
@ -260,9 +265,11 @@ ISR(TIMER5_COMPA_vect) //ignitionSchedule1
ignitionSchedule1.Status = OFF; //Turn off the schedule
TIMSK5 &= ~(1 << OCIE5A); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
interrupts();
}
ISR(TIMER5_COMPB_vect) //ignitionSchedule2
{
noInterrupts();
if (ignitionSchedule2.Status == PENDING) //Check to see if this schedule is turn on
{
ignitionSchedule2.StartCallback();
@ -277,9 +284,11 @@ ISR(TIMER5_COMPB_vect) //ignitionSchedule2
ignitionSchedule2.Status = OFF; //Turn off the schedule
TIMSK5 &= ~(1 << OCIE5B); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
interrupts();
}
ISR(TIMER5_COMPC_vect) //ignitionSchedule3
{
noInterrupts();
if (ignitionSchedule3.Status == PENDING) //Check to see if this schedule is turn on
{
ignitionSchedule3.StartCallback();
@ -294,9 +303,11 @@ ISR(TIMER5_COMPC_vect) //ignitionSchedule3
ignitionSchedule3.Status = OFF; //Turn off the schedule
TIMSK5 &= ~(1 << OCIE5C); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
interrupts();
}
ISR(TIMER4_COMPA_vect) //ignitionSchedule4
{
noInterrupts();
if (ignitionSchedule4.Status == PENDING) //Check to see if this schedule is turn on
{
ignitionSchedule4.StartCallback();
@ -311,4 +322,5 @@ ISR(TIMER4_COMPA_vect) //ignitionSchedule4
ignitionSchedule4.Status = OFF; //Turn off the schedule
TIMSK5 &= ~(1 << OCIE4A); //Turn off this output compare unit (This simply writes 0 to the OCIE3A bit of TIMSK3)
}
interrupts();
}

View File

@ -44,7 +44,7 @@ struct config2 configPage2;
int req_fuel_uS, triggerToothAngle;
volatile int triggerActualTeeth;
unsigned int triggerFilterTime = 500; // The shortest time (in uS) that pulses will be accepted (Used for debounce filtering)
unsigned int triggerFilterTime = 200; // The shortest time (in uS) that pulses will be accepted (Used for debounce filtering)
volatile int toothCurrentCount = 0; //The current number of teeth (Onec sync has been achieved, this can never actually be 0
volatile unsigned long toothLastToothTime = 0; //The time (micros()) that the last tooth was registered
@ -316,7 +316,8 @@ void loop()
//How fast are we going? Need to know how long (uS) it will take to get from one tooth to the next. We then use that to estimate how far we are between the last tooth and the next one
int timePerDegree = ldiv( (toothOneTime - toothOneMinusOneTime) , 360).quot; //The time (uS) it is currently taking to move 1 degree
crankAngle += div( (int)(micros() - toothLastToothTime), timePerDegree).quot; //Estimate the number of degrees travelled since the last tooth
//crankAngle += div( (int)(micros() - toothLastToothTime), timePerDegree).quot; //Estimate the number of degrees travelled since the last tooth
crankAngle += ldiv( (micros() - toothLastToothTime), timePerDegree).quot; //Estimate the number of degrees travelled since the last tooth
//Determine next firing angles
//1