mirror of https://github.com/rusefi/rusefi-1.git
auto-sync
This commit is contained in:
parent
d153fc390e
commit
afcd3f49c0
|
@ -171,7 +171,6 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
|
|||
}
|
||||
#endif
|
||||
|
||||
|
||||
isFirstEvent = false;
|
||||
// todo: skip a number of signal from the beginning
|
||||
|
||||
|
@ -191,10 +190,10 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
|
|||
/**
|
||||
* Here I prefer to have two multiplications instead of one division, that's a micro-optimization
|
||||
*/
|
||||
isSynchronizationPoint = currentDuration > toothed_previous_duration * TRIGGER_SHAPE(syncRatioFrom) &&
|
||||
currentDuration < toothed_previous_duration * TRIGGER_SHAPE(syncRatioTo) &&
|
||||
toothed_previous_duration > durationBeforePrevious * TRIGGER_SHAPE(secondSyncRatioFrom) &&
|
||||
toothed_previous_duration < durationBeforePrevious * TRIGGER_SHAPE(secondSyncRatioTo)
|
||||
isSynchronizationPoint = currentDuration > toothed_previous_duration * TRIGGER_SHAPE(syncRatioFrom)
|
||||
&& currentDuration < toothed_previous_duration * TRIGGER_SHAPE(syncRatioTo)
|
||||
&& toothed_previous_duration > durationBeforePrevious * TRIGGER_SHAPE(secondSyncRatioFrom)
|
||||
&& toothed_previous_duration < durationBeforePrevious * TRIGGER_SHAPE(secondSyncRatioTo)
|
||||
;
|
||||
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
|
@ -245,9 +244,10 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
|
|||
totalTriggerErrorCounter++;
|
||||
if (engineConfiguration->isPrintTriggerSynchDetails) {
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
scheduleMsg(logger, "error: synchronizationPoint @ index %d expected %d/%d/%d got %d/%d/%d", currentCycle.current_index,
|
||||
TRIGGER_SHAPE(expectedEventCount[0]), TRIGGER_SHAPE(expectedEventCount[1]),
|
||||
TRIGGER_SHAPE(expectedEventCount[2]), currentCycle.eventCount[0], currentCycle.eventCount[1], currentCycle.eventCount[2]);
|
||||
scheduleMsg(logger, "error: synchronizationPoint @ index %d expected %d/%d/%d got %d/%d/%d",
|
||||
currentCycle.current_index, TRIGGER_SHAPE(expectedEventCount[0]),
|
||||
TRIGGER_SHAPE(expectedEventCount[1]), TRIGGER_SHAPE(expectedEventCount[2]),
|
||||
currentCycle.eventCount[0], currentCycle.eventCount[1], currentCycle.eventCount[2]);
|
||||
#endif /* EFI_PROD_CODE */
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +257,8 @@ void TriggerState::decodeTriggerEvent(trigger_event_e const signal, efitime_t no
|
|||
if (isTriggerDecoderError()) {
|
||||
warning(OBD_PCM_Processor_Fault, "trigger decoding issue. expected %d/%d/%d got %d/%d/%d",
|
||||
TRIGGER_SHAPE(expectedEventCount[0]), TRIGGER_SHAPE(expectedEventCount[1]),
|
||||
TRIGGER_SHAPE(expectedEventCount[2]), currentCycle.eventCount[0], currentCycle.eventCount[1], currentCycle.eventCount[2]);
|
||||
TRIGGER_SHAPE(expectedEventCount[2]), currentCycle.eventCount[0], currentCycle.eventCount[1],
|
||||
currentCycle.eventCount[2]);
|
||||
}
|
||||
|
||||
shaft_is_synchronized = true;
|
||||
|
@ -307,10 +308,8 @@ float getEngineCycle(operation_mode_e operationMode) {
|
|||
return operationMode == TWO_STROKE ? 360 : 720;
|
||||
}
|
||||
|
||||
void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s,
|
||||
int totalTeethCount, int skippedCount,
|
||||
float toothWidth,
|
||||
float offset, float engineCycle, float filterLeft, float filterRight) {
|
||||
void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s, int totalTeethCount, int skippedCount,
|
||||
float toothWidth, float offset, float engineCycle, float filterLeft, float filterRight) {
|
||||
efiAssertVoid(totalTeethCount > 0, "total count");
|
||||
efiAssertVoid(skippedCount >= 0, "skipped count");
|
||||
|
||||
|
@ -321,7 +320,7 @@ void addSkippedToothTriggerEvents(trigger_wheel_e wheel, TriggerShape *s,
|
|||
s->addEvent(offset + angleUp, wheel, TV_LOW, filterLeft, filterRight);
|
||||
}
|
||||
|
||||
float angleDown = engineCycle / totalTeethCount * (totalTeethCount - skippedCount - 1 + (1 - toothWidth) );
|
||||
float angleDown = engineCycle / totalTeethCount * (totalTeethCount - skippedCount - 1 + (1 - toothWidth));
|
||||
s->addEvent(offset + angleDown, wheel, TV_HIGH, filterLeft, filterRight);
|
||||
s->addEvent(offset + engineCycle, wheel, TV_LOW, filterLeft, filterRight);
|
||||
}
|
||||
|
@ -514,8 +513,8 @@ static void onFindIndex(TriggerState *state) {
|
|||
*
|
||||
* This function finds the index of synchronization event within TriggerShape
|
||||
*/
|
||||
uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape, trigger_config_s const*triggerConfig
|
||||
DECLARE_ENGINE_PARAMETER_S) {
|
||||
uint32_t findTriggerZeroEventIndex(TriggerState *state, TriggerShape * shape,
|
||||
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S) {
|
||||
#if EFI_PROD_CODE || defined(__DOXYGEN__)
|
||||
efiAssert(getRemainingStack(chThdSelf()) > 128, "findPos", -1);
|
||||
#endif
|
||||
|
@ -541,7 +540,7 @@ DECLARE_ENGINE_PARAMETER_S) {
|
|||
*/
|
||||
state->cycleCallback = onFindIndex;
|
||||
|
||||
helper.assertSyncPositionAndSetDutyCycle(index, state, shape,triggerConfig PASS_ENGINE_PARAMETER);
|
||||
helper.assertSyncPositionAndSetDutyCycle(index, state, shape, triggerConfig PASS_ENGINE_PARAMETER);
|
||||
|
||||
return index % shape->getSize();
|
||||
}
|
||||
|
@ -552,7 +551,8 @@ void initTriggerDecoderLogger(Logging *sharedLogger) {
|
|||
|
||||
void initTriggerDecoder(void) {
|
||||
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
|
||||
outputPinRegisterExt2("trg_err", &triggerDecoderErrorPin, boardConfiguration->triggerErrorPin, &boardConfiguration->triggerErrorPinMode);
|
||||
outputPinRegisterExt2("trg_err", &triggerDecoderErrorPin, boardConfiguration->triggerErrorPin,
|
||||
&boardConfiguration->triggerErrorPinMode);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -123,10 +123,11 @@ public class AutoTest {
|
|||
x = 176.856;
|
||||
// todo: why is width precision so low here? is that because of loaded Windows with 1ms precision?
|
||||
double widthRatio = 0.25;
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_1, 0.009733333333333387, 0.01, widthRatio, x, x + 180, x + 360, x + 540);
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_2, 0.009733333333333387, 0.01, widthRatio, x, x + 180, x + 360, x + 540);
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.009733333333333387, 0.01, widthRatio, x, x + 180, x + 360, x + 540);
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.009733333333333387, 0.01, widthRatio, x, x + 180, x + 360, x + 540);
|
||||
// WAT? this was just 0.009733333333333387?
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_1, 0.006266666666666905, 0.01, widthRatio, x, x + 180, x + 360, x + 540);
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_2, 0.006266666666666905, 0.01, widthRatio, x, x + 180, x + 360, x + 540);
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_3, 0.006266666666666905, 0.01, widthRatio, x, x + 180, x + 360, x + 540);
|
||||
assertWave(true, msg, chart, EngineChart.INJECTOR_4, 0.006266666666666905, 0.01, widthRatio, x, x + 180, x + 360, x + 540);
|
||||
|
||||
msg = "2003 Neon running";
|
||||
IoUtil.changeRpm(2000);
|
||||
|
|
Loading…
Reference in New Issue