diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index b0dda1c228..edfc77497f 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 Mon Aug 22 22:39:28 EDT 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Aug 23 20:59:13 EDT 2016 // begin #ifndef ENGINE_CONFIGURATION_GENERATED_H_ #define ENGINE_CONFIGURATION_GENERATED_H_ @@ -596,6 +596,10 @@ typedef struct { /** offset 376 bit 16 */ bool isCJ125Enabled : 1; + /** + * Use rise or fall signal front + offset 376 bit 17 */ + bool vvtCamSensorUseRise : 1; /** * offset 380 */ @@ -1923,4 +1927,4 @@ typedef struct { #endif // end -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Aug 22 22:39:28 EDT 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Aug 23 20:59:13 EDT 2016 diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 868fc24733..09bc70e042 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -605,6 +605,14 @@ typedef enum { TRIGGER_COUNT = 5, FSIO_ADC = 6, AUX_PID_1 = 7, + VVT = 8, + DM_9 = 9, + DM_10 = 10, + DM_11 = 11, + DM_12 = 12, + DM_13 = 13, + DM_14 = 14, + DM_15 = 15, Force_4b_debug_mode_e = ENUM_32_BITS, } debug_mode_e; diff --git a/firmware/controllers/algo/rusefi_generated.h b/firmware/controllers/algo/rusefi_generated.h index e9bd526422..673f6a8367 100644 --- a/firmware/controllers/algo/rusefi_generated.h +++ b/firmware/controllers/algo/rusefi_generated.h @@ -425,6 +425,7 @@ #define useWarmupPidAfr_offset 1000 #define onOffAlternatorLogic_offset 1000 #define isCJ125Enabled_offset 1000 +#define vvtCamSensorUseRise_offset 1000 #define logicAnalyzerPins1_offset 1004 #define logicAnalyzerPins2_offset 1008 #define logicAnalyzerPins3_offset 1012 diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index 9aa9a9b91b..b0170d5839 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -111,7 +111,7 @@ static trigger_value_e eventType[6] = { TV_FALL, TV_RISE, TV_FALL, TV_RISE, TV_F prevCycleDuration = nowNt - startOfCycleNt; \ startOfCycleNt = nowNt; \ resetCurrentCycleState(); \ - totalRevolutionCounter++; \ + intTotalEventCounter(); \ runningRevolutionCounter++; \ totalEventCountBase += TRIGGER_SHAPE(size); \ } diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index d5f878512d..add28720fa 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -49,6 +49,11 @@ public: TriggerState(); int getCurrentIndex(); int getTotalRevolutionCounter(); + /** + * this is important for crank-based virtual trigger and VVT magic + */ + bool isEvenRevolution(); + void intTotalEventCounter(); efitime_t getTotalEventCounter(); efitime_t getStartOfRevolutionIndex(); void decodeTriggerEvent(trigger_event_e const signal, efitime_t nowUs DECLARE_ENGINE_PARAMETER_S); diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index fbb9d49455..85a34ca984 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -201,6 +201,15 @@ int TriggerState::getTotalRevolutionCounter() { return totalRevolutionCounter; } + +void TriggerState::intTotalEventCounter() { + totalRevolutionCounter++; +} + +bool TriggerState::isEvenRevolution() { + return totalRevolutionCounter & 1; +} + void TriggerState::resetCurrentCycleState() { memset(currentCycle.eventCount, 0, sizeof(currentCycle.eventCount)); memset(currentCycle.timeOfPreviousEventNt, 0, sizeof(currentCycle.timeOfPreviousEventNt)); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index 3692aea847..899173b560 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -109,7 +109,7 @@ float baseFuel;+Fuel squirt duration while cranking\nA number of curves adjust t int16_t rpm;+Cranking mode threshold. Special cranking logic controls fuel and spark while RPM is below this threshold\nset_cranking_rpm X;"RPM", 1, 0, 0, 3000, 0 end_struct -#define debug_mode_e_enum "Alternator", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "mode8", "mode9", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15" +#define debug_mode_e_enum "Alternator", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT", "mode9", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15" custom debug_mode_e 4 bits, U32, @OFFSET@, [0:3], @@debug_mode_e_enum@@ #define vvt_mode_e_enum "First half", "Second half", "2GZ", "mode3" @@ -486,6 +486,7 @@ bit is_enabled_spi_2 bit useWarmupPidAfr; bit onOffAlternatorLogic; bit isCJ125Enabled + bit vvtCamSensorUseRise;+Use rise or fall signal front brain_input_pin_e[LOGIC_ANALYZER_CHANNEL_COUNT iterate] logicAnalyzerPins; uint8_t[LOGIC_ANALYZER_CHANNEL_COUNT] logicAnalyzerMode;default or inverted input diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 19eec9d8eb..1190ec9783 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1440,6 +1440,7 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01" field = "Secondary channel", triggerInputPins2 field = "CAM input", camInput field = "VVT mode", vvtMode + field = "VVT use rise front", vvtCamSensorUseRise field = "Trigger error LED", triggerErrorPin field = "Trigger error LED mode", triggerErrorPinMode dialog = triggerConfiguration diff --git a/java_console/models/src/com/rusefi/config/Fields.java b/java_console/models/src/com/rusefi/config/Fields.java index 0c05ba1453..8eb01a3013 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 Mon Aug 22 22:39:28 EDT 2016 +// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Tue Aug 23 21:52:05 EDT 2016 public class Fields { public static final int LE_COMMAND_LENGTH = 200; public static final int FSIO_ADC_COUNT = 4; @@ -429,6 +429,7 @@ public class Fields { public static final int useWarmupPidAfr_offset = 1000; public static final int onOffAlternatorLogic_offset = 1000; public static final int isCJ125Enabled_offset = 1000; + public static final int vvtCamSensorUseRise_offset = 1000; public static final int logicAnalyzerPins1_offset = 1004; public static final int logicAnalyzerPins2_offset = 1008; public static final int logicAnalyzerPins3_offset = 1012; @@ -1206,6 +1207,7 @@ public class Fields { public static final Field USEWARMUPPIDAFR = Field.create("USEWARMUPPIDAFR", 1000, FieldType.BIT, 14); public static final Field ONOFFALTERNATORLOGIC = Field.create("ONOFFALTERNATORLOGIC", 1000, FieldType.BIT, 15); public static final Field ISCJ125ENABLED = Field.create("ISCJ125ENABLED", 1000, FieldType.BIT, 16); + public static final Field VVTCAMSENSORUSERISE = Field.create("VVTCAMSENSORUSERISE", 1000, FieldType.BIT, 17); public static final Field LOGICANALYZERPINS1 = Field.create("LOGICANALYZERPINS1", 1004, FieldType.INT, brain_input_pin_e); public static final Field LOGICANALYZERPINS2 = Field.create("LOGICANALYZERPINS2", 1008, FieldType.INT, brain_input_pin_e); public static final Field LOGICANALYZERPINS3 = Field.create("LOGICANALYZERPINS3", 1012, FieldType.INT, brain_input_pin_e); @@ -1457,7 +1459,7 @@ public class Fields { public static final Field TPSDECELENLEANMENTTHRESHOLD = Field.create("TPSDECELENLEANMENTTHRESHOLD", 2232, FieldType.FLOAT); public static final Field TPSDECELENLEANMENTMULTIPLIER = Field.create("TPSDECELENLEANMENTMULTIPLIER", 2236, FieldType.FLOAT); public static final Field SLOWADCALPHA = Field.create("SLOWADCALPHA", 2240, FieldType.FLOAT); - public static final String[] debug_mode_e = {"Alternator", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "mode8", "mode9", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15"}; + public static final String[] debug_mode_e = {"Alternator", "TPS accel enrich", "Warmup PID", "IDLE", "EL accl enrich", "Trigger Counters", "FSIO_ADC", "AUX_PID_1", "VVT", "mode9", "mode10", "mode11", "mode12", "mode13", "mode14", "mode15"}; public static final Field DEBUGMODE = Field.create("DEBUGMODE", 2244, FieldType.INT, debug_mode_e); public static final Field WARMUPAFRPID_PFACTOR = Field.create("WARMUPAFRPID_PFACTOR", 2248, FieldType.FLOAT); public static final Field WARMUPAFRPID_IFACTOR = Field.create("WARMUPAFRPID_IFACTOR", 2252, FieldType.FLOAT);