dual MAF sensors (#4697)
* add second MAF * output channesl * move them around * ok let's try at the very end * is the logic wrong, or something else? * ooh it's the sensor order
This commit is contained in:
parent
8c864fdce8
commit
f8a4d35d25
|
@ -368,5 +368,9 @@ bit injectorState12
|
|||
uint32_t outputRequestPeriod
|
||||
float mapFast
|
||||
float[LUA_GAUGE_COUNT iterate] luaGauges;;"value",1, 0, 0, 50000, 3
|
||||
uint8_t[142 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0
|
||||
|
||||
uint16_t autoscale rawMaf2;;"V",{1/@@PACK_MULT_VOLTAGE@@}, 0, 0, 5, 3
|
||||
uint16_t autoscale mafMeasured2;@@GAUGE_NAME_AIR_FLOW_MEASURED_2@@;"kg/h",{1/@@PACK_MULT_MASS_FLOW@@}, 0, 0, 0, 1
|
||||
|
||||
uint8_t[138 iterate] unusedAtTheEnd;;"",1, 0, 0, 0, 0
|
||||
end_struct
|
||||
|
|
|
@ -508,6 +508,7 @@ static void updateRawSensors() {
|
|||
engine->outputChannels.rawLowFuelPressure = Sensor::getRaw(SensorType::FuelPressureLow);
|
||||
engine->outputChannels.rawHighFuelPressure = Sensor::getRaw(SensorType::FuelPressureHigh);
|
||||
engine->outputChannels.rawMaf = Sensor::getRaw(SensorType::Maf);
|
||||
engine->outputChannels.rawMaf2 = Sensor::getRaw(SensorType::Maf2);
|
||||
engine->outputChannels.rawMap = Sensor::getRaw(SensorType::MapSlow);
|
||||
engine->outputChannels.rawWastegatePosition = Sensor::getRaw(SensorType::WastegatePosition);
|
||||
engine->outputChannels.rawIdlePositionSensor = Sensor::getRaw(SensorType::IdlePosition);
|
||||
|
@ -687,6 +688,7 @@ void updateTunerStudioState() {
|
|||
|
||||
// Output both the estimated air flow, and measured air flow (if available)
|
||||
tsOutputChannels->mafMeasured = Sensor::getOrZero(SensorType::Maf);
|
||||
tsOutputChannels->mafMeasured2 = Sensor::getOrZero(SensorType::Maf2);
|
||||
tsOutputChannels->mafEstimate = engine->engineState.airflowEstimate;
|
||||
|
||||
// offset 116
|
||||
|
|
|
@ -7,8 +7,33 @@
|
|||
#include "maf.h"
|
||||
#include "fuel_math.h"
|
||||
|
||||
float MafAirmass::getMaf() const {
|
||||
auto maf = Sensor::get(SensorType::Maf);
|
||||
|
||||
if (Sensor::hasSensor(SensorType::Maf2)) {
|
||||
auto maf2 = Sensor::get(SensorType::Maf2);
|
||||
|
||||
if (maf && maf2) {
|
||||
// Both MAFs work, return the sum
|
||||
return maf.Value + maf2.Value;
|
||||
} else if (maf) {
|
||||
// MAF 1 works, but not MAF 2, so double the value from #1
|
||||
return 2 * maf.Value;
|
||||
} else if (maf2) {
|
||||
// MAF 2 works, but not MAF 1, so double the value from #2
|
||||
return 2 * maf2.Value;
|
||||
} else {
|
||||
// Both MAFs are broken, give up.
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return maf.value_or(0);
|
||||
}
|
||||
}
|
||||
|
||||
AirmassResult MafAirmass::getAirmass(int rpm) {
|
||||
float maf = Sensor::getOrZero(SensorType::Maf);
|
||||
float maf = getMaf();
|
||||
|
||||
return getAirmassImpl(maf, rpm);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,4 +10,7 @@ public:
|
|||
|
||||
// Compute airmass based on flow & engine speed
|
||||
AirmassResult getAirmassImpl(float massAirFlow, int rpm) const;
|
||||
|
||||
private:
|
||||
float getMaf() const;
|
||||
};
|
||||
|
|
|
@ -84,6 +84,8 @@ enum class SensorType : unsigned char {
|
|||
EGT1,
|
||||
EGT2,
|
||||
|
||||
Maf2, // Second bank MAF sensor
|
||||
|
||||
// analog voltage inputs for Lua
|
||||
AuxAnalog1,
|
||||
AuxAnalog2,
|
||||
|
|
|
@ -5,7 +5,8 @@
|
|||
#include "functional_sensor.h"
|
||||
#include "table_func.h"
|
||||
|
||||
static FunctionalSensor maf(SensorType::Maf, /* timeout = */ MS2NT(50));
|
||||
static FunctionalSensor maf (SensorType::Maf , /* timeout = */ MS2NT(50));
|
||||
static FunctionalSensor maf2(SensorType::Maf2, /* timeout = */ MS2NT(50));
|
||||
|
||||
#if !EFI_UNIT_TEST
|
||||
// extract the type of the elements in the bin/value arrays
|
||||
|
@ -15,16 +16,19 @@ using ValueType = std::remove_extent_t<decltype(config->mafDecoding)>;
|
|||
// This function converts volts -> kg/h
|
||||
static TableFunc mafCurve(config->mafDecodingBins, config->mafDecoding);
|
||||
|
||||
void initMaf() {
|
||||
adc_channel_e channel = engineConfiguration->mafAdcChannel;
|
||||
|
||||
static void initMaf(adc_channel_e channel, FunctionalSensor& m) {
|
||||
if (!isAdcChannelValid(channel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
maf.setFunction(mafCurve);
|
||||
m.setFunction(mafCurve);
|
||||
|
||||
AdcSubscription::SubscribeSensor(maf, channel, /*lowpassCutoff =*/ 50);
|
||||
maf.Register();
|
||||
AdcSubscription::SubscribeSensor(m, channel, /*lowpassCutoff =*/ 50);
|
||||
m.Register();
|
||||
}
|
||||
|
||||
void initMaf() {
|
||||
initMaf(engineConfiguration->mafAdcChannel, maf);
|
||||
initMaf(engineConfiguration->maf2AdcChannel, maf2);
|
||||
}
|
||||
#endif // ! EFI_UNIT_TEST
|
||||
|
|
|
@ -599,7 +599,7 @@ custom spi_device_e 1 bits, U08, @OFFSET@, [0:2], "Off", "SPI1", "SPI2", "SPI3",
|
|||
spi_device_e hip9011SpiDevice;
|
||||
uint8_t failedMapFallback;Single value to be used in event of a failed MAP sensor \nThis value is only used for speed density fueling calculations.;"kPa", 1, 0, 0, 100, 0
|
||||
uint8_t boostControlSafeDutyCycle;Duty cycle to use in case of a sensor failure. This duty cycle should produce the minimum possible amount of boost. This duty is also used in case any of the minimum RPM/TPS/MAP conditions are not met.;"%", 1, 0, 0, 100, 0
|
||||
adc_channel_e mafAdcChannel
|
||||
adc_channel_e mafAdcChannel
|
||||
|
||||
float globalFuelCorrection;set global_fuel_correction X;"coef", 1, 0, 0, 1000, 2
|
||||
|
||||
|
@ -746,7 +746,7 @@ pin_input_mode_e throttlePedalUpPinMode;
|
|||
uint16_t autoscale fordInjectorSmallPulseSlope;;"g/s", 0.001, 0, 0, 65, 3
|
||||
|
||||
pin_output_mode_e[TRIGGER_SIMULATOR_PIN_COUNT iterate] triggerSimulatorPinModes;
|
||||
uint8_t unusedTrigMode
|
||||
adc_channel_e maf2AdcChannel
|
||||
output_pin_e o2heaterPin;Narrow band o2 heater, not used for CJ125. 'ON' if engine is running, 'OFF' if stopped or cranking. See wboHeaterPin
|
||||
pin_output_mode_e o2heaterPinModeTodO;
|
||||
|
||||
|
@ -1851,6 +1851,7 @@ end_struct
|
|||
#define INDICATOR_NAME_AC_SWITCH "AC switch"
|
||||
|
||||
#define GAUGE_NAME_AIR_FLOW_MEASURED "MAF sensor"
|
||||
#define GAUGE_NAME_AIR_FLOW_MEASURED_2 "MAF sensor 2"
|
||||
#define GAUGE_NAME_AIR_FLOW_ESTIMATE "MAF estimate"
|
||||
#define GAUGE_NAME_AIR_MASS "air mass"
|
||||
|
||||
|
|
|
@ -2596,6 +2596,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
|
|||
field = "TPS1 ADC input", tps1_1AdcChannel
|
||||
field = "TPS2 ADC input", tps2_1AdcChannel
|
||||
field = "MAF ADC input", mafAdcChannel
|
||||
field = "MAF 2 ADC input", maf2AdcChannel
|
||||
field = "AFR ADC input", afr_hwChannel
|
||||
field = "Baro ADC input", baroSensor_hwChannel
|
||||
field = "MAP ADC input", map_sensor_hwChannel
|
||||
|
@ -2932,6 +2933,7 @@ cmd_set_engine_type_default = "@@TS_IO_TEST_COMMAND_char@@@@ts_command_e_TS_
|
|||
|
||||
dialog = mafSettings, "MAF sensor", yAxis
|
||||
field = "MAF ADC input", mafAdcChannel
|
||||
field = "MAF 2 ADC input", maf2AdcChannel
|
||||
|
||||
; Sensors->EGO sensor
|
||||
dialog = egoSettings_sensor, "EGO sensor"
|
||||
|
|
Loading…
Reference in New Issue