Improved flex error checking

This commit is contained in:
Josh Stewart 2016-06-27 10:31:52 +10:00
parent 5847ee5330
commit a90d13b038
3 changed files with 21 additions and 4 deletions

View File

@ -262,7 +262,8 @@ void sendValues(int length)
response[31] = lowByte(currentStatus.rpmDOT);
response[32] = highByte(currentStatus.rpmDOT);
response[33] = currentStatus.flex;
response[33] = currentStatus.flex; //Flex sensor value (or 0 if not used)
cli();
Serial.write(response, (size_t)packetSize);
sei();

View File

@ -465,7 +465,7 @@ page = 8
requiresPowerCycle = launchPin
requiresPowerCycle = launchEnable
requiresPowerCycle = launchHiLo
; requiresPowerCycle = flexEnabled
requiresPowerCycle = flexEnabled
defaultValue = pinLayout, 1
defaultValue = TrigPattern, 0

View File

@ -99,9 +99,25 @@ void timer2Overflowinterrupt() //Most ARM chips can simply call a function
//Set the flex reading (if enabled). The flexCounter is updated with every pulse from the sensor. If cleared once per second, we get a frequency reading
if(configPage1.flexEnabled)
{
if(flexCounter > 150 || flexCounter < 50)
if(flexCounter < 50)
{
//This indicated an error condition. Spec of the sensor is that errors are above 170Hz)
currentStatus.flex = 0; //Standard GM Continental sensor reads from 50Hz (0 ethanol) to 150Hz (Pure ethanol). Subtracting 50 from the frequency therefore gives the ethanol percentage.
flexCounter = 0;
}
else if (flexCounter > 151) //1 pulse buffer
{
if(flexCounter < 169)
{
currentStatus.flex = 100; //Standard GM Continental sensor reads from 50Hz (0 ethanol) to 150Hz (Pure ethanol). Subtracting 50 from the frequency therefore gives the ethanol percentage.
flexCounter = 0;
}
else
{
//This indicates an error condition. Spec of the sensor is that errors are above 170Hz)
currentStatus.flex = 0;
flexCounter = 0;
}
}
else
{