From 8998e3abaedd9bd87962a70cb773ab659b0675d7 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 26 Dec 2019 21:33:12 -0500 Subject: [PATCH 1/4] laughable gdi progress --- .../controllers/algo/auto_generated_enums.cpp | 2 ++ firmware/config/engines/engines.mk | 1 + firmware/config/engines/vw.cpp | 2 +- firmware/config/engines/vw.h | 7 ++----- firmware/config/engines/vw_b6.cpp | 19 +++++++++++++++++++ firmware/config/engines/vw_b6.h | 10 ++++++++++ .../controllers/algo/auto_generated_enums.cpp | 2 ++ .../controllers/algo/engine_configuration.cpp | 1 + firmware/controllers/algo/rusefi_enums.h | 2 ++ 9 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 firmware/config/engines/vw_b6.cpp create mode 100644 firmware/config/engines/vw_b6.h diff --git a/firmware/config/boards/kinetis/config/controllers/algo/auto_generated_enums.cpp b/firmware/config/boards/kinetis/config/controllers/algo/auto_generated_enums.cpp index 1ee2fa9a3b..14ee7f8858 100644 --- a/firmware/config/boards/kinetis/config/controllers/algo/auto_generated_enums.cpp +++ b/firmware/config/boards/kinetis/config/controllers/algo/auto_generated_enums.cpp @@ -659,6 +659,8 @@ case TOYOTA_JZS147: return "TOYOTA_JZS147"; case VAG_18_TURBO: return "VAG_18_TURBO"; +case VW_B6: + return "VW_B6"; case VW_ABA: return "VW_ABA"; case ZIL_130: diff --git a/firmware/config/engines/engines.mk b/firmware/config/engines/engines.mk index 3801df7aed..6352602767 100644 --- a/firmware/config/engines/engines.mk +++ b/firmware/config/engines/engines.mk @@ -27,6 +27,7 @@ ENGINES_SRC_CPP = $(PROJECT_DIR)/config/engines/ford_aspire.cpp \ $(PROJECT_DIR)/config/engines/mitsubishi.cpp \ $(PROJECT_DIR)/config/engines/dodge_ram.cpp \ $(PROJECT_DIR)/config/engines/vw.cpp \ + $(PROJECT_DIR)/config/engines/vw_b6.cpp \ $(PROJECT_DIR)/config/engines/dodge_stratus.cpp \ $(PROJECT_DIR)/config/engines/chevrolet_camaro_4.cpp \ $(PROJECT_DIR)/config/engines/suzuki_vitara.cpp \ diff --git a/firmware/config/engines/vw.cpp b/firmware/config/engines/vw.cpp index 259b20f35f..968487ef8f 100644 --- a/firmware/config/engines/vw.cpp +++ b/firmware/config/engines/vw.cpp @@ -4,7 +4,7 @@ * set engine_type 32 * * @date May 24, 2015 - * @author Andrey Belomutskiy, (c) 2012-2018 + * @author Andrey Belomutskiy, (c) 2012-2019 */ #include "global.h" diff --git a/firmware/config/engines/vw.h b/firmware/config/engines/vw.h index c419b0ea95..d8528faf64 100644 --- a/firmware/config/engines/vw.h +++ b/firmware/config/engines/vw.h @@ -2,14 +2,11 @@ * @file vw.h * * @date May 24, 2015 - * @author Andrey Belomutskiy, (c) 2012-2017 + * @author Andrey Belomutskiy, (c) 2012-2019 */ -#ifndef CONFIG_ENGINES_VW_H_ -#define CONFIG_ENGINES_VW_H_ +#pragma once #include "engine_configuration.h" void setVwAba(DECLARE_CONFIG_PARAMETER_SIGNATURE); - -#endif /* CONFIG_ENGINES_VW_H_ */ diff --git a/firmware/config/engines/vw_b6.cpp b/firmware/config/engines/vw_b6.cpp new file mode 100644 index 0000000000..813a550586 --- /dev/null +++ b/firmware/config/engines/vw_b6.cpp @@ -0,0 +1,19 @@ +/* + * @file vw_b6.cpp + * + * @date Dec 26, 2019 + * @author Andrey Belomutskiy, (c) 2012-2019 + */ + +#include "engine.h" +#include "vw_b6.h" + +EXTERN_CONFIG; + +/** + * set engine_type 62 + */ + + + + diff --git a/firmware/config/engines/vw_b6.h b/firmware/config/engines/vw_b6.h new file mode 100644 index 0000000000..b679aa10a1 --- /dev/null +++ b/firmware/config/engines/vw_b6.h @@ -0,0 +1,10 @@ +/* + * @file vw_b6.h + * + * @date Dec 26, 2019 + * @author Andrey Belomutskiy, (c) 2012-2019 + */ + +#pragma once + +void setVwPassatB6(DECLARE_CONFIG_PARAMETER_SIGNATURE); diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index 8cffe770b9..faf4d88f64 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -803,6 +803,8 @@ case TOYOTA_JZS147: return "TOYOTA_JZS147"; case VAG_18_TURBO: return "VAG_18_TURBO"; +case VW_B6: + return "VW_B6"; case VW_ABA: return "VW_ABA"; case ZIL_130: diff --git a/firmware/controllers/algo/engine_configuration.cpp b/firmware/controllers/algo/engine_configuration.cpp index e26c18c861..f176831f3f 100644 --- a/firmware/controllers/algo/engine_configuration.cpp +++ b/firmware/controllers/algo/engine_configuration.cpp @@ -66,6 +66,7 @@ #include "test_engine.h" #include "sachs.h" #include "vw.h" +#include "vw_b6.h" #include "daihatsu.h" #include "chevrolet_camaro_4.h" #include "suzuki_vitara.h" diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index a9a94ada4d..07f1fde8cf 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -181,6 +181,8 @@ typedef enum { PROTEUS = 61, + VW_B6 = 62, + /** * this configuration has as few pins configured as possible */ From d03135aa134f45af18475cecf2d4dd3d71e7c478 Mon Sep 17 00:00:00 2001 From: rusefi Date: Thu, 26 Dec 2019 22:29:04 -0500 Subject: [PATCH 2/4] would URLs work? --- firmware/hw_layer/mc33816/mc33816.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 firmware/hw_layer/mc33816/mc33816.md diff --git a/firmware/hw_layer/mc33816/mc33816.md b/firmware/hw_layer/mc33816/mc33816.md new file mode 100644 index 0000000000..ed604ed4e0 --- /dev/null +++ b/firmware/hw_layer/mc33816/mc33816.md @@ -0,0 +1,4 @@ + +https://www.nxp.com/files-static/training_pdf/FTF/2012/americas/WBNR_FTF12_AUT_F0098.pdf has many cool pictures explaining the whole thing. + +https://www.nxp.com/docs/en/application-note/AN4849.pdf is literaly a complete example of a four cylinder internal combustion engine (ICE) injector drive. \ No newline at end of file From 75d94171315c836279350cabe20a1154fee11c94 Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 14 Feb 2020 00:37:36 -0500 Subject: [PATCH 3/4] miata vvt trigger decoding is broken #1145 --- .../trigger/decoders/trigger_mazda.cpp | 2 + unit_tests/tests/test_symmetrical_crank.cpp | 67 +++++++++++++++++++ unit_tests/tests/tests.mk | 1 + 3 files changed, 70 insertions(+) create mode 100644 unit_tests/tests/test_symmetrical_crank.cpp diff --git a/firmware/controllers/trigger/decoders/trigger_mazda.cpp b/firmware/controllers/trigger/decoders/trigger_mazda.cpp index 9a4f48dfa6..7356d38ec4 100644 --- a/firmware/controllers/trigger/decoders/trigger_mazda.cpp +++ b/firmware/controllers/trigger/decoders/trigger_mazda.cpp @@ -95,7 +95,9 @@ void initializeMazdaMiataNb2Crank(TriggerWaveform *s) { s->tdcPosition = 60 + 655; s->setTriggerSynchronizationGap2(0.35f, 0.98f); + // 384 s->addEvent720(o + 4 * 56.0f, T_PRIMARY, TV_FALL); + // 400 s->addEvent720(o + 4 * 60.0f, T_PRIMARY, TV_RISE); s->addEvent720(o + 4 * 136.0f, T_PRIMARY, TV_FALL); s->addEvent720(o + 4 * 140.0f, T_PRIMARY, TV_RISE); diff --git a/unit_tests/tests/test_symmetrical_crank.cpp b/unit_tests/tests/test_symmetrical_crank.cpp new file mode 100644 index 0000000000..26c49ff9ce --- /dev/null +++ b/unit_tests/tests/test_symmetrical_crank.cpp @@ -0,0 +1,67 @@ +/* + * @file test_symmetrical_crank.cpp + * + * @date Feb 14, 2020 + * @author Andrey Belomutskiy, (c) 2012-2020 + */ + +#include "engine_test_helper.h" + +TEST(engine, testSymmetricalCrank) { + + WITH_ENGINE_TEST_HELPER(MAZDA_MIATA_2003); + + float x = 0.02; + + ASSERT_EQ( 0, GET_RPM()) << "RPM#0"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 0, GET_RPM()) << "RPM#1"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 0, GET_RPM()) << "RPM#2"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + ASSERT_EQ( 549, GET_RPM()) << "RPM#2.5"; + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 549, GET_RPM()) << "RPM#3"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 549, GET_RPM()) << "RPM#4"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 549, GET_RPM()) << "RPM#5"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 549, GET_RPM()) << "RPM#6"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 374, GET_RPM()) << "RPM#7"; + + eth.fireFall(x * 384); + eth.fireRise(x * 16); + eth.fireFall(x * 304); + eth.fireRise(x * 16); + ASSERT_EQ( 374, GET_RPM()) << "RPM#8"; + +} diff --git a/unit_tests/tests/tests.mk b/unit_tests/tests/tests.mk index f3f3b35a19..61e1d94923 100644 --- a/unit_tests/tests/tests.mk +++ b/unit_tests/tests/tests.mk @@ -11,6 +11,7 @@ TESTS_SRC_CPP = \ tests/test_miata_na6_real_cranking.cpp \ tests/test_fasterEngineSpinningUp.cpp \ tests/test_dwell_corner_case_issue_796.cpp \ + tests/test_symmetrical_crank.cpp \ tests/test_idle_controller.cpp \ tests/test_trigger_decoder.cpp \ tests/test_trigger_noiseless.cpp \ From 97900525965372cdd8edfb939bfe426764025d26 Mon Sep 17 00:00:00 2001 From: rusefi Date: Fri, 14 Feb 2020 09:33:29 -0500 Subject: [PATCH 4/4] miata vvt trigger decoding is broken #1145 --- unit_tests/tests/test_symmetrical_crank.cpp | 67 +++++++-------------- 1 file changed, 21 insertions(+), 46 deletions(-) diff --git a/unit_tests/tests/test_symmetrical_crank.cpp b/unit_tests/tests/test_symmetrical_crank.cpp index 26c49ff9ce..6135694e35 100644 --- a/unit_tests/tests/test_symmetrical_crank.cpp +++ b/unit_tests/tests/test_symmetrical_crank.cpp @@ -7,61 +7,36 @@ #include "engine_test_helper.h" +static void postFourEvents(EngineTestHelper *eth, float mult) { + eth->fireFall(mult * 384); + eth->fireRise(mult * 16); + eth->fireFall(mult * 304); + eth->fireRise(mult * 16); +} + TEST(engine, testSymmetricalCrank) { WITH_ENGINE_TEST_HELPER(MAZDA_MIATA_2003); + // this test is not about isFasterEngineSpinUpEnabled so let's disable it to simplify things + CONFIG(isFasterEngineSpinUpEnabled) = false; + float x = 0.02; ASSERT_EQ( 0, GET_RPM()) << "RPM#0"; - eth.fireFall(x * 384); - eth.fireRise(x * 16); - eth.fireFall(x * 304); - eth.fireRise(x * 16); - ASSERT_EQ( 0, GET_RPM()) << "RPM#1"; + for (int i = 0; i < 8 ; i++) { + postFourEvents(ð, x); + ASSERT_EQ( 0, GET_RPM()) << "RPM#0"; + } - eth.fireFall(x * 384); - eth.fireRise(x * 16); - eth.fireFall(x * 304); - eth.fireRise(x * 16); - ASSERT_EQ( 0, GET_RPM()) << "RPM#2"; + x = 0.1; + postFourEvents(ð, x); + ASSERT_EQ( 1041, GET_RPM()) << "RPM#11"; - eth.fireFall(x * 384); - eth.fireRise(x * 16); - ASSERT_EQ( 549, GET_RPM()) << "RPM#2.5"; - eth.fireFall(x * 304); - eth.fireRise(x * 16); - ASSERT_EQ( 549, GET_RPM()) << "RPM#3"; - - eth.fireFall(x * 384); - eth.fireRise(x * 16); - eth.fireFall(x * 304); - eth.fireRise(x * 16); - ASSERT_EQ( 549, GET_RPM()) << "RPM#4"; - - eth.fireFall(x * 384); - eth.fireRise(x * 16); - eth.fireFall(x * 304); - eth.fireRise(x * 16); - ASSERT_EQ( 549, GET_RPM()) << "RPM#5"; - - eth.fireFall(x * 384); - eth.fireRise(x * 16); - eth.fireFall(x * 304); - eth.fireRise(x * 16); - ASSERT_EQ( 549, GET_RPM()) << "RPM#6"; - - eth.fireFall(x * 384); - eth.fireRise(x * 16); - eth.fireFall(x * 304); - eth.fireRise(x * 16); - ASSERT_EQ( 374, GET_RPM()) << "RPM#7"; - - eth.fireFall(x * 384); - eth.fireRise(x * 16); - eth.fireFall(x * 304); - eth.fireRise(x * 16); - ASSERT_EQ( 374, GET_RPM()) << "RPM#8"; + postFourEvents(ð, x); + ASSERT_EQ( 1041, GET_RPM()) << "RPM#11"; + postFourEvents(ð, x); + ASSERT_EQ( 1041, GET_RPM()) << "RPM#11"; }