diff --git a/firmware/config/engines/mazda_miata_1_6.cpp b/firmware/config/engines/mazda_miata_1_6.cpp index 0691f4433d..4e1ddb9609 100644 --- a/firmware/config/engines/mazda_miata_1_6.cpp +++ b/firmware/config/engines/mazda_miata_1_6.cpp @@ -39,6 +39,46 @@ static void setCrankingFuelBins(DECLARE_CONFIG_PARAMETER_SIGNATURE) { MEMCPY(config->crankingFuelCoef, hardCodedcrankingFuelCoef); } +static const float hardCodedmafDecodingBins[256] = {0.099999905, 0.19999981, 0.29999924, 0.39999962, 0.5, 0.5999985, 0.70000076, 0.79999924, 0.9000015, 1.0, 1.0999985, 1.199997, 1.300003, 1.4000015, 1.5, 1.5999985, 1.699997, 1.800003, 1.9000015, 2.0, 2.100006, 2.2000122, 2.2999878, 2.399994, 2.5, 2.600006, 2.7000122, 2.7999878, 2.899994, 3.0, 3.100006, 3.2000122, 3.2999878, 3.399994, 3.5, 3.600006, 3.7000122, 3.7999878, 3.899994, 4.0, 4.0999756, 4.200012, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988, 4.299988}; + +static const float hardCodedmafDecoding[256] = {570.0, 437.0, 351.5, 293.55078, 237.0, 186.0, 145.0, 116.0, 96.0, 78.84961, 65.549805, 56.049805, 48.0, 40.0, 33.25, 29.449951, 25.649902, 22.800049, 20.899902, 19.0, 17.100098, 16.149902, 13.775024, 12.824951, 11.400024, 10.449951, 9.5, 8.550049, 8.454956, 8.359985, 8.300049, 8.199951, 7.5999756, 7.125, 7.125, 7.125, 6.6500244, 6.6500244, 6.6500244, 6.6500244, 6.6500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 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; + +/* Generated by TS2C on Fri Jul 31 14:02:18 EDT 2020*/ +static void setMafDecodingBins(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + MEMCPY(config->mafDecodingBins, hardCodedmafDecodingBins); + MEMCPY(config->mafDecoding, hardCodedmafDecoding); +} + +static const float hardCodediacCoastingBins[16] = {-40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}; + +static const float hardCodediacCoasting[16] = {-40.0, -30.0, -20.0, -10.0, 0.0, 10.0, 20.0, 30.0, 40.0, 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 110.0}; + +/* Generated by TS2C on Fri Jul 31 14:02:18 EDT 2020*/ +static void setIacCoastingBins(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + MEMCPY(config->iacCoastingBins, hardCodediacCoastingBins); + MEMCPY(config->iacCoasting, hardCodediacCoasting); +} + +static const float hardCodedcltIdleCorrBins[16] = {-40.0, -30.0, -20.0, -10.0, 0.0, 9.439941, 19.120117, 30.810059, 42.509766, 54.529785, 64.21973, 71.90039, 80.0, 90.0, 100.0, 110.0}; + +static const float hardCodedcltIdleCorr[16] = {-40.0, -30.0, -20.0, -10.0, 0.0, 9.439941, 19.120117, 30.810059, 42.509766, 54.529785, 64.21973, 71.90039, 80.0, 90.0, 100.0, 110.0}; + +/* Generated by TS2C on Fri Jul 31 14:02:18 EDT 2020*/ +static void setCltIdleCorrBins(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + MEMCPY(config->cltIdleCorrBins, hardCodedcltIdleCorrBins); + MEMCPY(config->cltIdleCorr, hardCodedcltIdleCorr); +} + +static const float hardCodedcltIdleRpmBins[16] = {-40.0, -30.0, -20.0, 0.0, 10.0, 20.0, 30.0, 40.0, 60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 130.0, 140.0}; + +static const float hardCodedcltIdleRpm[16] = {-40.0, -30.0, -20.0, 0.0, 10.0, 20.0, 30.0, 40.0, 60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 130.0, 140.0}; + +/* Generated by TS2C on Fri Jul 31 14:02:18 EDT 2020*/ +static void setCltIdleRpmBins(DECLARE_CONFIG_PARAMETER_SIGNATURE) { + MEMCPY(config->cltIdleRpmBins, hardCodedcltIdleRpmBins); + MEMCPY(config->cltIdleRpm, hardCodedcltIdleRpm); +} + static const float ve16RpmBins[FUEL_RPM_COUNT] = { 650.0,1100.0,1550.0,2000.0, @@ -135,6 +175,11 @@ static void miataNAcommonEngineSettings(DECLARE_CONFIG_PARAMETER_SIGNATURE) { setCrankingCycleBins(PASS_CONFIG_PARAMETER_SIGNATURE); setCrankingFuelBins(PASS_CONFIG_PARAMETER_SIGNATURE); + setCltIdleCorrBins(PASS_CONFIG_PARAMETER_SIGNATURE); + setCltIdleRpmBins(PASS_CONFIG_PARAMETER_SIGNATURE); + setIacCoastingBins(PASS_CONFIG_PARAMETER_SIGNATURE); + setMafDecodingBins(PASS_CONFIG_PARAMETER_SIGNATURE); + engineConfiguration->idle.solenoidFrequency = 160; engineConfiguration->ignitionMode = IM_WASTED_SPARK; } @@ -392,17 +437,22 @@ void setMiataNA6_MAP_MRE(DECLARE_CONFIG_PARAMETER_SIGNATURE) { engineConfiguration->isVerboseIAC = true; - engineConfiguration->idleRpmPid.minValue = 20; engineConfiguration->idleRpmPid.pFactor = 0.01; engineConfiguration->idleRpmPid.iFactor = 0.02; + engineConfiguration->idle_antiwindupFreq = 0.1; + engineConfiguration->idle_derivativeFilterLoss = 0.1; engineConfiguration->idleRpmPid.dFactor = 0.002; engineConfiguration->idleRpmPid.offset = 37; + engineConfiguration->acIdleExtraOffset = 14; + engineConfiguration->idleRpmPid.minValue = 30; + engineConfiguration->acIdleExtraMin = 14; + engineConfiguration->idleRpmPid.minValue = 70; engineConfiguration->idleRpmPid.periodMs = 40; engineConfiguration->idlerpmpid_iTermMin = -6; engineConfiguration->idlerpmpid_iTermMax = 30; engineConfiguration->pidExtraForLowRpm = 25; engineConfiguration->idlePidRpmDeadZone = 25; - engineConfiguration->idlePidRpmUpperLimit = 100; + engineConfiguration->idlePidRpmUpperLimit = 1000; engineConfiguration->useFSIO12ForIdleOffset = true; diff --git a/java_console/models/src/main/java/com/rusefi/tools/tune/TS2C.java b/java_console/models/src/main/java/com/rusefi/tools/tune/TS2C.java index 227f602544..5e5fdca015 100644 --- a/java_console/models/src/main/java/com/rusefi/tools/tune/TS2C.java +++ b/java_console/models/src/main/java/com/rusefi/tools/tune/TS2C.java @@ -31,9 +31,9 @@ public class TS2C { private TS2C(String[] args) throws IOException { System.out.println("This tool reads TS tune file and produces some C code for hardcoded base tunes"); - if (args.length != 4 && args.length != 5) { - System.out.println("Four parameters expected: "); - System.out.println(" INPUT_MSQ_FILE NAME LOAD_SECTION_NAME RPM_SECTION_NAME TABLE_NAME"); + if (args.length != 3 && args.length != 4 && args.length != 5) { + System.out.println("Three parameters expected: "); + System.out.println(" INPUT_MSQ_FILE NAME LOAD_SECTION_NAME RPM_SECTION_NAME [TABLE_NAME]"); System.out.println("for example"); // section names are needed in order to generate comments about cell content System.out.println(" currenttune.msq veLoadBins veRpmBins veTable"); @@ -42,7 +42,7 @@ public class TS2C { String msqFileName = args[0]; String loadSectionName = args[1]; String rpmSectionName = args[2]; - String tableName = args[3]; + String tableName = args.length == 3 ? "none" : args[3]; IniFileModel model = IniFileModel.getInstance(); diff --git a/java_console/models/src/main/java/com/rusefi/tools/tune/TS2CRunner.java b/java_console/models/src/main/java/com/rusefi/tools/tune/TS2CRunner.java index d6a1af4ea9..f14372f5a8 100644 --- a/java_console/models/src/main/java/com/rusefi/tools/tune/TS2CRunner.java +++ b/java_console/models/src/main/java/com/rusefi/tools/tune/TS2CRunner.java @@ -8,10 +8,14 @@ public class TS2CRunner { - TS2C.main(new String[]{tuneFileName, "mafDecodingBins", "mafDecoding", "none"}); + TS2C.main(new String[]{tuneFileName, "mafDecodingBins", "mafDecoding"}); + TS2C.main(new String[]{tuneFileName, "cltIdleRpmBins", "cltIdleRpm"}); + TS2C.main(new String[]{tuneFileName, "cltIdleCorrBins", "cltIdleCorr"}); - TS2C.main(new String[]{tuneFileName, "crankingCycleBins", "crankingCycleCoef", "none"}); - TS2C.main(new String[]{tuneFileName, "crankingFuelBins", "crankingFuelCoef", "none"}); + TS2C.main(new String[]{tuneFileName, "crankingCycleBins", "crankingCycleCoef"}); + TS2C.main(new String[]{tuneFileName, "crankingFuelBins", "crankingFuelCoef"}); + + TS2C.main(new String[]{tuneFileName, "iacCoastingBins", "iacCoasting"}); // TS2C.main(new String[]{tuneFileName, "afrLoadBins", "afrRpmBins", "afrTable"}); // TS2C.main(new String[]{tuneFileName, "fuelLoadBins", "fuelRpmBins", "fuelTable"});