Improvements to tooth logger

This commit is contained in:
Josh Stewart 2015-10-26 06:21:12 +11:00
parent 27e88232ff
commit 5cd8b6852e
3 changed files with 25 additions and 48 deletions

View File

@ -822,7 +822,7 @@ void sendToothLog(bool useChar)
{ {
//We need 256 records to send to TunerStudio. If there aren't that many in the buffer (Buffer is 512 long) then we just return and wait for the next call //We need 256 records to send to TunerStudio. If there aren't that many in the buffer (Buffer is 512 long) then we just return and wait for the next call
if (toothHistoryIndex < 255) { if (toothHistoryIndex < TOOTH_LOG_SIZE) {
return; //This should no longer ever occur return; //This should no longer ever occur
} }
unsigned int tempToothHistory[512]; //Create a temporary array that will contain a copy of what is in the main toothHistory array unsigned int tempToothHistory[512]; //Create a temporary array that will contain a copy of what is in the main toothHistory array
@ -834,21 +834,20 @@ void sendToothLog(bool useChar)
//Loop only needs to go to 256 (Even though the buffer is 512 long) as we only ever send 256 entries at a time //Loop only needs to go to 256 (Even though the buffer is 512 long) as we only ever send 256 entries at a time
if (useChar) if (useChar)
{ {
for (int x = 0; x < 256; x++) for (int x = 0; x < TOOTH_LOG_SIZE; x++)
{ {
Serial.println(tempToothHistory[x]); Serial.println(tempToothHistory[x]);
} }
} }
else else
{ {
for (int x = 0; x < 256; x++) for (int x = 0; x < TOOTH_LOG_SIZE; x++)
{ {
Serial.write(highByte(tempToothHistory[x])); Serial.write(highByte(tempToothHistory[x]));
Serial.write(lowByte(tempToothHistory[x])); Serial.write(lowByte(tempToothHistory[x]));
} }
BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY);
} }
//Serial.flush();
} }

View File

