More TPS consumers: VE lookup (#1256)

* advance_map

* tests

* unneeded

* idle

* use driver intent instead

* and obd and lcd

* engine load

* ve lookup

* unused

* oops we needed that

* oops needed that too

* mocking

* test mocks

* oops

* helps to use the right sensor

* and cylinder cleanup

* fuel math

* typo

Co-authored-by: Matthew Kennedy <makenne@microsoft.com>
This commit is contained in:
Matthew Kennedy 2020-04-04 05:41:09 -07:00 committed by GitHub
parent f10f2109ab
commit bc3f0c6b27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 21 deletions

View File

@ -24,6 +24,7 @@
#include "map_averaging.h"
#include "fsio_impl.h"
#include "perf_trace.h"
#include "sensor.h"
#if EFI_PROD_CODE
#include "bench_test.h"
@ -113,7 +114,7 @@ static void cylinderCleanupControl(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
#if EFI_ENGINE_CONTROL
bool newValue;
if (engineConfiguration->isCylinderCleanupEnabled) {
newValue = !engine->rpmCalculator.isRunning(PASS_ENGINE_PARAMETER_SIGNATURE) && getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) > CLEANUP_MODE_TPS;
newValue = !engine->rpmCalculator.isRunning(PASS_ENGINE_PARAMETER_SIGNATURE) && Sensor::get(SensorType::DriverThrottleIntent).value_or(0) > CLEANUP_MODE_TPS;
} else {
newValue = false;
}

View File

@ -16,6 +16,7 @@
#include "advance_map.h"
#include "aux_valves.h"
#include "perf_trace.h"
#include "sensor.h"
#if EFI_PROD_CODE
#include "svnversion.h"
@ -201,8 +202,8 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
multispark.count = getMultiSparkCount(rpm PASS_ENGINE_PARAMETER_SUFFIX);
if (engineConfiguration->fuelAlgorithm == LM_SPEED_DENSITY) {
float tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
updateTChargeK(rpm, tps PASS_ENGINE_PARAMETER_SUFFIX);
auto tps = Sensor::get(SensorType::Tps1);
updateTChargeK(rpm, tps.value_or(0) PASS_ENGINE_PARAMETER_SUFFIX);
float map = getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
/**
@ -210,15 +211,16 @@ void EngineState::periodicFastCallback(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
*/
if (CONFIG(useTPSBasedVeTable)) {
// todo: should we have 'veTpsMap' fuel_Map3D_t variable here?
currentRawVE = interpolate3d<float, float>(tps, CONFIG(ignitionTpsBins), IGN_TPS_COUNT, rpm, config->veRpmBins, FUEL_RPM_COUNT, veMap.pointers);
currentRawVE = interpolate3d<float, float>(tps.value_or(50), CONFIG(ignitionTpsBins), IGN_TPS_COUNT, rpm, config->veRpmBins, FUEL_RPM_COUNT, veMap.pointers);
} else {
currentRawVE = veMap.getValue(rpm, map);
}
// get VE from the separate table for Idle
if (CONFIG(useSeparateVeForIdle)) {
if (tps.Valid && CONFIG(useSeparateVeForIdle)) {
float idleVe = interpolate2d("idleVe", rpm, config->idleVeBins, config->idleVe);
// interpolate between idle table and normal (running) table using TPS threshold
currentRawVE = interpolateClamped(0.0f, idleVe, CONFIG(idlePidDeactivationTpsThreshold), currentRawVE, tps);
currentRawVE = interpolateClamped(0.0f, idleVe, CONFIG(idlePidDeactivationTpsThreshold), currentRawVE, tps.Value);
}
currentBaroCorrectedVE = baroCorrection * currentRawVE * PERCENT_DIV;
targetAFR = afrMap.getValue(rpm, map);
@ -271,7 +273,7 @@ void StartupFuelPumping::setPumpsCounter(int newValue) {
void StartupFuelPumping::update(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
if (GET_RPM() == 0) {
bool isTpsAbove50 = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE) >= 50;
bool isTpsAbove50 = Sensor::get(SensorType::DriverThrottleIntent).value_or(0) >= 50;
if (this->isTpsAbove50 != isTpsAbove50) {
setPumpsCounter(pumpsCounter + 1);

View File

@ -30,6 +30,7 @@
#include "rpm_calculator.h"
#include "speed_density.h"
#include "perf_trace.h"
#include "sensor.h"
EXTERN_ENGINE;
@ -74,10 +75,10 @@ DISPLAY(DISPLAY_IF(isCrankingState)) floatms_t getCrankingFuel3(float coolantTem
DISPLAY_SENSOR(CLT);
DISPLAY_TEXT(eol);
percent_t tps = getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
auto tps = Sensor::get(SensorType::DriverThrottleIntent);
DISPLAY_TEXT(TPS_coef);
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(tpsCoefficient) = cisnan(tps) ? 1 : interpolate2d("crankTps", tps, engineConfiguration->crankingTpsBins,
engine->engineState.DISPLAY_PREFIX(cranking).DISPLAY_FIELD(tpsCoefficient) = tps.Valid ? 1 : interpolate2d("crankTps", tps.Value, engineConfiguration->crankingTpsBins,
engineConfiguration->crankingTpsCoef);
DISPLAY_SENSOR(TPS);
DISPLAY_TEXT(eol);

View File

@ -24,6 +24,7 @@
#include "engine_configuration.h"
#include "interpolation.h"
#include "allsensors.h"
#include "sensor.h"
#include "event_registry.h"
#include "efi_gpio.h"
#include "fuel_math.h"
@ -69,7 +70,7 @@ float getEngineLoadT(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
case LM_MAP:
return getMap(PASS_ENGINE_PARAMETER_SIGNATURE);
case LM_ALPHA_N:
return getTPS(PASS_ENGINE_PARAMETER_SIGNATURE);
return Sensor::get(SensorType::Tps1).value_or(0);
case LM_REAL_MAF: {
return getRealMaf(PASS_ENGINE_PARAMETER_SIGNATURE);
}

View File

@ -13,6 +13,7 @@
#include "engine_test_helper.h"
#include "efi_gpio.h"
#include "advance_map.h"
#include "sensor.h"
extern float testMafValue;
@ -246,9 +247,8 @@ TEST(fuel, testTpsBasedVeDefect799) {
// set TPS axis range which does not overlap MAP range for this test
setLinearCurve(CONFIG(ignitionTpsBins), 0, 15, 1);
engine->mockMapValue = 107;
setMockTpsValue(7 PASS_ENGINE_PARAMETER_SUFFIX);
Sensor::setMockValue(SensorType::Tps1, 7);
engine->engineState.periodicFastCallback(PASS_ENGINE_PARAMETER_SIGNATURE);
// value in the middle of the map as expected

View File

@ -21,6 +21,7 @@
#include "fuel_math.h"
#include "spark_logic.h"
#include "trigger_universal.h"
#include "sensor.h"
extern float testMafValue;
extern WarningCodeState unitTestWarningCodeState;
@ -245,21 +246,17 @@ static void testTriggerDecoder3(const char *msg, engine_type_e type, int synchPo
}
TEST(misc, testStartupFuelPumping) {
printf("*************************************************** testStartupFuelPumping\r\n");
WITH_ENGINE_TEST_HELPER(FORD_INLINE_6_1995);
StartupFuelPumping sf;
engine->rpmCalculator.mockRpm = 0;
engineConfiguration->tpsMin = 0;
engineConfiguration->tpsMax = 10;
setMockTpsAdc(6 PASS_ENGINE_PARAMETER_SUFFIX);
Sensor::setMockValue(SensorType::DriverThrottleIntent, 60);
sf.update(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 1, sf.pumpsCounter) << "pc#1";
setMockTpsAdc(3 PASS_ENGINE_PARAMETER_SUFFIX);
Sensor::setMockValue(SensorType::DriverThrottleIntent, 30);
sf.update(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 1, sf.pumpsCounter) << "pumpsCounter#2";
@ -270,16 +267,16 @@ TEST(misc, testStartupFuelPumping) {
sf.update(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 0, sf.pumpsCounter) << "pc#4";
setMockTpsAdc(7 PASS_ENGINE_PARAMETER_SUFFIX);
Sensor::setMockValue(SensorType::DriverThrottleIntent, 70);
engine->rpmCalculator.mockRpm = 0;
sf.update(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 1, sf.pumpsCounter) << "pc#5";
setMockTpsAdc(3 PASS_ENGINE_PARAMETER_SUFFIX);
Sensor::setMockValue(SensorType::DriverThrottleIntent, 30);
sf.update(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 1, sf.pumpsCounter) << "pc#6";
setMockTpsAdc(7 PASS_ENGINE_PARAMETER_SUFFIX);
Sensor::setMockValue(SensorType::DriverThrottleIntent, 70);
sf.update(PASS_ENGINE_PARAMETER_SIGNATURE);
ASSERT_EQ( 2, sf.pumpsCounter) << "pc#7";
}