Better handling of default values for ADC filters

This commit is contained in:
Josh Stewart 2018-11-11 19:25:00 +11:00
parent 3efb6abb9e
commit d93fbb96ec
3 changed files with 20 additions and 18 deletions

View File

@ -378,13 +378,13 @@ page = 4
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" 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" ignBypassHiLo = bits, U08, 63, [7:7], "LOW", "HIGH"
;Analog input filter levels (Note max values are 254 so that default values of 255 can be overwirtten on bootup) ;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_TPS = scalar, U08, 64, "%", 1.0, 0.0, 0, 240, 0
ADCFILTER_CLT = scalar, U08, 65, "%", 1.0, 0.0, 0, 254, 0 ADCFILTER_CLT = scalar, U08, 65, "%", 1.0, 0.0, 0, 240, 0
ADCFILTER_IAT = scalar, U08, 66, "%", 1.0, 0.0, 0, 254, 0 ADCFILTER_IAT = scalar, U08, 66, "%", 1.0, 0.0, 0, 240, 0
ADCFILTER_O2 = scalar, U08, 67, "%", 1.0, 0.0, 0, 254, 0 ADCFILTER_O2 = scalar, U08, 67, "%", 1.0, 0.0, 0, 240, 0
ADCFILTER_BAT = scalar, U08, 68, "%", 1.0, 0.0, 0, 254, 0 ADCFILTER_BAT = scalar, U08, 68, "%", 1.0, 0.0, 0, 240, 0
ADCFILTER_MAP = scalar, U08, 69, "%", 1.0, 0.0, 0, 254, 0 ADCFILTER_MAP = scalar, U08, 69, "%", 1.0, 0.0, 0, 240, 0
ADCFILTER_BARO = scalar, U08, 70, "%", 1.0, 0.0, 0, 254, 0 ADCFILTER_BARO = scalar, U08, 70, "%", 1.0, 0.0, 0, 240, 0
unused4-64 = array, U08, 71, [56], "%", 1.0, 0.0, 0.0, 255, 0 unused4-64 = array, U08, 71, [56], "%", 1.0, 0.0, 0.0, 255, 0
;-------------------------------------------------- ;--------------------------------------------------
@ -1481,7 +1481,7 @@ menuDialog = main
cmdtestspk350dc = "this will cycle the output at 50% Duty cycle" cmdtestspk350dc = "this will cycle the output at 50% Duty cycle"
cmdtestspk450dc = "this will cycle the output at 50% Duty cycle" cmdtestspk450dc = "this will cycle the output at 50% Duty cycle"
ADCFILTER_TPS = "Recommended value: 128" ADCFILTER_TPS = "Recommended value: 50"
ADCFILTER_CLT = "Recommended value: 180" ADCFILTER_CLT = "Recommended value: 180"
ADCFILTER_IAT = "Recommended value: 180" ADCFILTER_IAT = "Recommended value: 180"
ADCFILTER_O2 = "Recommended value: 128" ADCFILTER_O2 = "Recommended value: 128"

View File

@ -7,6 +7,7 @@ A full copy of the license may be found in the projects root directory
#include "crankMaths.h" #include "crankMaths.h"
#include "globals.h" #include "globals.h"
#include "maths.h" #include "maths.h"
#include "storage.h"
void initialiseADC() void initialiseADC()
{ {
@ -104,13 +105,14 @@ void initialiseADC()
//Sanity checks to ensure none of the filter values are set to 255 (Which would be the default on a new arduino, but can prevent the sensor readings from going through correctly) //Sanity checks to ensure none of the filter values are set to 255 (Which would be the default on a new arduino, but can prevent the sensor readings from going through correctly)
//Each sensor has it's own default value //Each sensor has it's own default value
if(configPage4.ADCFILTER_TPS == 255) { configPage4.ADCFILTER_TPS = 50; } if(configPage4.ADCFILTER_TPS > 240) { configPage4.ADCFILTER_TPS = 50; writeConfig(4); }
if(configPage4.ADCFILTER_CLT == 255) { configPage4.ADCFILTER_TPS = 180; } if(configPage4.ADCFILTER_CLT > 240) { configPage4.ADCFILTER_TPS = 180; writeConfig(4); }
if(configPage4.ADCFILTER_IAT == 255) { configPage4.ADCFILTER_TPS = 180; } if(configPage4.ADCFILTER_IAT > 240) { configPage4.ADCFILTER_TPS = 180; writeConfig(4); }
if(configPage4.ADCFILTER_O2 == 255) { configPage4.ADCFILTER_TPS = 100; } if(configPage4.ADCFILTER_O2 > 240) { configPage4.ADCFILTER_TPS = 100; writeConfig(4); }
if(configPage4.ADCFILTER_BAT == 255) { configPage4.ADCFILTER_TPS = 128; } if(configPage4.ADCFILTER_BAT > 240) { configPage4.ADCFILTER_TPS = 128; writeConfig(4); }
if(configPage4.ADCFILTER_MAP == 255) { configPage4.ADCFILTER_TPS = 20; } if(configPage4.ADCFILTER_MAP > 240) { configPage4.ADCFILTER_TPS = 20; writeConfig(4); }
if(configPage4.ADCFILTER_BARO == 255) { configPage4.ADCFILTER_TPS = 64; } if(configPage4.ADCFILTER_BARO > 240) { configPage4.ADCFILTER_TPS = 64; writeConfig(4); }
} }
static inline void instanteneousMAPReading() static inline void instanteneousMAPReading()

View File

@ -142,7 +142,7 @@ void doUpdates()
if(EEPROM.read(EEPROM_DATA_VERSION) == 9) if(EEPROM.read(EEPROM_DATA_VERSION) == 9)
{ {
//September 2018 set default values for all the aux in variables (These were introduced in Aug, but no defaults were set then) //October 2018 set default values for all the aux in variables (These were introduced in Aug, but no defaults were set then)
//All aux channels set to Off //All aux channels set to Off
for (byte AuxinChan = 0; AuxinChan <16 ; AuxinChan++) for (byte AuxinChan = 0; AuxinChan <16 ; AuxinChan++)
{ {
@ -150,12 +150,12 @@ void doUpdates()
} }
//Ability to change the analog filter values was added. Set default values for these: //Ability to change the analog filter values was added. Set default values for these:
configPage4.ADCFILTER_TPS = 128; configPage4.ADCFILTER_TPS = 50;
configPage4.ADCFILTER_CLT = 180; configPage4.ADCFILTER_CLT = 180;
configPage4.ADCFILTER_IAT = 180; configPage4.ADCFILTER_IAT = 180;
configPage4.ADCFILTER_O2 = 128; configPage4.ADCFILTER_O2 = 128;
configPage4.ADCFILTER_BAT = 128; configPage4.ADCFILTER_BAT = 128;
configPage4.ADCFILTER_MAP = 20; //This is only used on Instantaneous MAP readings and is intentionally very weak to allow for faster response configPage4.ADCFILTER_MAP = 20;
configPage4.ADCFILTER_BARO= 64; configPage4.ADCFILTER_BARO= 64;
writeAllConfig(); writeAllConfig();