Implement oil pressure sensor (#491)

* code changes

* config changes
This commit is contained in:
Matthew Kennedy 2017-11-15 14:30:13 -05:00 committed by rusefi
parent ff46103891
commit c3c38aa9bd
18 changed files with 176 additions and 14 deletions

View File

@ -162,7 +162,8 @@ typedef struct {
float coilDutyCycle; // 272
int16_t accelerationX; // 276
int16_t accelerationY; // 278
int unused3[19];
float oilPressure; // 280
int unused3[18];
} TunerStudioOutputChannels;
#endif /* TUNERSTUDIO_CONFIGURATION_H_ */

View File

@ -699,7 +699,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
tsOutputChannels->throttlePositon = tps;
tsOutputChannels->massAirFlowVoltage = hasMafSensor() ? getMaf(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
tsOutputChannels->massAirFlow = hasMafSensor() ? getRealMaf(PASS_ENGINE_PARAMETER_SIGNATURE) : 0;
tsOutputChannels->oilPressure = engine->sensors.oilPressure;
tsOutputChannels->accelerationX = engine->sensors.accelerometer.x;
tsOutputChannels->accelerationY = engine->sensors.accelerometer.y;

View File

@ -184,6 +184,7 @@ EngineState::EngineState() {
void EngineState::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engine->sensors.iat = getIntakeAirTemperature(PASS_ENGINE_PARAMETER_SIGNATURE);
engine->sensors.clt = getCoolantTemperature(PASS_ENGINE_PARAMETER_SIGNATURE);
engine->sensors.oilPressure = getOilPressure(PASS_ENGINE_PARAMETER_SIGNATURE);
warmupTargetAfr = interpolate2d("warm", engine->sensors.clt, engineConfiguration->warmupTargetAfrBins,
engineConfiguration->warmupTargetAfr, WARMUP_TARGET_AFR_SIZE);

View File

@ -89,6 +89,11 @@ public:
float iat;
float clt;
/**
* Oil pressure in kPa
*/
float oilPressure;
Accelerometer accelerometer;
float vBatt;

View File

@ -759,6 +759,12 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineConfiguration->tpsErrorDetectionTooLow = -10; // -10% open
engineConfiguration->tpsErrorDetectionTooHigh = 110; // 110% open
engineConfiguration->oilPressure.hwChannel = EFI_ADC_NONE;
engineConfiguration->oilPressure.v1 = 0.5f;
engineConfiguration->oilPressure.v2 = 4.5f;
engineConfiguration->oilPressure.value1 = 0;
engineConfiguration->oilPressure.value2 = 689.476f; // 100psi = 689.476kPa
setOperationMode(engineConfiguration, FOUR_STROKE_CAM_SENSOR);
engineConfiguration->specs.cylindersCount = 4;

View File

@ -1,4 +1,4 @@
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Oct 29 20:03:49 EDT 2017
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Nov 09 13:37:49 EST 2017
// begin
#ifndef ENGINE_CONFIGURATION_GENERATED_H_
#define ENGINE_CONFIGURATION_GENERATED_H_
@ -147,6 +147,34 @@ typedef struct {
/** total size 28*/
} thermistor_conf_s;
/**
* @brief Oil pressure sensor interpolation
*/
typedef struct {
/**
* offset 0
*/
adc_channel_e hwChannel;
/**
* offset 4
*/
float v1;
/**
* offset 8
*/
float value1;
/**
* offset 12
*/
float v2;
/**
* offset 16
*/
float value2;
/** total size 20*/
} oil_pressure_config_s;
/**
* @brief Thermistor curve parameters
@ -1948,7 +1976,11 @@ typedef struct {
/**
* offset 2944
*/
int unusedEnd[26];
oil_pressure_config_s oilPressure;
/**
* offset 2964
*/
int unusedEnd[21];
/** total size 3048*/
} engine_configuration_s;
@ -2163,4 +2195,4 @@ typedef struct {
#endif
// end
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Oct 29 20:03:49 EDT 2017
// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Nov 09 13:37:49 EST 2017

View File

@ -1449,8 +1449,20 @@
#define auxPid4_minValue_offset_hex b7c
#define auxPid4_maxValue_offset 2942
#define auxPid4_maxValue_offset_hex b7e
#define unusedEnd_offset 2944
#define unusedEnd_offset_hex b80
#define oilPressure_offset 2944
#define oilPressure_offset_hex b80
#define oilPressure_hwChannel_offset 2944
#define oilPressure_hwChannel_offset_hex b80
#define oilPressure_v1_offset 2948
#define oilPressure_v1_offset_hex b84
#define oilPressure_value1_offset 2952
#define oilPressure_value1_offset_hex b88
#define oilPressure_v2_offset 2956
#define oilPressure_v2_offset_hex b8c
#define oilPressure_value2_offset 2960
#define oilPressure_value2_offset_hex b90
#define unusedEnd_offset 2964
#define unusedEnd_offset_hex b94
#define fsioFormulas1_offset 3048
#define fsioFormulas1_offset_hex be8
#define fsioFormulas2_offset 3248

View File

@ -365,6 +365,8 @@ static void printAnalogInfo(void) {
printAnalogChannelInfo("extKno", engineConfiguration->externalKnockSenseAdc);
}
printAnalogChannelInfo("OilP", engineConfiguration->oilPressure.hwChannel);
printAnalogChannelInfo("A/C sw", engineConfiguration->acSwitchAdc);
printAnalogChannelInfo("HIP9011", engineConfiguration->hipOutputChannel);
printAnalogChannelInfoExt("Vbatt", engineConfiguration->vbattAdcChannel, getVoltage("vbatt", engineConfiguration->vbattAdcChannel),

View File

@ -19,6 +19,7 @@
#include "ego.h"
#include "voltage.h"
#include "thermistors.h"
#include "oil_pressure.h"
#include "adc_inputs.h"
#if EFI_PROD_CODE || EFI_SIMULATOR

View File

@ -0,0 +1,26 @@
/**
* @author Matthew Kennedy, (c) 2017
*/
#include "oil_pressure.h"
#include "interpolation.h"
#include "adc_inputs.h"
#include "engine.h"
EXTERN_ENGINE;
bool hasOilPressureSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
return engineConfiguration->oilPressure.hwChannel != EFI_ADC_NONE;
}
float getOilPressure(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// If there's no sensor, return 0 pressure.
if(!hasOilPressureSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
return 0.0f;
}
oil_pressure_config_s* sensor = &CONFIG(oilPressure);
float volts = getVoltageDivided("oilp", sensor->hwChannel);
return interpolate(sensor->v1, sensor->value1, sensor->v2, sensor->value2, volts);
}

View File

@ -0,0 +1,17 @@
/**
* @date Nov 9, 2017
* @author Matthew Kennedy, (c) 2017
*/
#ifndef OIL_PRESSURE_H_
#define OIL_PRESSURE_H_
#include "main.h"
#include "rusefi_enums.h"
#include "engine_configuration.h"
float getOilPressure(DECLARE_ENGINE_PARAMETER_SIGNATURE);
bool hasOilPressureSensor(DECLARE_ENGINE_PARAMETER_SIGNATURE);
#endif

View File

@ -8,4 +8,5 @@ CONTROLLERS_SENSORS_SRC_CPP = $(PROJECT_DIR)/controllers/sensors/thermistors.cp
$(PROJECT_DIR)/controllers/sensors/maf.cpp \
$(PROJECT_DIR)/controllers/sensors/tps.cpp \
$(PROJECT_DIR)/controllers/sensors/ego.cpp \
$(PROJECT_DIR)/controllers/sensors/hip9011_lookup.cpp
$(PROJECT_DIR)/controllers/sensors/hip9011_lookup.cpp \
$(PROJECT_DIR)/controllers/sensors/oil_pressure.cpp

View File

@ -615,6 +615,7 @@ static void configureInputs(void) {
addChannel("CLT", engineConfiguration->clt.adcChannel, ADC_SLOW);
addChannel("IAT", engineConfiguration->iat.adcChannel, ADC_SLOW);
addChannel("AFR", engineConfiguration->afr.hwChannel, ADC_SLOW);
addChannel("OilP", engineConfiguration->oilPressure.hwChannel, ADC_SLOW);
addChannel("AC", engineConfiguration->acSwitchAdc, ADC_SLOW);
for (int i = 0; i < FSIO_ANALOG_INPUT_COUNT ; i++) {

View File

@ -177,6 +177,14 @@ float resistance_3;;"Ohm", 1, 0, 0, 200000, 1
float bias_resistor;;"Ohm", 1, 0, 0, 200000, 1
end_struct
struct oil_pressure_config_s @brief Oil pressure sensor interpolation
adc_channel_e hwChannel;
float v1;; "volts", 1, 0.0, 0, 10.0, 2
float value1;; "kPa", 1, 0.0, 0, 1000.0, 2
float v2;; "volts", 1, 0.0, 0, 10.0, 2
float value2;; "kPa", 1, 0.0, 0, 1000.0, 2
end_struct
struct ThermistorConf @brief Thermistor curve parameters
thermistor_conf_s config;
adc_channel_e adcChannel;
@ -823,7 +831,10 @@ spi_device_e sdCardSpiDevice;
pin_mode_e spi1MisoMode;
brain_pin_e brakePedalPin
pid_s[AUX_PID_COUNT iterate] auxPid;
int[26] unusedEnd;
oil_pressure_config_s oilPressure;
int[21] unusedEnd;
end_struct

View File

@ -63,7 +63,7 @@ enable2ndByteCanID = false
; see PAGE_0_SIZE in C source code
; CONFIG_DEFINITION_START
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Nov 06 18:48:24 EST 2017
; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Nov 09 13:37:49 EST 2017
pageSize = 16376
page = 1
@ -733,7 +733,12 @@ page = 1
auxPid4_period = scalar, S16, 2938, "ms", 1, 0, 0, 3000, 0
auxPid4_minValue = scalar, S16, 2940, "", 1, 0, 0, 3000.0, 3
auxPid4_maxValue = scalar, S16, 2942, "", 1, 0, 0, 3000.0, 3
;skipping unusedEnd offset 2944
oilPressure_hwChannel = bits, U32, 2944, [0:4] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "Disabled", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
oilPressure_v1 = scalar, F32, 2948, "volts", 1, 0.0, 0, 10.0, 2
oilPressure_value1 = scalar, F32, 2952, "kPa", 1, 0.0, 0, 1000.0, 2
oilPressure_v2 = scalar, F32, 2956, "volts", 1, 0.0, 0, 10.0, 2
oilPressure_value2 = scalar, F32, 2960, "kPa", 1, 0.0, 0, 1000.0, 2
;skipping unusedEnd offset 2964
fsioFormulas1 = string, ASCII, 3048, 200
fsioFormulas2 = string, ASCII, 3248, 200
fsioFormulas3 = string, ASCII, 3448, 200
@ -1028,6 +1033,7 @@ fileVersion = { 20161225 }
coilDutyCycle = scalar, F32, 272, "perc", 1, 0
accelerationX = scalar, S16, 276, "G", 0.01, 0
accelerationY = scalar, S16, 276, "G", 0.01, 0
oilPressure = scalar, F32, 280, "kPa", 1, 0.0
; todo: generate this section programatically
LM_PLAIN_MAF = {0},
@ -1382,6 +1388,7 @@ gaugeCategory = Sensors
MAFGauge = MAFValue, "Mass Air Flow", "v", 0, 5, 0, 1, 3, 4, 1, 1
VBattGauge = VBatt, "Battery Voltage", "V", 8, 21, 9, 10, 17, 19, 1, 1
MAPGauge = MAPValue, "MAP", "kPa", 0, 300, 10, 10, 200, 200, 0, 0
OilPressGauge = oilPressure, "Oil Pressure", "kPa", 0, 750, 35, 75, 550, 700, 0, 0
tpsADCGauge = tpsADC, "tps ADC", "ADC", 0, 1024, 0, 0, 0, 0, 0, 0
atmPresCGauge = baroPressure, "Baro", "kPa", 0, 1024, 0, 0, 0, 0, 0, 0
vvtPositionGauge = vvtPosition, "VVT position", "deg", 0, 100, 0, 0, 720, 720, 0, 0
@ -1499,6 +1506,7 @@ gaugeCategory = Fuel Data
entry = firmwareVersion, "firmware", int, "%d"
entry = coolant, "CLT", float, "%.2f"
entry = intake, "IAT", float, "%.2f"
entry = oilPressure, "Oil Press", float, "%.1f"
entry = TPSValue, "TPS", float, "%.2f"
entry = MAFValue, "MAF", float, "%.2f"
entry = MAPValue, "MAP", float, "%.1f"
@ -1620,6 +1628,7 @@ gaugeCategory = Fuel Data
subMenu = egoSettings, "EGO Sensor Settings"
subMenu = narrowToWideOxygenCurve, "Narrow to Wideband approximation"
subMenu = egtInputs, "EGT inputs"
subMenu = oilPressureSensor, "Oil Pressure Sensor Settings"
subMenu = energySystems, "Battery and Alternator Settings"
subMenu = auxPidDialog, "Aux PID"
subMenu = speedSensor, "Speed Sensor Settings"
@ -2092,6 +2101,17 @@ cmd_stop_engine = "w\x00\x99\x00\x00"
panel = iat_thermistor, North
panel = iatSensor_IO, South
dialog = oilp_settings, "Oil Pressure Sensor Settings"
field = "low voltage", oilPressure_v1
field = "low pressure", oilPressure_value1
field = "high voltage", oilPressure_v2
field = "high pressure", oilPressure_value2
dialog = oilp_IO, "Oil Pressure Sensor I/O"
field = "Oil Pressure ADC input", oilPressure_hwChannel
dialog = oilPressureSensor, "", yAxis
panel = oilp_settings, North
panel = oilp_IO, South
; Engine->MAP Sensor Settings
dialog = mapSensorVDlg, "Voltage Sensor Settings", xAxis
field = "MAP ADC input", map_sensor_hwChannel, {hasFrequencyReportingMapSensor == 0}

View File

@ -255,6 +255,7 @@ fileVersion = { 20161225 }
coilDutyCycle = scalar, F32, 272, "perc", 1, 0
accelerationX = scalar, S16, 276, "G", 0.01, 0
accelerationY = scalar, S16, 276, "G", 0.01, 0
oilPressure = scalar, F32, 280, "kPa", 1, 0.0
; todo: generate this section programatically
LM_PLAIN_MAF = {0},
@ -609,6 +610,7 @@ gaugeCategory = Sensors
MAFGauge = MAFValue, "Mass Air Flow", "v", 0, 5, 0, 1, 3, 4, 1, 1
VBattGauge = VBatt, "Battery Voltage", "V", 8, 21, 9, 10, 17, 19, 1, 1
MAPGauge = MAPValue, "MAP", "kPa", 0, 300, 10, 10, 200, 200, 0, 0
OilPressGauge = oilPressure, "Oil Pressure", "kPa", 0, 750, 35, 75, 550, 700, 0, 0
tpsADCGauge = tpsADC, "tps ADC", "ADC", 0, 1024, 0, 0, 0, 0, 0, 0
atmPresCGauge = baroPressure, "Baro", "kPa", 0, 1024, 0, 0, 0, 0, 0, 0
vvtPositionGauge = vvtPosition, "VVT position", "deg", 0, 100, 0, 0, 720, 720, 0, 0
@ -726,6 +728,7 @@ gaugeCategory = Fuel Data
entry = firmwareVersion, @@GAUGE_NAME_VERSION@@, int, "%d"
entry = coolant, "CLT", float, "%.2f"
entry = intake, "IAT", float, "%.2f"
entry = oilPressure, "Oil Press", float, "%.1f"
entry = TPSValue, "TPS", float, "%.2f"
entry = MAFValue, "MAF", float, "%.2f"
entry = MAPValue, "MAP", float, "%.1f"
@ -847,6 +850,7 @@ gaugeCategory = Fuel Data
subMenu = egoSettings, "EGO Sensor Settings"
subMenu = narrowToWideOxygenCurve, "Narrow to Wideband approximation"
subMenu = egtInputs, "EGT inputs"
subMenu = oilPressureSensor, "Oil Pressure Sensor Settings"
subMenu = energySystems, "Battery and Alternator Settings"
subMenu = auxPidDialog, "Aux PID"
subMenu = speedSensor, "Speed Sensor Settings"
@ -1319,6 +1323,17 @@ cmd_stop_engine = "w\x00\x99\x00\x00"
panel = iat_thermistor, North
panel = iatSensor_IO, South
dialog = oilp_settings, "Oil Pressure Sensor Settings"
field = "low voltage", oilPressure_v1
field = "low pressure", oilPressure_value1
field = "high voltage", oilPressure_v2
field = "high pressure", oilPressure_value2
dialog = oilp_IO, "Oil Pressure Sensor I/O"
field = "Oil Pressure ADC input", oilPressure_hwChannel
dialog = oilPressureSensor, "", yAxis
panel = oilp_settings, North
panel = oilp_IO, South
; Engine->MAP Sensor Settings
dialog = mapSensorVDlg, "Voltage Sensor Settings", xAxis
field = "MAP ADC input", map_sensor_hwChannel, {hasFrequencyReportingMapSensor == 0}

View File

@ -1,6 +1,6 @@
package com.rusefi.config;
// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Oct 29 20:03:49 EDT 2017
// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Thu Nov 09 13:37:49 EST 2017
public class Fields {
public static final int LE_COMMAND_LENGTH = 200;
public static final int BLOCKING_FACTOR = 400;
@ -1002,7 +1002,13 @@ public class Fields {
public static final int auxPid4_period_offset = 2938;
public static final int auxPid4_minValue_offset = 2940;
public static final int auxPid4_maxValue_offset = 2942;
public static final int unusedEnd_offset = 2944;
public static final int oilPressure_offset = 2944;
public static final int oilPressure_hwChannel_offset = 2944;
public static final int oilPressure_v1_offset = 2948;
public static final int oilPressure_value1_offset = 2952;
public static final int oilPressure_v2_offset = 2956;
public static final int oilPressure_value2_offset = 2960;
public static final int unusedEnd_offset = 2964;
public static final int fsioFormulas1_offset = 3048;
public static final int fsioFormulas2_offset = 3248;
public static final int fsioFormulas3_offset = 3448;
@ -1773,6 +1779,11 @@ public class Fields {
public static final Field AUXPID4_PERIOD = Field.create("AUXPID4_PERIOD", 2938, FieldType.INT);
public static final Field AUXPID4_MINVALUE = Field.create("AUXPID4_MINVALUE", 2940, FieldType.INT);
public static final Field AUXPID4_MAXVALUE = Field.create("AUXPID4_MAXVALUE", 2942, FieldType.INT);
public static final Field OILPRESSURE_HWCHANNEL = Field.create("OILPRESSURE_HWCHANNEL", 2944, FieldType.INT, adc_channel_e);
public static final Field OILPRESSURE_V1 = Field.create("OILPRESSURE_V1", 2948, FieldType.FLOAT);
public static final Field OILPRESSURE_VALUE1 = Field.create("OILPRESSURE_VALUE1", 2952, FieldType.FLOAT);
public static final Field OILPRESSURE_V2 = Field.create("OILPRESSURE_V2", 2956, FieldType.FLOAT);
public static final Field OILPRESSURE_VALUE2 = Field.create("OILPRESSURE_VALUE2", 2960, FieldType.FLOAT);
public static final Field FSIOFORMULAS1 = Field.create("FSIOFORMULAS1", 3048, FieldType.INT);
public static final Field FSIOFORMULAS2 = Field.create("FSIOFORMULAS2", 3248, FieldType.INT);
public static final Field FSIOFORMULAS3 = Field.create("FSIOFORMULAS3", 3448, FieldType.INT);

View File

@ -1,6 +1,6 @@
<roms>
<!-- Generated by ConfigDefinition utility on Sun Jun 25 00:15:02 EEST 2017 -->
<!-- Generated by ConfigDefinition utility on Thu Nov 09 13:37:49 EST 2017 -->
<rom>
<romid>