diff --git a/firmware/config/engines/canam_canned.cpp b/firmware/config/engines/canam_canned.cpp index 2ab03582ec..e62a7cdf85 100644 --- a/firmware/config/engines/canam_canned.cpp +++ b/firmware/config/engines/canam_canned.cpp @@ -42,14 +42,14 @@ static void cannedignitionLoadBins() { } static void cannedveRpmBins() { -#if (IGN_LOAD_COUNT == 16) && (IGN_RPM_COUNT == 16) +#if (VE_LOAD_COUNT == 16) && (VE_RPM_COUNT == 16) static const float hardCodedveRpmBins[16] = {800.0, 1000.0, 1300.0, 1600.0, 2000.0, 2500.0, 3000.0, 3600.0, 4000.0, 4400.0, 4900.0, 5300.0, 5800.0, 6200.0, 7100.0, 8000.0}; copyArray(config->veRpmBins, hardCodedveRpmBins); #endif } static void cannedveLoadBins() { -#if (IGN_LOAD_COUNT == 16) && (IGN_RPM_COUNT == 16) +#if (VE_LOAD_COUNT == 16) && (VE_RPM_COUNT == 16) static const float hardCodedveLoadBins[16] = {15.0, 27.0, 33.0, 45.0, 57.0, 69.0, 81.0, 93.0, 105.0, 129.0, 157.0, 186.0, 214.0, 243.0, 271.0, 300.0}; copyArray(config->veLoadBins, hardCodedveLoadBins); #endif diff --git a/firmware/config/engines/ford_festiva.cpp b/firmware/config/engines/ford_festiva.cpp index 67a3e57e2c..6740a6e735 100644 --- a/firmware/config/engines/ford_festiva.cpp +++ b/firmware/config/engines/ford_festiva.cpp @@ -71,7 +71,7 @@ void setFordEscortGt() { engineConfiguration->displacement = 1.839; setAlgorithm(LM_SPEED_DENSITY); -#if (IGN_RPM_COUNT == 16) && (IGN_LOAD_COUNT == 16) +#if (VE_LOAD_COUNT == 16) && (VE_RPM_COUNT == 16) static const uint16_t veRpmBins[] = { 800, diff --git a/firmware/config/engines/hyundai_coupe_canned_tables.cpp b/firmware/config/engines/hyundai_coupe_canned_tables.cpp index 70250ea0e5..580f13ca6b 100644 --- a/firmware/config/engines/hyundai_coupe_canned_tables.cpp +++ b/firmware/config/engines/hyundai_coupe_canned_tables.cpp @@ -24,7 +24,7 @@ static void cannedcltIdleCorr() { } static void couplecannedveTable() { -#if (IGN_LOAD_COUNT == 16) && (IGN_RPM_COUNT == 16) +#if (VE_LOAD_COUNT == 16) && (VE_RPM_COUNT == 16) static const float hardCodedveTable[16][16] = { {52.000, 54.000, 54.000, 56.000, 61.000, 55.000, 55.000, 65.000, 65.000, 60.000, 60.000, 60.000, 60.000, 60.000, 60.000, 60.000, }, {51.500, 54.500, 54.400, 56.000, 61.000, 68.100, 66.800, 67.600, 68.200, 63.400, 63.400, 63.400, 63.400, 63.400, 63.400, 63.400, }, diff --git a/firmware/config/engines/hyundai_pb_canned_tables.cpp b/firmware/config/engines/hyundai_pb_canned_tables.cpp index 6423b3ec25..e4743e3709 100644 --- a/firmware/config/engines/hyundai_pb_canned_tables.cpp +++ b/firmware/config/engines/hyundai_pb_canned_tables.cpp @@ -55,6 +55,7 @@ static void pbcannedignitionTable() { } static void pbcannedveTable() { +#if (VE_LOAD_COUNT == 16) && (VE_RPM_COUNT == 16) static const float hardCodedveTable[16][16] = { {70.300, 70.300, 70.400, 70.500, 70.600, 70.600, 70.300, 29.900, 29.800, 29.900, 30.400, 31.400, 33.000, 35.100, 37.700, 40.900, }, {70.800, 71.500, 72.100, 72.900, 73.300, 72.800, 72.000, 31.300, 31.200, 31.500, 32.200, 33.500, 35.300, 37.700, 40.500, 43.900, }, @@ -74,6 +75,7 @@ static void pbcannedveTable() { {127.600, 127.600, 127.600, 127.600, 127.600, 127.600, 127.600, 127.600, 127.600, 127.600, 127.600, 127.600, 127.600, 127.600, 127.600, 127.600, }, }; copyTable(config->veTable, hardCodedveTable); +#endif } static void pbcannedinjectionPhase() { diff --git a/firmware/config/engines/mazda/mazda_miata_1_6.cpp b/firmware/config/engines/mazda/mazda_miata_1_6.cpp index aa6cdb00b0..c0b55c8ae8 100644 --- a/firmware/config/engines/mazda/mazda_miata_1_6.cpp +++ b/firmware/config/engines/mazda/mazda_miata_1_6.cpp @@ -66,7 +66,7 @@ static const uint8_t hardCodedveTable[16][16] = { /* Generated by TS2C on Sun Aug 02 10:02:25 EDT 2020*/ static void setMapVeTable() { -#if (IGN_LOAD_COUNT == 16) && (IGN_RPM_COUNT == 16) +#if (VE_LOAD_COUNT == 16) && (VE_RPM_COUNT == 16) copyArray(config->veLoadBins, hardCodedveLoadBins); copyArray(config->veRpmBins, hardCodedveRpmBins); copyTable(config->veTable, hardCodedveTable); diff --git a/firmware/config/engines/mazda/mazda_miata_vvt.cpp b/firmware/config/engines/mazda/mazda_miata_vvt.cpp index 1a3f1df5f7..37c14bce27 100644 --- a/firmware/config/engines/mazda/mazda_miata_vvt.cpp +++ b/firmware/config/engines/mazda/mazda_miata_vvt.cpp @@ -300,14 +300,14 @@ static void setCommonMazdaNB() { // Tach engineConfiguration->tachPulsePerRev = 2; -#if (FUEL_RPM_COUNT == 16) && (FUEL_LOAD_COUNT == 16) +#if (VE_RPM_COUNT == 16) && (VE_LOAD_COUNT == 16) // Tables copyArray(config->veRpmBins, mazda_miata_nb2_RpmBins); copyArray(config->veLoadBins, mazda_miata_nb2_LoadBins); + copyTable(config->veTable, mapBased18vvtVeTable_NB_fuel_rail); #endif #if (IGN_RPM_COUNT == 16) && (IGN_LOAD_COUNT == 16) - copyTable(config->veTable, mapBased18vvtVeTable_NB_fuel_rail); copyArray(config->ignitionRpmBins, ignition18vvtRpmBins); copyArray(config->ignitionLoadBins, ignition18vvtLoadBins); copyTable(config->ignitionTable, mapBased18vvtTimingTable); diff --git a/firmware/controllers/algo/defaults/default_fuel.cpp b/firmware/controllers/algo/defaults/default_fuel.cpp index b6be37891d..bf4a8a54c5 100644 --- a/firmware/controllers/algo/defaults/default_fuel.cpp +++ b/firmware/controllers/algo/defaults/default_fuel.cpp @@ -81,7 +81,7 @@ static void setDefaultWarmupFuelEnrichment() { static void setDefaultVETable() { setRpmTableBin(config->veRpmBins); -#if (IGN_LOAD_COUNT == 16) && (IGN_RPM_COUNT == 16) +#if (VE_LOAD_COUNT == 16) && (VE_RPM_COUNT == 16) static const float hardCodedveTable[16][16] = { {49.300, 49.300, 49.400, 49.600, 50.200, 51.400, 52.600, 53.800, 54.400, 54.600, 54.400, 53.700, 52.800, 51.800, 50.900, 50.000, }, {49.600, 50.500, 51.500, 54.100, 57.500, 60.700, 62.900, 64.400, 65.000, 65.000, 64.500, 63.500, 62.300, 61.100, 60.000, 58.800, }, diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index ea422730f4..c5c7e17b2b 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -34,7 +34,7 @@ #include "speed_density_base.h" #include "lua_hooks.h" -extern fuel_Map3D_t veMap; +extern ve_Map3D_t veMap; static mapEstimate_Map3D_t mapEstimationTable{"mape"}; #if EFI_ENGINE_CONTROL diff --git a/firmware/controllers/math/speed_density.cpp b/firmware/controllers/math/speed_density.cpp index f33c224df2..f5faf7c1b0 100644 --- a/firmware/controllers/math/speed_density.cpp +++ b/firmware/controllers/math/speed_density.cpp @@ -16,7 +16,7 @@ #define rpmMin 500 #define rpmMax 8000 -fuel_Map3D_t veMap{"ve"}; +ve_Map3D_t veMap{"ve"}; #define tpMin 0 #define tpMax 100 diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 9bedd34d64..54e498487e 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -215,6 +215,8 @@ struct_no_prefix engine_configuration_s #define VEHICLE_INFO_SIZE 32 +#define VE_RPM_COUNT 16 +#define VE_LOAD_COUNT 16 #define FUEL_RPM_COUNT 16 #define FUEL_LOAD_COUNT 16 #define INJ_PHASE_RPM_COUNT 16 @@ -1937,9 +1939,9 @@ int16_t[IGN_LOAD_COUNT x IGN_RPM_COUNT] autoscale ignitionTable;;"deg", 0.1, 0, uint16_t[IGN_LOAD_COUNT] ignitionLoadBins;;"Load", 1, 0, 0, @@MAP_UPPER_LIMIT@@, 0 uint16_t[IGN_RPM_COUNT] ignitionRpmBins;;"RPM", 1, 0, 0, 18000, 0 -uint16_t[FUEL_LOAD_COUNT x FUEL_RPM_COUNT] autoscale veTable;;"%", 0.1, 0, 0, 999, 1 -uint16_t[FUEL_LOAD_COUNT] veLoadBins;;{bitStringValue(fuelUnits, fuelAlgorithm) }, 1, 0, 0, @@MAP_UPPER_LIMIT@@, 0 -uint16_t[FUEL_RPM_COUNT] veRpmBins;;"RPM", 1, 0, 0, 18000, 0 +uint16_t[VE_LOAD_COUNT x VE_RPM_COUNT] autoscale veTable;;"%", 0.1, 0, 0, 999, 1 +uint16_t[VE_LOAD_COUNT] veLoadBins;;{bitStringValue(fuelUnits, fuelAlgorithm) }, 1, 0, 0, @@MAP_UPPER_LIMIT@@, 0 +uint16_t[VE_RPM_COUNT] veRpmBins;;"RPM", 1, 0, 0, 18000, 0 #if LAMBDA uint8_t[FUEL_LOAD_COUNT x FUEL_RPM_COUNT] autoscale lambdaTable;;"lambda", {1/@@PACK_MULT_LAMBDA_CFG@@}, 0, 0.6, 1.5, 2 diff --git a/firmware/util/containers/table_helper.h b/firmware/util/containers/table_helper.h index 532a8f375f..2e0398c3a5 100644 --- a/firmware/util/containers/table_helper.h +++ b/firmware/util/containers/table_helper.h @@ -132,7 +132,7 @@ private: const char *m_name; }; -typedef Map3D fuel_Map3D_t; +typedef Map3D ve_Map3D_t; typedef Map3D pedal2tps_t; typedef Map3D mapEstimate_Map3D_t; diff --git a/unit_tests/tests/test_engine_math.cpp b/unit_tests/tests/test_engine_math.cpp index c988df089d..4813f0e347 100644 --- a/unit_tests/tests/test_engine_math.cpp +++ b/unit_tests/tests/test_engine_math.cpp @@ -25,6 +25,7 @@ TEST(misc, testEngineMath) { // todo: let's see if we can make 'engine' unneeded in this test? EngineTestHelper eth(engine_type_e::FORD_ESCORT_GT); + setTable(config->veTable, 80); setCamOperationMode(); engineConfiguration->fuelAlgorithm = LM_SPEED_DENSITY; @@ -63,7 +64,7 @@ TEST(misc, testEngineMath) { // calc. airFlow using airMass, and find tCharge engine->periodicFastCallback(); ASSERT_NEAR(59.12f, engine->engineState.sd.tCharge, EPS4D); - ASSERT_NEAR(56.9758f/*kg/h*/, engine->engineState.airflowEstimate, EPS4D); + ASSERT_NEAR(46.2747f/*kg/h*/, engine->engineState.airflowEstimate, EPS4D); } typedef enum {