Multiple fixes for low speed issues with the high speed loggers. See #190

This commit is contained in:
Josh Stewart 2019-02-04 12:44:57 +11:00
parent 5c8697e3e4
commit 24981dc01f
4 changed files with 38 additions and 14 deletions

View File

@ -3353,23 +3353,23 @@ cmdtestspk450dc = "E\x03\x0C"
startCommand = "H"
stopCommand = "h"
dataReadCommand = "T" ; Basic TS command format
dataReadTimeout = 15000 ; time in ms
dataReadyCondition = { toothLog1Ready }
dataReadTimeout = 5000 ; time in ms
dataReadyCondition = { toothLog1Ready == 1 }
;dataLength = 256 ; in bytes, including headers, footers and data (not used)
dataLength = 128 ; in bytes, including headers, footers and data (not used)
;dataLength = 128 ; 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
recordDef = 0, 0, 4; in bytes, the recordLen is for each record, currently limited to 4 bytes
;recordField = Name, HeaderName, startBit, bitCount, scale, units, updateCondition
recordField = toothTime, "ToothTime", 0, 16, 1.0, "uS"
recordField = toothTime, "ToothTime", 0, 32, 1.0, "uS"
loggerDef = compositeLogger, "Composite Logger", composite
startCommand = "J"
stopCommand = "j"
dataReadCommand = "T" ; Basic TS command format. Note that this is shared with the composite logger. Firmware detects which log is currently running
dataReadTimeout = 5000 ; time in ms
dataReadyCondition = { toothLog1Ready }
dataReadyCondition = { toothLog1Ready == 1 }
;dataLength = 256 ; in bytes, including headers, footers and data (not used)
;dataLength = 320 ; in bytes, including headers, footers and data (not used)
@ -3381,10 +3381,10 @@ cmdtestspk450dc = "E\x03\x0C"
recordField = secLevel, "SecLevel", 1, 1, 1.0, "Flag"
recordField = trigger, "Trigger", 2, 1, 1.0, "Flag"
recordField = sync, "Sync", 3, 1, 1.0, "Flag"
recordField = refTime, "RefTime", 8, 32, 0.001, "ms", hidden
recordField = refTime, "RefTime", 8, 32, 0.001, "ms"
; hidden calcField serves as intermediate variable
calcField = maxTime, "MaxTime", "ms", { maxValue(refTime) }, hidden
calcField = maxTime, "MaxTime", "ms", { maxValue(refTime) }
calcField = toothTime, "ToothTime", "ms", { refTime - pastValue(refTime, 1) }
;recordField = time, "Time", 24, 16, 1.0, "ms"

View File

@ -80,10 +80,26 @@ void command()
currentStatus.compositeLogEnabled = false; //Safety first (Should never be required)
toothHistoryIndex = 0;
toothHistorySerialIndex = 0;
//Disconnect the standard interrupt and add the logger version
detachInterrupt( digitalPinToInterrupt(pinTrigger) );
attachInterrupt( digitalPinToInterrupt(pinTrigger), loggerPrimaryISR, CHANGE );
detachInterrupt( digitalPinToInterrupt(pinTrigger2) );
attachInterrupt( digitalPinToInterrupt(pinTrigger2), loggerSecondaryISR, CHANGE );
Serial.write(1); //TS needs an acknowledgement that this was received. I don't know if this is the correct response, but it seems to work
break;
case 'h': //Stop the tooth logger
currentStatus.toothLogEnabled = false;
//Disconnect the logger interrupts and attach the normal ones
detachInterrupt( digitalPinToInterrupt(pinTrigger) );
attachInterrupt( digitalPinToInterrupt(pinTrigger), triggerHandler, primaryTriggerEdge );
detachInterrupt( digitalPinToInterrupt(pinTrigger2) );
attachInterrupt( digitalPinToInterrupt(pinTrigger2), triggerSecondaryHandler, secondaryTriggerEdge );
break;
case 'J': //Start the composite logger
@ -93,12 +109,14 @@ void command()
toothHistorySerialIndex = 0;
compositeLastToothTime = 0;
//Disconnect the standard interrupt and add the logger verion
//Disconnect the standard interrupt and add the logger version
detachInterrupt( digitalPinToInterrupt(pinTrigger) );
attachInterrupt( digitalPinToInterrupt(pinTrigger), loggerPrimaryISR, CHANGE );
detachInterrupt( digitalPinToInterrupt(pinTrigger2) );
attachInterrupt( digitalPinToInterrupt(pinTrigger2), loggerSecondaryISR, CHANGE );
Serial.write(1); //TS needs an acknowledgement that this was received. I don't know if this is the correct response, but it seems to work
break;
case 'j': //Stop the composite logger
@ -1436,8 +1454,12 @@ void sendToothLog(bool useChar)
{
for (int x = 0; x < TOOTH_LOG_SIZE; x++)
{
Serial.write(highByte(toothHistory[toothHistorySerialIndex]));
Serial.write(lowByte(toothHistory[toothHistorySerialIndex]));
//Serial.write(highByte(toothHistory[toothHistorySerialIndex]));
//Serial.write(lowByte(toothHistory[toothHistorySerialIndex]));
Serial.write(toothHistory[toothHistorySerialIndex] >> 24);
Serial.write(toothHistory[toothHistorySerialIndex] >> 16);
Serial.write(toothHistory[toothHistorySerialIndex] >> 8);
Serial.write(toothHistory[toothHistorySerialIndex]);
if(toothHistorySerialIndex == (TOOTH_LOG_BUFFER-1)) { toothHistorySerialIndex = 0; }
else { toothHistorySerialIndex++; }

View File

@ -88,7 +88,9 @@ void loggerPrimaryISR()
{
validTrigger = false; //This value will be set to the return value of the decoder function, indicating whether or not this pulse passed the filters
bool validEdge = false; //This is set true below if the edge
/* Two checks here:
/*
Need to still call the standard decoder trigger.
Two checks here:
1) If the primary trigger is RISING, then check whether the primary is currently HIGH
2) If the primary trigger is FALLING, then check whether the primary is currently LOW
If either of these are true, the primary decoder funtino is called

View File

@ -141,7 +141,7 @@
#define VALID_MAP_MIN 2 //The smallest ADC value that is valid for the MAP sensor
#define TOOTH_LOG_SIZE 64
#define TOOTH_LOG_BUFFER 256
#define TOOTH_LOG_BUFFER 128 //256
#define COMPOSITE_LOG_PRI 0
#define COMPOSITE_LOG_SEC 1
@ -319,7 +319,7 @@ volatile unsigned long ms_counter = 0; //A counter that increments once per ms
uint16_t fixedCrankingOverride = 0;
bool clutchTrigger;
bool previousClutchTrigger;
volatile uint16_t toothHistory[TOOTH_LOG_BUFFER];
volatile uint32_t toothHistory[TOOTH_LOG_BUFFER];
volatile uint8_t compositeLogHistory[TOOTH_LOG_BUFFER];
volatile bool fpPrimed = false; //Tracks whether or not the fuel pump priming has been completed yet
volatile unsigned int toothHistoryIndex = 0;