Better tuned tooth logger

This commit is contained in:
Josh Stewart 2015-10-30 20:35:45 +11:00
parent 7ea2757c95
commit ed02ba79f7
6 changed files with 13 additions and 16 deletions

View File

@ -820,18 +820,17 @@ Send 256 tooth log entries
*/
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 TOOTH_LOG_SIZE number of records to send to TunerStudio. If there aren't that many in the buffer then we just return and wait for the next call
if (toothHistoryIndex < TOOTH_LOG_SIZE) {
return; //This should no longer ever occur
return; //This should no longer ever occur since the flagging system was put in place
}
unsigned int tempToothHistory[512]; //Create a temporary array that will contain a copy of what is in the main toothHistory array
unsigned int tempToothHistory[TOOTH_LOG_BUFFER]; //Create a temporary array that will contain a copy of what is in the main toothHistory array
//Copy the working history into the temporary buffer array. This is done so that, if the history loops whilst the values are being sent over serial, it doesn't affect the values
memcpy( (void*)tempToothHistory, (void*)toothHistory, sizeof(tempToothHistory) );
toothHistoryIndex = 0; //Reset the history index
//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 half the buffer size
if (useChar)
{
for (int x = 0; x < TOOTH_LOG_SIZE; x++)

View File

@ -1,5 +1,3 @@
#define TOOTH_HISTORY_LENGTH 512
volatile unsigned long curTime;
volatile unsigned int curGap;
volatile unsigned long curTime2;
@ -13,7 +11,7 @@ volatile unsigned long toothLastSecToothTime = 0; //The time (micros()) that the
volatile unsigned long toothLastMinusOneToothTime = 0; //The time (micros()) that the tooth before the last tooth was registered
volatile unsigned long toothOneTime = 0; //The time (micros()) that tooth 1 last triggered
volatile unsigned long toothOneMinusOneTime = 0; //The 2nd to last time (micros()) that tooth 1 last triggered
volatile unsigned int toothHistory[TOOTH_HISTORY_LENGTH];
volatile unsigned int toothHistory[TOOTH_LOG_BUFFER];
volatile unsigned int toothHistoryIndex = 0;
volatile byte secondaryToothCount; //Used for identifying the current secondary (Usually cam) tooth for patterns with multiple secondary teeth

View File

@ -21,12 +21,12 @@ toothLastToothTime - The time (In uS) that the last primary tooth was 'seen'
*/
__inline void addToothLogEntry(unsigned long time)
inline void addToothLogEntry(unsigned long time)
{
//High speed tooth logging history
toothHistory[toothHistoryIndex] = curGap;
if(toothHistoryIndex == (TOOTH_LOG_BUFFER-1))
{ 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.
{ toothHistoryIndex = 0; BIT_CLEAR(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); } //The tooth log ready bit is cleared to ensure that we only get a set of concurrent values.
else
{ toothHistoryIndex++; }
}
@ -35,7 +35,7 @@ __inline void addToothLogEntry(unsigned long time)
As nearly all the decoders use a common method of determining RPM (The time the last full revolution took)
A common function is simpler
*/
__inline int stdGetRPM()
inline int stdGetRPM()
{
noInterrupts();
revolutionTime = (toothOneTime - toothOneMinusOneTime); //The time in uS that one revolution would take at current speed (The time tooth 1 was last seen, minus the time it was seen prior to that)

View File

@ -33,8 +33,8 @@ const int map_page_size = 288;
#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 TOOTH_LOG_SIZE 256
#define TOOTH_LOG_BUFFER 512
#define TOOTH_LOG_SIZE 128
#define TOOTH_LOG_BUFFER 256
#define SIZE_BYTE 8
#define SIZE_INT 16

View File

@ -1254,9 +1254,9 @@ page = 8
loggerDef = tooth, "Tooth Logger", tooth
;dataReadCommand = "r\\x00\\xf4\\x00\\x00\\x04\\x00" ; standard TS command format
dataReadCommand = "T" ; Basic TS command format
dataReadTimeout = 10000 ; time in ms
dataReadTimeout = 15000 ; time in ms
dataReadyCondition = { toothLog1Ready }
dataLength = 512 ; in bytes, including headers, footers and data (not used)
dataLength = 256 ; in bytes, including headers, footers and data (not used)
;recordDef = headerLen. footerLen, recordLen
recordDef = 0, 0, 2; in bytes, the recordLen is for each record, currently limited to 4 bytes

View File

@ -629,7 +629,7 @@ void loop()
//Check for launch in (clutch) can be done around here too
currentStatus.launching = !digitalRead(pinLaunch);
//And check whether the tooth log buffer is ready
if(toothHistoryIndex > 255) { BIT_SET(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); }
if(toothHistoryIndex > TOOTH_LOG_SIZE) { BIT_SET(currentStatus.squirt, BIT_SQUIRT_TOOTHLOG1READY); }
}
//The IAT and CLT readings can be done less frequently. This still runs about 4 times per second