New and improved tooth logger
This commit is contained in:
parent
24692dc5ee
commit
fd10a77ff4
|
@ -377,14 +377,14 @@ page = 4
|
|||
ignBypassEnable = bits, U08, 63, [0:0], "Off", "On"
|
||||
ignBypassPin = bits , U08, 63, [1:6], "INVALID", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
||||
ignBypassHiLo = bits, U08, 63, [7:7], "LOW", "HIGH"
|
||||
;Analog input filter levels
|
||||
ADCFILTER_TPS = scalar, U08, 64, "%", 1.0, 0.0, 0, 255, 0
|
||||
ADCFILTER_CLT = scalar, U08, 65, "%", 1.0, 0.0, 0, 255, 0
|
||||
ADCFILTER_IAT = scalar, U08, 66, "%", 1.0, 0.0, 0, 255, 0
|
||||
ADCFILTER_O2 = scalar, U08, 67, "%", 1.0, 0.0, 0, 255, 0
|
||||
ADCFILTER_BAT = scalar, U08, 68, "%", 1.0, 0.0, 0, 255, 0
|
||||
ADCFILTER_MAP = scalar, U08, 69, "%", 1.0, 0.0, 0, 255, 0
|
||||
ADCFILTER_BARO = scalar, U08, 70, "%", 1.0, 0.0, 0, 255, 0
|
||||
;Analog input filter levels (Note max values are 254 so that default values of 255 can be overwirtten on bootup)
|
||||
ADCFILTER_TPS = scalar, U08, 64, "%", 1.0, 0.0, 0, 254, 0
|
||||
ADCFILTER_CLT = scalar, U08, 65, "%", 1.0, 0.0, 0, 254, 0
|
||||
ADCFILTER_IAT = scalar, U08, 66, "%", 1.0, 0.0, 0, 254, 0
|
||||
ADCFILTER_O2 = scalar, U08, 67, "%", 1.0, 0.0, 0, 254, 0
|
||||
ADCFILTER_BAT = scalar, U08, 68, "%", 1.0, 0.0, 0, 254, 0
|
||||
ADCFILTER_MAP = scalar, U08, 69, "%", 1.0, 0.0, 0, 254, 0
|
||||
ADCFILTER_BARO = scalar, U08, 70, "%", 1.0, 0.0, 0, 254, 0
|
||||
|
||||
unused4-64 = array, U08, 71, [56], "%", 1.0, 0.0, 0.0, 255, 0
|
||||
;--------------------------------------------------
|
||||
|
@ -1025,10 +1025,10 @@ page = 10
|
|||
defaultValue = resetControlPin, 0
|
||||
|
||||
;Default ADC filter values
|
||||
defaultValue = ADCFILTER_TPS 128
|
||||
defaultValue = ADCFILTER_TPS 50
|
||||
defaultValue = ADCFILTER_CLT 180
|
||||
defaultValue = ADCFILTER_IAT 180
|
||||
defaultValue = ADCFILTER_O2 128
|
||||
defaultValue = ADCFILTER_O2 100
|
||||
defaultValue = ADCFILTER_BAT 128
|
||||
defaultValue = ADCFILTER_MAP 20 ;This is only used on Instantaneous MAP readings and is intentionally very weak to allow for faster response
|
||||
defaultValue = ADCFILTER_BARO 64
|
||||
|
@ -3071,10 +3071,13 @@ cmdtestspk450dc = "E\x03\x0C"
|
|||
;loggerDef = uniqueName, Display Name, type
|
||||
loggerDef = tooth, "Tooth Logger", tooth
|
||||
;dataReadCommand = "r\\x00\\xf4\\x00\\x00\\x04\\x00" ; standard TS command format
|
||||
startCommand = "H"
|
||||
stopCommand = "h"
|
||||
dataReadCommand = "T" ; Basic TS command format
|
||||
dataReadTimeout = 15000 ; time in ms
|
||||
dataReadyCondition = { toothLog1Ready }
|
||||
dataLength = 256 ; in bytes, including headers, footers and data (not used)
|
||||
;dataLength = 256 ; 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
|
||||
|
|
|
@ -74,6 +74,16 @@ void command()
|
|||
Serial.print("001");
|
||||
break;
|
||||
|
||||
case 'H': //Start the tooth logger
|
||||
currentStatus.toothLogEnabled = true;
|
||||
toothHistoryIndex = 0;
|
||||
toothHistorySerialIndex = 0;
|
||||
break;
|
||||
|
||||
case 'h': //Stop the tooth logger
|
||||
currentStatus.toothLogEnabled = false;
|
||||
break;
|
||||
|
||||
case 'L': // List the contents of current page in human readable form
|
||||
sendPage(true);
|
||||
break;
|
||||
|
@ -1391,32 +1401,18 @@ Send 256 tooth log entries
|
|||
void sendToothLog(bool useChar)
|
||||
{
|
||||
//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) //Sanity check. Flagging system means this should always be true
|
||||
if (BIT_CHECK(currentStatus.status1, BIT_STATUS1_TOOTHLOG1READY)) //Sanity check. Flagging system means this should always be true
|
||||
{
|
||||
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 half the buffer size
|
||||
if (useChar)
|
||||
{
|
||||
for (int x = 0; x < TOOTH_LOG_SIZE; x++)
|
||||
{
|
||||
Serial.println(tempToothHistory[x]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int x = 0; x < TOOTH_LOG_SIZE; x++)
|
||||
{
|
||||
Serial.write(highByte(tempToothHistory[x]));
|
||||
Serial.write(lowByte(tempToothHistory[x]));
|
||||
Serial.write(highByte(toothHistory[toothHistorySerialIndex]));
|
||||
Serial.write(lowByte(toothHistory[toothHistorySerialIndex]));
|
||||
|
||||
if(toothHistorySerialIndex == (TOOTH_LOG_BUFFER-1)) { toothHistorySerialIndex = 0; }
|
||||
else { toothHistorySerialIndex++; }
|
||||
}
|
||||
BIT_CLEAR(currentStatus.status1, BIT_STATUS1_TOOTHLOG1READY);
|
||||
}
|
||||
toothLogRead = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -197,4 +197,7 @@ int16_t toothAngles[24]; //An array for storing fixed tooth angles. Currently si
|
|||
#define CRANK_SPEED 0
|
||||
#define CAM_SPEED 1
|
||||
|
||||
#define TOOTH_CRANK 0
|
||||
#define TOOTH_CAM 1
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,18 +30,34 @@ toothLastToothTime - The time (In uS) that the last primary tooth was 'seen'
|
|||
static inline void addToothLogEntry(unsigned long toothTime)
|
||||
{
|
||||
//High speed tooth logging history
|
||||
toothHistory[toothHistoryIndex] = toothTime;
|
||||
if(toothHistoryIndex == (TOOTH_LOG_BUFFER-1))
|
||||
if(currentStatus.toothLogEnabled == true)
|
||||
{
|
||||
if (toothLogRead)
|
||||
toothHistory[toothHistoryIndex] = toothTime;
|
||||
if(toothHistoryIndex == (TOOTH_LOG_BUFFER-1))
|
||||
{
|
||||
/*
|
||||
if (toothLogRead)
|
||||
{
|
||||
toothHistoryIndex = 0;
|
||||
BIT_CLEAR(currentStatus.status1, BIT_STATUS1_TOOTHLOG1READY);
|
||||
toothLogRead = false; //The tooth log ready bit is cleared to ensure that we only get a set of concurrent values.
|
||||
}
|
||||
*/
|
||||
toothHistoryIndex = 0;
|
||||
BIT_CLEAR(currentStatus.status1, BIT_STATUS1_TOOTHLOG1READY);
|
||||
toothLogRead = false; //The tooth log ready bit is cleared to ensure that we only get a set of concurrent values.
|
||||
}
|
||||
}
|
||||
else
|
||||
{ toothHistoryIndex++; }
|
||||
else
|
||||
{ toothHistoryIndex++; }
|
||||
|
||||
uint16_t absoluteToothHistoryIndex = toothHistoryIndex;
|
||||
if(toothHistoryIndex < toothHistorySerialIndex)
|
||||
{
|
||||
//If the main history index is lower than the serial index, it means that this has looped. To calculate the delta between the two indexes, add the buffer size back on
|
||||
absoluteToothHistoryIndex += TOOTH_LOG_BUFFER;
|
||||
}
|
||||
//Check whether the current index is ahead of the serial index by at least the size of the log
|
||||
if( (absoluteToothHistoryIndex - toothHistorySerialIndex) >= TOOTH_LOG_SIZE ) { BIT_SET(currentStatus.status1, BIT_STATUS1_TOOTHLOG1READY); }
|
||||
else { BIT_CLEAR(currentStatus.status1, BIT_STATUS1_TOOTHLOG1READY); } //Tooth log is not yet ahead of the serial index by enough, so mark the log as not yet ready
|
||||
} //Tooth log enabled
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -127,8 +127,8 @@
|
|||
#define VALID_MAP_MAX 1022 //The largest ADC value that is valid for the MAP sensor
|
||||
#define VALID_MAP_MIN 2 //The smallest ADC value that is valid for the MAP sensor
|
||||
|
||||
#define TOOTH_LOG_SIZE 128
|
||||
#define TOOTH_LOG_BUFFER 256
|
||||
#define TOOTH_LOG_SIZE 64
|
||||
#define TOOTH_LOG_BUFFER 128
|
||||
|
||||
#define INJ_PAIRED 0
|
||||
#define INJ_SEMISEQUENTIAL 1
|
||||
|
@ -302,9 +302,10 @@ uint16_t fixedCrankingOverride = 0;
|
|||
bool clutchTrigger;
|
||||
bool previousClutchTrigger;
|
||||
volatile uint16_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;
|
||||
volatile bool toothLogRead = false; //Flag to indicate whether the current tooth log values have been read out yet
|
||||
volatile byte toothHistorySerialIndex = 0;
|
||||
int CRANK_ANGLE_MAX = 720;
|
||||
int CRANK_ANGLE_MAX_IGN = 360;
|
||||
int CRANK_ANGLE_MAX_INJ = 360; // The number of crank degrees that the system track over. 360 for wasted / timed batch and 720 for sequential
|
||||
|
@ -404,6 +405,8 @@ struct statuses {
|
|||
byte syncLossCounter;
|
||||
byte knockRetard;
|
||||
bool knockActive;
|
||||
bool toothLogEnabled;
|
||||
bool compositeLogEnabled;
|
||||
|
||||
//Helpful bitwise operations:
|
||||
//Useful reference: http://playground.arduino.cc/Code/BitMath
|
||||
|
@ -520,7 +523,7 @@ struct config2 {
|
|||
} __attribute__((__packed__)); //The 32 bi systems require all structs to be fully packed
|
||||
#endif
|
||||
|
||||
//Page 2 of the config - See the ini file for further reference
|
||||
//Page 4 of the config - See the ini file for further reference
|
||||
//This mostly covers off variables that are required for ignition
|
||||
struct config4 {
|
||||
|
||||
|
|
Loading…
Reference in New Issue