Skip to content

Commit

Permalink
additional aux linear sensors #476
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Aug 30, 2024
1 parent 03ac7f1 commit a269b9a
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 1 deletion.
2 changes: 2 additions & 0 deletions firmware/console/binary/output_channels.txt
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ int16_t rpmAcceleration;dRPM;"RPM acceleration",1, 0, 0, 5, 2

float auxLinear1;@@GAUGE_NAME_AUX_LINEAR_1@@;"", 1, 0, 0, 0, 2
float auxLinear2;@@GAUGE_NAME_AUX_LINEAR_2@@;"", 1, 0, 0, 0, 2
float auxLinear3;@@GAUGE_NAME_AUX_LINEAR_3@@;"", 1, 0, 0, 0, 2
float auxLinear4;@@GAUGE_NAME_AUX_LINEAR_4@@;"", 1, 0, 0, 0, 2


uint16_t autoscale fallbackMap;;"kPa", 0.1, 0, 0, 1000, 1
Expand Down
2 changes: 2 additions & 0 deletions firmware/console/status_loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ static void updatePressures() {

engine->outputChannels.auxLinear1 = Sensor::getOrZero(SensorType::AuxLinear1);
engine->outputChannels.auxLinear2 = Sensor::getOrZero(SensorType::AuxLinear2);
engine->outputChannels.auxLinear3 = Sensor::getOrZero(SensorType::AuxLinear3);
engine->outputChannels.auxLinear4 = Sensor::getOrZero(SensorType::AuxLinear4);
}

