mirror of https://github.com/rusefi/speeduino.git
Minor fixes
This commit is contained in:
parent
a789f7bbe6
commit
acf0d47c0d
|
@ -359,6 +359,7 @@ void triggerSetup_4G63()
|
|||
toothAngles[3] = 355; //Rising edge of tooth #1
|
||||
|
||||
triggerFilterTime = 1500; //10000 rpm, assuming we're triggering on both edges off the crank tooth.
|
||||
triggerSecFilterTime = (int)(1000000 / (MAX_RPM / 60 * 2)) / 2; //Same as above, but fixed at 2 teeth on the secondary input and divided by 2 (for cam speed)
|
||||
}
|
||||
|
||||
void triggerPri_4G63()
|
||||
|
@ -373,7 +374,8 @@ void triggerPri_4G63()
|
|||
toothOneMinusOneTime = toothOneTime;
|
||||
toothOneTime = curTime;
|
||||
currentStatus.hasSync = true;
|
||||
startRevolutions++; //Counter
|
||||
startRevolutions++; //Counter
|
||||
//if ((startRevolutions & 63) == 1) { currentStatus.hasSync = false; } //Every 64 revolutions, force a resync with the cam
|
||||
}
|
||||
else if (!currentStatus.hasSync) { return; }
|
||||
else { toothCurrentCount++; }
|
||||
|
@ -390,6 +392,11 @@ void triggerPri_4G63()
|
|||
}
|
||||
void triggerSec_4G63()
|
||||
{
|
||||
curTime2 = micros();
|
||||
curGap2 = curTime2 - toothLastSecToothTime;
|
||||
if ( curGap2 < triggerSecFilterTime ) { return; }
|
||||
toothLastSecToothTime = curTime2;
|
||||
|
||||
if(!currentStatus.hasSync)
|
||||
{
|
||||
//Check the status of the crank trigger
|
||||
|
|
|
@ -141,8 +141,8 @@ void setIgnitionSchedule2(void (*startCallback)(), unsigned long timeout, unsign
|
|||
|
||||
//We need to calculate the value to reset the timer to (preload) in order to achieve the desired overflow time
|
||||
//As the timer is ticking every 16uS (Time per Tick = (Prescale)*(1/Frequency))
|
||||
unsigned int absoluteTimeout = TCNT5 + (timeout >> 4 ); //Each tick occurs every 16uS with the 256 prescaler, so divide the timeout by 16 to get ther required number of ticks. Add this to the current tick count to get the target time. This will automatically overflow as required
|
||||
//unsigned int absoluteTimeout = TCNT5 + (timeout >> 2); //As above, but with bit shift instead of / 16
|
||||
//unsigned int absoluteTimeout = TCNT5 + (timeout >> 4 ); //Each tick occurs every 16uS with the 256 prescaler, so divide the timeout by 16 to get ther required number of ticks. Add this to the current tick count to get the target time. This will automatically overflow as required
|
||||
unsigned int absoluteTimeout = TCNT5 + (timeout >> 2); //As above, but with bit shift instead of / 16 (high precision)
|
||||
OCR5B = absoluteTimeout;
|
||||
ignitionSchedule2.duration = duration;
|
||||
ignitionSchedule2.StartCallback = startCallback; //Name the start callback function
|
||||
|
@ -285,9 +285,8 @@ ISR(TIMER5_COMPB_vect, ISR_NOBLOCK) //ignitionSchedule2
|
|||
ignitionSchedule2.Status = RUNNING; //Set the status to be in progress (ie The start callback has been called, but not the end callback)
|
||||
ignitionSchedule2.startTime = currentLoopTime;
|
||||
ignitionSchedule2.StartCallback();
|
||||
unsigned int absoluteTimeout = TCNT5 + (ignitionSchedule2.duration >> 4);
|
||||
ign2LastRev = startRevolutions;
|
||||
//unsigned int absoluteTimeout = TCNT5 + (ignitionSchedule2.duration >> 2); //Divide by 4
|
||||
unsigned int absoluteTimeout = TCNT5 + (ignitionSchedule2.duration >> 2);
|
||||
OCR5B = absoluteTimeout;
|
||||
}
|
||||
else if (ignitionSchedule2.Status == RUNNING)
|
||||
|
@ -306,9 +305,8 @@ ISR(TIMER5_COMPC_vect, ISR_NOBLOCK) //ignitionSchedule3
|
|||
ignitionSchedule3.Status = RUNNING; //Set the status to be in progress (ie The start callback has been called, but not the end callback)
|
||||
ignitionSchedule3.startTime = currentLoopTime;
|
||||
ignitionSchedule3.StartCallback();
|
||||
unsigned int absoluteTimeout = TCNT5 + (ignitionSchedule2.duration >> 4);
|
||||
unsigned int absoluteTimeout = TCNT5 + (ignitionSchedule2.duration >> 2);
|
||||
ign3LastRev = startRevolutions;
|
||||
//unsigned int absoluteTimeout = TCNT5 + (ignitionSchedule3.duration >> 2); //Divide by 4
|
||||
OCR5C = absoluteTimeout;
|
||||
}
|
||||
else if (ignitionSchedule3.Status == RUNNING)
|
||||
|
|
|
@ -277,12 +277,12 @@ void setup()
|
|||
if(configPage2.TrigEdge == 0)
|
||||
{
|
||||
attachInterrupt(triggerInterrupt, trigger, CHANGE); // Attach the crank trigger wheel interrupt (Hall sensor drags to ground when triggering)
|
||||
attachInterrupt(triggerInterrupt2, triggerSec_4G63, RISING); //changed
|
||||
attachInterrupt(triggerInterrupt2, triggerSec_4G63, FALLING); //changed
|
||||
}
|
||||
else
|
||||
{
|
||||
attachInterrupt(triggerInterrupt, trigger, CHANGE); // Primary trigger connects to
|
||||
attachInterrupt(triggerInterrupt2, triggerSec_4G63, RISING);
|
||||
attachInterrupt(triggerInterrupt2, triggerSec_4G63, FALLING);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue