rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
init_fluid_pressure.cpp
Go to the documentation of this file.
1#include "pch.h"
2
3#include "init.h"
4#include "sent.h"
5#include "adc_subscription.h"
6#include "functional_sensor.h"
7#include "proxy_sensor.h"
8#include "linear_func.h"
9
11static FunctionalSensor oilpSensor(SensorType::OilPressure, /* timeout = */ MS2NT(50));
12
15
18
20
22static FunctionalSensor acPressureSensor(SensorType::AcPressure, /* timeout = */ MS2NT(50));
23
25static FunctionalSensor auxLinear1Sensor(SensorType::AuxLinear1, /* timeout = */ MS2NT(50));
26
28static FunctionalSensor auxLinear2Sensor(SensorType::AuxLinear2, /* timeout = */ MS2NT(50));
29
31static FunctionalSensor auxLinear3Sensor(SensorType::AuxLinear3, /* timeout = */ MS2NT(50));
32
34static FunctionalSensor auxLinear4Sensor(SensorType::AuxLinear4, /* timeout = */ MS2NT(50));
35
36/**
37 * @param bandwidth Hertz, used by low pass filter in to analog subscribers
38 */
39static void initFluidPressure(LinearFunc& func, FunctionalSensor& sensor, const linear_sensor_s& cfg, float bandwidth) {
40 auto channel = cfg.hwChannel;
41
42 // Only register if we have a sensor
44 return;
45 }
46
47 float val1 = cfg.value1;
48 float val2 = cfg.value2;
49
50 // Limit to max given pressure - val1 or val2 could be larger
51 // (sensor may be backwards, high voltage = low pressure)
52 float greaterOutput = val1 > val2 ? val1 : val2;
53
54 // Allow slightly negative output (-5kpa) so as to not fail the sensor when engine is off
55 func.configure(cfg.v1, val1, cfg.v2, val2, /*minOutput*/ -5, greaterOutput);
56
57 sensor.setFunction(func);
58
60
62}
63
64#if EFI_SENT_SUPPORT
65static void initSentLinearSensor(LinearFunc& func, FunctionalSensor& sensor, int in1, float out1, int in2, float out2, float min, float max)
66{
67 func.configure(in1, out1, in2, out2, min, max);
68
69 sensor.setFunction(func);
70
72}
73#endif
74
78
79#if EFI_SENT_SUPPORT
83 /* This sensor sends two pressure signals:
84 * Sig0 occupies 3 first nibbles
85 * Sig1 occupies next 3 nibbles
86 * Signals are close, but not identical.
87 * Sig0 shows about 197..198 at 1 Atm (open air) and 282 at 1000 KPa (10 Bar)
88 * Sig1 shows abour 202..203 at 1 Atm (open air) and 283 at 1000 KPa (10 Bar)
89 */
91 200, BAR2KPA(1),
92 283, BAR2KPA(10),
93 BAR2KPA(0), BAR2KPA(1000) /* What is limit of this sensor? */);
94 }
95 } else
96#endif
97 {
99 }
105
110 );
111
113}
114
124
125#if EFI_PROD_CODE
126#if EFI_SENT_SUPPORT
127/* init_ file is not correct place for following code, but pressure sensor is defined here and static */
128/* TODO: move? */
129
132 return;
133 }
134
136 uint16_t sig0, sig1;
137 int ret = getSentValues(sentCh, &sig0, &sig1);
138
139 if (ret) {
140 return;
141 }
142
143 /* This sensor sends two pressure signals - average */
144 fuelPressureSensorHigh.postRawValue(((float)sig0 + (float)sig1) / 2, getTimeNowNt());
145 }
146}
147
148#endif /* EFI_SENT_SUPPORT */
149#endif /* EFI_PROD_CODE */
bool isAdcChannelValid(adc_channel_e hwChannel)
Definition adc_inputs.h:23
uint16_t channel
Definition adc_inputs.h:104
static AdcSubscriptionEntry * SubscribeSensor(FunctionalSensorBase &sensor, adc_channel_e channel, float lowpassCutoffHZ, float voltsPerAdcVolt=0.0f)
static void UnsubscribeSensor(FunctionalSensorBase &sensor)
Class for sensors that convert from some raw floating point value (ex: voltage, frequency,...
void postRawValue(float inputValue, efitick_t timestamp) override
void configure(float in1, float out1, float in2, float out2, float minOutput, float maxOutput)
void setProxiedSensor(SensorType proxiedSensor)
bool Register()
Definition sensor.cpp:131
efitick_t getTimeNowNt()
Definition efitime.cpp:19
static constexpr engine_configuration_s * engineConfiguration
static Lps25Sensor sensor(device)
static FunctionalSensor auxLinear1Sensor(SensorType::AuxLinear1, MS2NT(50))
static LinearFunc auxLinear2Func
static LinearFunc acPressureFunc
void initFluidPressure()
static ProxySensor injectorPressure(SensorType::FuelPressureInjector)
static void initSentLinearSensor(LinearFunc &func, FunctionalSensor &sensor, int in1, float out1, int in2, float out2, float min, float max)
static LinearFunc auxLinear1Func
static FunctionalSensor oilpSensor(SensorType::OilPressure, MS2NT(50))
static FunctionalSensor acPressureSensor(SensorType::AcPressure, MS2NT(50))
static LinearFunc fuelPressureFuncLow
static FunctionalSensor auxLinear3Sensor(SensorType::AuxLinear3, MS2NT(50))
static LinearFunc auxLinear3Func
static FunctionalSensor auxLinear4Sensor(SensorType::AuxLinear4, MS2NT(50))
static FunctionalSensor fuelPressureSensorLow(SensorType::FuelPressureLow, MS2NT(50))
void sentPressureDecode(SentInput sentCh)
void deinitFluidPressure()
static LinearFunc oilpSensorFunc
static FunctionalSensor auxLinear2Sensor(SensorType::AuxLinear2, MS2NT(50))
static FunctionalSensor fuelPressureSensorHigh(SensorType::FuelPressureHigh, MS2NT(50))
static LinearFunc auxLinear4Func
static LinearFunc fuelPressureFuncHigh
A sensor to duplicate a sensor to an additional SensorType.
SentInput
@ FuelPressureInjector
int getSentValues(SentInput input, uint16_t *sig0, uint16_t *sig1)
Definition sent.cpp:153