@ -21,6 +21,16 @@ toothLastToothTime - The time (In uS) that the last primary tooth was 'seen'
*/ */
inline void addToothLogEntry(unsigned long time)
{
//High speed tooth logging history
toothHistory[toothHistoryIndex] = curGap;
if(toothHistoryIndex == 511)
{ toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent.
else
{ toothHistoryIndex++; }
}
/* /*
Name: Missing tooth wheel Name: Missing tooth wheel
Desc: A multi-tooth wheel with one of more 'missing' teeth. The first tooth after the missing one is considered number 1 and isthe basis for the trigger angle Desc: A multi-tooth wheel with one of more 'missing' teeth. The first tooth after the missing one is considered number 1 and isthe basis for the trigger angle
@ -43,12 +53,7 @@ void triggerPri_missingTooth()
if ( curGap < triggerFilterTime ) { return; } //Debounce check. Pulses should never be less than triggerFilterTime, so if they are it means a false trigger. (A 36-1 wheel at 8000pm will have triggers approx. every 200uS) if ( curGap < triggerFilterTime ) { return; } //Debounce check. Pulses should never be less than triggerFilterTime, so if they are it means a false trigger. (A 36-1 wheel at 8000pm will have triggers approx. every 200uS)
toothCurrentCount++; //Increment the tooth counter toothCurrentCount++; //Increment the tooth counter
//High speed tooth logging history addToothLogEntry(curGap);
toothHistory[toothHistoryIndex] = curGap;
if(toothHistoryIndex == 511)
{ toothHistoryIndex = 0; }
else
{ toothHistoryIndex++; }
//Begin the missing tooth detection //Begin the missing tooth detection
//If the time between the current tooth and the last is greater than 1.5x the time between the last tooth and the tooth before that, we make the assertion that we must be at the first tooth after the gap //If the time between the current tooth and the last is greater than 1.5x the time between the last tooth and the tooth before that, we make the assertion that we must be at the first tooth after the gap
@ -128,12 +133,7 @@ void triggerPri_DualWheel()
if ((startRevolutions & 63) == 1) { currentStatus.hasSync = false; } //Every 64 revolutions, force a resync with the cam if ((startRevolutions & 63) == 1) { currentStatus.hasSync = false; } //Every 64 revolutions, force a resync with the cam
} }
//High speed tooth logging history addToothLogEntry(curGap);
toothHistory[toothHistoryIndex] = curGap;
if(toothHistoryIndex == 511)
{ toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent.
else
{ toothHistoryIndex++; }
toothLastMinusOneToothTime = toothLastToothTime; toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime; toothLastToothTime = curTime;
@ -212,15 +212,10 @@ void triggerPri_BasicDistributor()
} }
else { toothCurrentCount++; } //Increment the tooth counter else { toothCurrentCount++; } //Increment the tooth counter
//High speed tooth logging history addToothLogEntry(curGap);
toothHistory[toothHistoryIndex] = curGap;
if(toothHistoryIndex == 511)
{ toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent.
else
{ toothHistoryIndex++; }
toothLastMinusOneToothTime = toothLastToothTime; toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime; toothLastToothTime = curTime;
} }
void triggerSec_BasicDistributor() { return; } //Not required void triggerSec_BasicDistributor() { return; } //Not required
int getRPM_BasicDistributor() int getRPM_BasicDistributor()
@ -265,12 +260,7 @@ void triggerPri_GM7X()
curGap = curTime - toothLastToothTime; curGap = curTime - toothLastToothTime;
toothCurrentCount++; //Increment the tooth counter toothCurrentCount++; //Increment the tooth counter
//High speed tooth logging history addToothLogEntry(curGap);
toothHistory[toothHistoryIndex] = curGap;
if(toothHistoryIndex == 511)
{ toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent.
else
{ toothHistoryIndex++; }
// //
if( toothCurrentCount > 7 ) if( toothCurrentCount > 7 )
@ -382,12 +372,7 @@ void triggerPri_4G63()
else if (!currentStatus.hasSync) { return; } else if (!currentStatus.hasSync) { return; }
else { toothCurrentCount++; } else { toothCurrentCount++; }
//High speed tooth logging history addToothLogEntry(curGap);
toothHistory[toothHistoryIndex] = curGap;
if(toothHistoryIndex == 511)
{ toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent.
else
{ toothHistoryIndex++; }
toothLastMinusOneToothTime = toothLastToothTime; toothLastMinusOneToothTime = toothLastToothTime;
toothLastToothTime = curTime; toothLastToothTime = curTime;
@ -494,12 +479,7 @@ void triggerPri_24X()
toothCurrentCount++; //Increment the tooth counter toothCurrentCount++; //Increment the tooth counter
} }
//High speed tooth logging history addToothLogEntry(curGap);
toothHistory[toothHistoryIndex] = curGap;
if(toothHistoryIndex == 511)
{ toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent.
else
{ toothHistoryIndex++; }
toothLastToothTime = curTime; toothLastToothTime = curTime;
} }
@ -581,12 +561,7 @@ void triggerPri_Jeep2000()
toothCurrentCount++; //Increment the tooth counter toothCurrentCount++; //Increment the tooth counter
} }
//High speed tooth logging history addToothLogEntry(curGap);
toothHistory[toothHistoryIndex] = curGap;
if(toothHistoryIndex == 511)
{ toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a true 255 values, all concurrent.
else
{ toothHistoryIndex++; }
toothLastToothTime = curTime; toothLastToothTime = curTime;
} }

View File

@ -33,6 +33,9 @@ const int map_page_size = 288;
#define BIT_SQUIRT_TOOTHLOG1READY 6 //Used to flag if tooth log 1 is ready #define BIT_SQUIRT_TOOTHLOG1READY 6 //Used to flag if tooth log 1 is ready
#define BIT_SQUIRT_TOOTHLOG2READY 7 //Used to flag if tooth log 2 is ready (Log is not currently used) #define BIT_SQUIRT_TOOTHLOG2READY 7 //Used to flag if tooth log 2 is ready (Log is not currently used)
#define TOOTH_LOG_SIZE 256
#define TOOTH_LOG_BUFFER 512
#define SIZE_BYTE 8 #define SIZE_BYTE 8
#define SIZE_INT 16 #define SIZE_INT 16