diff --git a/firmware/config/engines/citroenBerlingoTU3JP.cpp b/firmware/config/engines/citroenBerlingoTU3JP.cpp index 5a51cb18ad..faf9c3d4b6 100644 --- a/firmware/config/engines/citroenBerlingoTU3JP.cpp +++ b/firmware/config/engines/citroenBerlingoTU3JP.cpp @@ -26,6 +26,7 @@ void setLCD(board_configuration_s *boardConfiguration) { boardConfiguration->HD44780_db7 = GPIOB_10; } +#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT static const fuel_table_t tps_fuel_table = { {/*0 engineLoad=0.00*/ /*0 800.0*/4.00, /*1 1213.0*/4.00, /*2 1626.0*/4.00, /*3 2040.0*/4.00, /*4 2453.0*/4.00, /*5 2866.0*/4.00, /*6 3280.0*/4.00, /*7 3693.0*/4.00, /*8 4106.0*/4.00, /*9 4520.0*/4.00, /*10 4933.0*/4.00, /*11 5346.0*/4.00, /*12 5760.0*/4.00, /*13 6173.0*/4.00, /*14 6586.0*/4.00, /*15 7000.0*/4.00}, {/*1 engineLoad=6.66*/ /*0 800.0*/5.07, /*1 1213.0*/5.07, /*2 1626.0*/5.07, /*3 2040.0*/5.07, /*4 2453.0*/5.07, /*5 2866.0*/5.07, /*6 3280.0*/5.07, /*7 3693.0*/5.07, /*8 4106.0*/5.07, /*9 4520.0*/5.07, /*10 4933.0*/5.07, /*11 5346.0*/5.07, /*12 5760.0*/5.07, /*13 6173.0*/5.07, /*14 6586.0*/5.07, /*15 7000.0*/5.07}, @@ -44,8 +45,10 @@ static const fuel_table_t tps_fuel_table = { {/*14 engineLoad=93.33*/ /*0 800.0*/18.93, /*1 1213.0*/18.93, /*2 1626.0*/18.93, /*3 2040.0*/18.93, /*4 2453.0*/18.93, /*5 2866.0*/18.93, /*6 3280.0*/18.93, /*7 3693.0*/18.93, /*8 4106.0*/18.93, /*9 4520.0*/18.93, /*10 4933.0*/18.93, /*11 5346.0*/18.93, /*12 5760.0*/18.93, /*13 6173.0*/18.93, /*14 6586.0*/18.93, /*15 7000.0*/18.93}, {/*15 engineLoad=100.00*/ /*0 800.0*/20.00, /*1 1213.0*/20.00, /*2 1626.0*/20.00, /*3 2040.0*/20.00, /*4 2453.0*/20.00, /*5 2866.0*/20.00, /*6 3280.0*/20.00, /*7 3693.0*/20.00, /*8 4106.0*/20.00, /*9 4520.0*/20.00, /*10 4933.0*/20.00, /*11 5346.0*/20.00, /*12 5760.0*/20.00, /*13 6173.0*/20.00, /*14 6586.0*/20.00, /*15 7000.0*/20.00} }; +#endif -static const ignition_table_t tps_advance_table = { +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT +static const ignition_table_t default_tps_advance_table = { {/*0 engineLoad=0.00*/ /*0 800.0*/+15.00, /*1 1213.0*/+16.33, /*2 1626.0*/+17.67, /*3 2040.0*/+19.00, /*4 2453.0*/+20.33, /*5 2866.0*/+21.67, /*6 3280.0*/+23.00, /*7 3693.0*/+24.33, /*8 4106.0*/+25.67, /*9 4520.0*/+27.00, /*10 4933.0*/+28.33, /*11 5346.0*/+29.67, /*12 5760.0*/+31.00, /*13 6173.0*/+32.33, /*14 6586.0*/+33.67, /*15 7000.0*/+35.00}, {/*1 engineLoad=6.66*/ /*0 800.0*/+14.80, /*1 1213.0*/+16.12, /*2 1626.0*/+17.45, /*3 2040.0*/+18.77, /*4 2453.0*/+20.10, /*5 2866.0*/+21.42, /*6 3280.0*/+22.75, /*7 3693.0*/+24.07, /*8 4106.0*/+25.40, /*9 4520.0*/+26.72, /*10 4933.0*/+28.04, /*11 5346.0*/+29.37, /*12 5760.0*/+30.69, /*13 6173.0*/+32.02, /*14 6586.0*/+33.34, /*15 7000.0*/+34.67}, {/*2 engineLoad=13.33*/ /*0 800.0*/+14.60, /*1 1213.0*/+15.92, /*2 1626.0*/+17.23, /*3 2040.0*/+18.55, /*4 2453.0*/+19.86, /*5 2866.0*/+21.18, /*6 3280.0*/+22.49, /*7 3693.0*/+23.81, /*8 4106.0*/+25.12, /*9 4520.0*/+26.44, /*10 4933.0*/+27.76, /*11 5346.0*/+29.07, /*12 5760.0*/+30.39, /*13 6173.0*/+31.70, /*14 6586.0*/+33.02, /*15 7000.0*/+34.33}, @@ -63,6 +66,7 @@ static const ignition_table_t tps_advance_table = { {/*14 engineLoad=93.33*/ /*0 800.0*/+12.20, /*1 1213.0*/+13.41, /*2 1626.0*/+14.62, /*3 2040.0*/+15.83, /*4 2453.0*/+17.04, /*5 2866.0*/+18.24, /*6 3280.0*/+19.45, /*7 3693.0*/+20.66, /*8 4106.0*/+21.87, /*9 4520.0*/+23.08, /*10 4933.0*/+24.29, /*11 5346.0*/+25.50, /*12 5760.0*/+26.71, /*13 6173.0*/+27.92, /*14 6586.0*/+29.12, /*15 7000.0*/+30.33}, {/*15 engineLoad=100.00*/ /*0 800.0*/+12.00, /*1 1213.0*/+13.20, /*2 1626.0*/+14.40, /*3 2040.0*/+15.60, /*4 2453.0*/+16.80, /*5 2866.0*/+18.00, /*6 3280.0*/+19.20, /*7 3693.0*/+20.40, /*8 4106.0*/+21.60, /*9 4520.0*/+22.80, /*10 4933.0*/+24.00, /*11 5346.0*/+25.20, /*12 5760.0*/+26.40, /*13 6173.0*/+27.60, /*14 6586.0*/+28.80, /*15 7000.0*/+30.00} }; +#endif //static const float rpmSteps[16] = {400, 800, 1200, 1600, 2000, 2400, 2800, 3200, 3600, 4000, 4400, 4800, 5200, 5600, 6000, 6400}; //static const float mapSteps[16] = {25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100}; @@ -206,8 +210,13 @@ void setCitroenBerlingoTU3JPConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { */ // engineConfiguration->mafAdcChannel = GPIO_UNASSIGNED; +#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT copyFuelTable(tps_fuel_table, config->fuelTable); - copyTimingTable(tps_advance_table, config->ignitionTable); +#endif + +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT + copyTimingTable(default_tps_advance_table, config->ignitionTable); +#endif engineConfiguration->dizzySparkOutputPin = GPIOE_3; engineConfiguration->dizzySparkOutputPinMode = OM_INVERTED; diff --git a/firmware/config/engines/dodge_neon.cpp b/firmware/config/engines/dodge_neon.cpp index b024606a92..dd11b25ad4 100644 --- a/firmware/config/engines/dodge_neon.cpp +++ b/firmware/config/engines/dodge_neon.cpp @@ -80,6 +80,7 @@ static const fuel_table_t alphaNfuel = { // {/* 15 100.000 *//* 0 800.0*/12.000, /* 1 1213.3281*/12.000, /* 2 1626.6562*/12.000, /* 3 2040.0*/26.000, /* 4 2453.3438*/29.000, /* 5 2866.6562*/31.000, /* 6 3280.0*/31.000, /* 7 3693.3438*/38.000, /* 8 4106.6875*/40.000, /* 9 4520.0*/40.000, /* 10 4933.3125*/40.000, /* 11 5346.6875*/42.000, /* 12 5760.0*/42.000, /* 13 6173.3125*/42.000, /* 14 6586.6875*/42.000, /* 15 7000.0*/42.000, }, //}; +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT static const ignition_table_t fromODB = { /* Generated by OBD2C on Tue Jun 30 18:47:52 EDT 2015*/ {/* 0 0.000 *//* 0 800.0*/10.000, /* 1 1213.0*/22.000, /* 2 1626.0*/22.000, /* 3 2040.0*/22.000, /* 4 2453.0*/24.000, /* 5 2866.0*/22.000, /* 6 3280.0*/23.000, /* 7 3693.0*/23.000, /* 8 4106.0*/22.000, /* 9 4520.0*/22.000, /* 10 4933.0*/22.000, /* 11 5346.0*/32.000, /* 12 5760.0*/22.000, /* 13 6173.0*/22.000, /* 14 6586.0*/20.000, /* 15 7000.0*/20.000, }, @@ -99,7 +100,7 @@ static const ignition_table_t fromODB = { {/* 14 93.333 *//* 0 800.0*/-7.500, /* 1 1213.0*/-1.167, /* 2 1626.0*/7.000, /* 3 2040.0*/11.750, /* 4 2453.0*/31.000, /* 5 2866.0*/18.167, /* 6 3280.0*/23.167, /* 7 3693.0*/23.500, /* 8 4106.0*/20.000, /* 9 4520.0*/25.000, /* 10 4933.0*/25.667, /* 11 5346.0*/28.000, /* 12 5760.0*/30.000, /* 13 6173.0*/30.500, /* 14 6586.0*/33.000, /* 15 7000.0*/33.000, }, {/* 15 100.000 *//* 0 800.0*/-5.714, /* 1 1213.0*/-2.694, /* 2 1626.0*/1.818, /* 3 2040.0*/4.891, /* 4 2453.0*/9.543, /* 5 2866.0*/12.825, /* 6 3280.0*/17.861, /* 7 3693.0*/19.500, /* 8 4106.0*/17.833, /* 9 4520.0*/17.857, /* 10 4933.0*/20.125, /* 11 5346.0*/21.000, /* 12 5760.0*/24.125, /* 13 6173.0*/31.000, /* 14 6586.0*/28.500, /* 15 7000.0*/33.000 } }; - +#endif // http://rusefi.com/forum/viewtopic.php?f=3&t=360&start=40 @@ -291,7 +292,9 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { //setWholeFuelMap(12 PASS_CONFIG_PARAMETER_SUFFIX); // copyFuelTable(alphaNfuel, config->fuelTable); //setWholeTimingTable_d(12 PASS_CONFIG_PARAMETER_SUFFIX); +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT copyTimingTable(fromODB, config->ignitionTable); +#endif copy2DTable(vBattTarget, config->fsioTable1); diff --git a/firmware/config/engines/ford_aspire.cpp b/firmware/config/engines/ford_aspire.cpp index 2e00972b3a..9600086c22 100644 --- a/firmware/config/engines/ford_aspire.cpp +++ b/firmware/config/engines/ford_aspire.cpp @@ -20,6 +20,8 @@ #if EFI_SUPPORT_FORD_ASPIRE +#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT + /** * This is just the default map which is stored into flash memory in case flash is empty * The convenient way to override these default would be to tune this map using TunerStudio software @@ -44,7 +46,9 @@ static const fuel_table_t default_aspire_fuel_table = { /* Load 4.186667 */{ 16.961868, 15.368391, 15.210348, 15.290641, 15.263707, 15.485778, 15.827333, 15.802435, 15.677885, 15.827120, 15.997155, 16.027468, 15.478480, 15.190000, 15.190000, 15.190000}, /* Load 4.400000 */{ 17.010000, 15.250000, 15.680000, 15.440000, 15.270000, 15.470000, 15.800000, 15.730000, 15.600000, 15.790000, 16.120001, 16.110001, 15.630000, 15.150000, 15.150000, 15.150000} }; +#endif +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT static const ignition_table_t default_aspire_timing_table = { /* RPM 800.000000 1213.333374 1626.666748 2040.000000 2453.333496 2866.666748 3280.000000 3693.333496 4106.666992 4520.000000 4933.333496 5346.666992 5760.000000 6173.333496 6586.666992 7000.000000*/ /* Load 1.200000 */{ -0.662000, +7.730000, +16.722000, +23.139999, +29.398001, +31.268000, +32.108002, +30.436001, +30.896000, +26.656000, +24.704000, +25.108000, +25.132000, +25.459999, +25.459999, +25.459999}, @@ -64,6 +68,7 @@ static const ignition_table_t default_aspire_timing_table = { /* Load 4.186667 */{ -9.750000, -5.518000, -2.604000, -0.000000, +2.880000, +3.654000, +6.050000, +6.888000, +8.372000, +9.364000, +11.764000, +11.732000, +11.864000, +12.376000, +12.376000, +12.376000}, /* Load 4.400000 */{ -0.350000, -5.590000, -0.502000, -0.910000, -0.864000, -0.954000, -1.324000, +7.436000, -1.170000, -1.054000, -2.058000, -2.098000, -2.636000, +12.352000, +12.352000, +12.352000} }; +#endif EXTERN_CONFIG; @@ -74,8 +79,12 @@ static void setDefaultAspireMaps(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setTimingLoadBin(1.2, 4.4 PASS_CONFIG_PARAMETER_SUFFIX); setTimingRpmBin(800, 7000 PASS_CONFIG_PARAMETER_SUFFIX); +#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT copyFuelTable(default_aspire_fuel_table, config->fuelTable); +#endif +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT copyTimingTable(default_aspire_timing_table, config->ignitionTable); +#endif } void setFordAspireEngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { diff --git a/firmware/config/engines/ford_festiva.cpp b/firmware/config/engines/ford_festiva.cpp index f51328f613..4ba51eb87e 100644 --- a/firmware/config/engines/ford_festiva.cpp +++ b/firmware/config/engines/ford_festiva.cpp @@ -20,6 +20,7 @@ #include "mazda_miata.h" #include "custom_engine.h" +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT static const ignition_table_t racingFestivaIgnitionTable = { /* Generated by TS2C on Mon Feb 08 13:59:57 EST 2016*/ {/* 0 10.000 *//* 0 800.0*/13.000, /* 1 1213.3281*/12.900, /* 2 1626.6562*/10.500, /* 3 2040.0*/10.500, /* 4 2453.3438*/10.500, /* 5 2866.6562*/10.500, /* 6 3280.0*/11.500, /* 7 3693.3438*/11.500, /* 8 4106.6875*/11.500, /* 9 4520.0*/12.000, /* 10 4933.3125*/12.000, /* 11 5346.6875*/12.000, /* 12 5760.0*/12.000, /* 13 6173.3125*/12.000, /* 14 6586.6875*/12.000, /* 15 7000.0*/12.000, }, @@ -39,6 +40,7 @@ static const ignition_table_t racingFestivaIgnitionTable = { {/* 14 94.000 *//* 0 800.0*/20.000, /* 1 1213.3281*/16.000, /* 2 1626.6562*/16.000, /* 3 2040.0*/19.500, /* 4 2453.3438*/19.700, /* 5 2866.6562*/25.000, /* 6 3280.0*/26.200, /* 7 3693.3438*/26.200, /* 8 4106.6875*/26.900, /* 9 4520.0*/27.500, /* 10 4933.3125*/27.600, /* 11 5346.6875*/28.100, /* 12 5760.0*/28.000, /* 13 6173.3125*/28.700, /* 14 6586.6875*/28.900, /* 15 7000.0*/30.200, }, {/* 15 101.000 *//* 0 800.0*/20.000, /* 1 1213.3281*/16.200, /* 2 1626.6562*/16.200, /* 3 2040.0*/19.500, /* 4 2453.3438*/19.500, /* 5 2866.6562*/23.100, /* 6 3280.0*/24.000, /* 7 3693.3438*/24.000, /* 8 4106.6875*/26.900, /* 9 4520.0*/27.500, /* 10 4933.3125*/27.600, /* 11 5346.6875*/28.100, /* 12 5760.0*/28.000, /* 13 6173.3125*/30.000, /* 14 6586.6875*/30.900, /* 15 7000.0*/30.200, }, }; +#endif static const fuel_table_t racingFestivaVeTable = { /* Generated by TS2C on Mon Feb 08 13:58:49 EST 2016*/ @@ -268,7 +270,9 @@ void setFordEscortGt(DECLARE_CONFIG_PARAMETER_SIGNATURE) { config->ignitionRpmBins[13] = 6100; config->ignitionRpmBins[14] = 6500; config->ignitionRpmBins[15] = 7000; +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT copyTimingTable(racingFestivaIgnitionTable, config->ignitionTable); +#endif // boardConfiguration->useWarmupPidAfr = true; engineConfiguration->warmupAfrPid.pFactor = -0.2; diff --git a/firmware/config/engines/honda_600.cpp b/firmware/config/engines/honda_600.cpp index 6e089c5d29..1ed6b9767d 100644 --- a/firmware/config/engines/honda_600.cpp +++ b/firmware/config/engines/honda_600.cpp @@ -30,6 +30,7 @@ static const fuel_table_t default_custom_fuel_table = { {3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3} }; +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT static const ignition_table_t default_custom_timing_table = { /* RPM 0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000 5500 6000 6500 7000 */ /* Load 0% */{ 10, 10, 10, 12, 12, 12, 12, 15, 15, 15, 15, 26, 28, 30, 32}, @@ -44,6 +45,7 @@ static const ignition_table_t default_custom_timing_table = { /* Load 90% */{ 10, 10, 10, 10, 10, 10, 15, 18, 20, 22, 24, 26, 28, 30, 32}, /* Load 100% */{ 10, 10, 10, 10, 10, 10, 15, 18, 20, 22, 24, 26, 28, 30, 32}, }; +#endif EXTERN_CONFIG; @@ -55,8 +57,10 @@ static void setDefaultCustomMaps(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setTimingRpmBin(0,7000 PASS_CONFIG_PARAMETER_SUFFIX); copyFuelTable(default_custom_fuel_table, config->fuelTable); - copyFuelTable(default_custom_fuel_table, config->veTable); + copyFuelTable(default_custom_fuel_table, config->veTable); +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT copyTimingTable(default_custom_timing_table, config->ignitionTable); +#endif } void setHonda600(DECLARE_CONFIG_PARAMETER_SIGNATURE) { @@ -88,7 +92,9 @@ void setHonda600(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setFrankenso_01_LCD(boardConfiguration); commonFrankensoAnalogInputs(engineConfiguration); setFrankenso0_1_joystick(engineConfiguration); +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT setMap(config->injectionPhase, 320); +#endif /** * Frankenso analog #1 PC2 ADC12 CLT * Frankenso analog #2 PC1 ADC11 IAT diff --git a/firmware/config/engines/mazda_miata.cpp b/firmware/config/engines/mazda_miata.cpp index f443f31c20..b406f12407 100644 --- a/firmware/config/engines/mazda_miata.cpp +++ b/firmware/config/engines/mazda_miata.cpp @@ -23,6 +23,7 @@ #include "allsensors.h" #include "custom_engine.h" +#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT static const fuel_table_t miataNA8_maf_fuel_table = { {/*0 engineLoad=1.2*//*0 800.0*/1.53, /*1 1213.0*/0.92, /*2 1626.0*/ 0.74, /*3 2040.0*/0.69, /*4 2453.0*/0.69, /*5 2866.0*/0.67, /*6 3280.0*/0.67, /*7 3693.0*/0.67, /*8 4106.0*/ 0.67, /*9 4520.0*/1.02, /*10 4933.0*/0.98, /*11 5346.0*/0.98, /*12 5760.0*/0.92, /*13 6173.0*/0.89, /*14 6586.0*/ @@ -68,7 +69,9 @@ static const fuel_table_t miataNA8_maf_fuel_table = { {/*0 engineLoad=1.2*//*0 8 12.34, /*3 2040.0*/12.43, /*4 2453.0*/12.74, /*5 2866.0*/12.91, /*6 3280.0*/12.71, /*7 3693.0*/12.54, /*8 4106.0*/ 12.97, /*9 4520.0*/13.53, /*10 4933.0*/14.87, /*11 5346.0*/15.48, /*12 5760.0*/16.1, /*13 6173.0*/16.18, /*14 6586.0*/ 15.93, /*15 7000.0*/0.0 } }; +#endif +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT static const ignition_table_t miataNA8_maf_advance_table = { {/*0 engineLoad=1.200*//*0 800.0*/+4.498, /*1 1213.0*/+11.905, /*2 1626.0*/ +23.418, /*3 2040.0*/+25.357, /*4 2453.0*/+25.441, /*5 2866.0*/+25.468, /*6 3280.0*/+29.425, /*7 3693.0*/ +32.713, /*8 4106.0*/+35.556, /*9 4520.0*/+37.594, /*10 4933.0*/+36.165, /*11 5346.0*/+30.578, /*12 5760.0*/ @@ -118,6 +121,7 @@ static const ignition_table_t miataNA8_maf_advance_table = { {/*0 engineLoad=1. +4.85, /*1 1213.0*/+12.24, /*2 1626.0*/+24.091, /*3 2040.0*/+25.394, /*4 2453.0*/+25.323, /*5 2866.0*/+25.544, /*6 3280.0*/ +29.915, /*7 3693.0*/+33.104, /*8 4106.0*/+36.016, /*9 4520.0*/+37.933, /*10 4933.0*/+36.254, /*11 5346.0*/ +29.712, /*12 5760.0*/+28.651, /*13 6173.0*/+28.045, /*14 6586.0*/+27.228, /*15 7000.0*/+27.784 } }; +#endif static void setDefaultCrankingFuel(engine_configuration_s *engineConfiguration) { // todo: set cranking parameters method based on injectors and displacement? @@ -241,9 +245,13 @@ static void setMiata1994_common(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->crankingChargeAngle = 70; +#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT copyFuelTable(miataNA8_maf_fuel_table, config->fuelTable); +#endif +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT copyTimingTable(miataNA8_maf_advance_table, config->ignitionTable); +#endif // boardConfiguration->triggerSimulatorPins[0] = GPIOD_2; // 2G - YEL/BLU // boardConfiguration->triggerSimulatorPins[1] = GPIOB_3; // 2E - WHT - four times @@ -369,8 +377,12 @@ void setMiata1996(DECLARE_CONFIG_PARAMETER_SIGNATURE) { commonMiataNa(PASS_CONFIG_PARAMETER_SIGNATURE); engineConfiguration->specs.displacement = 1.839; +#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT copyFuelTable(miataNA8_maf_fuel_table, config->fuelTable); +#endif +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT copyTimingTable(miataNA8_maf_advance_table, config->ignitionTable); +#endif // upside down boardConfiguration->triggerInputPins[0] = GPIOA_5; diff --git a/firmware/config/engines/mazda_miata_1_6.cpp b/firmware/config/engines/mazda_miata_1_6.cpp index 1dbadc49d9..1e52cd87e4 100644 --- a/firmware/config/engines/mazda_miata_1_6.cpp +++ b/firmware/config/engines/mazda_miata_1_6.cpp @@ -32,6 +32,7 @@ static const float ve16LoadBins[FUEL_LOAD_COUNT] = { 120.0, 140.0, 150.0, 160.0, 170.0, 180.0, 190.0, 200.0}; +#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT static const fuel_table_t mapBased16VeTable = { /* Generated by TS2C on Sun Oct 02 19:40:18 EDT 2016*/ {/* 0 30.000 *//* 0 650.0*/23.348, /* 1 1100.0*/32.544, /* 2 1550.0*/50.000, /* 3 2000.0*/57.000, /* 4 2450.0*/53.000, /* 5 2900.0*/53.000, /* 6 3350.0*/57.000, /* 7 3800.0*/59.000, /* 8 4250.0*/59.000, /* 9 4700.0*/59.000, /* 10 5150.0*/59.000, /* 11 5650.0*/61.000, /* 12 6100.0*/65.000, /* 13 6550.0*/65.000, /* 14 7000.0*/65.000, /* 15 7450.0*/65.000, }, @@ -51,7 +52,9 @@ static const fuel_table_t mapBased16VeTable = { {/* 14 190.000 *//* 0 650.0*/65.435, /* 1 1100.0*/65.435, /* 2 1550.0*/65.435, /* 3 2000.0*/82.884, /* 4 2450.0*/90.735, /* 5 2900.0*/92.479, /* 6 3350.0*/93.352, /* 7 3800.0*/93.352, /* 8 4250.0*/93.352, /* 9 4700.0*/93.352, /* 10 5150.0*/93.352, /* 11 5650.0*/93.352, /* 12 6100.0*/110.774, /* 13 6550.0*/116.262, /* 14 7000.0*/121.749, /* 15 7450.0*/127.237, }, {/* 15 200.000 *//* 0 650.0*/66.307, /* 1 1100.0*/66.307, /* 2 1550.0*/66.307, /* 3 2000.0*/83.756, /* 4 2450.0*/91.608, /* 5 2900.0*/93.352, /* 6 3350.0*/94.224, /* 7 3800.0*/94.224, /* 8 4250.0*/94.224, /* 9 4700.0*/94.224, /* 10 5150.0*/94.224, /* 11 5650.0*/94.224, /* 12 6100.0*/118.805, /* 13 6550.0*/124.742, /* 14 7000.0*/130.684, /* 15 7450.0*/136.627, }, }; +#endif +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT static const ignition_table_t mapBased16IgnitionTable = { /* Generated by TS2C on Wed Jun 15 21:22:11 EDT 2016*/ {/* 0 18.000 *//* 0 650.0*/10.000, /* 1 1100.0*/11.432, /* 2 1550.0*/12.863, /* 3 2000.0*/14.295, /* 4 2450.0*/15.726, /* 5 2900.0*/17.157, /* 6 3350.0*/18.589, /* 7 3800.0*/20.021, /* 8 4250.0*/21.452, /* 9 4700.0*/22.884, /* 10 5150.0*/24.315, /* 11 5650.0*/25.906, /* 12 6100.0*/27.337, /* 13 6550.0*/28.769, /* 14 7000.0*/30.200, /* 15 7450.0*/30.200, }, @@ -71,6 +74,7 @@ static const ignition_table_t mapBased16IgnitionTable = { {/* 14 111.000 *//* 0 650.0*/5.720, /* 1 1100.0*/6.535, /* 2 1550.0*/7.350, /* 3 2000.0*/8.165, /* 4 2450.0*/8.980, /* 5 2900.0*/9.795, /* 6 3350.0*/10.610, /* 7 3800.0*/11.425, /* 8 4250.0*/12.240, /* 9 4700.0*/13.055, /* 10 5150.0*/13.870, /* 11 5650.0*/14.776, /* 12 6100.0*/15.591, /* 13 6550.0*/16.406, /* 14 7000.0*/17.221, /* 15 7450.0*/17.221, }, {/* 15 120.000 *//* 0 650.0*/5.000, /* 1 1100.0*/5.780, /* 2 1550.0*/6.559, /* 3 2000.0*/7.339, /* 4 2450.0*/8.118, /* 5 2900.0*/8.898, /* 6 3350.0*/9.677, /* 7 3800.0*/10.457, /* 8 4250.0*/11.236, /* 9 4700.0*/12.016, /* 10 5150.0*/12.795, /* 11 5650.0*/13.661, /* 12 6100.0*/14.441, /* 13 6550.0*/15.220, /* 14 7000.0*/16.000, /* 15 7450.0*/16.000, }, }; +#endif static const fuel_table_t miataNA6_maf_fuel_table = { /* Generated by TS2C on Tue Mar 12 13:59:29 EDT 2019*/ @@ -102,7 +106,9 @@ void miataNAcommon(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setCommonNTCSensor(&engineConfiguration->iat); engineConfiguration->iat.config.bias_resistor = 2700; +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT copyTimingTable(mapBased16IgnitionTable, config->ignitionTable); +#endif boardConfiguration->idle.solenoidFrequency = 160; boardConfiguration->idle.solenoidPin = GPIOB_9; // this W61 <> W61 jumper, pin 3W @@ -133,7 +139,9 @@ void setMiataNA6_MAP_Configuration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { memcpy(config->veRpmBins, ve16RpmBins, sizeof(ve16RpmBins)); memcpy(config->veLoadBins, ve16LoadBins, sizeof(ve16LoadBins)); +#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT copyFuelTable(mapBased16VeTable, config->veTable); +#endif // Wide band oxygen (from middle plug) to W52 engineConfiguration->afr.hwChannel = EFI_ADC_13; // PA3 diff --git a/firmware/config/engines/mazda_miata_vvt.cpp b/firmware/config/engines/mazda_miata_vvt.cpp index 36d9fd2f30..1fe1d54f2a 100644 --- a/firmware/config/engines/mazda_miata_vvt.cpp +++ b/firmware/config/engines/mazda_miata_vvt.cpp @@ -177,6 +177,7 @@ static const float targetAfrLoadBins[FUEL_LOAD_COUNT] = {10.0, 20.0, 30.0, 40.0, 90.0, 100.0, 110.0, 120.0, 130.0, 140.0, 150.0, 160.0}; +#if DEFAULT_FUEL_LOAD_COUNT == FUEL_LOAD_COUNT static const fuel_table_t mapBased18vvtVeTable_NA_fuel_rail = { /* Generated by TS2C on Sun May 07 09:37:15 EDT 2017*/ {/* 0 20.000 *//* 0 700.0*/35.685, /* 1 820.0*/36.982, /* 2 950.0*/37.200, /* 3 1100.0*/35.796, /* 4 1300.0*/36.149, /* 5 1550.0*/42.781, /* 6 1800.0*/45.281, /* 7 2150.0*/34.447, /* 8 2500.0*/26.662, /* 9 3000.0*/27.834, /* 10 3500.0*/29.178, /* 11 4150.0*/32.136, /* 12 4900.0*/36.009, /* 13 5800.0*/32.815, /* 14 6800.0*/34.415, /* 15 8000.0*/36.896, }, @@ -196,7 +197,9 @@ static const fuel_table_t mapBased18vvtVeTable_NA_fuel_rail = { {/* 14 185.000 *//* 0 700.0*/80.000, /* 1 820.0*/80.000, /* 2 950.0*/80.000, /* 3 1100.0*/80.000, /* 4 1300.0*/80.000, /* 5 1550.0*/80.000, /* 6 1800.0*/80.000, /* 7 2150.0*/80.000, /* 8 2500.0*/80.000, /* 9 3000.0*/80.000, /* 10 3500.0*/80.000, /* 11 4150.0*/80.000, /* 12 4900.0*/80.000, /* 13 5800.0*/80.000, /* 14 6800.0*/80.000, /* 15 8000.0*/80.000, }, {/* 15 220.000 *//* 0 700.0*/80.000, /* 1 820.0*/80.000, /* 2 950.0*/80.000, /* 3 1100.0*/80.000, /* 4 1300.0*/80.000, /* 5 1550.0*/80.000, /* 6 1800.0*/80.000, /* 7 2150.0*/80.000, /* 8 2500.0*/80.000, /* 9 3000.0*/80.000, /* 10 3500.0*/80.000, /* 11 4150.0*/80.000, /* 12 4900.0*/80.000, /* 13 5800.0*/80.000, /* 14 6800.0*/80.000, /* 15 8000.0*/80.000, }, }; +#endif +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT static const ignition_table_t mapBased18vvtTimingTable = { /* Generated by TS2C on Tue Apr 18 21:43:57 EDT 2017*/ {/* 0 25.000 *//* 0 700.0*/14.800, /* 1 850.0*/13.000, /* 2 943.0*/13.000, /* 3 1112.0*/16.000, /* 4 1310.0*/21.500, /* 5 1545.0*/25.100, /* 6 1821.0*/28.300, /* 7 2146.0*/31.460, /* 8 2530.0*/34.370, /* 9 2982.0*/36.598, /* 10 3515.0*/38.698, /* 11 4144.0*/39.728, /* 12 4884.0*/40.346, /* 13 5757.0*/40.758, /* 14 6787.0*/40.964, /* 15 8000.0*/41.170, }, @@ -216,6 +219,7 @@ static const ignition_table_t mapBased18vvtTimingTable = { {/* 14 214.400 *//* 0 700.0*/5.000, /* 1 850.0*/5.300, /* 2 943.0*/5.600, /* 3 1112.0*/5.900, /* 4 1310.0*/6.400, /* 5 1545.0*/7.000, /* 6 1821.0*/7.600, /* 7 2146.0*/8.400, /* 8 2530.0*/9.600, /* 9 2982.0*/10.800, /* 10 3515.0*/12.100, /* 11 4144.0*/13.400, /* 12 4884.0*/14.800, /* 13 5757.0*/16.200, /* 14 6787.0*/17.400, /* 15 8000.0*/18.700, }, {/* 15 250.000 *//* 0 700.0*/1.100, /* 1 850.0*/1.400, /* 2 943.0*/1.600, /* 3 1112.0*/2.000, /* 4 1310.0*/2.500, /* 5 1545.0*/3.000, /* 6 1821.0*/3.700, /* 7 2146.0*/4.400, /* 8 2530.0*/5.400, /* 9 2982.0*/6.600, /* 10 3515.0*/7.600, /* 11 4144.0*/9.000, /* 12 4884.0*/10.500, /* 13 5757.0*/12.000, /* 14 6787.0*/13.400, /* 15 8000.0*/14.900, }, }; +#endif void setMazdaMiataNbTpsTps(DECLARE_CONFIG_PARAMETER_SIGNATURE) { memcpy(config->tpsTpsAccelFromRpmBins, tpsTspSame, sizeof(tpsTspSame)); @@ -326,8 +330,9 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_CONFIG_PARAMETER_SIGNATURE) { memcpy(config->ignitionRpmBins, ignition18vvtRpmBins, sizeof(ignition18vvtRpmBins)); memcpy(config->ignitionLoadBins, ignition18vvtLoadBins, sizeof(ignition18vvtLoadBins)); +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT copyTimingTable(mapBased18vvtTimingTable, config->ignitionTable); - +#endif memcpy(config->fsioTable1RpmBins, ve18fsioRpmBins, sizeof(ve18fsioRpmBins)); memcpy(config->fsioTable1LoadBins, ve18fsioLoadBins, sizeof(ve18fsioLoadBins)); diff --git a/firmware/controllers/algo/advance_map.cpp b/firmware/controllers/algo/advance_map.cpp index e0b14d1c61..dd60e6343b 100644 --- a/firmware/controllers/algo/advance_map.cpp +++ b/firmware/controllers/algo/advance_map.cpp @@ -46,6 +46,7 @@ static bool shouldResetTimingPid = false; static int minCrankingRpm = 0; +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT static const float iatTimingRpmBins[IGN_LOAD_COUNT] = {880, 1260, 1640, 2020, 2400, 2780, 3000, 3380, 3760, 4140, 4520, 5000, 5700, 6500, 7200, 8000}; //880 1260 1640 2020 2400 2780 3000 3380 3760 4140 4520 5000 5700 6500 7200 8000 @@ -68,6 +69,8 @@ static const ignition_table_t defaultIatTiming = { {-4.4, -4.9, -5.9, -5.9, -5.9, -5.9, -4.9, -4.9, -4.9, -4.9, -4.9, -3.9, -3.9, -3.9, -3.9, -3.9}, }; +#endif /* IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT */ + bool isStep1Condition(int rpm DECLARE_ENGINE_PARAMETER_SUFFIX) { return CONFIGB(enabledStep1Limiter) && rpm >= engineConfiguration->step1rpm; } @@ -226,8 +229,12 @@ angle_t getAdvance(int rpm, float engineLoad DECLARE_ENGINE_PARAMETER_SUFFIX) { void setDefaultIatTimingCorrection(DECLARE_ENGINE_PARAMETER_SIGNATURE) { setLinearCurve(config->ignitionIatCorrLoadBins, IGN_LOAD_COUNT, /*from*/CLT_CURVE_RANGE_FROM, 110, 1); +#if IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT memcpy(config->ignitionIatCorrRpmBins, iatTimingRpmBins, sizeof(iatTimingRpmBins)); copyTimingTable(defaultIatTiming, config->ignitionIatCorrTable); +#else + setLinearCurve(config->ignitionIatCorrLoadBins, IGN_RPM_COUNT, /*from*/0, 6000, 1); +#endif /* IGN_LOAD_COUNT == DEFAULT_IGN_LOAD_COUNT */ } void initTimingMap(DECLARE_ENGINE_PARAMETER_SIGNATURE) { diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index 94febb7d9c..a32f99bfbb 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -219,6 +219,7 @@ void setAfrMap(afr_table_t table, float value) { } } +// todo: make this a template void setMap(fuel_table_t table, float value) { for (int l = 0; l < FUEL_LOAD_COUNT; l++) { for (int rpmIndex = 0; rpmIndex < FUEL_RPM_COUNT; rpmIndex++) { @@ -236,7 +237,10 @@ void setWholeFuelMap(float value DECLARE_CONFIG_PARAMETER_SUFFIX) { } void setWholeIgnitionIatCorr(float value DECLARE_CONFIG_PARAMETER_SUFFIX) { +#if (IGN_LOAD_COUNT == FUEL_LOAD_COUNT) && (IGN_RPM_COUNT == FUEL_RPM_COUNT) + // todo: make setMap a template setMap(config->ignitionIatCorrTable, value); +#endif } void setFuelTablesLoadBin(float minValue, float maxValue DECLARE_CONFIG_PARAMETER_SUFFIX) { @@ -794,7 +798,10 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) { setDefaultVETable(PASS_ENGINE_PARAMETER_SIGNATURE); +#if (IGN_LOAD_COUNT == FUEL_LOAD_COUNT) && (IGN_RPM_COUNT == FUEL_RPM_COUNT) + // todo: make setMap a template setMap(config->injectionPhase, -180); +#endif setRpmTableBin(config->injPhaseRpmBins, FUEL_RPM_COUNT); setFuelTablesLoadBin(10, 160 PASS_CONFIG_PARAMETER_SUFFIX); setDefaultIatTimingCorrection(PASS_ENGINE_PARAMETER_SIGNATURE); diff --git a/firmware/controllers/algo/fuel_math.cpp b/firmware/controllers/algo/fuel_math.cpp index 1c3779fbeb..9b6a9b19ab 100644 --- a/firmware/controllers/algo/fuel_math.cpp +++ b/firmware/controllers/algo/fuel_math.cpp @@ -232,7 +232,9 @@ floatms_t getInjectorLag(float vBatt DECLARE_ENGINE_PARAMETER_SUFFIX) { */ void initFuelMap(DECLARE_ENGINE_PARAMETER_SIGNATURE) { fuelMap.init(config->fuelTable, config->fuelLoadBins, config->fuelRpmBins); +#if (IGN_LOAD_COUNT == FUEL_LOAD_COUNT) && (IGN_RPM_COUNT == FUEL_RPM_COUNT) fuelPhaseMap.init(config->injectionPhase, config->injPhaseLoadBins, config->injPhaseRpmBins); +#endif /* (IGN_LOAD_COUNT == FUEL_LOAD_COUNT) && (IGN_RPM_COUNT == FUEL_RPM_COUNT) */ } /** diff --git a/firmware/controllers/algo/rusefi_types.h b/firmware/controllers/algo/rusefi_types.h index 58ab3ea814..0ec8d764ae 100644 --- a/firmware/controllers/algo/rusefi_types.h +++ b/firmware/controllers/algo/rusefi_types.h @@ -23,6 +23,9 @@ typedef unsigned int time_t; #include "firing_order.h" #include "rusefi_generated.h" +#define DEFAULT_FUEL_LOAD_COUNT 16 +#define DEFAULT_IGN_LOAD_COUNT 16 + // time in seconds typedef time_t efitimesec_t;