auto-sync

This commit is contained in:
rusEfi 2014-12-14 13:03:57 -06:00
parent 9654638bb3
commit 18d3ff6d71
4 changed files with 30 additions and 12 deletions

View File

@ -497,6 +497,7 @@ typedef struct {
bool isTunerStudioEnabled : 1; // bit 8 bool isTunerStudioEnabled : 1; // bit 8
bool isWaveAnalyzerEnabled : 1; // bit 9 bool isWaveAnalyzerEnabled : 1; // bit 9
bool isIdleThreadEnabled : 1; // bit 10 bool isIdleThreadEnabled : 1; // bit 10
bool isPrintTriggerSynchDetails : 1; // bit 11
/** /**
* Usually if we have no trigger events that means engine is stopped * Usually if we have no trigger events that means engine is stopped
* Unless we are troubleshooting and spinning the engine by hand - this case a longer * Unless we are troubleshooting and spinning the engine by hand - this case a longer

View File

@ -666,6 +666,8 @@ static void enableOrDisable(const char *param, bool isEnabled) {
boardConfiguration->isFastAdcEnabled = isEnabled; boardConfiguration->isFastAdcEnabled = isEnabled;
} else if (strEqualCaseInsensitive(param, "injection")) { } else if (strEqualCaseInsensitive(param, "injection")) {
engineConfiguration->isInjectionEnabled = isEnabled; engineConfiguration->isInjectionEnabled = isEnabled;
} else if (strEqualCaseInsensitive(param, "trigger_details")) {
engineConfiguration->isPrintTriggerSynchDetails = isEnabled;
} else if (strEqualCaseInsensitive(param, "ignition")) { } else if (strEqualCaseInsensitive(param, "ignition")) {
engineConfiguration->isIgnitionEnabled = isEnabled; engineConfiguration->isIgnitionEnabled = isEnabled;
} else if (strEqualCaseInsensitive(param, "self_stimulation")) { } else if (strEqualCaseInsensitive(param, "self_stimulation")) {

View File

@ -32,7 +32,8 @@
#include "efiGpio.h" #include "efiGpio.h"
#include "engine.h" #include "engine.h"
EXTERN_ENGINE; EXTERN_ENGINE
;
// todo: better name for this constant // todo: better name for this constant
#define HELPER_PERIOD 100000 #define HELPER_PERIOD 100000
@ -92,13 +93,11 @@ static trigger_value_e eventType[6] = { TV_LOW, TV_HIGH, TV_LOW, TV_HIGH, TV_LOW
totalEventCountBase += TRIGGER_SHAPE(size); \ totalEventCountBase += TRIGGER_SHAPE(size); \
} }
/** /**
* @brief Trigger decoding happens here * @brief Trigger decoding happens here
* This method changes the state of trigger_state_s data structure according to the trigger event * This method changes the state of trigger_state_s data structure according to the trigger event
*/ */
void TriggerState::decodeTriggerEvent( void TriggerState::decodeTriggerEvent(trigger_event_e const signal, uint64_t nowNt DECLARE_ENGINE_PARAMETER_S) {
trigger_event_e const signal, uint64_t nowNt DECLARE_ENGINE_PARAMETER_S) {
efiAssertVoid(signal <= SHAFT_3RD_UP, "unexpected signal"); efiAssertVoid(signal <= SHAFT_3RD_UP, "unexpected signal");
trigger_wheel_e triggerWheel = eventIndex[signal]; trigger_wheel_e triggerWheel = eventIndex[signal];
@ -122,13 +121,15 @@ void TriggerState::decodeTriggerEvent(
* For performance reasons, we want to work with 32 bit values. If there has been more then * For performance reasons, we want to work with 32 bit values. If there has been more then
* 10 seconds since previous trigger event we do not really care. * 10 seconds since previous trigger event we do not really care.
*/ */
currentDuration = currentDurationLong > 10 * US2NT(US_PER_SECOND_LL) ? 10 * US2NT(US_PER_SECOND_LL) : currentDurationLong; currentDuration =
currentDurationLong > 10 * US2NT(US_PER_SECOND_LL) ? 10 * US2NT(US_PER_SECOND_LL) : currentDurationLong;
if (isLessImportant) { if (isLessImportant) {
/** /**
* For less important events we simply increment the index. * For less important events we simply increment the index.
*/ */
nextTriggerEvent(); nextTriggerEvent()
;
if (TRIGGER_SHAPE(gapBothDirections)) { if (TRIGGER_SHAPE(gapBothDirections)) {
toothed_previous_duration = currentDuration; toothed_previous_duration = currentDuration;
isFirstEvent = false; isFirstEvent = false;
@ -154,14 +155,18 @@ void TriggerState::decodeTriggerEvent(
if (TRIGGER_SHAPE(isSynchronizationNeeded)) { if (TRIGGER_SHAPE(isSynchronizationNeeded)) {
#if ! EFI_PROD_CODE #if ! EFI_PROD_CODE
// todo: replace printGapRatio with engineConfiguration->isPrintTriggerSynchDetails
// and merge these two sections
if (printGapRatio) { if (printGapRatio) {
float gap = 1.0 * currentDuration / toothed_previous_duration; float gap = 1.0 * currentDuration / toothed_previous_duration;
print("current gap %f\r\n", gap); print("current gap %f\r\n", gap);
} }
#else #else
// float gap = 1.0 * currentDuration / shaftPositionState->toothed_previous_duration; if (engineConfiguration->isPrintTriggerSynchDetails) {
// scheduleMsg(&logger, "gap=%f @ %d", gap, shaftPositionState->getCurrentIndex()); float gap = 1.0 * currentDuration / toothed_previous_duration;
scheduleMsg(&logger, "gap=%f @ %d", gap, current_index);
}
#endif /* ! EFI_PROD_CODE */ #endif /* ! EFI_PROD_CODE */
@ -187,6 +192,13 @@ void TriggerState::decodeTriggerEvent(
setOutputPinValue(LED_TRIGGER_ERROR, isDecodingError); setOutputPinValue(LED_TRIGGER_ERROR, isDecodingError);
if (isDecodingError) { if (isDecodingError) {
totalTriggerErrorCounter++; totalTriggerErrorCounter++;
if (engineConfiguration->isPrintTriggerSynchDetails) {
#if EFI_PROD_CODE
scheduleMsg(&logger, "error: synchronizationPoint @ index %d expected %d/%d/%d got %d/%d/%d", current_index,
TRIGGER_SHAPE(expectedEventCount[0]), TRIGGER_SHAPE(expectedEventCount[1]),
TRIGGER_SHAPE(expectedEventCount[2]), eventCount[0], eventCount[1], eventCount[2]);
#endif /* EFI_PROD_CODE */
}
} }
errorDetection.add(isDecodingError); errorDetection.add(isDecodingError);
@ -199,11 +211,13 @@ void TriggerState::decodeTriggerEvent(
shaft_is_synchronized = true; shaft_is_synchronized = true;
// this call would update duty cycle values // this call would update duty cycle values
nextTriggerEvent(); nextTriggerEvent()
;
nextRevolution(); nextRevolution();
} else { } else {
nextTriggerEvent(); nextTriggerEvent()
;
} }
toothed_previous_duration = currentDuration; toothed_previous_duration = currentDuration;
@ -389,7 +403,8 @@ static uint32_t doFindTrigger(TriggerStimulatorHelper *helper, trigger_shape_s *
* *
* This function finds the index of synchronization event within trigger_shape_s * This function finds the index of synchronization event within trigger_shape_s
*/ */
uint32_t findTriggerZeroEventIndex(trigger_shape_s * shape, trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S) { uint32_t findTriggerZeroEventIndex(trigger_shape_s * shape,
trigger_config_s const*triggerConfig DECLARE_ENGINE_PARAMETER_S) {
TriggerState state; TriggerState state;
errorDetection.clear(); errorDetection.clear();

View File

@ -265,5 +265,5 @@ int getRusEfiVersion(void) {
return 1; // this is here to make the compiler happy about the unused array return 1; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE == 0) if (UNUSED_CCM_SIZE == 0)
return 1; // this is here to make the compiler happy about the unused array return 1; // this is here to make the compiler happy about the unused array
return 20141213; return 20141214;
} }