Allocate memory for fuel/oil pressure inputs

This commit is contained in:
Josh Stewart 2020-05-29 12:21:28 +10:00
parent 2c1269eef9
commit fc43f3a479
8 changed files with 114 additions and 11 deletions

View File

@ -1027,7 +1027,21 @@ page = 10
vvtCLMaxAng = scalar, U16, 132, "deg", 1.0, 0.0, 0.0, 360.0, 0 ; * ( 1 bytes)
crankingEnrichTaper = scalar, U08, 134, "s", 0.1, 0.0, 0.0, 25.5, 1
unused11_135_191 = array, U08, 135, [56], "RPM", 100.0, 0.0, 100, 25500, 0
;Pressure transducers
fuelPressureEnable = bits, U08, 135, [0:0], "Off", "On"
oilPressureEnable = bits, U08, 135, [1:1], "Off", "On"
fuelPressurePin = bits, U08, 136, [0:3], "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A8", "A10", "A11", "A12", "A13", "A14", "A15"
oilPressurePin = bits, U08, 136, [4:7], "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A8", "A10", "A11", "A12", "A13", "A14", "A15"
fuelPressureMin = scalar, S08, 137, "kpa", 1.0, 0.0, -100, 127, 0 ;Note signed int
fuelPressureMax = scalar, U08, 138, "kpa", 1.0, 0.0, 0.0, 255, 0
oilPressureMin = scalar, S08, 139, "kpa", 1.0, 0.0, -100, 127, 0 ;Note signed int
oilPressureMax = scalar, U08, 140, "kpa", 1.0, 0.0, 0.0, 255, 0
unused11_135_191 = array, U08, 141, [50], "RPM", 100.0, 0.0, 100, 25500, 0
;unused11_135_191 = array, U08, 135, [56], "RPM", 100.0, 0.0, 100, 25500, 0
;Page 11 is the fuel map and axis bins only
page = 11
@ -1395,17 +1409,18 @@ menuDialog = main
#if CAN_COMMANDS
subMenu = can_serial3IO, "Canbus/Secondary Serial IO Interface"
subMenu = std_separator
subMenu = std_separator
subMenu = Canin_config, "External Auxillary Input Channel Configuration", {enable_secondarySerial || (enable_intcan && intcan_available)}
subMenu = Auxin_config, "Local Auxillary Input Channel Configuration"
subMenu = Auxin_config, "Local Auxillary Input Channel Configuration"
;subMenu = std_separator
;subMenu = Canout_config, "Canbus Output Configuration"
#else
subMenu = serial3IO, "Canbus/Secondary Serial IO Interface"
subMenu = std_separator
subMenu = serial3IO, "Canbus/Secondary Serial IO Interface"
subMenu = std_separator
subMenu = Canin_config, "External Auxillary Input Channel Configuration", {enable_secondarySerial || (enable_intcan && intcan_available)}
subMenu = Auxin_config, "Local Auxillary Input Channel Configuration"
subMenu = Auxin_config, "Local Auxillary Input Channel Configuration"
#endif
subMenu = pressureSensors, "Fuel/Oil pressure"
menuDialog = main
menu = "Tools"
@ -2441,6 +2456,37 @@ menuDialog = main
slider = "MAP sensor", ADCFILTER_MAP, horizontal
slider = "Baro sensor", ADCFILTER_BARO, horizontal, { useExtBaro > 0 }
dialog = fuelPressureSettings
field = "Enabled", fuelPressureEnable
field = "Pin", fuelPressurePin, { fuelPressureEnable }
settingSelector = "Common Sensors", { fuelPressureEnable }
settingOption = "0-100 PSI", fuelPressureMin=-3, fuelPressureMax=103 ; Vout = VCC x (P x .97 / 200 + 0.5)
settingOption = "0-150 PSI", fuelPressureMin=-18, fuelPressureMax=168 ; Vout = VCC x (P x 0.8 / 150 + 0.1) https://aftermarketindustries.com.au/image/cache/data/aftermarket%20industries%20fuel%20pressure%20sensor%20data%202-500x500.png
field = "Pressure at 0v", fuelPressureMin, { fuelPressureEnable }
field = "Pressure at 5v", fuelPressureMax, { fuelPressureEnable }
dialog = fuelPressureDialog, "Fuel Pressure", xAxis
gauge = fuelPressureGauge
panel = fuelPressureSettings
dialog = oilPressureSettings
field = "Enabled", oilPressureEnable
field = "Pin", oilPressurePin, { oilPressureEnable }
settingSelector = "Common Sensors", { oilPressureEnable }
settingOption = "0-100 PSI", oilPressureMin=-3, oilPressureMax=103 ; Vout = VCC x (P x .97 / 200 + 0.5)
settingOption = "0-150 PSI", oilPressureMin=-18, oilPressureMax=168 ; Vout = VCC x (P x 0.8 / 150 + 0.1) https://aftermarketindustries.com.au/image/cache/data/aftermarket%20industries%20fuel%20pressure%20sensor%20data%202-500x500.png
field = "Pressure at 0v", oilPressureMin, { oilPressureEnable }
field = "Pressure at 5v", oilPressureMax, { oilPressureEnable }
dialog = oilPressureDialog, "Oil Pressure", xAxis
gauge = oilPressureGauge
panel = oilPressureSettings
dialog = pressureSensors, "Pressure Transducers"
topicHelp = "https://wiki.speeduino.com/en/configuration/Sensor_Calibration"
panel = fuelPressureDialog
panel = oilPressureDialog
dialog = boostSettings, "Boost Control"
topicHelp = "https://wiki.speeduino.com/en/configuration/Boost_Control"
field = "Boost Control Enabled", boostEnabled
@ -3698,6 +3744,9 @@ cmdVSSratio6 = "E\x99\x06"
#endif
flexGauge = flex, "Flex sensor", "%", 0, 100, -1, -1, 999, 999, 0, 0
fuelPressureGauge = fuelPressure, "Fuel Pressure", "PSI", -15, 100, 0, 20, 200, 245, 0, 0
oilPressureGauge = oilPressure, "Oil Pressure", "PSI", -15, 100, 0, 20, 200, 245, 0, 0
gaugeCategory = "Auxillary Input Channels"
AuxInGauge0 = auxin_gauge0, { stringValue(AUXin00Alias) }, "", 0, 1024, -1, -1, 1025, 1025, 0, 0
AuxInGauge1 = auxin_gauge1, { stringValue(AUXin01Alias) }, "", 0, 1024, -1, -1, 1025, 1025, 0, 0
@ -3776,7 +3825,8 @@ cmdVSSratio6 = "E\x99\x06"
; you change it.
ochGetCommand = "r\$tsCanId\x30%2o%2c"
ochBlockSize = 104
;ochBlockSize = 104
ochBlockSize = 106
secl = scalar, U08, 0, "sec", 1.000, 0.000
status1 = scalar, U08, 1, "bits", 1.000, 0.000
@ -3884,7 +3934,9 @@ cmdVSSratio6 = "E\x99\x06"
veCurr = scalar, U08, 99, "%", 1.000, 0.000
ASECurr = scalar, U08, 100, "%", 1.000, 0.000
vss = scalar, U16, 101, "km/h", 1.000, 0.000
gear = scalar, U08, 103, "", 1.000, 0.000
gear = scalar, U08, 103, "", 1.000, 0.000
fuelPressure = scalar, U08, 104, "PSI", 1.000, 0.000
oilPressure = scalar, U08, 105, "PSI", 1.000, 0.000
#sd_status = scalar, U08, 99, "", 1.0, 0.0
#if CELSIUS

