diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index f4b709547c..e34ec1f058 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -94,6 +94,8 @@ trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode) { return TT_VVT_BARRA_3_PLUS_1; case VVT_NISSAN_VQ: return TT_VVT_NISSAN_VQ35; + case VVT_NISSAN_MR: + return TT_NISSAN_MR18_CAM_VVT; default: firmwareError(OBD_PCM_Processor_Fault, "getVvtTriggerType for %s", getVvt_mode_e(vvtMode)); return TT_ONE; // we have to return something for the sake of -Werror=return-type diff --git a/firmware/controllers/algo/engine_types.h b/firmware/controllers/algo/engine_types.h index 0cc50e9ba1..7a71d01092 100644 --- a/firmware/controllers/algo/engine_types.h +++ b/firmware/controllers/algo/engine_types.h @@ -478,7 +478,7 @@ typedef enum { // todo: remove this trigger once we have https://github.com/rusefi/rusefi/issues/2073 TT_SUBARU_7_WITHOUT_6 = 51, - TT_52 = 52, + TT_NISSAN_MR18_CAM_VVT = 52, // https://rusefi.com/forum/viewtopic.php?f=5&t=1912 TT_TRI_TACH = 53, @@ -503,7 +503,7 @@ typedef enum { TT_NISSAN_QR25 = 61, - TT_TEMP_62 = 62, + TT_UNUSED_62 = 62, TT_SUBARU_SVX_CRANK_1 = 63, diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 8ceef68b50..165a6841df 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -106,6 +106,8 @@ typedef enum __attribute__ ((__packed__)) { * 4 plus one */ VVT_HONDA_K = 10, + + VVT_NISSAN_MR = 11, } vvt_mode_e; /** diff --git a/firmware/controllers/trigger/decoders/trigger_nissan.cpp b/firmware/controllers/trigger/decoders/trigger_nissan.cpp index dc7e8b8056..409cb9c686 100644 --- a/firmware/controllers/trigger/decoders/trigger_nissan.cpp +++ b/firmware/controllers/trigger/decoders/trigger_nissan.cpp @@ -221,3 +221,36 @@ void initializeNissanVQ30cam(TriggerWaveform *s) { s->setTriggerSynchronizationGap3(/*gapIndex*/1, 0.38 * TRIGGER_GAP_DEVIATION_LOW, 0.38 * TRIGGER_GAP_DEVIATION_HIGH); s->setTriggerSynchronizationGap3(/*gapIndex*/2, 2.67 * TRIGGER_GAP_DEVIATION_LOW, 2.67 * TRIGGER_GAP_DEVIATION_HIGH); } + +void initializeNissanMRvvt(TriggerWaveform *s) { + s->initialize(FOUR_STROKE_CAM_SENSOR); + s->tdcPosition = 0; + + int x = 74; + + // All "groups" start every 90 degrees of cam rotation + // The groups have 1, 3, 4, 2 teeth each (which is the firing order?) + + // Teeth within a group are spaced 16 cam degrees apart + int toothSpacing = 16; + + // "1" + addvq30tooth(s, x + 0); + + // "3" + addvq30tooth(s, x + 90 + 0 * toothSpacing); + addvq30tooth(s, x + 90 + 1 * toothSpacing); + addvq30tooth(s, x + 90 + 2 * toothSpacing); + + // "4" + addvq30tooth(s, x + 180 + 0 * toothSpacing); + addvq30tooth(s, x + 180 + 1 * toothSpacing); + addvq30tooth(s, x + 180 + 2 * toothSpacing); + addvq30tooth(s, x + 180 + 3 * toothSpacing); + + // "2" + addvq30tooth(s, x + 270 + 0 * toothSpacing); + addvq30tooth(s, x + 270 + 1 * toothSpacing); + + s->setTriggerSynchronizationGap(5.4); +} diff --git a/firmware/controllers/trigger/decoders/trigger_nissan.h b/firmware/controllers/trigger/decoders/trigger_nissan.h index deeee350dc..82ef9cb32e 100644 --- a/firmware/controllers/trigger/decoders/trigger_nissan.h +++ b/firmware/controllers/trigger/decoders/trigger_nissan.h @@ -13,6 +13,7 @@ void initializeNissanSR20VE_4(TriggerWaveform *s); void initializeNissanSR20VE_4_360(TriggerWaveform *s); void initializeNissanVQvvt(TriggerWaveform *s); +void initializeNissanMRvvt(TriggerWaveform *s); void initializeNissanVQ35crank(TriggerWaveform *s); void initializeNissanMR18crank(TriggerWaveform *s); void initializeNissanQR25crank(TriggerWaveform *s); diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 2cf8721c84..3df4af620c 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -566,7 +566,6 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e ambiguousOperat break; case TT_NISSAN_QR25: - case TT_TEMP_62: initializeNissanQR25crank(this); break; @@ -582,6 +581,10 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e ambiguousOperat initializeNissanMR18crank(this); break; + case TT_NISSAN_MR18_CAM_VVT: + initializeNissanMRvvt(this); + break; + case TT_KAWA_KX450F: configureKawaKX450F(this); break; @@ -661,7 +664,6 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e ambiguousOperat configureHondaK_12_1(this); break; - case TT_UNUSED_10: case TT_HONDA_4_24: configureHonda_1_4_24(this, false, true, T_NONE, T_PRIMARY, 0); shapeWithoutTdc = true; @@ -748,7 +750,6 @@ void TriggerWaveform::initializeTriggerWaveform(operation_mode_e ambiguousOperat break; case TT_SUBARU_7_WITHOUT_6: - case TT_52: initializeSubaruOnly7(this); break; diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index b5a2e538c0..9bf252242e 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -309,7 +309,7 @@ custom debug_mode_e 4 bits, U32, @OFFSET@, [0:5], @@debug_mode_e_enum@@ #define VM_VVT_INACTIVE 0 -#define vvt_mode_e_enum "Inactive", "Single Tooth Second Half", "2GZ", "Miata NB2", "Single Tooth First Half", "Bosch Quick Start", "4/1", "ST 170", "Ford Barra 3+1", "Nissan VQ", "Honda K 4+1", "vvt11", "vvt12", "vvt13" +#define vvt_mode_e_enum "Inactive", "Single Tooth Second Half", "2GZ", "Miata NB2", "Single Tooth First Half", "Bosch Quick Start", "4/1", "ST 170", "Ford Barra 3+1", "Nissan VQ", "Honda K 4+1", "Nissan MR18", "vvt12", "vvt13" custom vvt_mode_e 1 bits, U08, @OFFSET@, [0:3], @@vvt_mode_e_enum@@ ! At the moment TIM1, TIM2, TIM3 and TIM9 are configured as ICU @@ -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", "Nissan MR18 Crank", "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", "INVALID", "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", "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", "INVALID", "Subaru SVX Crank 1", "Subaru SVX Cam VVT", "Ford PIP", "Suzuki G13B", "Honda K 4+1", "Nissan MR18 Crank", "INVALID" 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