diff --git a/firmware/config/engines/mazda_miata_vvt.cpp b/firmware/config/engines/mazda_miata_vvt.cpp index f8a0dd5d9a..b668db6e05 100644 --- a/firmware/config/engines/mazda_miata_vvt.cpp +++ b/firmware/config/engines/mazda_miata_vvt.cpp @@ -18,7 +18,8 @@ void setMazdaMiata2003EngineConfiguration(DECLARE_ENGINE_PARAMETER_F) { engineConfiguration->hasMapSensor = true; - engineConfiguration->trigger.type = TT_ONE; + engineConfiguration->trigger.type = TT_MIATA_VVT; + setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR); engineConfiguration->specs.displacement = 1.8; boardConfiguration->triggerInputPins[0] = GPIOA_5; diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index e346815205..87582b0e06 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -395,6 +395,8 @@ case FOUR_STROKE_CRANK_SENSOR: return "FOUR_STROKE_CRANK_SENSOR"; case TWO_STROKE: return "TWO_STROKE"; +case FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR: + return "FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR"; case Force_4b_operation_mode_e: return "Force_4b_operation_mode_e"; case OM_NONE: diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index e9c29d63dd..7529a65dd5 100644 --- a/firmware/controllers/algo/engine_configuration_generated_structures.h +++ b/firmware/controllers/algo/engine_configuration_generated_structures.h @@ -1,4 +1,4 @@ -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Nov 11 21:53:11 EST 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Nov 13 22:09:24 EST 2016 // begin #ifndef ENGINE_CONFIGURATION_GENERATED_H_ #define ENGINE_CONFIGURATION_GENERATED_H_ @@ -1116,6 +1116,7 @@ typedef struct { int canSleepPeriod; /** * See engineCycle + * set operation_mode X * offset 500 */ operation_mode_e operationMode; @@ -1993,4 +1994,4 @@ typedef struct { #endif // end -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Nov 11 21:53:11 EST 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Nov 13 22:09:24 EST 2016 diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index c29249516d..75eb3cb0c5 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -365,6 +365,11 @@ typedef enum { */ TWO_STROKE = 3, + /** + * 720 degree engine cycle but trigger is defined using a 180 cycle which is when repeated three more times + */ + FOUR_STROKE_SYMMETRICAL_CRANK_SENSOR = 4, + Force_4b_operation_mode_e = ENUM_32_BITS, } operation_mode_e; diff --git a/firmware/controllers/settings.cpp b/firmware/controllers/settings.cpp index 1c05becf6e..247460aae4 100644 --- a/firmware/controllers/settings.cpp +++ b/firmware/controllers/settings.cpp @@ -988,6 +988,8 @@ static void setValue(const char *paramStr, const char *valueStr) { engineConfiguration->step1rpm = valueI; } else if (strEqualCaseInsensitive(paramStr, "step1timing")) { engineConfiguration->step1timing = valueI; + } else if (strEqualCaseInsensitive(paramStr, "operation_mode")) { + engineConfiguration->operationMode = (operation_mode_e)valueI; } else if (strEqualCaseInsensitive(paramStr, "suckedOffCoef")) { engineConfiguration->suckedOffCoef = valueF; } else if (strEqualCaseInsensitive(paramStr, "addedToWallCoef")) { diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index 3c77604d3e..37ea2ee312 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -240,13 +240,16 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR * cycle into a four stroke, 720 degrees cycle. */ int triggerIndexForListeners; - if (engineConfiguration->operationMode != FOUR_STROKE_CRANK_SENSOR) { + if (engineConfiguration->operationMode == FOUR_STROKE_CAM_SENSOR || + engineConfiguration->operationMode == TWO_STROKE) { // That's easy - trigger cycle matches engine cycle triggerIndexForListeners = triggerState.getCurrentIndex(); } else { - bool isEven = triggerState.isEvenRevolution(); + int crankDivider = engineConfiguration->operationMode == FOUR_STROKE_CRANK_SENSOR ? 2 : 4; - triggerIndexForListeners = triggerState.getCurrentIndex() + (isEven ? 0 : TRIGGER_SHAPE(size)); + int crankInternalIndex = triggerState.getTotalRevolutionCounter() % crankDivider; + + triggerIndexForListeners = triggerState.getCurrentIndex() + (crankInternalIndex * TRIGGER_SHAPE(size)); } if (triggerIndexForListeners == 0) { timeAtVirtualZeroNt = nowNt; diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index cc1b8a6623..bce10b8e26 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -482,6 +482,8 @@ void TriggerShape::initializeTriggerShape(Logging *logger DECLARE_ENGINE_PARAMET break; case TT_MIATA_VVT: + initializeMazdaMiataNb2Crank(triggerShape PASS_ENGINE_PARAMETER); + break; case TT_DODGE_NEON_1995: configureNeon1995TriggerShape(triggerShape PASS_ENGINE_PARAMETER); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 74da6335c6..cb3c12e16c 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -319,8 +319,8 @@ can_nbc_e canNbcType; int canSleepPeriod;CANbus thread period, ms;"ms", 1, 0, 0, 1000.0, 2 -custom operation_mode_e 4 bits, U32, @OFFSET@, [0:1], "INVALID", "4 stroke without cam sensor", "4 stroke with cam sensor", "2 stroke" -operation_mode_e operationMode;See engineCycle +custom operation_mode_e 4 bits, U32, @OFFSET@, [0:2], "INVALID", "4 stroke without cam sensor", "4 stroke with cam sensor", "2 stroke", "4 stroke with symmetrical crank", "INVALID", "INVALID", "INVALID" +operation_mode_e operationMode;See engineCycle\nset operation_mode X custom display_mode_e 4 bits, U32, @OFFSET@, [0:1], "none", "hd44780", "hd44780 over pcf8574", "INVALID" display_mode_e displayMode; @@ -340,9 +340,9 @@ 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", "Miata NA", "Miata NB", "GM_7X", "Cooper", "Mazda SOHC 4", "60/2", "36/1", "Accord CD", "MITSU", "ACCORD 2", "ACCORD DIP", "Neon 2003", "MAZDA D 1+4", "1+1", "1+60/2", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Accord 1+24", "DODGE STRATUS", "36_2_2_2", "Nissan", "2JZ", "Rover K", "GM LS 24", "Honda CBR 600", "trg29", "trg30", "INVALID" +#define trigger_type_e_enum "custom toothed wheel", "ford aspire", "dodge neon", "Miata NA", "Miata NB", "GM_7X", "Cooper", "Mazda SOHC 4", "60/2", "36/1", "Accord CD", "MITSU", "ACCORD 2", "ACCORD DIP", "Neon 2003", "MAZDA D 1+4", "1+1", "1+60/2", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Accord 1+24", "DODGE STRATUS", "36_2_2_2", "Nissan", "2JZ", "Rover K", "GM LS 24", "Honda CBR 600", "2JZ_1_12", "Honda CBR 600 custom", "3/1 skipped" , "2003 neon crank", "Miata VVT", "INVALID", "INVALID", "INVALID", "INVALID" -custom trigger_type_e 4 bits, U32, @OFFSET@, [0:4], @@trigger_type_e_enum@@ +custom trigger_type_e 4 bits, U32, @OFFSET@, [0:5], @@trigger_type_e_enum@@ trigger_type_e type;set_trigger_type X bit customIsSynchronizationNeeded; diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 2536f6e87e..07b6763683 100644 --- a/firmware/tunerstudio/rusefi.ini +++ b/firmware/tunerstudio/rusefi.ini @@ -42,7 +42,7 @@ enable2ndByteCanID = false ; see PAGE_0_SIZE in C source code ; CONFIG_DEFINITION_START -; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Nov 11 21:56:01 EST 2016 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Nov 13 22:30:49 EST 2016 pageSize = 16376 page = 1 @@ -146,7 +146,7 @@ page = 1 vehicleSpeedCoef = scalar, F32, 488, "coef", 1, 0, 0.01, 2000.0, 2 canNbcType = bits, U32, 492, [0:1], "BMW", "FIAT", "VAG" , "MAZDA RX8" canSleepPeriod = scalar, S32, 496, "ms", 1, 0, 0, 1000.0, 2 - operationMode = bits, U32, 500, [0:1], "INVALID", "4 stroke without cam sensor", "4 stroke with cam sensor", "2 stroke" + operationMode = bits, U32, 500, [0:2], "INVALID", "4 stroke without cam sensor", "4 stroke with cam sensor", "2 stroke", "4 stroke with symmetrical crank", "INVALID", "INVALID", "INVALID" displayMode = bits, U32, 504, [0:1], "none", "hd44780", "hd44780 over pcf8574", "INVALID" logFormat = bits, U32, 508, [0:0], "native", "Mega Log Viewer" firmwareVersion = scalar, S32, 512, "index", 1, 0, 0, 300, 0 @@ -155,7 +155,7 @@ page = 1 tpsAdcChannel = bits, U32, 524, [0:4] "PA0", "PA1", "PA2", "PA3", "PA4", "PA5", "PA6", "PA7", "PB0", "PB1", "PC0", "PC1", "PC2", "PC3", "PC4", "PC5", "Disabled", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" ;skipping overrideCrankingIgnition offset 528 sensorChartFrequency = scalar, S32, 532, "index", 1, 0, 0, 300, 0 ; size 4 - trigger_type = bits, U32, 536, [0:4], "custom toothed wheel", "ford aspire", "dodge neon", "Miata NA", "Miata NB", "GM_7X", "Cooper", "Mazda SOHC 4", "60/2", "36/1", "Accord CD", "MITSU", "ACCORD 2", "ACCORD DIP", "Neon 2003", "MAZDA D 1+4", "1+1", "1+60/2", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Accord 1+24", "DODGE STRATUS", "36_2_2_2", "Nissan", "2JZ", "Rover K", "GM LS 24", "Honda CBR 600", "trg29", "trg30", "INVALID" + trigger_type = bits, U32, 536, [0:5], "custom toothed wheel", "ford aspire", "dodge neon", "Miata NA", "Miata NB", "GM_7X", "Cooper", "Mazda SOHC 4", "60/2", "36/1", "Accord CD", "MITSU", "ACCORD 2", "ACCORD DIP", "Neon 2003", "MAZDA D 1+4", "1+1", "1+60/2", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Accord 1+24", "DODGE STRATUS", "36_2_2_2", "Nissan", "2JZ", "Rover K", "GM LS 24", "Honda CBR 600", "2JZ_1_12", "Honda CBR 600 custom", "3/1 skipped" , "2003 neon crank", "Miata VVT", "INVALID", "INVALID", "INVALID", "INVALID" trigger_customIsSynchronizationNeeded= bits, U32, 540, [0:0], "false", "true" trigger_customNeedSecondTriggerInput= bits, U32, 540, [1:1], "false", "true" trigger_useOnlyFirstChannel= bits, U32, 540, [2:2], "false", "true" diff --git a/java_console/models/src/com/rusefi/config/Fields.java b/java_console/models/src/com/rusefi/config/Fields.java index 7cbf99d9af..ddb215e121 100644 --- a/java_console/models/src/com/rusefi/config/Fields.java +++ b/java_console/models/src/com/rusefi/config/Fields.java @@ -1,6 +1,6 @@ package com.rusefi.config; -// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Fri Nov 11 21:53:11 EST 2016 +// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sun Nov 13 22:09:24 EST 2016 public class Fields { public static final int LE_COMMAND_LENGTH = 200; public static final int FSIO_ADC_COUNT = 4; @@ -1075,7 +1075,7 @@ public class Fields { public static final Field TPSADCCHANNEL = Field.create("TPSADCCHANNEL", 524, FieldType.INT, adc_channel_e); public static final Field OVERRIDECRANKINGIGNITION = Field.create("OVERRIDECRANKINGIGNITION", 528, FieldType.INT); public static final Field SENSORCHARTFREQUENCY = Field.create("SENSORCHARTFREQUENCY", 532, FieldType.INT); - public static final String[] trigger_type_e = {"custom toothed wheel", "ford aspire", "dodge neon", "Miata NA", "Miata NB", "GM_7X", "Cooper", "Mazda SOHC 4", "60/2", "36/1", "Accord CD", "MITSU", "ACCORD 2", "ACCORD DIP", "Neon 2003", "MAZDA D 1+4", "1+1", "1+60/2", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Accord 1+24", "DODGE STRATUS", "36_2_2_2", "Nissan", "2JZ", "Rover K", "GM LS 24", "Honda CBR 600", "trg29", "trg30", "INVALID"}; + public static final String[] trigger_type_e = {"custom toothed wheel", "ford aspire", "dodge neon", "Miata NA", "Miata NB", "GM_7X", "Cooper", "Mazda SOHC 4", "60/2", "36/1", "Accord CD", "MITSU", "ACCORD 2", "ACCORD DIP", "Neon 2003", "MAZDA D 1+4", "1+1", "1+60/2", "Single Tooth", "Dodge Ram 1+16", "60/2 VW", "Accord 1+24", "DODGE STRATUS", "36_2_2_2", "Nissan", "2JZ", "Rover K", "GM LS 24", "Honda CBR 600", "2JZ_1_12", "Honda CBR 600 custom", "3/1 skipped" , "2003 neon crank", "Miata VVT", "INVALID", "INVALID", "INVALID", "INVALID"}; public static final Field TRIGGER_TYPE = Field.create("TRIGGER_TYPE", 536, FieldType.INT, trigger_type_e); public static final Field TRIGGER_CUSTOMISSYNCHRONIZATIONNEEDED = Field.create("TRIGGER_CUSTOMISSYNCHRONIZATIONNEEDED", 540, FieldType.BIT, 0); public static final Field TRIGGER_CUSTOMNEEDSECONDTRIGGERINPUT = Field.create("TRIGGER_CUSTOMNEEDSECONDTRIGGERINPUT", 540, FieldType.BIT, 1);