View File

@ -650,6 +650,8 @@ void sendValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum)
fullStatus[101] = lowByte(currentStatus.vss);
fullStatus[102] = highByte(currentStatus.vss);
fullStatus[103] = currentStatus.gear;
fullStatus[104] = currentStatus.fuelPressure;
fullStatus[105] = currentStatus.oilPressure;
for(byte x=0; x<packetLength; x++)
{

View File

@ -539,6 +539,8 @@ struct statuses {
byte ASEValue;
uint16_t vss; /**< Current speed reading. Natively stored in kph and converted to mph in TS if required */
byte gear; /**< Current gear (Calculated from vss) */
byte fuelPressure; /**< Fuel pressure in PSI */
byte oilPressure; /**< Oil pressure in PSI */
};
/**
@ -1065,7 +1067,20 @@ struct config10 {
uint16_t vvtCLMaxAng; //Bytes 132-133
byte crankingEnrichTaper; //Byte 134
byte unused11_135_191[57]; //Bytes 135-191
byte fuelPressureEnable : 1;
byte oilPressureEnable : 1;
byte unused10_135 : 6;
byte fuelPressurePin : 4;
byte oilPressurePin : 4;
int8_t fuelPressureMin;
byte fuelPressureMax;
int8_t oilPressureMin;
byte oilPressureMax;
byte unused11_135_191[51]; //Bytes 135-191
#if defined(CORE_AVR)
};
@ -1137,6 +1152,8 @@ extern byte pinFlex; //Pin with the flex sensor attached
extern byte pinVSS;
extern byte pinBaro; //Pin that an external barometric pressure sensor is attached to (If used)
extern byte pinResetControl; // Output pin used control resetting the Arduino
extern byte pinFuelPressure;
extern byte pinOilPressure;
#ifdef USE_MC33810
//If the MC33810 IC\s are in use, these are the chip select pins
extern byte pinMC33810_1_CS;

View File

@ -204,6 +204,8 @@ byte pinFlex; //Pin with the flex sensor attached
byte pinVSS;
byte pinBaro; //Pin that an al barometric pressure sensor is attached to (If used)
byte pinResetControl; // Output pin used control resetting the Arduino
byte pinFuelPressure;
byte pinOilPressure;
#ifdef USE_MC33810
//If the MC33810 IC\s are in use, these are the chip select pins
byte pinMC33810_1_CS;

View File

@ -2329,6 +2329,8 @@ void setPinMapping(byte boardID)
if ( (configPage6.useEMAP != 0) && (configPage10.EMAPPin < BOARD_NR_GPIO_PINS) ) { pinEMAP = configPage10.EMAPPin + A0; }
if ( (configPage10.fuel2InputPin != 0) && (configPage10.fuel2InputPin < BOARD_NR_GPIO_PINS) ) { pinFuel2Input = pinTranslate(configPage10.fuel2InputPin); }
if ( (configPage2.vssPin != 0) && (configPage2.vssPin < BOARD_NR_GPIO_PINS) ) { pinVSS = pinTranslate(configPage2.vssPin); }
if ( (configPage10.fuelPressurePin != 0) && (configPage10.fuelPressurePin < BOARD_NR_GPIO_PINS) ) { pinFuelPressure = configPage10.fuelPressurePin + A0; }
if ( (configPage10.oilPressurePin != 0) && (configPage10.oilPressurePin < BOARD_NR_GPIO_PINS) ) { pinOilPressure = configPage10.oilPressurePin + A0; }
//Currently there's no default pin for Idle Up
pinIdleUp = pinTranslate(configPage2.idleUpPin);
@ -2489,6 +2491,14 @@ void setPinMapping(byte boardID)
if (configPage10.fuel2InputPullup == true) { pinMode(pinFuel2Input, INPUT_PULLUP); } //With pullup
else { pinMode(pinFuel2Input, INPUT); } //Normal input
}
if(configPage10.fuelPressureEnable > 0)
{
pinMode(pinFuelPressure, INPUT);
}
if(configPage10.oilPressureEnable > 0)
{
pinMode(pinOilPressure, INPUT);
}
//These must come after the above pinMode statements

View File

@ -9,8 +9,8 @@
#ifndef LOGGER_H
#define LOGGER_H
#define LOG_ENTRY_SIZE 104 /**< The size of the live data packet. This MUST match ochBlockSize setting in the ini file */
#define SD_LOG_ENTRY_SIZE 104 /**< The size of the live data packet used by the SD car.*/
#define LOG_ENTRY_SIZE 106 /**< The size of the live data packet. This MUST match ochBlockSize setting in the ini file */
#define SD_LOG_ENTRY_SIZE 106 /**< The size of the live data packet used by the SD car.*/
void createLog(uint8_t *array);
void createSDLog(uint8_t *array);

View File

@ -69,6 +69,8 @@ void flexPulse();
void vssPulse();
uint16_t getSpeed();
byte getGear();
byte getFuelPressure();
byte getOilPressure();
uint16_t readAuxanalog(uint8_t analogPin);
uint16_t readAuxdigital(uint8_t digitalPin);
void readCLT(bool=true); //Allows the option to override the use of the filter

View File

@ -569,6 +569,24 @@ byte getGear()
return tempGear;
}
byte getFuelPressure()
{
int16_t tempFuelPressure = 0;
uint16_t tempReading;
//Perform ADC read
tempReading = analogRead(pinFuelPressure);
tempReading = analogRead(pinFuelPressure);
tempFuelPressure = fastMap10Bit(tempReading, configPage10.fuelPressureMin, configPage10.fuelPressureMax);
//Sanity checks
if(tempFuelPressure < 0) { tempFuelPressure = 0; }
if(tempFuelPressure > configPage10.fuelPressureMax) { tempFuelPressure = configPage10.fuelPressureMax; }
return (byte)tempFuelPressure;
}
/*
* The interrupt function for reading the flex sensor frequency
* This value is incremented with every pulse and reset back to 0 once per second