From b650bbe46c420dbada44b7066eaf661ef1545c31 Mon Sep 17 00:00:00 2001 From: Matthew Kennedy Date: Fri, 6 May 2022 05:25:44 -0700 Subject: [PATCH] Trigger gm 3 vs 5 (#4140) * add parameter * two modes * add new mode to list * format * s Co-authored-by: Matthew Kennedy --- .../config/engines/chevrolet_camaro_4.cpp | 2 +- firmware/controllers/algo/engine_types.h | 10 +++-- .../trigger/decoders/trigger_gm.cpp | 38 ++++++++++++++----- .../controllers/trigger/decoders/trigger_gm.h | 3 +- .../trigger/decoders/trigger_structure.cpp | 8 +++- .../trigger/decoders/triggers-meta.yaml | 5 ++- firmware/integration/rusefi_config.txt | 2 +- .../java/com/rusefi/trigger/TriggerImage.java | 4 +- unit_tests/tests/trigger/test_real_gm_24x.cpp | 4 +- 9 files changed, 54 insertions(+), 22 deletions(-) diff --git a/firmware/config/engines/chevrolet_camaro_4.cpp b/firmware/config/engines/chevrolet_camaro_4.cpp index 56a0b1e937..45f1b1ce11 100644 --- a/firmware/config/engines/chevrolet_camaro_4.cpp +++ b/firmware/config/engines/chevrolet_camaro_4.cpp @@ -33,7 +33,7 @@ void setCamaro4() { engineConfiguration->ignitionMode = IM_WASTED_SPARK; setCrankOperationMode(); - engineConfiguration->trigger.type = TT_GM_LS_24; + engineConfiguration->trigger.type = TT_GM_24x; engineConfiguration->map.sensor.hwChannel = EFI_ADC_0; // PA0 diff --git a/firmware/controllers/algo/engine_types.h b/firmware/controllers/algo/engine_types.h index bd00c35fee..be87433e07 100644 --- a/firmware/controllers/algo/engine_types.h +++ b/firmware/controllers/algo/engine_types.h @@ -389,8 +389,6 @@ typedef enum { TT_ROVER_K = 26, - TT_GM_LS_24 = 27, - TT_HONDA_CBR_600 = 28, TT_2JZ_1_12 = 29, @@ -519,13 +517,19 @@ typedef enum { TT_VVT_TOYOTA_4_1 = 73, + // GM 24x with 5/10 degree gaps + TT_GM_24x = 27, + + // GM 24x with 3/12 degree gaps + TT_GM_24x_2 = 74, + // do not forget to edit "#define trigger_type_e_enum" line in integration/rusefi_config.txt file to propogate new value to rusefi.ini TS project // do not forget to invoke "gen_config.bat" once you make changes to integration/rusefi_config.txt // todo: one day a hero would integrate some of these things into Makefile in order to reduce manual magic // // Another point: once you add a new trigger, run get_trigger_images.bat which would run rusefi_test.exe from unit_tests // - TT_UNUSED = 74, // this is used if we want to iterate over all trigger types + TT_UNUSED = 75, // this is used if we want to iterate over all trigger types // java code generator handles this value in a special way // also looks like 2 enums are either 1 byte or 4 bytes diff --git a/firmware/controllers/trigger/decoders/trigger_gm.cpp b/firmware/controllers/trigger/decoders/trigger_gm.cpp index a30781ad8e..6eedb9c21b 100644 --- a/firmware/controllers/trigger/decoders/trigger_gm.cpp +++ b/firmware/controllers/trigger/decoders/trigger_gm.cpp @@ -89,9 +89,9 @@ void configureGmTriggerWaveform(TriggerWaveform *s) { s->setTriggerSynchronizationGap(6); } -static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerWaveform* s, int mult) +static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerWaveform* s, int mult, float shortToothWidth) { - int window = (isShortLong ? 5 : 10) * mult; + int window = (isShortLong ? shortToothWidth : (15 - shortToothWidth)) * mult; int end = startAngle + mult * 15; s->addEvent720(startAngle + window, T_PRIMARY, TV_RISE); @@ -101,7 +101,7 @@ static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerWaveform* s, } /** - * TT_GM_LS_24 + * TT_GM_24x and TT_GM_24x_2 * https://www.mediafire.com/?40mfgeoe4ctti * http://www.ls1gto.com/forums/archive/index.php/t-190549.htm * http://www.ls2.com/forums/showthread.php/834483-LS-Timing-Reluctor-Wheels-Explained @@ -109,7 +109,7 @@ static int gm_tooth_pair(float startAngle, bool isShortLong, TriggerWaveform* s, * * based on data in https://rusefi.com/forum/viewtopic.php?f=3&t=936&p=30303#p30285 */ -void initGmLS24(TriggerWaveform *s) { +static void initGmLS24(TriggerWaveform *s, float shortToothWidth) { s->initialize(FOUR_STROKE_CRANK_SENSOR); /* @@ -121,14 +121,15 @@ void initGmLS24(TriggerWaveform *s) { * encodes the pattern of which type of gap occurs in the * pattern. Starting from the LSB, each bit left is the * next gap in sequence as the crank turns. A 0 indicates - * long-short, while a 1 indicates short-long. + * long-short (late rising edge), while a 1 indicates + * short-long (early rising edge). * * The first few bits read are 0xE (LSB first!) = 0 - 1 - 1 - 1, so the pattern * looks like this: - * ___ _ ___ ___ ___ - * |___| |_| |_| |_| |_ etc + * ___ _ ___ ___ _ + * |___| |_| |_| |___| |_ etc * - * | 0 | 1 | 1 | 1 | + * | 0 | 1 | 1 | 0 | * * ___ = 10 degrees, _ = 5 deg * @@ -148,15 +149,32 @@ void initGmLS24(TriggerWaveform *s) { bool bit = code & 0x000001; code = code >> 1; - angle = gm_tooth_pair(angle, bit, s, CRANK_MODE_MULTIPLIER); + angle = gm_tooth_pair(angle, bit, s, CRANK_MODE_MULTIPLIER, shortToothWidth); } - s->tdcPosition = 50; s->useOnlyPrimaryForSync = true; +} + +// TT_GM_24x +void initGmLS24_5deg(TriggerWaveform *s) { + initGmLS24(s, 5); // This is tooth #20, at 310 degrees ATDC #1 s->setTriggerSynchronizationGap(2.0f); s->setSecondTriggerSynchronizationGap(0.5f); s->setThirdTriggerSynchronizationGap(2.0f); + + s->tdcPosition = 50; } +// TT_GM_24x_2 +void initGmLS24_3deg(TriggerWaveform *s) { + initGmLS24(s, 3); + + // This is tooth #20, at 312 degrees ATDC #1 + s->setTriggerSynchronizationGap(4.0f); + s->setSecondTriggerSynchronizationGap(0.25f); + s->setThirdTriggerSynchronizationGap(4.0f); + + s->tdcPosition = 48; +} diff --git a/firmware/controllers/trigger/decoders/trigger_gm.h b/firmware/controllers/trigger/decoders/trigger_gm.h index 056e040899..36021678b9 100644 --- a/firmware/controllers/trigger/decoders/trigger_gm.h +++ b/firmware/controllers/trigger/decoders/trigger_gm.h @@ -11,4 +11,5 @@ class TriggerWaveform; void configureGm60_2_2_2(TriggerWaveform *s); void configureGmTriggerWaveform(TriggerWaveform *s); -void initGmLS24(TriggerWaveform *s); +void initGmLS24_5deg(TriggerWaveform *s); +void initGmLS24_3deg(TriggerWaveform *s); diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 0f0f8d2b66..3111478ec8 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -746,8 +746,12 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e triggerOperatio configureTriTach(this); break; - case TT_GM_LS_24: - initGmLS24(this); + case TT_GM_24x: + initGmLS24_5deg(this); + break; + + case TT_GM_24x_2: + initGmLS24_3deg(this); break; case TT_SUBARU_7_WITHOUT_6: diff --git a/firmware/controllers/trigger/decoders/triggers-meta.yaml b/firmware/controllers/trigger/decoders/triggers-meta.yaml index 0078d74857..8fdc1b2ea2 100644 --- a/firmware/controllers/trigger/decoders/triggers-meta.yaml +++ b/firmware/controllers/trigger/decoders/triggers-meta.yaml @@ -1,7 +1,10 @@ # this file is consumed by TriggerProcessor.java during the gen_config.sh code generation phase triggers: - - name: TT_GM_LS_24 + - name: TT_GM_24x + isFirstCrankBased: true + + - name: TT_GM_24x_2 isFirstCrankBased: true - name: TT_HONDA_K_12_1 diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 4c55002898..5692c66ccd 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -579,7 +579,7 @@ adc_channel_e fuelLevelSensor;+This is the processor pin that your fuel level se struct trigger_config_s @brief Trigger wheel(s) configuration -#define trigger_type_e_enum "custom toothed wheel", "Ford Aspire", "Dodge Neon 1995", "Miata NA", "INVALID", "GM_7X", "Cooper R50", "Mazda SOHC 4", "60/2", "36/1", "Mercedes Two Segment", "Mitsubishi 4G93", "Honda 4+24", "Honda 1+4+24", "Dodge Neon 2003", "Mazda DOHC 1+4", "1+1", "INVALID", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Honda 1+24", "Dodge Stratus", "36_2_2_2", "Nissan Primera", "dev 2JZ 3/34 simulator", "Rover K", "GM LS 24", "Honda CBR 600", "2JZ_1_12", "Honda CBR 600 custom", "3/1 skipped", "Dodge Neon 2003 crank", "Miata NB", "INVALID", "INVALID", "Subaru 7+6", "Jeep 18-2-2-2", "WIP", "Dodge Neon 1995 crank only", "Jeep XJ 4 cyl", "FiatIAQ_P8", "Mazda Z5", "INVALID", "Renix 44-2-2", "Renix 66-2-2-2", "Honda K 12+1", "INVALID", "36/2", "Subaru SVX", "1+16", "Subaru 7 without 6", "INVALID", "TriTach", "GM 60/2/2/2", "Skoda Favorit", "Barra 3+1 Cam", "Kawa KX450F", "Nissan VQ35", "INVALID", "Nissan VQ30", "Nissan QR25", "Mitsubishi 3A92", "Subaru SVX Crank 1", "Subaru SVX Cam VVT", "Ford PIP", "Suzuki G13B", "Honda K 4+1", "Nissan MR18 Crank", "32/2", "36-2-1", "36-2-1-1", "trg72" +#define trigger_type_e_enum "custom toothed wheel", "Ford Aspire", "Dodge Neon 1995", "Miata NA", "INVALID", "GM_7X", "Cooper R50", "Mazda SOHC 4", "60/2", "36/1", "Mercedes Two Segment", "Mitsubishi 4G93", "Honda 4+24", "Honda 1+4+24", "Dodge Neon 2003", "Mazda DOHC 1+4", "1+1", "INVALID", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Honda 1+24", "Dodge Stratus", "36_2_2_2", "Nissan Primera", "dev 2JZ 3/34 simulator", "Rover K", "GM 24x 5 degree", "Honda CBR 600", "2JZ_1_12", "Honda CBR 600 custom", "3/1 skipped", "Dodge Neon 2003 crank", "Miata NB", "INVALID", "INVALID", "Subaru 7+6", "Jeep 18-2-2-2", "WIP", "Dodge Neon 1995 crank only", "Jeep XJ 4 cyl", "FiatIAQ_P8", "Mazda Z5", "INVALID", "Renix 44-2-2", "Renix 66-2-2-2", "Honda K 12+1", "INVALID", "36/2", "Subaru SVX", "1+16", "Subaru 7 without 6", "INVALID", "TriTach", "GM 60/2/2/2", "Skoda Favorit", "Barra 3+1 Cam", "Kawa KX450F", "Nissan VQ35", "INVALID", "Nissan VQ30", "Nissan QR25", "Mitsubishi 3A92", "Subaru SVX Crank 1", "Subaru SVX Cam VVT", "Ford PIP", "Suzuki G13B", "Honda K 4+1", "Nissan MR18 Crank", "32/2", "36-2-1", "36-2-1-1", "INVALID", "INVALID", "GM 24x 3 degree", "trg75" custom trigger_type_e 4 bits, U32, @OFFSET@, [0:6], @@trigger_type_e_enum@@ trigger_type_e type;+https://github.com/rusefi/rusefi/wiki/All-Supported-Triggers\nset trigger_type X diff --git a/java_console/ui/src/main/java/com/rusefi/trigger/TriggerImage.java b/java_console/ui/src/main/java/com/rusefi/trigger/TriggerImage.java index 9a284fd84d..49d4504c64 100644 --- a/java_console/ui/src/main/java/com/rusefi/trigger/TriggerImage.java +++ b/java_console/ui/src/main/java/com/rusefi/trigger/TriggerImage.java @@ -61,8 +61,10 @@ public class TriggerImage { return "Honda 1+24"; case TT_SUBARU_7_6: return "Subaru 7/6"; - case TT_GM_LS_24: + case TT_GM_24x: return "GM 24x"; + case TT_GM_24x_2: + return "GM 24x 2"; case TT_SKODA_FAVORIT: return "Skoda Favorit"; case TT_GM_7X: diff --git a/unit_tests/tests/trigger/test_real_gm_24x.cpp b/unit_tests/tests/trigger/test_real_gm_24x.cpp index 912bf0b8ef..6e530074a9 100644 --- a/unit_tests/tests/trigger/test_real_gm_24x.cpp +++ b/unit_tests/tests/trigger/test_real_gm_24x.cpp @@ -10,7 +10,7 @@ TEST(crankingGm24x, gmRealCrankingFromFile) { EngineTestHelper eth(TEST_ENGINE); engineConfiguration->isFasterEngineSpinUpEnabled = true; - eth.setTriggerType(TT_GM_LS_24); + eth.setTriggerType(TT_GM_24x); while (reader.haveMore()) { reader.processLine(ð); @@ -20,4 +20,4 @@ TEST(crankingGm24x, gmRealCrankingFromFile) { ASSERT_EQ( 0, eth.recentWarnings()->getCount())<< "warningCounter#vwRealCranking"; ASSERT_EQ( 128, round(Sensor::getOrZero(SensorType::Rpm)))<< reader.lineIndex(); -} \ No newline at end of file +}