diff --git a/firmware/controllers/algo/engine.cpp b/firmware/controllers/algo/engine.cpp index 18ec00971b..94ce0f9c78 100644 --- a/firmware/controllers/algo/engine.cpp +++ b/firmware/controllers/algo/engine.cpp @@ -98,6 +98,8 @@ trigger_type_e getVvtTriggerType(vvt_mode_e vvtMode) { return TT_ONE; case VVT_FORD_ST170: return TT_FORD_ST170; + case VVT_BARRA_3_PLUS_1: + return TT_VVT_BARRA_3_PLUS_1; default: return TT_ONE; } diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 436666bbd9..58704ffe7a 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -377,13 +377,15 @@ typedef enum { */ TT_SKODA_FAVORIT = TT_TT_SKODA_FAVORIT, + TT_VVT_BARRA_3_PLUS_1 = TT_TT_VVT_BARRA_3_PLUS_1, + // 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 = 56, // this is used if we want to iterate over all trigger types + TT_UNUSED = 57, // this is used if we want to iterate over all trigger types Force_4_bytes_size_trigger_type = ENUM_32_BITS, } trigger_type_e; @@ -456,6 +458,8 @@ typedef enum __attribute__ ((__packed__)) { VVT_4_1 = 6, VVT_FORD_ST170 = 7, + + VVT_BARRA_3_PLUS_1 = 8, } vvt_mode_e; /** diff --git a/firmware/controllers/trigger/decoders/trigger_misc.cpp b/firmware/controllers/trigger/decoders/trigger_misc.cpp index 27c94ebeb7..0764b30e95 100644 --- a/firmware/controllers/trigger/decoders/trigger_misc.cpp +++ b/firmware/controllers/trigger/decoders/trigger_misc.cpp @@ -92,3 +92,44 @@ void configureDaihatsu4(TriggerWaveform * s) { s->addEventAngle(s->getCycleDuration(), T_PRIMARY, TV_FALL); } + +void configureBarra3plus1cam(TriggerWaveform *s) { + s->initialize(FOUR_STROKE_CAM_SENSOR); + + s->useRiseEdge = true; + // TODO: gapBothDirections? + + // This wheel has four teeth + // two short gaps, and two long gaps + // short = 60 deg + // long = 120 deg + + { + int offset = 120; + + s->addEventAngle(offset + 2 * 0 - 10, T_PRIMARY, TV_RISE); + s->addEventAngle(offset + 2 * 0 + 0, T_PRIMARY, TV_FALL); + + // short gap 60 deg + + s->addEventAngle(offset + 2 * 60 - 10, T_PRIMARY, TV_RISE); + s->addEventAngle(offset + 2 * 60 + 0, T_PRIMARY, TV_FALL); + + // long gap 120 deg + + s->addEventAngle(offset + 2 * 180 - 10, T_PRIMARY, TV_RISE); + s->addEventAngle(offset + 2 * 180 + 0, T_PRIMARY, TV_FALL); + + // long gap 120 deg + + s->addEventAngle(offset + 2 * 300 - 10, T_PRIMARY, TV_RISE); + s->addEventAngle(offset + 2 * 300 + 0, T_PRIMARY, TV_FALL); + + // short gap, 60 deg back to zero/720 + } + + // sync tooth is the zero tooth, the first short gap after two long gaps + s->setTriggerSynchronizationGap3(0, 1.6f, 2.4f); + // previous gap should be 1.0 + s->setTriggerSynchronizationGap3(1, 0.8f, 1.2f); +} diff --git a/firmware/controllers/trigger/decoders/trigger_misc.h b/firmware/controllers/trigger/decoders/trigger_misc.h index a9e80eca09..c684536509 100644 --- a/firmware/controllers/trigger/decoders/trigger_misc.h +++ b/firmware/controllers/trigger/decoders/trigger_misc.h @@ -13,4 +13,6 @@ void configureFiatIAQ_P8(TriggerWaveform * s); void configureDaihatsu4(TriggerWaveform * s); void configureFordST170(TriggerWaveform * s); void configureTriTach(TriggerWaveform * s); +// TT_VVT_BARRA_3_PLUS_1 +void configureBarra3plus1cam(TriggerWaveform *s); diff --git a/firmware/controllers/trigger/decoders/trigger_structure.cpp b/firmware/controllers/trigger/decoders/trigger_structure.cpp index 0f7badda15..dca0b3d8f8 100644 --- a/firmware/controllers/trigger/decoders/trigger_structure.cpp +++ b/firmware/controllers/trigger/decoders/trigger_structure.cpp @@ -603,6 +603,10 @@ void TriggerWaveform::initializeTriggerWaveform(Logging *logger, operation_mode_ configureQuickStartSenderWheel(this); break; + case TT_VVT_BARRA_3_PLUS_1: + configureBarra3plus1cam(this); + break; + case TT_HONDA_K_12_1: configureHondaK_12_1(this); break; diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index f0829347f0..ad576353b2 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -202,9 +202,10 @@ void hwHandleVvtCamSignal(trigger_value_e front, efitick_t nowNt, int index DECL break; case VVT_MIATA_NB2: case VVT_BOSCH_QUICK_START: + case VVT_BARRA_3_PLUS_1: { if (engine->triggerCentral.vvtState[bankIndex][camIndex].currentCycle.current_index != 0) { - // this is not NB2 sync tooth - exiting + // this is not sync tooth - exiting return; } if (engineConfiguration->debugMode == DBG_VVT) { diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 71ad1dee05..0f035cf6d5 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -289,8 +289,8 @@ end_struct #define debug_mode_e_enum "Alternator PID", "TPS acceleration enrichment", "GPPWM", "Idle Control", "Engine Load accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT input", "Cranking", "Timing", "Closed-loop fuel corr PID", "VSS", "SD card", "sr5", "Knock", "mode16", "Electronic Throttle", "Executor", "Bench Test / TS commands", "Aux Valves", "Analog inputs #1", "INSTANT_RPM", "FSIO_EXPRESSION_1_7", "Status", "CJ125", "CAN", "MAP", "Metrics", "ETB#2", "Ion Sense", "TLE8888", "Analog inputs #2", "Dwell Metric", "INVALID", "ETB Logic", "Boost Control", "Start/Stop", "Launch", "ETB Autotune", "FSIO_COMPOSITE_LOG", "FSIO_EXPRESSION_8_14", "FSIO_SPECIAL", "Injector Compensation", "Dyno_View", "Logic_Analyzer", "rusEFI Wideband", "TCU", "Mode48" custom debug_mode_e 4 bits, U32, @OFFSET@, [0:5], @@debug_mode_e_enum@@ -#define vvt_mode_e_enum "Inactive", "Single Tooth Second Half", "2GZ", "Miata NB2", "Single Tooth First Half", "Bosch Quick Start", "4/1", "mode7" -custom vvt_mode_e 1 bits, U08, @OFFSET@, [0:2], @@vvt_mode_e_enum@@ +#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" +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 ! todo: as of ChibiOS3, only channels 1 & 2 are allowed to capture input, that's a ChibiOS driver limitation @@ -442,6 +442,7 @@ end_struct #define TT_TT_TRI_TACH 53 #define TT_TT_GM_60_2_2_2 54 #define TT_TT_SKODA_FAVORIT 55 +#define TT_TT_VVT_BARRA_3_PLUS_1 56 ! todo https://github.com/rusefi/rusefi/issues/2102 @@ -654,7 +655,7 @@ struct trigger_config_s @brief Trigger wheel(s) configuration custom bool32_t 4 bits, U32, @OFFSET@, [0:0], "false", "true" -#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", "trg56", "trg57", "INVALID" +#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", "trg57", "INVALID" custom trigger_type_e 4 bits, U32, @OFFSET@, [0:5], @@trigger_type_e_enum@@ trigger_type_e type;set trigger_type X