diff --git a/firmware/controllers/algo/engine_types.h b/firmware/controllers/algo/engine_types.h index 101db5b89f..37dcc74b53 100644 --- a/firmware/controllers/algo/engine_types.h +++ b/firmware/controllers/algo/engine_types.h @@ -515,13 +515,15 @@ typedef enum { TT_HONDA_K_4_1 = 67, + TT_NISSAN_MR18_CRANK = 68, + // 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 = 68, // this is used if we want to iterate over all trigger types + TT_UNUSED = 69, // this is used if we want to iterate over all trigger types // todo: convert to ENUM_16_BITS? I can see 257 triggers but not 65K triggers Force_4_bytes_size_trigger_type = ENUM_32_BITS, diff --git a/firmware/controllers/trigger/decoders/trigger_nissan.cpp b/firmware/controllers/trigger/decoders/trigger_nissan.cpp index 0b7845fc71..dc7e8b8056 100644 --- a/firmware/controllers/trigger/decoders/trigger_nissan.cpp +++ b/firmware/controllers/trigger/decoders/trigger_nissan.cpp @@ -129,20 +129,40 @@ void initializeNissanVQvvt(TriggerWaveform *s) { s->setTriggerSynchronizationGap(5); } -void initializeNissanVQ35crank(TriggerWaveform *s) { - s->initialize(FOUR_STROKE_THREE_TIMES_CRANK_SENSOR); +void makeNissanPattern(TriggerWaveform* s, size_t halfCylinderCount, size_t totalWheel, size_t missing) { s->setTriggerSynchronizationGap(0.33); - s->tdcPosition = 675; + auto toothAngle = 360.0f / totalWheel; - float currentAngle = 20; - for (int i = 0;i < 10;i++) { - currentAngle += 10; + auto patternTeeth = totalWheel / halfCylinderCount; + auto toothCount = patternTeeth - missing; + + float currentAngle = missing * toothAngle; + for (int i = 0; i < toothCount; i++) { + currentAngle += toothAngle; s->addEventAngle(currentAngle - 5, T_PRIMARY, TV_RISE); s->addEventAngle(currentAngle, T_PRIMARY, TV_FALL); } } +void initializeNissanVQ35crank(TriggerWaveform *s) { + s->initialize(FOUR_STROKE_THREE_TIMES_CRANK_SENSOR); + + s->tdcPosition = 675; + + // 6 cylinder = 36 tooth wheel, missing 2 teeth in 3 spots + makeNissanPattern(s, 3, 36, 2); +} + +void initializeNissanMR18crank(TriggerWaveform *s) { + s->initialize(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR); + + s->tdcPosition = 640; + + // 4 cylinder = 36 tooth wheel, missing 2 teeth in 2 spots + makeNissanPattern(s, 2, 36, 2); +} + void initializeNissanQR25crank(TriggerWaveform *s) { s->initialize(FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR); s->setTriggerSynchronizationGap(0.33); diff --git a/firmware/controllers/trigger/decoders/trigger_nissan.h b/firmware/controllers/trigger/decoders/trigger_nissan.h index 42509559b1..deeee350dc 100644 --- a/firmware/controllers/trigger/decoders/trigger_nissan.h +++ b/firmware/controllers/trigger/decoders/trigger_nissan.h @@ -14,6 +14,7 @@ void initializeNissanSR20VE_4_360(TriggerWaveform *s); void initializeNissanVQvvt(TriggerWaveform *s); void initializeNissanVQ35crank(TriggerWaveform *s); +void initializeNissanMR18crank(TriggerWaveform *s); void initializeNissanQR25crank(TriggerWaveform *s); void initializeNissanVQ30cam(TriggerWaveform *s); diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index e5bfd35807..2cf8721c84 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -578,6 +578,10 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e ambiguousOperat initializeNissanVQ35crank(this); break; + case TT_NISSAN_MR18_CRANK: + initializeNissanMR18crank(this); + break; + case TT_KAWA_KX450F: configureKawaKX450F(this); break; diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index ede78cb283..306ca97a29 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -583,7 +583,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", "Miata NB", "GM_7X", "Cooper R50", "Mazda SOHC 4", "60/2", "36/1", "Honda 4+24+1", "Mitsubishi", "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 VVT", "trg34", "trg35", "Subaru 7+6", "Jeep 18-2-2-2", "WIP", "Dodge Neon 1995 crank only", "Jeep XJ 4 cyl", "FiatIAQ_P8", "Mazda Z5", "trg43", "Renix 44-2-2", "Renix 66-2-2-2", "Honda K 12+1", "trg47", "36/2", "Subaru SVX", "1+16", "Subaru 7 without 6", "trg52", "TriTach", "GM 60/2/2/2", "Skoda Favorit", "Barra 3+1 Cam", "Kawa KX450F", "Nissan VQ35", "trg59", "Nissan VQ30", "Nissan QR25", "trg62", "Subaru SVX Crank 1", "Subaru SVX Cam VVT", "Ford PIP", "Suzuki G13B", "Honda K 4+1", "trg68", "trg69" +#define trigger_type_e_enum "custom toothed wheel", "Ford Aspire", "Dodge Neon 1995", "Miata NA", "Miata NB", "GM_7X", "Cooper R50", "Mazda SOHC 4", "60/2", "36/1", "Honda 4+24+1", "Mitsubishi", "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 VVT", "trg34", "trg35", "Subaru 7+6", "Jeep 18-2-2-2", "WIP", "Dodge Neon 1995 crank only", "Jeep XJ 4 cyl", "FiatIAQ_P8", "Mazda Z5", "trg43", "Renix 44-2-2", "Renix 66-2-2-2", "Honda K 12+1", "trg47", "36/2", "Subaru SVX", "1+16", "Subaru 7 without 6", "trg52", "TriTach", "GM 60/2/2/2", "Skoda Favorit", "Barra 3+1 Cam", "Kawa KX450F", "Nissan VQ35", "trg59", "Nissan VQ30", "Nissan QR25", "trg62", "Subaru SVX Crank 1", "Subaru SVX Cam VVT", "Ford PIP", "Suzuki G13B", "Honda K 4+1", "Nissan MR18 Crank", "trg69" 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