mirror of https://github.com/rusefi/rusefi-1.git
switch more map to read from sensor model (#2162)
* hook up map * check for init * switch some consumers * that's the rest of them * test * tests Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
parent
c06fea083e
commit
92ea09b0a6
|
@ -638,7 +638,7 @@ void updateTunerStudioState(TunerStudioOutputChannels *tsOutputChannels DECLARE_
|
||||||
tsOutputChannels->tpsAccelFuel = engine->engineState.tpsAccelEnrich;
|
tsOutputChannels->tpsAccelFuel = engine->engineState.tpsAccelEnrich;
|
||||||
// engine load acceleration
|
// engine load acceleration
|
||||||
if (hasMapSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
if (hasMapSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||||
tsOutputChannels->engineLoadAccelExtra = engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_SIGNATURE) * 100 / getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
|
tsOutputChannels->engineLoadAccelExtra = engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_SIGNATURE) * 100 / Sensor::get(SensorType::Map).value_or(0);
|
||||||
}
|
}
|
||||||
tsOutputChannels->engineLoadDelta = engine->engineLoadAccelEnrichment.getMaxDelta();
|
tsOutputChannels->engineLoadDelta = engine->engineLoadAccelEnrichment.getMaxDelta();
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "speed_density_airmass.h"
|
#include "speed_density_airmass.h"
|
||||||
#include "map.h"
|
|
||||||
#include "perf_trace.h"
|
#include "perf_trace.h"
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
@ -18,15 +17,15 @@ AirmassResult SpeedDensityAirmass::getAirmass(int rpm) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
float map = getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
|
auto map = Sensor::get(SensorType::Map);
|
||||||
if (cisnan(map)) {
|
if (!map) {
|
||||||
warning(CUSTOM_ERR_TCHARGE_NOT_READY2, "map not ready"); // this could happen during HW CI during configuration reset
|
warning(CUSTOM_ERR_TCHARGE_NOT_READY2, "map not ready"); // this could happen during HW CI during configuration reset
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
engine->engineState.sd.manifoldAirPressureAccelerationAdjustment = engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_SIGNATURE);
|
engine->engineState.sd.manifoldAirPressureAccelerationAdjustment = engine->engineLoadAccelEnrichment.getEngineLoadEnrichment(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
float adjustedMap = engine->engineState.sd.adjustedManifoldAirPressure = map + engine->engineState.sd.manifoldAirPressureAccelerationAdjustment;
|
float adjustedMap = engine->engineState.sd.adjustedManifoldAirPressure = map.Value + engine->engineState.sd.manifoldAirPressureAccelerationAdjustment;
|
||||||
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(adjustedMap), "NaN adjustedMap", {});
|
efiAssert(CUSTOM_ERR_ASSERT, !cisnan(adjustedMap), "NaN adjustedMap", {});
|
||||||
|
|
||||||
float ve = getVe(rpm, adjustedMap);
|
float ve = getVe(rpm, adjustedMap);
|
||||||
|
@ -43,6 +42,6 @@ AirmassResult SpeedDensityAirmass::getAirmass(int rpm) {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
airMass,
|
airMass,
|
||||||
map, // AFR/VE table Y axis
|
map.Value, // AFR/VE table Y axis
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,8 @@ float FuelComputer::getTargetLambdaLoadAxis(float defaultLoad) const {
|
||||||
float getLoadOverride(float defaultLoad, afr_override_e overrideMode DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
float getLoadOverride(float defaultLoad, afr_override_e overrideMode DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
switch(overrideMode) {
|
switch(overrideMode) {
|
||||||
case AFR_None: return defaultLoad;
|
case AFR_None: return defaultLoad;
|
||||||
case AFR_MAP: return getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
|
// MAP default to 200kpa - failed MAP goes rich
|
||||||
|
case AFR_MAP: return Sensor::get(SensorType::Map).value_or(200);
|
||||||
// TPS/pedal default to 100% - failed TPS goes rich
|
// TPS/pedal default to 100% - failed TPS goes rich
|
||||||
case AFR_Tps: return Sensor::get(SensorType::Tps1).value_or(100);
|
case AFR_Tps: return Sensor::get(SensorType::Tps1).value_or(100);
|
||||||
case AFR_AccPedal: return Sensor::get(SensorType::AcceleratorPedal).value_or(100);
|
case AFR_AccPedal: return Sensor::get(SensorType::AcceleratorPedal).value_or(100);
|
||||||
|
|
|
@ -43,10 +43,15 @@ float InjectorModel::getInjectorFlowRatio() const {
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float map = getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
|
auto map = Sensor::get(SensorType::Map);
|
||||||
|
|
||||||
|
// Map has failed, assume nominal pressure
|
||||||
|
if (!map) {
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: what to do when pressureDelta is less than 0?
|
// TODO: what to do when pressureDelta is less than 0?
|
||||||
float pressureDelta = absRailPressure.Value - map;
|
float pressureDelta = absRailPressure.Value - map.Value;
|
||||||
float pressureRatio = pressureDelta / referencePressure;
|
float pressureRatio = pressureDelta / referencePressure;
|
||||||
float flowRatio = sqrtf(pressureRatio);
|
float flowRatio = sqrtf(pressureRatio);
|
||||||
|
|
||||||
|
|
|
@ -406,8 +406,11 @@ float getFuelCutOffCorrection(efitick_t nowNt, int rpm DECLARE_ENGINE_PARAMETER_
|
||||||
return 1.0f;
|
return 1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float map = getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
|
const auto [mapValid, map] = Sensor::get(SensorType::Map);
|
||||||
|
if (!mapValid) {
|
||||||
|
return 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
// gather events
|
// gather events
|
||||||
bool mapDeactivate = (map >= CONFIG(coastingFuelCutMap));
|
bool mapDeactivate = (map >= CONFIG(coastingFuelCutMap));
|
||||||
bool tpsDeactivate = (tpsPos >= CONFIG(coastingFuelCutTps));
|
bool tpsDeactivate = (tpsPos >= CONFIG(coastingFuelCutTps));
|
||||||
|
|
|
@ -133,7 +133,7 @@ static void handleGetDataRequest(const CANRxFrame& rx) {
|
||||||
obdSendValue(_1_MODE, pid, 1, 128 * ENGINE(engineState.running.pidCorrection));
|
obdSendValue(_1_MODE, pid, 1, 128 * ENGINE(engineState.running.pidCorrection));
|
||||||
break;
|
break;
|
||||||
case PID_INTAKE_MAP:
|
case PID_INTAKE_MAP:
|
||||||
obdSendValue(_1_MODE, pid, 1, getMap(PASS_ENGINE_PARAMETER_SIGNATURE));
|
obdSendValue(_1_MODE, pid, 1, Sensor::get(SensorType::Map).value_or(0));
|
||||||
break;
|
break;
|
||||||
case PID_RPM:
|
case PID_RPM:
|
||||||
obdSendValue(_1_MODE, pid, 2, GET_RPM() * ODB_RPM_MULT); // rotation/min. (A*256+B)/4
|
obdSendValue(_1_MODE, pid, 2, GET_RPM() * ODB_RPM_MULT); // rotation/min. (A*256+B)/4
|
||||||
|
|
|
@ -134,7 +134,7 @@ FsioResult getEngineValue(le_action_e action DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
||||||
case LE_METHOD_MAF:
|
case LE_METHOD_MAF:
|
||||||
return getRealMaf(PASS_ENGINE_PARAMETER_SIGNATURE);
|
return getRealMaf(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
case LE_METHOD_MAP:
|
case LE_METHOD_MAP:
|
||||||
return getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
|
return Sensor::get(SensorType::Map).value_or(0);
|
||||||
#if EFI_SHAFT_POSITION_INPUT
|
#if EFI_SHAFT_POSITION_INPUT
|
||||||
case LE_METHOD_INTAKE_VVT:
|
case LE_METHOD_INTAKE_VVT:
|
||||||
case LE_METHOD_EXHAUST_VVT:
|
case LE_METHOD_EXHAUST_VVT:
|
||||||
|
|
|
@ -228,7 +228,7 @@ static void showLine(lcd_line_e line, int /*screenY*/) {
|
||||||
return;
|
return;
|
||||||
case LL_MAP:
|
case LL_MAP:
|
||||||
if (hasMapSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
if (hasMapSensor(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||||
lcdPrintf("MAP %.2f", getMap(PASS_ENGINE_PARAMETER_SIGNATURE));
|
lcdPrintf("MAP %.2f", Sensor::get(SensorType::Map).value_or(0));
|
||||||
} else {
|
} else {
|
||||||
lcdPrintf("MAP: none");
|
lcdPrintf("MAP: none");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "limp_manager.h"
|
#include "limp_manager.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "map.h"
|
|
||||||
#include "efilib.h"
|
#include "efilib.h"
|
||||||
|
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
@ -20,7 +19,7 @@ void LimpManager::updateState(int rpm) {
|
||||||
|
|
||||||
// Limit fuel only on boost pressure (limiting spark bends valves)
|
// Limit fuel only on boost pressure (limiting spark bends valves)
|
||||||
if (CONFIG(boostCutPressure) != 0) {
|
if (CONFIG(boostCutPressure) != 0) {
|
||||||
if (getMap(PASS_ENGINE_PARAMETER_SIGNATURE) > CONFIG(boostCutPressure)) {
|
if (Sensor::get(SensorType::Map).value_or(0) > CONFIG(boostCutPressure)) {
|
||||||
limitFuel = true;
|
limitFuel = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ float getEngineLoadT(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
efiAssert(CUSTOM_ERR_ASSERT, engineConfiguration!=NULL, "engineConfiguration 2NULL", NAN);
|
efiAssert(CUSTOM_ERR_ASSERT, engineConfiguration!=NULL, "engineConfiguration 2NULL", NAN);
|
||||||
switch (engineConfiguration->fuelAlgorithm) {
|
switch (engineConfiguration->fuelAlgorithm) {
|
||||||
case LM_SPEED_DENSITY:
|
case LM_SPEED_DENSITY:
|
||||||
return getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
|
return Sensor::get(SensorType::Map).value_or(0);
|
||||||
case LM_ALPHA_N:
|
case LM_ALPHA_N:
|
||||||
return Sensor::get(SensorType::Tps1).value_or(0);
|
return Sensor::get(SensorType::Tps1).value_or(0);
|
||||||
case LM_REAL_MAF:
|
case LM_REAL_MAF:
|
||||||
|
|
|
@ -31,6 +31,8 @@ TEST(fuelCut, coasting) {
|
||||||
// basic engine setup
|
// basic engine setup
|
||||||
setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð);
|
setupSimpleTestEngineWithMafAndTT_ONE_trigger(ð);
|
||||||
|
|
||||||
|
Sensor::setMockValue(SensorType::Map, 0);
|
||||||
|
|
||||||
// mock CLT - just above threshold ('hot engine')
|
// mock CLT - just above threshold ('hot engine')
|
||||||
float hotClt = engineConfiguration->coastingFuelCutClt + 1;
|
float hotClt = engineConfiguration->coastingFuelCutClt + 1;
|
||||||
Sensor::setMockValue(SensorType::Clt, hotClt);
|
Sensor::setMockValue(SensorType::Clt, hotClt);
|
||||||
|
|
|
@ -109,7 +109,7 @@ TEST_P(FlowRateFixture, PressureRatio) {
|
||||||
engineConfiguration->fuelReferencePressure = 400.0f;
|
engineConfiguration->fuelReferencePressure = 400.0f;
|
||||||
|
|
||||||
// MAP sensor always reads 35 kpa
|
// MAP sensor always reads 35 kpa
|
||||||
engine->mockMapValue = fakeMap;
|
Sensor::setMockValue(SensorType::Map, fakeMap);
|
||||||
|
|
||||||
// Should return the expected ratio
|
// Should return the expected ratio
|
||||||
EXPECT_FLOAT_EQ(expectedFlowRatio, dut.getInjectorFlowRatio());
|
EXPECT_FLOAT_EQ(expectedFlowRatio, dut.getInjectorFlowRatio());
|
||||||
|
|
|
@ -54,23 +54,23 @@ TEST(limp, boostCut) {
|
||||||
INJECT_ENGINE_REFERENCE(&dut);
|
INJECT_ENGINE_REFERENCE(&dut);
|
||||||
|
|
||||||
// Below threshold, injection allowed
|
// Below threshold, injection allowed
|
||||||
engine->mockMapValue = 80;
|
Sensor::setMockValue(SensorType::Map, 80);
|
||||||
dut.updateState(1000);
|
dut.updateState(1000);
|
||||||
EXPECT_TRUE(dut.allowInjection());
|
EXPECT_TRUE(dut.allowInjection());
|
||||||
|
|
||||||
// Above threshold, injection cut
|
// Above threshold, injection cut
|
||||||
engine->mockMapValue = 120;
|
Sensor::setMockValue(SensorType::Map, 120);
|
||||||
dut.updateState(1000);
|
dut.updateState(1000);
|
||||||
EXPECT_FALSE(dut.allowInjection());
|
EXPECT_FALSE(dut.allowInjection());
|
||||||
|
|
||||||
// Below threshold, should recover
|
// Below threshold, should recover
|
||||||
engine->mockMapValue = 80;
|
Sensor::setMockValue(SensorType::Map, 80);
|
||||||
dut.updateState(1000);
|
dut.updateState(1000);
|
||||||
EXPECT_TRUE(dut.allowInjection());
|
EXPECT_TRUE(dut.allowInjection());
|
||||||
|
|
||||||
// SPECIAL CASE: threshold of 0 means never boost cut
|
// SPECIAL CASE: threshold of 0 means never boost cut
|
||||||
engineConfiguration->boostCutPressure = 0;
|
engineConfiguration->boostCutPressure = 0;
|
||||||
engine->mockMapValue = 500;
|
Sensor::setMockValue(SensorType::Map, 500);
|
||||||
dut.updateState(1000);
|
dut.updateState(1000);
|
||||||
EXPECT_TRUE(dut.allowInjection());
|
EXPECT_TRUE(dut.allowInjection());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue