diff --git a/firmware/controllers/algo/engine_configuration_generated_structures.h b/firmware/controllers/algo/engine_configuration_generated_structures.h index 3b5203298f..b0dda1c228 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 Sat Aug 20 18:52:45 EDT 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Aug 22 22:39:28 EDT 2016 // begin #ifndef ENGINE_CONFIGURATION_GENERATED_H_ #define ENGINE_CONFIGURATION_GENERATED_H_ @@ -970,6 +970,7 @@ typedef struct { int rpmHardLimit; /** * This setting controls which algorithm is used for ENGINE LOAD + * set_algorithm X * offset 424 */ engine_load_mode_e algorithm; @@ -1703,7 +1704,11 @@ typedef struct { /** * offset 2552 */ - int unused[124]; + vvt_mode_e vvtMode; + /** + * offset 2556 + */ + int unused[123]; /** total size 3048*/ } engine_configuration_s; @@ -1918,4 +1923,4 @@ typedef struct { #endif // end -// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Sat Aug 20 18:52:45 EDT 2016 +// this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Aug 22 22:39:28 EDT 2016 diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index cc16e079fc..868fc24733 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -224,6 +224,13 @@ typedef enum { SHAFT_3RD_RISING = 5, } trigger_event_e; +typedef enum { + VVT_FIRST_HALF = 0, + VVT_SECOND_HALF = 1, + VVT_2GZ = 2, + Force_4b_vvt_mode = ENUM_32_BITS, +} vvt_mode_e; + /** * This enum is used to select your desired Engine Load calculation algorithm */ diff --git a/firmware/controllers/algo/rusefi_generated.h b/firmware/controllers/algo/rusefi_generated.h index 6649c539c1..e9bd526422 100644 --- a/firmware/controllers/algo/rusefi_generated.h +++ b/firmware/controllers/algo/rusefi_generated.h @@ -880,7 +880,8 @@ #define auxPid4_iFactor_offset 2540 #define auxPid4_dFactor_offset 2544 #define auxPid4_offset_offset 2548 -#define unused_offset 2552 +#define vvtMode_offset 2552 +#define unused_offset 2556 #define le_formulas1_offset 3048 #define le_formulas2_offset 3248 #define le_formulas3_offset 3448 diff --git a/firmware/controllers/trigger/trigger_central.cpp b/firmware/controllers/trigger/trigger_central.cpp index ced7fa92a0..f6397f3df1 100644 --- a/firmware/controllers/trigger/trigger_central.cpp +++ b/firmware/controllers/trigger/trigger_central.cpp @@ -76,12 +76,12 @@ extern bool isInsideTriggerHandler; void hwHandleVvtCamSignal(trigger_value_e front) { - efitick_t offsetNt = getTimeNowNt() - engine->triggerCentral.triggerState.startOfCycleNt; + efitick_t offsetNt = getTimeNowNt() - engine->triggerCentral.timeAtVirtualZeroNt; angle_t vvtPosition = NT2US(offsetNt) / engine->rpmCalculator.oneDegreeUs; // convert engine cycle angle into trigger cycle angle - vvtPosition += tdcPosition(); + vvtPosition -= tdcPosition(); fixAngle(vvtPosition); engine->triggerCentral.vvtPosition = vvtPosition; @@ -113,6 +113,7 @@ void hwHandleShaftSignal(trigger_event_e signal) { TriggerCentral::TriggerCentral() { nowNt = 0; vvtPosition = 0; + timeAtVirtualZeroNt = 0; // we need this initial to have not_running at first invocation previousShaftEventTimeNt = (efitimems_t) -10 * US2NT(US_PER_SECOND_LL); @@ -189,6 +190,9 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR triggerIndexForListeners = triggerState.getCurrentIndex() + (isEven ? 0 : TRIGGER_SHAPE(size)); } + if (triggerIndexForListeners == 0) { + timeAtVirtualZeroNt = nowNt; + } reportEventToWaveChart(signal, triggerIndexForListeners PASS_ENGINE_PARAMETER); if (!triggerState.shaft_is_synchronized) { diff --git a/firmware/controllers/trigger/trigger_central.h b/firmware/controllers/trigger/trigger_central.h index 16106d9d8a..cb01d9b678 100644 --- a/firmware/controllers/trigger/trigger_central.h +++ b/firmware/controllers/trigger/trigger_central.h @@ -31,6 +31,10 @@ public: TriggerState triggerState; efitick_t nowNt; angle_t vvtPosition; + /** + * this is similar to TriggerState#startOfCycleNt but with the crank-only sensor magic + */ + efitick_t timeAtVirtualZeroNt; volatile efitime_t previousShaftEventTimeNt; private: diff --git a/firmware/controllers/trigger/trigger_decoder.h b/firmware/controllers/trigger/trigger_decoder.h index bcc8646352..d5f878512d 100644 --- a/firmware/controllers/trigger/trigger_decoder.h +++ b/firmware/controllers/trigger/trigger_decoder.h @@ -97,6 +97,10 @@ public: void resetRunningCounters(); uint32_t runningRevolutionCounter; + /** + * this is start of real trigger cycle + * for virtual double trigger see timeAtVirtualZeroNt + */ efitick_t startOfCycleNt; private: void resetCurrentCycleState(); diff --git a/firmware/integration/rusefi_config.txt b/firmware/integration/rusefi_config.txt index fa4f7a590a..3692aea847 100644 --- a/firmware/integration/rusefi_config.txt +++ b/firmware/integration/rusefi_config.txt @@ -112,6 +112,10 @@ 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" 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" +custom vvt_mode_e 4 bits, U32, @OFFSET@, [0:1], @@vvt_mode_e_enum@@ + + #define mass_storage_e_enum "Auto", "Always", "Never" custom mass_storage_e 4 bits, U32, @OFFSET@, [0:1], @@mass_storage_e_enum@@ @@ -260,7 +264,7 @@ int sensorSnifferRpmThreshold;+Disable sensor sniffer above this rpm;"RPM", custom engine_load_mode_e 4 bits, U32, @OFFSET@, [0:1], @@engine_load_mode_e_enum@@ -engine_load_mode_e algorithm;+This setting controls which algorithm is used for ENGINE LOAD +engine_load_mode_e algorithm;+This setting controls which algorithm is used for ENGINE LOAD\nset_algorithm X custom injection_mode_e 4 bits, U32, @OFFSET@, [0:1], "Simultaneous", "Sequential", "Batch", "INVALID" @@ -730,7 +734,8 @@ float[MAP_ACCEL_TAPER] mapAccelTaperMult;;"mult", 1, 0, 0.0, 300, spi_device_e cj125SpiDevice; pin_output_mode_e cj125CsPinMode; pid_s[AUX_PID_COUNT iterate] auxPid; - int[124] unused; + vvt_mode_e vvtMode; + int[123] unused; end_struct diff --git a/firmware/rusefi.cpp b/firmware/rusefi.cpp index 939b83552c..3025e7888d 100644 --- a/firmware/rusefi.cpp +++ b/firmware/rusefi.cpp @@ -294,7 +294,7 @@ void firmwareError(const char *errorMsg, ...) { } } -static char UNUSED_RAM_SIZE[1000]; +static char UNUSED_RAM_SIZE[900]; static char UNUSED_CCM_SIZE[8500] CCM_OPTIONAL; @@ -303,5 +303,5 @@ int getRusEfiVersion(void) { return 123; // this is here to make the compiler happy about the unused array if (UNUSED_CCM_SIZE[0] * 0 != 0) return 3211; // this is here to make the compiler happy about the unused array - return 20160819; + return 20160822; } diff --git a/firmware/tunerstudio/rusefi.ini b/firmware/tunerstudio/rusefi.ini index 954cf5ae25..6389704256 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 Sat Aug 20 18:52:45 EDT 2016 +; this section was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Aug 22 22:41:38 EDT 2016 pageSize = 16376 page = 1 @@ -612,7 +612,8 @@ page = 1 auxPid4_iFactor = scalar, F32, 2540, "value", 1, 0, 0, 1000, 5 auxPid4_dFactor = scalar, F32, 2544, "value", 1, 0, 0, 1000, 5 auxPid4_offset = scalar, F32, 2548, "value", 1, 0, 0, 1000, 3 -;skipping unused offset 2552 + vvtMode = bits, U32, 2552, [0:1], "First half", "Second half", "2GZ", "mode3" +;skipping unused offset 2556 le_formulas1 = array, U08, 3048, [200],"char", 1, 0, 0.0, 3.0, 2 le_formulas2 = array, U08, 3248, [200],"char", 1, 0, 0.0, 3.0, 2 le_formulas3 = array, U08, 3448, [200],"char", 1, 0, 0.0, 3.0, 2 @@ -686,7 +687,7 @@ page = 1 knockBandCustom = "kHz knock band override" cylinderBore = "Cylinder diameter, in mm." sensorSnifferRpmThreshold = "Disable sensor sniffer above this rpm" - algorithm = "This setting controls which algorithm is used for ENGINE LOAD" + algorithm = "This setting controls which algorithm is used for ENGINE LOAD\nset_algorithm X" injectionMode = "'batched' means two injectors are wired together" injectionOffset = "this is about deciding when the injector starts it's squirt\nSee also injectionPhase map" crankingTimingAngle = "Timing advance while engine cranking\nset_cranking_timing_angle X" @@ -1454,6 +1455,7 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01" field = "Primary input channel", triggerInputPins1 field = "Secondary channel", triggerInputPins2 field = "CAM input", camInput + field = "VVT mode", vvtMode field = "Trigger error LED", triggerErrorPin field = "Trigger error LED mode", triggerErrorPinMode dialog = triggerConfiguration diff --git a/firmware/tunerstudio/rusefi.input b/firmware/tunerstudio/rusefi.input index 95ef54b580..19eec9d8eb 100644 --- a/firmware/tunerstudio/rusefi.input +++ b/firmware/tunerstudio/rusefi.input @@ -1439,6 +1439,7 @@ cmd_test_idle_valve = "w\x00\x17\x00\x01" field = "Primary input channel", triggerInputPins1 field = "Secondary channel", triggerInputPins2 field = "CAM input", camInput + field = "VVT mode", vvtMode 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 bd70252bea..0c05ba1453 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 01 21:44:40 EDT 2016 +// this file was generated automatically by ConfigDefinition.jar based on rusefi_config.txt Mon Aug 22 22:39:28 EDT 2016 public class Fields { public static final int LE_COMMAND_LENGTH = 200; public static final int FSIO_ADC_COUNT = 4; @@ -884,7 +884,8 @@ public class Fields { public static final int auxPid4_iFactor_offset = 2540; public static final int auxPid4_dFactor_offset = 2544; public static final int auxPid4_offset_offset = 2548; - public static final int unused_offset = 2552; + public static final int vvtMode_offset = 2552; + public static final int unused_offset = 2556; public static final int le_formulas1_offset = 3048; public static final int le_formulas2_offset = 3248; public static final int le_formulas3_offset = 3448; @@ -1513,6 +1514,8 @@ public class Fields { public static final Field AUXPID4_IFACTOR = Field.create("AUXPID4_IFACTOR", 2540, FieldType.FLOAT); public static final Field AUXPID4_DFACTOR = Field.create("AUXPID4_DFACTOR", 2544, FieldType.FLOAT); public static final Field AUXPID4_OFFSET = Field.create("AUXPID4_OFFSET", 2548, FieldType.FLOAT); + public static final String[] vvt_mode_e = {"First half", "Second half", "2GZ", "mode3"}; + public static final Field VVTMODE = Field.create("VVTMODE", 2552, FieldType.INT, vvt_mode_e); public static final Field LE_FORMULAS1 = Field.create("LE_FORMULAS1", 3048, FieldType.INT); public static final Field LE_FORMULAS2 = Field.create("LE_FORMULAS2", 3248, FieldType.INT); public static final Field LE_FORMULAS3 = Field.create("LE_FORMULAS3", 3448, FieldType.INT);