From 4e249889a63a9f6db742dc26d82bb8be02a924bf Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Fri, 23 Oct 2020 04:31:47 -0700 Subject: [PATCH] implement fuel pressure sensors (#1897) * add * remove old * remove more old * makefile * fix init * patch up other stuff * actually fix it this time * raw output channels * gauges, UI * scaled channel * fix field ordering --- firmware/config/engines/vw_b6.cpp | 4 +- firmware/console/binary/tunerstudio_outputs.h | 9 ++- firmware/console/status_loop.cpp | 18 +++--- .../controllers/algo/engine_configuration.cpp | 34 ----------- firmware/controllers/engine_controller.cpp | 5 +- firmware/controllers/sensors/sensor.cpp | 3 + firmware/controllers/sensors/sensor_type.h | 3 + firmware/hw_layer/adc/adc_inputs.cpp | 5 +- firmware/init/init.mk | 2 +- firmware/init/sensor/init_fluid_pressure.cpp | 60 +++++++++++++++++++ firmware/init/sensor/init_oil_pressure.cpp | 49 --------------- firmware/integration/rusefi_config.txt | 24 +++++--- firmware/tunerstudio/rusefi.input | 44 ++++++++++---- firmware/util/scaled_channel.h | 1 + 14 files changed, 137 insertions(+), 124 deletions(-) create mode 100644 firmware/init/sensor/init_fluid_pressure.cpp delete mode 100644 firmware/init/sensor/init_oil_pressure.cpp diff --git a/firmware/config/engines/vw_b6.cpp b/firmware/config/engines/vw_b6.cpp index 9daf34aacd..77d4aa0c30 100644 --- a/firmware/config/engines/vw_b6.cpp +++ b/firmware/config/engines/vw_b6.cpp @@ -36,9 +36,9 @@ void setVwPassatB6(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_7; // "26 - AN volt 2" - engineConfiguration->high_fuel_pressure_sensor_1 = EFI_ADC_6; + engineConfiguration->highPressureFuel.hwChannel = EFI_ADC_6; // "19 - AN volt 4" - engineConfiguration->low_fuel_pressure_sensor = EFI_ADC_12; + engineConfiguration->lowPressureFuel.hwChannel = EFI_ADC_12; CONFIG(isSdCardEnabled) = false; diff --git a/firmware/console/binary/tunerstudio_outputs.h b/firmware/console/binary/tunerstudio_outputs.h index 183fd8a2ea..8a3d533967 100644 --- a/firmware/console/binary/tunerstudio_outputs.h +++ b/firmware/console/binary/tunerstudio_outputs.h @@ -250,10 +250,13 @@ typedef struct { scaled_percent wastegatePosition; // 268 scaled_percent idlePositionSensor; // 270 - scaled_voltage lowFuelPressure; // 272 - scaled_voltage highFuelPressure1; // 274 + scaled_voltage rawLowFuelPressure; // 272 + scaled_voltage rawHighFuelPressure; // 274 - uint8_t unusedAtTheEnd[12]; // we have some unused bytes to allow compatible TS changes + scaled_pressure lowFuelPressure; // 276 + scaled_high_pressure highFuelPressure; // 278 + + uint8_t unusedAtTheEnd[8]; // we have some unused bytes to allow compatible TS changes // Temporary - will remove soon TsDebugChannels* getDebugChannels() { diff --git a/firmware/console/status_loop.cpp b/firmware/console/status_loop.cpp index d4eece9d54..963e58dd82 100644 --- a/firmware/console/status_loop.cpp +++ b/firmware/console/status_loop.cpp @@ -519,20 +519,12 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->rawClt = Sensor::getRaw(SensorType::Clt); tsOutputChannels->rawIat = Sensor::getRaw(SensorType::Iat); tsOutputChannels->rawOilPressure = Sensor::getRaw(SensorType::OilPressure); + tsOutputChannels->rawLowFuelPressure = Sensor::getRaw(SensorType::FuelPressureLow); + tsOutputChannels->rawHighFuelPressure = Sensor::getRaw(SensorType::FuelPressureHigh); // offset 16 tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMafVoltage(PASS_ENGINE_PARAMETER_SIGNATURE) : 0; - - if (engineConfiguration->high_fuel_pressure_sensor_1 != EFI_ADC_NONE) { - tsOutputChannels->highFuelPressure1 = getVoltage("highFP", engineConfiguration->high_fuel_pressure_sensor_1 PASS_ENGINE_PARAMETER_SUFFIX); - } - - if (engineConfiguration->low_fuel_pressure_sensor != EFI_ADC_NONE) { - tsOutputChannels->lowFuelPressure = getVoltage("lowFP", engineConfiguration->low_fuel_pressure_sensor PASS_ENGINE_PARAMETER_SUFFIX); - } - - // offset 20 tsOutputChannels->airFuelRatio = Sensor::get(SensorType::Lambda).value_or(0) * 14.7f; @@ -613,6 +605,12 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_ tsOutputChannels->accelerationY = engine->sensors.accelerometer.y; // 280 tsOutputChannels->oilPressure = Sensor::get(SensorType::OilPressure).Value; + + // Low pressure is directly in kpa + tsOutputChannels->lowFuelPressure = Sensor::get(SensorType::FuelPressureLow).Value; + // High pressure is in bar, aka 100 kpa + tsOutputChannels->highFuelPressure = Sensor::get(SensorType::FuelPressureHigh).Value * 0.01f; + // 288 tsOutputChannels->injectionOffset = engine->engineState.injectionOffset; diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 931963ef3b..311c35daee 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -309,43 +309,9 @@ void prepareVoidConfiguration(engine_configuration_s *engineConfiguration) { efiAssertVoid(OBD_PCM_Processor_Fault, engineConfiguration != NULL, "ec NULL"); memset(engineConfiguration, 0, sizeof(engine_configuration_s)); - - // Now that GPIO_UNASSIGNED == 0 we do not really need explicit zero assignments since memset above does that - // todo: migrate 'EFI_ADC_NONE' to '0' and eliminate the need in this method altogether - for (int i = 0; i < FSIO_ANALOG_INPUT_COUNT ; i++) { - engineConfiguration->fsioAdc[i] = EFI_ADC_NONE; - } - - engineConfiguration->clt.adcChannel = EFI_ADC_NONE; - engineConfiguration->iat.adcChannel = EFI_ADC_NONE; - - engineConfiguration->cj125ua = EFI_ADC_NONE; - engineConfiguration->cj125ur = EFI_ADC_NONE; - engineConfiguration->auxTempSensor1.adcChannel = EFI_ADC_NONE; - engineConfiguration->auxTempSensor2.adcChannel = EFI_ADC_NONE; - engineConfiguration->baroSensor.hwChannel = EFI_ADC_NONE; - engineConfiguration->throttlePedalPositionAdcChannel = EFI_ADC_NONE; - engineConfiguration->oilPressure.hwChannel = EFI_ADC_NONE; - engineConfiguration->vRefAdcChannel = EFI_ADC_NONE; - engineConfiguration->vbattAdcChannel = EFI_ADC_NONE; - engineConfiguration->map.sensor.hwChannel = EFI_ADC_NONE; - engineConfiguration->mafAdcChannel = EFI_ADC_NONE; -/* this breaks unit tests lovely TODO: fix this? - engineConfiguration->tps1_1AdcChannel = EFI_ADC_NONE; -*/ - engineConfiguration->tps2_1AdcChannel = EFI_ADC_NONE; - engineConfiguration->auxFastSensor1_adcChannel = EFI_ADC_NONE; - engineConfiguration->externalKnockSenseAdc = EFI_ADC_NONE; - engineConfiguration->fuelLevelSensor = EFI_ADC_NONE; - engineConfiguration->hipOutputChannel = EFI_ADC_NONE; - engineConfiguration->afr.hwChannel = EFI_ADC_NONE; - engineConfiguration->high_fuel_pressure_sensor_1 = EFI_ADC_NONE; - engineConfiguration->high_fuel_pressure_sensor_2 = EFI_ADC_NONE; - engineConfiguration->clutchDownPinMode = PI_PULLUP; engineConfiguration->clutchUpPinMode = PI_PULLUP; engineConfiguration->brakePedalPinMode = PI_PULLUP; - } void setDefaultBasePins(DECLARE_CONFIG_PARAMETER_SIGNATURE) { diff --git a/firmware/controllers/engine_controller.cpp b/firmware/controllers/engine_controller.cpp index cf00f86f63..c26f6314c0 100644 --- a/firmware/controllers/engine_controller.cpp +++ b/firmware/controllers/engine_controller.cpp @@ -325,9 +325,8 @@ static void printAnalogInfo(void) { printAnalogChannelInfo("TPS1 Secondary", engineConfiguration->tps1_2AdcChannel); printAnalogChannelInfo("TPS2 Primary", engineConfiguration->tps2_1AdcChannel); printAnalogChannelInfo("TPS2 Secondary", engineConfiguration->tps2_2AdcChannel); - printAnalogChannelInfo("LPF", engineConfiguration->low_fuel_pressure_sensor); - printAnalogChannelInfo("HPF1", engineConfiguration->high_fuel_pressure_sensor_1); - printAnalogChannelInfo("HPF2", engineConfiguration->high_fuel_pressure_sensor_2); + printAnalogChannelInfo("LPF", engineConfiguration->lowPressureFuel.hwChannel); + printAnalogChannelInfo("HPF", engineConfiguration->highPressureFuel.hwChannel); printAnalogChannelInfo("pPS1", engineConfiguration->throttlePedalPositionAdcChannel); printAnalogChannelInfo("pPS2", engineConfiguration->throttlePedalPositionSecondAdcChannel); printAnalogChannelInfo("CLT", engineConfiguration->clt.adcChannel); diff --git a/firmware/controllers/sensors/sensor.cpp b/firmware/controllers/sensors/sensor.cpp index b23dc381ff..e692a97e89 100644 --- a/firmware/controllers/sensors/sensor.cpp +++ b/firmware/controllers/sensors/sensor.cpp @@ -58,6 +58,9 @@ static const char* s_sensorNames[] = { "Oil Pressure", + "Fuel Pressure (LP)", + "Fuel Pressure (HP)", + "TPS 1", "TPS 1 Primary", "TPS 1 Secondary", diff --git a/firmware/controllers/sensors/sensor_type.h b/firmware/controllers/sensors/sensor_type.h index 660d64555d..3a695e8a58 100644 --- a/firmware/controllers/sensors/sensor_type.h +++ b/firmware/controllers/sensors/sensor_type.h @@ -26,6 +26,9 @@ enum class SensorType : unsigned char { OilPressure, + FuelPressureLow, + FuelPressureHigh, + // This is the "resolved" position, potentially composited out of the following two Tps1, // This is the first sensor diff --git a/firmware/hw_layer/adc/adc_inputs.cpp b/firmware/hw_layer/adc/adc_inputs.cpp index 53cc778427..9e8a827b63 100644 --- a/firmware/hw_layer/adc/adc_inputs.cpp +++ b/firmware/hw_layer/adc/adc_inputs.cpp @@ -571,9 +571,8 @@ static void configureInputs(void) { addChannel("AFR", engineConfiguration->afr.hwChannel, ADC_SLOW); addChannel("Oil Pressure", engineConfiguration->oilPressure.hwChannel, ADC_SLOW); - addChannel("HFP1", engineConfiguration->high_fuel_pressure_sensor_1, ADC_SLOW); - addChannel("HFP2", engineConfiguration->high_fuel_pressure_sensor_2, ADC_SLOW); - addChannel("LFP", engineConfiguration->low_fuel_pressure_sensor, ADC_SLOW); + addChannel("LFP", engineConfiguration->lowPressureFuel.hwChannel, ADC_SLOW); + addChannel("HFP", engineConfiguration->highPressureFuel.hwChannel, ADC_SLOW); if (CONFIG(isCJ125Enabled)) { diff --git a/firmware/init/init.mk b/firmware/init/init.mk index 66674ac195..e54179f8d4 100644 --- a/firmware/init/init.mk +++ b/firmware/init/init.mk @@ -1,6 +1,6 @@ INIT_SRC_CPP = $(PROJECT_DIR)/init/sensor/init_sensors.cpp \ - $(PROJECT_DIR)/init/sensor/init_oil_pressure.cpp \ + $(PROJECT_DIR)/init/sensor/init_fluid_pressure.cpp \ $(PROJECT_DIR)/init/sensor/init_tps.cpp \ $(PROJECT_DIR)/init/sensor/init_can_sensors.cpp \ $(PROJECT_DIR)/init/sensor/init_thermistors.cpp \ diff --git a/firmware/init/sensor/init_fluid_pressure.cpp b/firmware/init/sensor/init_fluid_pressure.cpp new file mode 100644 index 0000000000..d9f88921db --- /dev/null +++ b/firmware/init/sensor/init_fluid_pressure.cpp @@ -0,0 +1,60 @@ +#include "init.h" +#include "adc_subscription.h" +#include "engine.h" +#include "error_handling.h" +#include "global.h" +#include "functional_sensor.h" +#include "linear_func.h" + +EXTERN_ENGINE; + +static LinearFunc oilpSensorFunc; +static FunctionalSensor oilpSensor(SensorType::OilPressure, /* timeout = */ MS2NT(50)); + +static LinearFunc fuelPressureFuncLow; +static FunctionalSensor fuelPressureSensorLow(SensorType::FuelPressureLow, /* timeout = */ MS2NT(50)); + +static LinearFunc fuelPressureFuncHigh; +static FunctionalSensor fuelPressureSensorHigh(SensorType::FuelPressureHigh, /* timeout = */ MS2NT(50)); + +static void configureFluidPressure(LinearFunc& func, const linear_sensor_s& cfg) { + float val1 = cfg.value1; + float val2 = cfg.value2; + + // Limit to max given pressure - val1 or val2 could be larger + // (sensor may be backwards, high voltage = low pressure) + float greaterOutput = val1 > val2 ? val1 : val2; + + // Allow slightly negative output (-5kpa) so as to not fail the sensor when engine is off + func.configure(cfg.v1, val1, cfg.v2, val2, /*minOutput*/ -5, greaterOutput); +} + +static void initFluidPressure(LinearFunc& func, FunctionalSensor& sensor, const linear_sensor_s& cfg, float bandwidth) { + auto channel = cfg.hwChannel; + + // Only register if we have a sensor + if (channel == EFI_ADC_NONE) { + return; + } + + configureFluidPressure(func, cfg); + sensor.setFunction(func); + + AdcSubscription::SubscribeSensor(sensor, channel, bandwidth); + + if (!sensor.Register()) { + firmwareError(CUSTOM_INVALID_TPS_SETTING, "Duplicate registration for sensor \"%s\"", sensor.getSensorName()); + } +} + +void initOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + initFluidPressure(oilpSensorFunc, oilpSensor, CONFIG(oilPressure), 10); + initFluidPressure(fuelPressureFuncLow, fuelPressureSensorLow, CONFIG(lowPressureFuel), 10); + initFluidPressure(fuelPressureFuncHigh, fuelPressureSensorHigh, CONFIG(highPressureFuel), 100); +} + +void reconfigureOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + configureFluidPressure(oilpSensorFunc, CONFIG(oilPressure)); + configureFluidPressure(fuelPressureFuncLow, CONFIG(lowPressureFuel)); + configureFluidPressure(fuelPressureFuncHigh, CONFIG(highPressureFuel)); +} diff --git a/firmware/init/sensor/init_oil_pressure.cpp b/firmware/init/sensor/init_oil_pressure.cpp deleted file mode 100644 index 2675a4f2e7..0000000000 --- a/firmware/init/sensor/init_oil_pressure.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "init.h" -#include "adc_subscription.h" -#include "engine.h" -#include "error_handling.h" -#include "global.h" -#include "functional_sensor.h" -#include "linear_func.h" -#if EFI_TUNER_STUDIO -#include "tunerstudio_outputs.h" -#endif - -EXTERN_ENGINE; - -LinearFunc oilpSensorFunc; -FunctionalSensor oilpSensor(SensorType::OilPressure, /* timeout = */ MS2NT(50)); - -void configureOilPressure(LinearFunc& func, const oil_pressure_config_s& cfg) { - float val1 = cfg.value1; - float val2 = cfg.value2; - - // Limit to max given pressure - val1 or val2 could be larger - // (sensor may be backwards, high voltage = low pressure) - float greaterOutput = val1 > val2 ? val1 : val2; - - // Allow slightly negative output (-5kpa) so as to not fail the sensor when engine is off - func.configure(cfg.v1, val1, cfg.v2, val2, /*minOutput*/ -5, greaterOutput); -} - -void initOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - // Only register if we have a sensor - auto channel = CONFIG(oilPressure.hwChannel); - if (channel == EFI_ADC_NONE) { - return; - } - - configureOilPressure(oilpSensorFunc, CONFIG(oilPressure)); - oilpSensor.setFunction(oilpSensorFunc); - - // Subscribe the sensor to the ADC - AdcSubscription::SubscribeSensor(oilpSensor, channel, 10); - - if (!oilpSensor.Register()) { - warning(OBD_Oil_Pressure_Sensor_Malfunction, "Duplicate oilp sensor registration, ignoring"); - } -} - -void reconfigureOilPressure(DECLARE_CONFIG_PARAMETER_SIGNATURE) { - configureOilPressure(oilpSensorFunc, CONFIG(oilPressure)); -} diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 2bcd8870f8..c7c563a821 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -168,6 +168,7 @@ struct_no_prefix engine_configuration_s ! These are used currently only for output channels - but could be for config as well #define PACK_MULT_PRESSURE 30 +#define PACK_MULT_HIGH_PRESSURE 10 #define PACK_MULT_PERCENT 100 #define PACK_MULT_TEMPERATURE 100 #define PACK_ADD_TEMPERATURE 40 @@ -368,13 +369,13 @@ float resistance_3;;"Ohm", 1, 0, 0, 200000, 1 float bias_resistor;+Pull-up resistor value on your board;"Ohm", 1, 0, 0, 200000, 1 end_struct -struct oil_pressure_config_s @brief Oil pressure sensor interpolation +struct linear_sensor_s @brief Linear sensor interpolation adc_channel_e hwChannel; uint8_t[3] alignmentFill;;"unit", 1, 0, 0, 100, 0 float v1;; "volts", 1, 0.0, 0, 10.0, 2 - float value1;; "kPa", 1, 0.0, 0, 1000.0, 2 + float value1;; "kPa", 1, 0.0, 0, 1000000.0, 2 float v2;; "volts", 1, 0.0, 0, 10.0, 2 - float value2;; "kPa", 1, 0.0, 0, 1000.0, 2 + float value2;; "kPa", 1, 0.0, 0, 1000000.0, 2 end_struct struct ThermistorConf @brief Thermistor curve parameters @@ -601,8 +602,8 @@ trigger_config_s trigger; custom spi_device_e 1 bits,U32, @OFFSET@, [0:2], "Off", "SPI1", "SPI2", "SPI3", "SPI4", "INVALID", "INVALID", "INVALID" spi_device_e hip9011SpiDevice; - adc_channel_e high_fuel_pressure_sensor_1; - adc_channel_e high_fuel_pressure_sensor_2; + uint8_t unused541;;"unit", 1, 0, 0, 100, 0 + uint8_t unused542;;"unit", 1, 0, 0, 100, 0 adc_channel_e mafAdcChannel;See hasMafSensor @@ -1195,8 +1196,7 @@ int16_t tps2Max;Full throttle#2. tpsMax value as 10 bit ADC value. Not Voltage!\ pin_output_mode_e starterControlPinMode; adc_channel_e wastegatePositionSensor; afr_override_e ignOverrideMode;+Override the Y axis (load) value used for the ignition table.\nAdvanced users only: If you aren't sure you need this, you probably don't need this. - uint8_t[2] unused_former_warmup_target_afr;;"units", 1, 0, -20, 100, 0 - adc_channel_e low_fuel_pressure_sensor; + uint8_t[3] unused_former_warmup_target_afr;;"units", 1, 0, -20, 100, 0 float boostCutPressure;+MAP value above which fuel is cut in case of overboost.\n0 to disable overboost cut.;"kPa (absolute)", 1, 0, 0, 500, 0 @@ -1282,7 +1282,7 @@ tle8888_mode_e tle8888mode; pid_s[AUX_PID_COUNT iterate] auxPid; - oil_pressure_config_s oilPressure; + linear_sensor_s oilPressure; spi_device_e accelerometerSpiDevice; uint8_t[1] unusedAuxVoltage1_TODO_332;;"units", 1, 0, -20, 100, 0 @@ -1322,7 +1322,10 @@ float[CRANKING_ADVANCE_CURVE_SIZE] crankingAdvance ;+Optional timing advance float[CLT_CURVE_SIZE] iacCoastingBins;CLT-based idle position for coasting (used in Auto-PID Idle mode);"C", 1, 0, -100.0, 250.0, 2 float[CLT_CURVE_SIZE] iacCoasting; CLT-based idle position for coasting (used in Auto-PID Idle mode);"%", 1, 0, 0.0, 100.0, 2 -uint8_t[576] unused3288;;"units", 1, 0, -20, 100, 0 + linear_sensor_s highPressureFuel; + linear_sensor_s lowPressureFuel; + +uint8_t[536] unused3328;;"units", 1, 0, -20, 100, 0 float tChargeAirCoefMin;;"Min tCharge Coeff.", 1, 0, 0.0, 1.0, 4 float tChargeAirCoefMax;;"Max tCharge Coeff.", 1, 0, 0.0, 1.0, 4 @@ -1554,6 +1557,9 @@ end_struct #define GAUGE_NAME_ETB_ERROR "ETB position error" #define GAUGE_NAME_ETB_DUTY "ETB Duty" +#define GAUGE_NAME_FUEL_PRESSURE_LOW "Fuel pressure (low)" +#define GAUGE_NAME_FUEL_PRESSURE_HIGH "Fuel pressure (high)" + #define GAUGE_NAME_ACCEL_X "Acceleration: X" #define GAUGE_NAME_ACCEL_Y "Acceleration: Y" #define GAUGE_NAME_ACCEL_Z "Acceleration: Z" diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index a8c2145a0b..45f171e9d5 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -363,9 +363,10 @@ enable2ndByteCanID = false rawWastegatePosition = scalar, U16, 266, "V",{1/@@PACK_MULT_VOLTAGE@@}, 0.0 wastegatePositionSensor = scalar, S16, 268, "%",{1/@@PACK_MULT_PERCENT@@}, 0 idlePositionSensor = scalar, S16, 270, "%",{1/@@PACK_MULT_PERCENT@@}, 0 - - lowFPValue = scalar, U16, 272, "V",,{1/@@PACK_MULT_VOLTAGE@@},, 0 - highFP1Value = scalar, U16, 274, "V",,{1/@@PACK_MULT_VOLTAGE@@},, 0 + rawLowFuelPressure = scalar, U16, 272, "V",{1/@@PACK_MULT_VOLTAGE@@}, 0 + rawHighFuelPressure = scalar, U16, 274, "V",{1/@@PACK_MULT_VOLTAGE@@}, 0 + lowFuelPressure = scalar, S16, 276, "kpa", {1/@@PACK_MULT_PRESSURE@@}, 0 + highFuelPressure = scalar, S16, 278, "bar", {1/@@PACK_MULT_HIGH_PRESSURE@@}, 0 ; ; see TunerStudioOutputChannels struct @@ -953,6 +954,8 @@ gaugeCategory = Sensors - Extra 1 idleAirValvePositionGauge = idleAirValvePosition, "Idle position", "%", 0, 100, 0, 0, 100, 100, 1, 1 AuxT1Gauge = auxt1, "Aux temp 1", "deg C", -40, 140, -15, 1, 95, 110, 1, 1 AuxT2Gauge = auxt2, "Aux temp 2", "deg C", -40, 140, -15, 1, 95, 110, 1, 1 + lowFuelPressureGauge = lowFuelPressure, @@GAUGE_NAME_FUEL_PRESSURE_LOW@@, "kPa", 0, 700, 0, 0, 700, 700, 1, 0 + highFuelPressureGauge = highFuelPressure, @@GAUGE_NAME_FUEL_PRESSURE_HIGH@@, "bar", 0, 200, 0, 0, 200, 200, 1, 0 gaugeCategory = Ignition ignadvGauge = ignitionAdvance, "Ignition timing", "degrees", -100, 100, -999, -999, 999, 999, 1, 1 @@ -1004,8 +1007,8 @@ gaugeCategory = Sensors - Raw rawPpsSecondaryGauge = rawPpsSecondary,"Raw Pedal Secondary","volts", 0, 5, 0, 0, 5, 5, 3, 0 rawIdlePositionSensorGauge = rawIdlePositionSensor, "Raw Idle Position", "volts", 0, 5, 0, 0, 5, 5, 3, 0 rawWastegatePositionGauge = rawWastegatePosition,"Raw Wastegate Position","volts", 0, 5, 0, 0, 5, 5, 3, 0 - lowFPValueGauge = lowFPValue,"Raw low fuel voltage","volts", 0, 5, 0, 0, 5, 5, 3, 0 - highFP1ValueGauge = highFP1Value,"Raw high1 fuel voltage","volts", 0, 5, 0, 0, 5, 5, 3, 0 + rawLowFuelPressureGauge = rawLowFuelPressure,"Raw fuel pressure (low) voltage","volts", 0, 5, 0, 0, 5, 5, 3, 0 + rawHighFuelPressureGauge = rawHighFuelPressure,"Raw fuel pressure (high) voltage","volts", 0, 5, 0, 0, 5, 5, 3, 0 gaugeCategory = Transmission desiredGearGauge = tcuDesiredGear, "Desired", "gear", -1, 10, -1, -1, 10, 10, 0, 0 @@ -1139,8 +1142,8 @@ gaugeCategory = Knock entry = throttlePedalPosition, @@GAUGE_NAME_THROTTLE_PEDAL@@, float, "%.3f" entry = totalTriggerErrorCounter, @@GAUGE_NAME_TRG_ERR@@,int, "%d" entry = idleAirValvePosition, @@GAUGE_NAME_IAC@@, float, "%.3f" - entry = lowFPValue, "low pressure", float, "%.3f" - entry = highFP1Value, "high pressure", float, "%.3f" + entry = lowFuelPressure, @@GAUGE_NAME_FUEL_PRESSURE_LOW@@, float, "%.3f" + entry = highFuelPressure, @@GAUGE_NAME_FUEL_PRESSURE_HIGH@@, float, "%.3f" entry = injectorLagMs, @@GAUGE_NAME_INJECTOR_LAG@@, float, "%.3f" entry = fuelRunning, @@GAUGE_NAME_FUEL_RUNNING@@, float, "%.3f" @@ -1411,6 +1414,7 @@ menuDialog = main # Misc sensors subMenu = speedSensor, "Vehicle speed sensor" subMenu = oilPressureSensor, "Oil pressure" + subMenu = fuelPressureSensor, "Fuel pressure" subMenu = egtInputs, "EGT" @@if_ts_show_egt subMenu = wastegateIdlePos, "Wastegate and idle position sensors" @@ -1996,9 +2000,6 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00" field = "trigger stimulator pin #1", triggerSimulatorPins1 field = "trigger stimulator pin #2", triggerSimulatorPins2 field = "trigger stimulator pin #2", triggerSimulatorPins3 - field = high_fuel_pressure_sensor_1, high_fuel_pressure_sensor_1 - field = high_fuel_pressure_sensor_2, high_fuel_pressure_sensor_2 - field = low_fuel_pressure_sensor, low_fuel_pressure_sensor field = "Warning Led", warningLedPin field = "tle6240_cs", tle6240_cs field = "tle6240 SPI", tle6240spiDevice @@ -2240,6 +2241,29 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@\x00\x31\x00\x00" panel = oilp_settings, West panel = oilPressureGauges, East + dialog = fuelp_settings, "Fuel Pressure Sensor" + field = "Fuel low pressure ADC input", lowPressureFuel_hwChannel + field = "low voltage", lowPressureFuel_v1, {lowPressureFuel_hwChannel != @@ADC_CHANNEL_NONE@@} + field = "low pressure", lowPressureFuel_value1, {lowPressureFuel_hwChannel != @@ADC_CHANNEL_NONE@@} + field = "high voltage", lowPressureFuel_v2, {lowPressureFuel_hwChannel != @@ADC_CHANNEL_NONE@@} + field = "high pressure", lowPressureFuel_value2, {lowPressureFuel_hwChannel != @@ADC_CHANNEL_NONE@@} + + field = "Fuel high pressure ADC input", highPressureFuel_hwChannel + field = "low voltage", highPressureFuel_v1, {highPressureFuel_hwChannel != @@ADC_CHANNEL_NONE@@} + field = "low pressure", highPressureFuel_value1, {highPressureFuel_hwChannel != @@ADC_CHANNEL_NONE@@} + field = "high voltage", highPressureFuel_v2, {highPressureFuel_hwChannel != @@ADC_CHANNEL_NONE@@} + field = "high pressure", highPressureFuel_value2, {highPressureFuel_hwChannel != @@ADC_CHANNEL_NONE@@} + + dialog = fuelPressureGauges + gauge = lowFuelPressureGauge + gauge = rawLowFuelPressureGauge + gauge = highFuelPressureGauge + gauge = rawHighFuelPressureGauge + + dialog = fuelPressureSensor, "", border + panel = fuelp_settings, West + panel = fuelPressureGauges, East + ; Sensors->MAP sensor dialog = mapSensorAnalog, "MAP sensor", yAxis field = "MAP ADC input", map_sensor_hwChannel diff --git a/firmware/util/scaled_channel.h b/firmware/util/scaled_channel.h index b3f130afa3..652ab05505 100644 --- a/firmware/util/scaled_channel.h +++ b/firmware/util/scaled_channel.h @@ -51,6 +51,7 @@ using scaled_temperature = scaled_channel; // +- using scaled_ms = scaled_channel; // +- 100ms at 0.003ms precision using scaled_percent = scaled_channel; // +-327% at 0.01% resolution using scaled_pressure = scaled_channel; // 0-2000kPa (~300psi) at 0.03kPa resolution +using scaled_high_pressure = scaled_channel; // 0-6553 bar (~95k psi) at 0.1 bar resolution using scaled_angle = scaled_channel; // +-655 degrees at 0.02 degree resolution using scaled_voltage = scaled_channel; // 0-65v at 1mV resolution using scaled_afr = scaled_channel; // 0-65afr at 0.001 resolution