Initial (mostly untested) live baro reading
This commit is contained in:
parent
905a8642ff
commit
9d2e938a4d
|
@ -370,7 +370,7 @@ page = 6
|
||||||
egoType = bits , U08, 0, [2:3], "Disabled", "Narrow Band", "Wide Band", "INVALID" ; egoOption
|
egoType = bits , U08, 0, [2:3], "Disabled", "Narrow Band", "Wide Band", "INVALID" ; egoOption
|
||||||
boostEnabled= bits, U08, 0, [4:4], "Off", "On"
|
boostEnabled= bits, U08, 0, [4:4], "Off", "On"
|
||||||
vvtEnabled = bits, U08, 0, [5:5], "Off", "On"
|
vvtEnabled = bits, U08, 0, [5:5], "Off", "On"
|
||||||
boostCutType= bits, U08, 0, [6:7], "Off", "Spark Only", "Fuel Only","Both"
|
boostCutType= bits, U08, 0, [6:7], "Off", "Spark Only", "Fuel Only","Both"
|
||||||
|
|
||||||
egoKP = scalar, U08, 1, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
|
egoKP = scalar, U08, 1, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
|
||||||
egoKI = scalar, U08, 2, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
|
egoKI = scalar, U08, 2, "%", 1.0, 0.0, 0.0, 200.0, 0 ; * ( 1 byte)
|
||||||
|
@ -389,7 +389,7 @@ page = 6
|
||||||
egoRPM = scalar, U08, 11, "rpm", 100, 0.0, 100, 25500, 0
|
egoRPM = scalar, U08, 11, "rpm", 100, 0.0, 100, 25500, 0
|
||||||
egoTPSMax = scalar, U08, 12, "%", 1, 0, 0, 120, 0
|
egoTPSMax = scalar, U08, 12, "%", 1, 0, 0, 120, 0
|
||||||
vvtPin = bits , U08, 13, [0:5], "Board Default", "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"
|
vvtPin = bits , U08, 13, [0:5], "Board Default", "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"
|
||||||
unused6-13e = bits, U08, 13, [6:6], "ONE", "INVALID"
|
useExtBaro = bits, U08, 13, [6:6], "No", "Yes"
|
||||||
unused6-13f = bits, U08, 13, [7:7], "ONE", "INVALID"
|
unused6-13f = bits, U08, 13, [7:7], "ONE", "INVALID"
|
||||||
boostPin = bits, U08, 14, [0:5], "Board Default", "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"
|
boostPin = bits, U08, 14, [0:5], "Board Default", "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"
|
||||||
unused6-14e = bits, U08, 14, [6:6], "ONE", "INVALID"
|
unused6-14e = bits, U08, 14, [6:6], "ONE", "INVALID"
|
||||||
|
@ -429,9 +429,8 @@ page = 6
|
||||||
lnchPullRes = bits, U08, 60, [0:1], "Float" , "Pullup", "INVALID", "INVALID"
|
lnchPullRes = bits, U08, 60, [0:1], "Float" , "Pullup", "INVALID", "INVALID"
|
||||||
fuelTrimEnabled= bits, U08, 60, [2:2], "No", "Yes"
|
fuelTrimEnabled= bits, U08, 60, [2:2], "No", "Yes"
|
||||||
flatSEnable = bits, U08, 60, [3:3], "No", "Yes"
|
flatSEnable = bits, U08, 60, [3:3], "No", "Yes"
|
||||||
; Baro Sensor
|
; Baro Sensor pin
|
||||||
useExtBaro = bits, U08, 60, [4:4], "No", "Yes"
|
baroPin = bits, U08, 60, [4:7], "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A8", "A10", "A11", "A12", "A13", "A14", "A15"
|
||||||
baroPin = bits, U08, 60, [5:7], "ONE", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
|
|
||||||
|
|
||||||
; Flat shift
|
; Flat shift
|
||||||
flatSSoftWin = scalar, U08, 61, "rpm", 100, 0.0, 100, 25500, 0
|
flatSSoftWin = scalar, U08, 61, "rpm", 100, 0.0, 100, 25500, 0
|
||||||
|
@ -723,6 +722,8 @@ page = 10
|
||||||
requiresPowerCycle = iacCLmaxDuty
|
requiresPowerCycle = iacCLmaxDuty
|
||||||
requiresPowerCycle = boostMinDuty
|
requiresPowerCycle = boostMinDuty
|
||||||
requiresPowerCycle = boostMaxDuty
|
requiresPowerCycle = boostMaxDuty
|
||||||
|
requiresPowerCycle = useExtBaro
|
||||||
|
requiresPowerCycle = baroPin
|
||||||
|
|
||||||
defaultValue = pinLayout, 1
|
defaultValue = pinLayout, 1
|
||||||
defaultValue = TrigPattern, 0
|
defaultValue = TrigPattern, 0
|
||||||
|
@ -1398,7 +1399,7 @@ menuDialog = main
|
||||||
|
|
||||||
field = "#Baro Sensor"
|
field = "#Baro Sensor"
|
||||||
field = "Use external Baro sensor", useExtBaro
|
field = "Use external Baro sensor", useExtBaro
|
||||||
field = "Analog pin to use for ext. Baro sensor", baroPin
|
field = "Analog pin to use for ext. Baro sensor", baroPin, { useExtBaro }
|
||||||
|
|
||||||
|
|
||||||
dialog = boostSettings, "Boost Control"
|
dialog = boostSettings, "Boost Control"
|
||||||
|
|
|
@ -181,8 +181,9 @@ struct statuses {
|
||||||
uint16_t RPM;
|
uint16_t RPM;
|
||||||
long longRPM;
|
long longRPM;
|
||||||
int mapADC;
|
int mapADC;
|
||||||
|
int baroADC;
|
||||||
long MAP; //Has to be a long for PID calcs (Boost control)
|
long MAP; //Has to be a long for PID calcs (Boost control)
|
||||||
byte baro; //Barometric pressure is simply the inital MAP reading, taken before the engine is running
|
byte baro; //Barometric pressure is simply the inital MAP reading, taken before the engine is running. Alternatively, can be taken from an external sensor
|
||||||
byte TPS; //The current TPS reading (0% - 100%)
|
byte TPS; //The current TPS reading (0% - 100%)
|
||||||
byte TPSlast; //The previous TPS reading
|
byte TPSlast; //The previous TPS reading
|
||||||
unsigned long TPS_time; //The time the TPS sample was taken
|
unsigned long TPS_time; //The time the TPS sample was taken
|
||||||
|
@ -432,7 +433,8 @@ struct config3 {
|
||||||
byte egoRPM; //RPM must be above this for closed loop to function
|
byte egoRPM; //RPM must be above this for closed loop to function
|
||||||
byte egoTPSMax; //TPS must be below this for closed loop to function
|
byte egoTPSMax; //TPS must be below this for closed loop to function
|
||||||
byte vvtPin : 6;
|
byte vvtPin : 6;
|
||||||
byte unused6_13 : 2;
|
byte useExtBaro : 1;
|
||||||
|
byte unused6_13f : 1;
|
||||||
byte boostPin : 6;
|
byte boostPin : 6;
|
||||||
byte unused6_14 : 2;
|
byte unused6_14 : 2;
|
||||||
byte voltageCorrectionBins[6]; //X axis bins for voltage correction tables
|
byte voltageCorrectionBins[6]; //X axis bins for voltage correction tables
|
||||||
|
@ -465,7 +467,7 @@ struct config3 {
|
||||||
byte lnchPullRes : 2;
|
byte lnchPullRes : 2;
|
||||||
byte fuelTrimEnabled : 1;
|
byte fuelTrimEnabled : 1;
|
||||||
byte flatSEnable : 1;
|
byte flatSEnable : 1;
|
||||||
byte unused60 : 4;
|
byte baroPin : 4;
|
||||||
byte flatSSoftWin;
|
byte flatSSoftWin;
|
||||||
byte flatSRetard;
|
byte flatSRetard;
|
||||||
byte flatSArm;
|
byte flatSArm;
|
||||||
|
@ -620,6 +622,7 @@ byte pinStepperEnable; //Turning the DRV8825 driver on/off
|
||||||
byte pinLaunch;
|
byte pinLaunch;
|
||||||
byte pinIgnBypass; //The pin used for an ignition bypass (Optional)
|
byte pinIgnBypass; //The pin used for an ignition bypass (Optional)
|
||||||
byte pinFlex; //Pin with the flex sensor attached
|
byte pinFlex; //Pin with the flex sensor attached
|
||||||
|
byte pinBaro; //Pin that an external barometric pressure sensor is attached to (If used)
|
||||||
|
|
||||||
// global variables // from speeduino.ino
|
// global variables // from speeduino.ino
|
||||||
extern struct statuses currentStatus; // from speeduino.ino
|
extern struct statuses currentStatus; // from speeduino.ino
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#define ADCFILTER_O2 128
|
#define ADCFILTER_O2 128
|
||||||
#define ADCFILTER_BAT 128
|
#define ADCFILTER_BAT 128
|
||||||
#define ADCFILTER_MAP 20 //This is only used on Instantaneous MAP readings and is intentionally very weak to allow for faster response
|
#define ADCFILTER_MAP 20 //This is only used on Instantaneous MAP readings and is intentionally very weak to allow for faster response
|
||||||
|
#define ADCFILTER_BARO 64
|
||||||
|
|
||||||
#define BARO_MIN 87
|
#define BARO_MIN 87
|
||||||
#define BARO_MAX 108
|
#define BARO_MAX 108
|
||||||
|
|
|
@ -202,6 +202,25 @@ void readIAT()
|
||||||
currentStatus.IAT = iatCalibrationTable[currentStatus.iatADC] - CALIBRATION_TEMPERATURE_OFFSET;
|
currentStatus.IAT = iatCalibrationTable[currentStatus.iatADC] - CALIBRATION_TEMPERATURE_OFFSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void readBaro()
|
||||||
|
{
|
||||||
|
if ( configPage3.useExtBaro != 0 )
|
||||||
|
{
|
||||||
|
int tempReading;
|
||||||
|
// readings
|
||||||
|
#if defined(ANALOG_ISR_MAP)
|
||||||
|
tempReading = AnChannel[pinBaro-A0];
|
||||||
|
#else
|
||||||
|
tempReading = analogRead(pinBaro);
|
||||||
|
tempReading = analogRead(pinBaro);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
currentStatus.baroADC = ADC_FILTER(tempReading, ADCFILTER_BARO, currentStatus.baroADC); //Very weak filter
|
||||||
|
|
||||||
|
currentStatus.baro = fastMap1023toX(currentStatus.baroADC, configPage1.mapMax); //Get the current MAP value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void readO2()
|
void readO2()
|
||||||
{
|
{
|
||||||
unsigned int tempReading;
|
unsigned int tempReading;
|
||||||
|
|
|
@ -228,22 +228,31 @@ void setup()
|
||||||
|
|
||||||
//Lookup the current MAP reading for barometric pressure
|
//Lookup the current MAP reading for barometric pressure
|
||||||
readMAP();
|
readMAP();
|
||||||
/*
|
//barometric reading can be taken from either an external sensor if enabled, or simply by using the initial MAP value
|
||||||
* The highest sea-level pressure on Earth occurs in Siberia, where the Siberian High often attains a sea-level pressure above 105 kPa;
|
if ( configPage3.useExtBaro != 0 )
|
||||||
* with record highs close to 108.5 kPa.
|
|
||||||
* The lowest measurable sea-level pressure is found at the centers of tropical cyclones and tornadoes, with a record low of 87 kPa;
|
|
||||||
*/
|
|
||||||
if ((currentStatus.MAP >= BARO_MIN) && (currentStatus.MAP <= BARO_MAX)) //Check if engine isn't running
|
|
||||||
{
|
{
|
||||||
currentStatus.baro = currentStatus.MAP;
|
readBaro();
|
||||||
EEPROM.update(EEPROM_LAST_BARO, currentStatus.baro);
|
EEPROM.update(EEPROM_LAST_BARO, currentStatus.baro);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Attempt to use the last known good baro reading from EEPROM
|
/*
|
||||||
if ((EEPROM.read(EEPROM_LAST_BARO) >= BARO_MIN) && (EEPROM.read(EEPROM_LAST_BARO) <= BARO_MAX)) //Make sure it's not invalid (Possible on first run etc)
|
* The highest sea-level pressure on Earth occurs in Siberia, where the Siberian High often attains a sea-level pressure above 105 kPa;
|
||||||
{ currentStatus.baro = EEPROM.read(EEPROM_LAST_BARO); } //last baro correction
|
* with record highs close to 108.5 kPa.
|
||||||
else { currentStatus.baro = 100; } //Final fall back position.
|
* The lowest measurable sea-level pressure is found at the centers of tropical cyclones and tornadoes, with a record low of 87 kPa;
|
||||||
|
*/
|
||||||
|
if ((currentStatus.MAP >= BARO_MIN) && (currentStatus.MAP <= BARO_MAX)) //Check if engine isn't running
|
||||||
|
{
|
||||||
|
currentStatus.baro = currentStatus.MAP;
|
||||||
|
EEPROM.update(EEPROM_LAST_BARO, currentStatus.baro);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//Attempt to use the last known good baro reading from EEPROM
|
||||||
|
if ((EEPROM.read(EEPROM_LAST_BARO) >= BARO_MIN) && (EEPROM.read(EEPROM_LAST_BARO) <= BARO_MAX)) //Make sure it's not invalid (Possible on first run etc)
|
||||||
|
{ currentStatus.baro = EEPROM.read(EEPROM_LAST_BARO); } //last baro correction
|
||||||
|
else { currentStatus.baro = 100; } //Final fall back position.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Perform all initialisations
|
//Perform all initialisations
|
||||||
|
@ -1077,6 +1086,12 @@ void loop()
|
||||||
vvtControl();
|
vvtControl();
|
||||||
idleControl(); //Perform any idle related actions. Even at higher frequencies, running 4x per second is sufficient.
|
idleControl(); //Perform any idle related actions. Even at higher frequencies, running 4x per second is sufficient.
|
||||||
}
|
}
|
||||||
|
if ((mainLoopCount & 1023) == 1) //Every 1024 loops
|
||||||
|
{
|
||||||
|
//Approx. once per second
|
||||||
|
readBaro();
|
||||||
|
}
|
||||||
|
|
||||||
if(configPage4.iacAlgorithm == IAC_ALGORITHM_STEP_OL || configPage4.iacAlgorithm == IAC_ALGORITHM_STEP_CL) { idleControl(); } //Run idlecontrol every loop for stepper idle.
|
if(configPage4.iacAlgorithm == IAC_ALGORITHM_STEP_OL || configPage4.iacAlgorithm == IAC_ALGORITHM_STEP_CL) { idleControl(); } //Run idlecontrol every loop for stepper idle.
|
||||||
|
|
||||||
//Always check for sync
|
//Always check for sync
|
||||||
|
|
|
@ -452,6 +452,7 @@ void setPinMapping(byte boardID)
|
||||||
if ( (configPage4.fanPin != 0) && (configPage4.fanPin < BOARD_NR_GPIO_PINS) ) { pinFan = configPage4.fanPin; }
|
if ( (configPage4.fanPin != 0) && (configPage4.fanPin < BOARD_NR_GPIO_PINS) ) { pinFan = configPage4.fanPin; }
|
||||||
if ( (configPage3.boostPin != 0) && (configPage3.boostPin < BOARD_NR_GPIO_PINS) ) { pinBoost = configPage3.boostPin; }
|
if ( (configPage3.boostPin != 0) && (configPage3.boostPin < BOARD_NR_GPIO_PINS) ) { pinBoost = configPage3.boostPin; }
|
||||||
if ( (configPage3.vvtPin != 0) && (configPage3.vvtPin < BOARD_NR_GPIO_PINS) ) { pinVVT_1 = configPage3.vvtPin; }
|
if ( (configPage3.vvtPin != 0) && (configPage3.vvtPin < BOARD_NR_GPIO_PINS) ) { pinVVT_1 = configPage3.vvtPin; }
|
||||||
|
if ( (configPage3.useExtBaro != 0) ) { pinBaro = configPage3.baroPin + A0; }
|
||||||
|
|
||||||
//Finally, set the relevant pin modes for outputs
|
//Finally, set the relevant pin modes for outputs
|
||||||
pinMode(pinCoil1, OUTPUT);
|
pinMode(pinCoil1, OUTPUT);
|
||||||
|
@ -510,6 +511,7 @@ void setPinMapping(byte boardID)
|
||||||
pinMode(pinIAT, INPUT_ANALOG);
|
pinMode(pinIAT, INPUT_ANALOG);
|
||||||
pinMode(pinCLT, INPUT_ANALOG);
|
pinMode(pinCLT, INPUT_ANALOG);
|
||||||
pinMode(pinBat, INPUT_ANALOG);
|
pinMode(pinBat, INPUT_ANALOG);
|
||||||
|
pinMode(pinBaro, INPUT_ANALOG);
|
||||||
#else
|
#else
|
||||||
pinMode(pinMAP, INPUT);
|
pinMode(pinMAP, INPUT);
|
||||||
pinMode(pinO2, INPUT);
|
pinMode(pinO2, INPUT);
|
||||||
|
@ -518,6 +520,7 @@ void setPinMapping(byte boardID)
|
||||||
pinMode(pinIAT, INPUT);
|
pinMode(pinIAT, INPUT);
|
||||||
pinMode(pinCLT, INPUT);
|
pinMode(pinCLT, INPUT);
|
||||||
pinMode(pinBat, INPUT);
|
pinMode(pinBat, INPUT);
|
||||||
|
pinMode(pinBaro, INPUT);
|
||||||
#endif
|
#endif
|
||||||
pinMode(pinTrigger, INPUT);
|
pinMode(pinTrigger, INPUT);
|
||||||
pinMode(pinTrigger2, INPUT);
|
pinMode(pinTrigger2, INPUT);
|
||||||
|
|
Loading…
Reference in New Issue