auto-sync

This commit is contained in:
rusEfi 2015-04-05 17:06:17 -05:00
parent f5d5552f10
commit 58fb926db9
5 changed files with 44 additions and 14 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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<int> 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;

View File

@ -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");

View File

@ -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();