auto-sync
This commit is contained in:
parent
75ec671f0e
commit
a55a5825ba
|
@ -13,11 +13,13 @@
|
||||||
EXTERN_ENGINE;
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
void setTestEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
void setTestEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
engineConfiguration->trigger.type = TT_TOOTHED_WHEEL;
|
// engineConfiguration->trigger.type = TT_TOOTHED_WHEEL;
|
||||||
|
engineConfiguration->trigger.type = TT_ONE_PLUS_ONE;
|
||||||
|
|
||||||
trigger_config_s *triggerConfig = &engineConfiguration->trigger;
|
trigger_config_s *triggerConfig = &engineConfiguration->trigger;
|
||||||
triggerConfig->customTotalToothCount = 60;
|
triggerConfig->customTotalToothCount = 60;
|
||||||
triggerConfig->customSkippedToothCount = 0;
|
triggerConfig->customSkippedToothCount = 0;
|
||||||
|
engineConfiguration->useOnlyFrontForTrigger = true;
|
||||||
|
|
||||||
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
|
setOperationMode(engineConfiguration, FOUR_STROKE_CRANK_SENSOR);
|
||||||
|
|
||||||
|
|
|
@ -782,6 +782,9 @@ static void enableOrDisable(const char *param, bool isEnabled) {
|
||||||
boardConfiguration->isFastAdcEnabled = isEnabled;
|
boardConfiguration->isFastAdcEnabled = isEnabled;
|
||||||
} else if (strEqualCaseInsensitive(param, "stepperidle")) {
|
} else if (strEqualCaseInsensitive(param, "stepperidle")) {
|
||||||
boardConfiguration->useStepperIdle = isEnabled;
|
boardConfiguration->useStepperIdle = isEnabled;
|
||||||
|
} else if (strEqualCaseInsensitive(param, "trigger_only_front")) {
|
||||||
|
engineConfiguration->useOnlyFrontForTrigger = isEnabled;
|
||||||
|
incrementGlobalConfigurationVersion();
|
||||||
} else if (strEqualCaseInsensitive(param, "two_wire_batch")) {
|
} else if (strEqualCaseInsensitive(param, "two_wire_batch")) {
|
||||||
engineConfiguration->twoWireBatch = isEnabled;
|
engineConfiguration->twoWireBatch = isEnabled;
|
||||||
incrementGlobalConfigurationVersion();
|
incrementGlobalConfigurationVersion();
|
||||||
|
|
|
@ -43,7 +43,6 @@ EXTERN_ENGINE
|
||||||
// todo: better name for this constant
|
// todo: better name for this constant
|
||||||
#define HELPER_PERIOD 100000
|
#define HELPER_PERIOD 100000
|
||||||
|
|
||||||
|
|
||||||
#define NO_LEFT_FILTER -1
|
#define NO_LEFT_FILTER -1
|
||||||
#define NO_RIGHT_FILTER 1000
|
#define NO_RIGHT_FILTER 1000
|
||||||
|
|
||||||
|
@ -122,7 +121,6 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, uint64_t now
|
||||||
eventCount[triggerWheel]++;
|
eventCount[triggerWheel]++;
|
||||||
eventCountExt[signal]++;
|
eventCountExt[signal]++;
|
||||||
|
|
||||||
|
|
||||||
uint64_t currentDurationLong = getCurrentGapDuration(nowNt);
|
uint64_t currentDurationLong = getCurrentGapDuration(nowNt);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,7 +181,8 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, uint64_t now
|
||||||
/**
|
/**
|
||||||
* in case of noise the counter could be above the expected number of events
|
* in case of noise the counter could be above the expected number of events
|
||||||
*/
|
*/
|
||||||
isSynchronizationPoint = !shaft_is_synchronized || (current_index >= TRIGGER_SHAPE(size) - 1);
|
int d = engineConfiguration->useOnlyFrontForTrigger ? 2 : 1;
|
||||||
|
isSynchronizationPoint = !shaft_is_synchronized || (current_index >= TRIGGER_SHAPE(size) - d);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,8 +234,7 @@ float getEngineCycle(operation_mode_e operationMode) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, int totalTeethCount, int skippedCount,
|
void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, int totalTeethCount, int skippedCount,
|
||||||
float offset,
|
float offset, float engineCycle, float filterLeft, float filterRight) {
|
||||||
float engineCycle, float filterLeft, float filterRight) {
|
|
||||||
float toothWidth = 0.5;
|
float toothWidth = 0.5;
|
||||||
|
|
||||||
for (int i = 0; i < totalTeethCount - skippedCount - 1; i++) {
|
for (int i = 0; i < totalTeethCount - skippedCount - 1; i++) {
|
||||||
|
@ -255,7 +253,6 @@ void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount,
|
||||||
operation_mode_e operationMode) {
|
operation_mode_e operationMode) {
|
||||||
efiAssertVoid(totalTeethCount > 0, "totalTeethCount is zero");
|
efiAssertVoid(totalTeethCount > 0, "totalTeethCount is zero");
|
||||||
|
|
||||||
|
|
||||||
s->totalToothCount = totalTeethCount;
|
s->totalToothCount = totalTeethCount;
|
||||||
s->skippedToothCount = skippedCount;
|
s->skippedToothCount = skippedCount;
|
||||||
|
|
||||||
|
@ -265,7 +262,8 @@ void initializeSkippedToothTriggerShapeExt(TriggerShape *s, int totalTeethCount,
|
||||||
efiAssertVoid(s != NULL, "TriggerShape is NULL");
|
efiAssertVoid(s != NULL, "TriggerShape is NULL");
|
||||||
s->reset(operationMode, false);
|
s->reset(operationMode, false);
|
||||||
|
|
||||||
addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, skippedCount, 0, getEngineCycle(operationMode), NO_LEFT_FILTER, NO_RIGHT_FILTER);
|
addSkippedToothTriggerEvents(T_PRIMARY, s, totalTeethCount, skippedCount, 0, getEngineCycle(operationMode),
|
||||||
|
NO_LEFT_FILTER, NO_RIGHT_FILTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode) {
|
static void configureOnePlusOne(TriggerShape *s, operation_mode_e operationMode) {
|
||||||
|
@ -293,7 +291,8 @@ static void configureOnePlus60_2(TriggerShape *s, operation_mode_e operationMode
|
||||||
s->addEvent(20, T_PRIMARY, TV_LOW);
|
s->addEvent(20, T_PRIMARY, TV_LOW);
|
||||||
addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0, 360, 20, NO_RIGHT_FILTER);
|
addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 0, 360, 20, NO_RIGHT_FILTER);
|
||||||
|
|
||||||
addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 360, 360, NO_LEFT_FILTER, NO_RIGHT_FILTER);
|
addSkippedToothTriggerEvents(T_SECONDARY, s, totalTeethCount, skippedCount, 360, 360, NO_LEFT_FILTER,
|
||||||
|
NO_RIGHT_FILTER);
|
||||||
|
|
||||||
s->isSynchronizationNeeded = false;
|
s->isSynchronizationNeeded = false;
|
||||||
}
|
}
|
||||||
|
@ -398,21 +397,25 @@ void initializeTriggerShape(Logging *logger, engine_configuration_s const *engin
|
||||||
}
|
}
|
||||||
|
|
||||||
TriggerStimulatorHelper::TriggerStimulatorHelper() {
|
TriggerStimulatorHelper::TriggerStimulatorHelper() {
|
||||||
primaryWheelState = false;
|
|
||||||
secondaryWheelState = false;
|
|
||||||
thirdWheelState = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TriggerStimulatorHelper::nextStep(TriggerState *state, TriggerShape * shape, int i,
|
void TriggerStimulatorHelper::nextStep(TriggerState *state, TriggerShape * shape, int i,
|
||||||
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S) {
|
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S) {
|
||||||
int stateIndex = i % shape->getSize();
|
int stateIndex = i % shape->getSize();
|
||||||
|
int prevIndex = (stateIndex + shape->getSize() - 1 ) % shape->getSize();
|
||||||
|
|
||||||
|
|
||||||
int loopIndex = i / shape->getSize();
|
int loopIndex = i / shape->getSize();
|
||||||
|
|
||||||
int time = (int) (HELPER_PERIOD * (loopIndex + shape->wave.getSwitchTime(stateIndex)));
|
int time = (int) (HELPER_PERIOD * (loopIndex + shape->wave.getSwitchTime(stateIndex)));
|
||||||
|
|
||||||
|
bool_t primaryWheelState = shape->wave.getChannelState(0, prevIndex);
|
||||||
bool newPrimaryWheelState = shape->wave.getChannelState(0, stateIndex);
|
bool newPrimaryWheelState = shape->wave.getChannelState(0, stateIndex);
|
||||||
|
|
||||||
|
bool_t secondaryWheelState = shape->wave.getChannelState(1, prevIndex);
|
||||||
bool newSecondaryWheelState = shape->wave.getChannelState(1, stateIndex);
|
bool newSecondaryWheelState = shape->wave.getChannelState(1, stateIndex);
|
||||||
|
|
||||||
|
bool_t thirdWheelState = shape->wave.getChannelState(2, prevIndex);
|
||||||
bool new3rdWheelState = shape->wave.getChannelState(2, stateIndex);
|
bool new3rdWheelState = shape->wave.getChannelState(2, stateIndex);
|
||||||
|
|
||||||
if (primaryWheelState != newPrimaryWheelState) {
|
if (primaryWheelState != newPrimaryWheelState) {
|
||||||
|
@ -460,7 +463,7 @@ static uint32_t doFindTrigger(TriggerStimulatorHelper *helper, TriggerShape * sh
|
||||||
* This function finds the index of synchronization event within TriggerShape
|
* This function finds the index of synchronization event within TriggerShape
|
||||||
*/
|
*/
|
||||||
uint32_t findTriggerZeroEventIndex(TriggerShape * shape, trigger_config_s const*triggerConfig
|
uint32_t findTriggerZeroEventIndex(TriggerShape * shape, trigger_config_s const*triggerConfig
|
||||||
DECLARE_ENGINE_PARAMETER_S) {
|
DECLARE_ENGINE_PARAMETER_S) {
|
||||||
|
|
||||||
// todo: should this variable be declared 'static' to reduce stack usage?
|
// todo: should this variable be declared 'static' to reduce stack usage?
|
||||||
TriggerState state;
|
TriggerState state;
|
||||||
|
@ -482,8 +485,13 @@ uint32_t findTriggerZeroEventIndex(TriggerShape * shape, trigger_config_s const*
|
||||||
* todo: add a comment why are we doing '2 * shape->getSize()' here?
|
* todo: add a comment why are we doing '2 * shape->getSize()' here?
|
||||||
*/
|
*/
|
||||||
state.cycleCallback = onFindIndex;
|
state.cycleCallback = onFindIndex;
|
||||||
for (uint32_t i = index + 1; i <= index + 2 * shape->getSize(); i++) {
|
|
||||||
|
int startIndex = engineConfiguration->useOnlyFrontForTrigger ? index + 2 : index + 1;
|
||||||
|
|
||||||
|
for (uint32_t i = startIndex; i <= index + 2 * shape->getSize(); i++) {
|
||||||
helper.nextStep(&state, shape, i, triggerConfig PASS_ENGINE_PARAMETER);
|
helper.nextStep(&state, shape, i, triggerConfig PASS_ENGINE_PARAMETER);
|
||||||
|
if (engineConfiguration->useOnlyFrontForTrigger)
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
efiAssert(state.getTotalRevolutionCounter() == 3, "totalRevolutionCounter2", EFI_ERROR_CODE);
|
efiAssert(state.getTotalRevolutionCounter() == 3, "totalRevolutionCounter2", EFI_ERROR_CODE);
|
||||||
|
|
||||||
|
|
|
@ -83,10 +83,6 @@ class TriggerStimulatorHelper {
|
||||||
public:
|
public:
|
||||||
TriggerStimulatorHelper();
|
TriggerStimulatorHelper();
|
||||||
void nextStep(TriggerState *state, TriggerShape * shape, int i, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S);
|
void nextStep(TriggerState *state, TriggerShape * shape, int i, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S);
|
||||||
private:
|
|
||||||
bool primaryWheelState;
|
|
||||||
bool secondaryWheelState;
|
|
||||||
bool thirdWheelState;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
float getEngineCycle(operation_mode_e operationMode);
|
float getEngineCycle(operation_mode_e operationMode);
|
||||||
|
|
|
@ -516,7 +516,7 @@ void testTriggerDecoder(void) {
|
||||||
test1995FordInline6TriggerDecoder();
|
test1995FordInline6TriggerDecoder();
|
||||||
testMazdaMianaNbDecoder();
|
testMazdaMianaNbDecoder();
|
||||||
|
|
||||||
testTriggerDecoder2("test engine", TEST_ENGINE, 0, 0.5000, 0.0);
|
testTriggerDecoder2("test engine", TEST_ENGINE, 0, 0.0, 0.0);
|
||||||
testTriggerDecoder2("testGY6_139QMB", GY6_139QMB, 0, 0.4375, 0.0);
|
testTriggerDecoder2("testGY6_139QMB", GY6_139QMB, 0, 0.4375, 0.0);
|
||||||
testTriggerDecoder2("testSubary", SUBARU_2003_WRX, 0, 0.4000, 0.0);
|
testTriggerDecoder2("testSubary", SUBARU_2003_WRX, 0, 0.4000, 0.0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue