MAF2MAP convestion #538

This commit is contained in:
rusefi 2019-01-13 01:53:58 -05:00
parent 0283cb1a2a
commit 2e1d552396
11 changed files with 51 additions and 8 deletions

View File

@ -770,7 +770,7 @@ void initEngineContoller(Logging *sharedLogger DECLARE_ENGINE_PARAMETER_SUFFIX)
#endif /* EFI_PROD_CODE */
}
static char UNUSED_RAM_SIZE[10300];
static char UNUSED_RAM_SIZE[10200];
static char UNUSED_CCM_SIZE[7100] CCM_OPTIONAL;

View File

@ -13,6 +13,7 @@
#include "rpm_calculator.h"
#include "engine_math.h"
#include "engine_state.h"
#include "maf2map.h"
#define rpmMin 500
#define rpmMax 8000
@ -172,4 +173,5 @@ void initSpeedDensity(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
// ve2Map.init(engineConfiguration->ve2Table, engineConfiguration->ve2LoadBins, engineConfiguration->ve2RpmBins);
afrMap.init(config->afrTable, config->afrLoadBins, config->afrRpmBins);
baroCorrMap.init(engineConfiguration->baroCorrTable, engineConfiguration->baroCorrPressureBins, engineConfiguration->baroCorrRpmBins);
initMaf2Map();
}

View File

@ -1,11 +1,11 @@
/*
* @file maf2map.cpp
*
* @author Andrey Belomutskiy, (c) 2012-2018
* @author Andrey Belomutskiy, (c) 2012-2019
* @date Jan 20, 2018
*/
#define ASIZE 16
#include "maf2map.h"
/* rpm bins */
static const float rpmBins[ASIZE] = {500.0, 1000.0, 1500.0, 2000.0, 2500.0, 3000.0, 3500.0, 4000.0, 4500.0, 5000.0, 5500.0, 6000.0, 6500.0, 7000.0, 7500.0, 8000.0};
@ -35,3 +35,14 @@ static const float maf2map16[ASIZE][ASIZE] = {
/*v=0.230000 kpa=*/ 225.399979, /*v=0.300000 kpa=*/ 165.699997, /*v=0.400000 kpa=*/ 102.175003, /*v=0.500000 kpa=*/ 76.000000, /*v=0.600000 kpa=*/ 61.100002, /*v=0.700000 kpa=*/ 52.335297, /*v=0.800000 kpa=*/ 41.700005, /*v=1.000000 kpa=*/ 20.438889, /*v=1.100000 kpa=*/ 12.161111, /*v=1.200000 kpa=*/ 3.883333, /*v=1.500000 kpa=*/ 1.400000, /*v=2.000000 kpa=*/ 1.400000, /*v=2.500000 kpa=*/ 1.400000, /*v=3.000000 kpa=*/ 1.400000, /*v=3.500000 kpa=*/ 1.400000, /*v=4.500000 kpa=*/ 1.400000,
};
maf2map_Map3D_t maf2MapMap("maf2map");
void initMaf2Map() {
// RPM and load are flipped in this table, that's just the way we have data
maf2MapMap.init((float (*)[ASIZE])maf2map16, rpmBins, voltageBins);
}
float estimateMapByRpmAndMaf(int rpm, float maf) {
// RPM and load are flipped in this table, that's just the way we have data
return maf2MapMap.getValue(maf, rpm);
}

View File

@ -1,15 +1,20 @@
/*
* @file maf2map.h
*
* @author Andrey Belomutskiy, (c) 2012-2018
* @author Andrey Belomutskiy, (c) 2012-2019
* @date Jan 20, 2018
*/
#ifndef CONTROLLERS_SENSORS_MAF2MAP_H_
#define CONTROLLERS_SENSORS_MAF2MAP_H_
#include "table_helper.h"
#define ASIZE 16
typedef Map3D<ASIZE, ASIZE, float> maf2map_Map3D_t;
void initMaf2Map();
float estimateMapByRpmAndMaf(int rpm, float maf);
#endif /* CONTROLLERS_SENSORS_MAF2MAP_H_ */

View File

@ -8,6 +8,7 @@ CONTROLLERS_SENSORS_SRC_CPP = $(PROJECT_DIR)/controllers/sensors/thermistors.cp
$(PROJECT_DIR)/controllers/sensors/maf.cpp \
$(PROJECT_DIR)/controllers/sensors/tps.cpp \
$(PROJECT_DIR)/controllers/sensors/ego.cpp \
$(PROJECT_DIR)/controllers/sensors/maf2map.cpp \
$(PROJECT_DIR)/controllers/sensors/hip9011_lookup.cpp \
$(PROJECT_DIR)/controllers/sensors/flex_fuel.cpp \
$(PROJECT_DIR)/controllers/sensors/oil_pressure.cpp

View File

@ -16,6 +16,7 @@ TEST_SRC_CPP = unit_test_framework.cpp \
tests/test_trigger_decoder.cpp \
tests/test_trigger_noiseless.cpp \
tests/test_fuel_map.cpp \
tests/test_maf2map.cpp \
tests/test_fuelCut.cpp \
tests/test_pwm_generator.cpp \
tests/test_logic_expression.cpp \

View File

@ -7,7 +7,6 @@
#include "engine_math.h"
#include "test_fasterEngineSpinningUp.h"
#include "test_trigger_decoder.h"
#include "unit_test_framework.h"
extern int timeNowUs;

View File

@ -7,7 +7,6 @@
#include "engine_math.h"
#include "test_trigger_decoder.h"
#include "event_queue.h"
#include "unit_test_framework.h"
#include "tps.h"
extern int timeNowUs;

View File

@ -2,7 +2,7 @@
* @file test_fuel_map.cpp
*
* @date Nov 6, 2013
* @author Andrey Belomutskiy, (c) 2012-2018
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#include "test_fuel_map.h"

View File

@ -0,0 +1,26 @@
/*
* test_maf2map.cpp
*
* Created on: Jan 13, 2019
* @author Andrey Belomutskiy, (c) 2012-2019
*/
#include "engine_test_helper.h"
#include "maf2map.h"
#define round_2d(x) efiRound(x, 0.01)
// todo: this should be improved to use relative 6 digit precision not just digits after decimal point
#define ASSERT_FLOAT_EQ(x, y) ASSERT_DOUBLE_EQ(round_2d(x), round_2d(y))
TEST(fuel, maf2map) {
EngineTestHelper eth(FORD_ASPIRE_1996);
EXPAND_EngineTestHelper;
engineConfiguration->fuelAlgorithm = LM_REAL_MAF;
ASSERT_FLOAT_EQ(61.1, estimateMapByRpmAndMaf(8000, 0.6));
ASSERT_FLOAT_EQ(1.4, estimateMapByRpmAndMaf(2000, 5.6));
}

View File

@ -7,7 +7,6 @@
#include "test_startOfCrankingPrimingPulse.h"
#include "test_trigger_decoder.h"
#include "unit_test_framework.h"
extern int timeNowUs;
extern EnginePins enginePins;