static void updateMiscSensors() {
Expand Down
4 changes: 4 additions & 0 deletions firmware/controllers/actuators/gppwm/gppwm_channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ expected<float> readGppwmChannel(gppwm_channel_e channel) {
return Sensor::get(SensorType::AuxLinear1);
case GPPWM_AuxLinear2:
return Sensor::get(SensorType::AuxLinear2);
case GPPWM_AuxLinear3:
return Sensor::get(SensorType::AuxLinear3);
case GPPWM_AuxLinear4:
return Sensor::get(SensorType::AuxLinear4);
case GPPWM_GppwmOutput1:
return (float)engine->outputChannels.gppwmOutput[0];
case GPPWM_GppwmOutput2:
Expand Down
2 changes: 2 additions & 0 deletions firmware/controllers/algo/rusefi_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,8 @@ typedef enum __attribute__ ((__packed__)) {
GPPWM_BaroPressure = 26,
GPPWM_Egt1 = 27,
GPPWM_Egt2 = 28,
GPPWM_AuxLinear3 = 29,
GPPWM_AuxLinear4 = 30,
} gppwm_channel_e;

typedef enum __attribute__ ((__packed__)) {
Expand Down
2 changes: 2 additions & 0 deletions firmware/controllers/sensors/sensor_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ enum class SensorType : unsigned char {

AuxLinear1,
AuxLinear2,
AuxLinear3,
AuxLinear4,

// frequency sensors
AuxSpeed1,
Expand Down
10 changes: 10 additions & 0 deletions firmware/init/sensor/init_fluid_pressure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ static FunctionalSensor auxLinear1Sensor(SensorType::AuxLinear1, /* timeout = */
static LinearFunc auxLinear2Func;
static FunctionalSensor auxLinear2Sensor(SensorType::AuxLinear2, /* timeout = */ MS2NT(50));

static LinearFunc auxLinear3Func;
static FunctionalSensor auxLinear3Sensor(SensorType::AuxLinear3, /* timeout = */ MS2NT(50));

static LinearFunc auxLinear4Func;
static FunctionalSensor auxLinear4Sensor(SensorType::AuxLinear4, /* timeout = */ MS2NT(50));

/**
* @param bandwidth Hertz, used by low pass filter in to analog subscribers
*/
Expand Down Expand Up @@ -57,6 +63,8 @@ void initFluidPressure() {
initFluidPressure(fuelPressureFuncHigh, fuelPressureSensorHigh, engineConfiguration->highPressureFuel, 100);
initFluidPressure(auxLinear1Func, auxLinear1Sensor, engineConfiguration->auxLinear1, 10);
initFluidPressure(auxLinear2Func, auxLinear2Sensor, engineConfiguration->auxLinear2, 10);
initFluidPressure(auxLinear3Func, auxLinear3Sensor, engineConfiguration->auxLinear3, 10);
initFluidPressure(auxLinear4Func, auxLinear4Sensor, engineConfiguration->auxLinear4, 10);

injectorPressure.setProxiedSensor(
engineConfiguration->injectorPressureType == IPT_High
Expand All @@ -73,4 +81,6 @@ void deinitFluidPressure() {
AdcSubscription::UnsubscribeSensor(fuelPressureSensorHigh, engineConfiguration->highPressureFuel.hwChannel);
AdcSubscription::UnsubscribeSensor(auxLinear1Sensor, engineConfiguration->auxLinear1.hwChannel);
AdcSubscription::UnsubscribeSensor(auxLinear2Sensor, engineConfiguration->auxLinear2.hwChannel);
AdcSubscription::UnsubscribeSensor(auxLinear3Sensor, engineConfiguration->auxLinear3.hwChannel);
AdcSubscription::UnsubscribeSensor(auxLinear4Sensor, engineConfiguration->auxLinear4.hwChannel);
}
4 changes: 3 additions & 1 deletion firmware/integration/rusefi_config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ custom pin_output_mode_e 1 bits, U08, @OFFSET@, [0:1], @@pin_output_mode_e_enum@
#define pin_input_mode_e_enum "DEFAULT", "PULLUP", "PULLDOWN"
custom pin_input_mode_e 1 bits, U08, @OFFSET@, [0:1], @@pin_input_mode_e_enum@@

#define gppwm_channel_e_enum "Zero", "TPS", "MAP", "CLT", "IAT", "Fuel Load", "Ignition Load", "Aux Temp 1", "Aux Temp 2", "Accel Pedal", "Battery Voltage", "VVT 1 I", "VVT 1 E", "VVT 2 I", "VVT 2 E", "Ethanol (Flex) %", "Aux Linear 1", "Aux Linear 2", "GPPWM Output 1", "GPPWM Output 2", "GPPWM Output 3", "GPPWM Output 4", "Lua Gauge 1", "Lua Gauge 2", "RPM", "Gear (detected)", "Baro pressure", "EGT 1", "EGT 2"
#define gppwm_channel_e_enum "Zero", "TPS", "MAP", "CLT", "IAT", "Fuel Load", "Ignition Load", "Aux Temp 1", "Aux Temp 2", "Accel Pedal", "Battery Voltage", "VVT 1 I", "VVT 1 E", "VVT 2 I", "VVT 2 E", "Ethanol (Flex) %", "Aux Linear 1", "Aux Linear 2", "GPPWM Output 1", "GPPWM Output 2", "GPPWM Output 3", "GPPWM Output 4", "Lua Gauge 1", "Lua Gauge 2", "RPM", "Gear (detected)", "Baro pressure", "EGT 1", "EGT 2", "Aux Linear 3", "Aux Linear 4"
custom gppwm_channel_e 1 bits, U08, @OFFSET@, [0:4], @@gppwm_channel_e_enum@@

struct gppwm_channel
Expand Down Expand Up @@ -1364,6 +1364,8 @@ uint16_t vvtActivationDelayMs;We need to give engine time to build oil pressure

linear_sensor_s auxLinear1
linear_sensor_s auxLinear2
linear_sensor_s auxLinear3
linear_sensor_s auxLinear4

output_pin_e tcu_tcc_onoff_solenoid
pin_output_mode_e tcu_tcc_onoff_solenoid_mode
Expand Down
2 changes: 2 additions & 0 deletions firmware/integration/rusefi_config_shared.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@

#define GAUGE_NAME_AUX_LINEAR_1 "Aux linear #1"
#define GAUGE_NAME_AUX_LINEAR_2 "Aux linear #2"
#define GAUGE_NAME_AUX_LINEAR_3 "Aux linear #3"
#define GAUGE_NAME_AUX_LINEAR_4 "Aux linear #4"

#define GAUGE_NAME_BOOST_OUTPUT "Boost: Output"
#define GAUGE_NAME_BOOST_CLOSED_LOOP "Boost: Closed loop"
Expand Down
18 changes: 18 additions & 0 deletions firmware/tunerstudio/tunerstudio.template.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,8 @@ gaugeCategory = Sensors - Extra 1
fuelTankLevelGauge = fuelTankLevel,"Fuel level", "%", 0, 100, 10, 20, 100, 100, 1, 1
AuxL1Gauge = auxLinear1, @@GAUGE_NAME_AUX_LINEAR_1@@, "", -100, 100, -100, -100, 100, 100, 2, 2
AuxL2Gauge = auxLinear2, @@GAUGE_NAME_AUX_LINEAR_2@@, "", -100, 100, -100, -100, 100, 100, 2, 2
AuxL3Gauge = auxLinear3, @@GAUGE_NAME_AUX_LINEAR_3@@, "", -100, 100, -100, -100, 100, 100, 2, 2
AuxL4Gauge = auxLinear4, @@GAUGE_NAME_AUX_LINEAR_4@@, "", -100, 100, -100, -100, 100, 100, 2, 2

gaugeCategory = Sensors - Extra 2
accelerationLatGauge = accelerationLat, @@GAUGE_NAME_ACCEL_LAT@@, "acc", -2, 2, -2, -1, 1, 2, 3, 1
Expand Down Expand Up @@ -3140,9 +3142,25 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
field = "High voltage", auxLinear2_v2, {auxLinear2_hwChannel != @@ADC_CHANNEL_NONE@@}
field = "High value", auxLinear2_value2, {auxLinear2_hwChannel != @@ADC_CHANNEL_NONE@@}

dialog = auxLinearSensor3, "Aux Linear Sensor #3"
field = "ADC input", auxLinear3_hwChannel
field = "Low voltage", auxLinear3_v1, {auxLinear3_hwChannel != @@ADC_CHANNEL_NONE@@}
field = "Low value", auxLinear3_value1, {auxLinear3_hwChannel != @@ADC_CHANNEL_NONE@@}
field = "High voltage", auxLinear3_v2, {auxLinear3_hwChannel != @@ADC_CHANNEL_NONE@@}
field = "High value", auxLinear3_value2, {auxLinear3_hwChannel != @@ADC_CHANNEL_NONE@@}

dialog = auxLinearSensor4, "Aux Linear Sensor #4"
field = "ADC input", auxLinear4_hwChannel
field = "Low voltage", auxLinear4_v1, {auxLinear4_hwChannel != @@ADC_CHANNEL_NONE@@}
field = "Low value", auxLinear4_value1, {auxLinear4_hwChannel != @@ADC_CHANNEL_NONE@@}
field = "High voltage", auxLinear4_v2, {auxLinear4_hwChannel != @@ADC_CHANNEL_NONE@@}
field = "High value", auxLinear4_value2, {auxLinear4_hwChannel != @@ADC_CHANNEL_NONE@@}

dialog = auxLinearSensors
panel = auxLinearSensor1
panel = auxLinearSensor2
panel = auxLinearSensor3
panel = auxLinearSensor4
field = auxSpeedSensorInputPin1, auxSpeedSensorInputPin1
field = auxSpeedSensorInputPin2, auxSpeedSensorInputPin2

Expand Down

0 comments on commit a269b9a

Please sign in to comment.