From 58fb926db976fab8ab7b2f40727332fff9c28f19 Mon Sep 17 00:00:00 2001 From: rusEfi Date: Sun, 5 Apr 2015 17:06:17 -0500 Subject: [PATCH] auto-sync --- .../controllers/algo/auto_generated_enums.cpp | 2 + firmware/controllers/algo/rusefi_enums.h | 1 + .../controllers/trigger/trigger_decoder.cpp | 49 +++++++++++++------ .../controllers/trigger/trigger_structure.cpp | 5 ++ .../controllers/trigger/trigger_structure.h | 1 + 5 files changed, 44 insertions(+), 14 deletions(-) diff --git a/firmware/controllers/algo/auto_generated_enums.cpp b/firmware/controllers/algo/auto_generated_enums.cpp index a9b74e967d..3706901faf 100644 --- a/firmware/controllers/algo/auto_generated_enums.cpp +++ b/firmware/controllers/algo/auto_generated_enums.cpp @@ -115,6 +115,8 @@ case TT_TOOTHED_WHEEL_36_1: return "TT_TOOTHED_WHEEL_36_1"; case TT_TOOTHED_WHEEL_60_2: return "TT_TOOTHED_WHEEL_60_2"; +case TT_ONE_PLUS_TOOTHED_WHEEL_60_2: + return "TT_ONE_PLUS_TOOTHED_WHEEL_60_2"; } return NULL; } diff --git a/firmware/controllers/algo/rusefi_enums.h b/firmware/controllers/algo/rusefi_enums.h index 89ae0cd6fa..71e4dd071f 100644 --- a/firmware/controllers/algo/rusefi_enums.h +++ b/firmware/controllers/algo/rusefi_enums.h @@ -127,6 +127,7 @@ typedef enum { TT_MAZDA_DOHC_1_4 = 15, TT_ONE_PLUS_ONE = 16, + TT_ONE_PLUS_TOOTHED_WHEEL_60_2 = 17, Force_4b_trigger_type = ENUM_32_BITS, } trigger_type_e; diff --git a/firmware/controllers/trigger/trigger_decoder.cpp b/firmware/controllers/trigger/trigger_decoder.cpp index be19091eda..70250ce17d 100644 --- a/firmware/controllers/trigger/trigger_decoder.cpp +++ b/firmware/controllers/trigger/trigger_decoder.cpp @@ -43,6 +43,10 @@ EXTERN_ENGINE // todo: better name for this constant #define HELPER_PERIOD 100000 + +#define NO_LEFT_FILTER -1 +#define NO_RIGHT_FILTER 1000 + static cyclic_buffer errorDetection; #if ! EFI_PROD_CODE @@ -231,10 +235,28 @@ float getEngineCycle(operation_mode_e operationMode) { return operationMode == TWO_STROKE ? 360 : 720; } +void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, int totalTeethCount, int skippedCount, + operation_mode_e operationMode, float filterLeft, float filterRight) { + float toothWidth = 0.5; + float engineCycle = getEngineCycle(operationMode); + + for (int i = 0; i < totalTeethCount - skippedCount - 1; i++) { + float angleDown = engineCycle / totalTeethCount * (i + toothWidth); + float angleUp = engineCycle / totalTeethCount * (i + 1); + s->addEvent(angleDown, wheel, TV_HIGH, filterLeft, filterRight); + s->addEvent(angleUp, wheel, TV_LOW); + } + + float angleDown = engineCycle / totalTeethCount * (totalTeethCount - skippedCount - 1 + toothWidth); + s->addEvent(angleDown, wheel, TV_HIGH); + s->addEvent(engineCycle, wheel, TV_LOW); +} + void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, int skippedCount, operation_mode_e operationMode) { efiAssertVoid(totalTeethCount > 0, "totalTeethCount is zero"); + s->totalToothCount = totalTeethCount; s->skippedToothCount = skippedCount; @@ -244,20 +266,7 @@ void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount, efiAssertVoid(s != NULL, "TriggerShape is NULL"); s->reset(operationMode, false); - float toothWidth = 0.5; - - float engineCycle = getEngineCycle(operationMode); - - for (int i = 0; i < totalTeethCount - skippedCount - 1; i++) { - float angleDown = engineCycle / totalTeethCount * (i + toothWidth); - float angleUp = engineCycle / totalTeethCount * (i + 1); - s->addEvent(angleDown, T_PRIMARY, TV_HIGH); - s->addEvent(angleUp, T_PRIMARY, TV_LOW); - } - - float angleDown = engineCycle / totalTeethCount * (totalTeethCount - skippedCount - 1 + toothWidth); - s->addEvent(angleDown, T_PRIMARY, TV_HIGH); - s->addEvent(engineCycle, T_PRIMARY, TV_LOW); + addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, skippedCount, operationMode, NO_LEFT_FILTER, NO_RIGHT_FILTER); } static void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode) { @@ -274,6 +283,14 @@ static void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode) s->isSynchronizationNeeded = false; } +static void configureOnePlus60_2(TriggerShape *s, operation_mode_e operationMode) { + s->reset(FOUR_STROKE_CAM_SENSOR, true); + + s->addEvent(180, T_PRIMARY, TV_HIGH); + s->addEvent(360, T_PRIMARY, TV_LOW); + s->isSynchronizationNeeded = false; +} + /** * External logger is needed because at this point our logger is not yet initialized */ @@ -325,6 +342,10 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin configureOnePlusOne(triggerShape, engineConfiguration->operationMode); break; + case TT_ONE_PLUS_TOOTHED_WHEEL_60_2: + configureOnePlus60_2(triggerShape, engineConfiguration->operationMode); + break; + case TT_MAZDA_SOHC_4: configureMazdaProtegeSOHC(triggerShape); break; diff --git a/firmware/controllers/trigger/trigger_structure.cpp b/firmware/controllers/trigger/trigger_structure.cpp index 6a15ae296a..4bbecb9e4d 100644 --- a/firmware/controllers/trigger/trigger_structure.cpp +++ b/firmware/controllers/trigger/trigger_structure.cpp @@ -201,6 +201,11 @@ float TriggerShape::getAngle(int index) const { } } +void TriggerShape::addEvent(float angle, trigger_wheel_e const waveIndex, trigger_value_e const stateParam, float filterLeft, float filterRight) { + if(angle > filterLeft && angle < filterRight) + addEvent(angle, waveIndex, stateParam); +} + void TriggerShape::addEvent(float angle, trigger_wheel_e const waveIndex, trigger_value_e const stateParam) { efiAssertVoid(operationMode != OM_NONE, "operationMode not set"); diff --git a/firmware/controllers/trigger/trigger_structure.h b/firmware/controllers/trigger/trigger_structure.h index ac3b09294b..585eb1b338 100644 --- a/firmware/controllers/trigger/trigger_structure.h +++ b/firmware/controllers/trigger/trigger_structure.h @@ -89,6 +89,7 @@ public: int size; void addEvent(float angle, trigger_wheel_e const waveIndex, trigger_value_e const state); + void addEvent(float angle, trigger_wheel_e const waveIndex, trigger_value_e const stateParam, float filterLeft, float filterRight); // todo: these two methods here, something could be improved void clear();