This commit is contained in:
rusefi 2017-11-20 15:01:48 -05:00
parent 321e41e53d
commit 405f06a608
3 changed files with 13 additions and 8 deletions

View File

@ -79,9 +79,9 @@ void Engine::updateSlowSensors(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineState.injectorLag = getInjectorLag(sensors.vBatt PASS_ENGINE_PARAMETER_SUFFIX); engineState.injectorLag = getInjectorLag(sensors.vBatt PASS_ENGINE_PARAMETER_SUFFIX);
} }
void Engine::onTriggerEvent(efitick_t nowNt) { void Engine::onTriggerSignalEvent(efitick_t nowNt) {
isSpinning = true; isSpinning = true;
lastTriggerEventTimeNt = nowNt; lastTriggerToothEventTimeNt = nowNt;
} }
Engine::Engine() { Engine::Engine() {
@ -120,7 +120,7 @@ void Engine::reset() {
* it's important for fixAngle() that engineCycle field never has zero * it's important for fixAngle() that engineCycle field never has zero
*/ */
engineCycle = getEngineCycle(FOUR_STROKE_CRANK_SENSOR); engineCycle = getEngineCycle(FOUR_STROKE_CRANK_SENSOR);
lastTriggerEventTimeNt = 0; lastTriggerToothEventTimeNt = 0;
isCylinderCleanupMode = false; isCylinderCleanupMode = false;
engineCycleEventCount = 0; engineCycleEventCount = 0;
stopEngineRequestTimeNt = 0; stopEngineRequestTimeNt = 0;
@ -339,6 +339,8 @@ void Engine::watchdog() {
#ifndef RPM_LOW_THRESHOLD #ifndef RPM_LOW_THRESHOLD
#define RPM_LOW_THRESHOLD 240 #define RPM_LOW_THRESHOLD 240
#endif #endif
// note that we are ignoring the number of tooth here - we
// check for duration between tooth as if we only have one tooth per revolution which is not the case
#define REVOLUTION_TIME_HIGH_THRESHOLD (60 * 1000000LL / RPM_LOW_THRESHOLD) #define REVOLUTION_TIME_HIGH_THRESHOLD (60 * 1000000LL / RPM_LOW_THRESHOLD)
/** /**
* todo: better watch dog implementation should be implemented - see * todo: better watch dog implementation should be implemented - see
@ -347,7 +349,7 @@ void Engine::watchdog() {
* note that the result of this subtraction could be negative, that would happen if * note that the result of this subtraction could be negative, that would happen if
* we have a trigger event between the time we've invoked 'getTimeNow' and here * we have a trigger event between the time we've invoked 'getTimeNow' and here
*/ */
efitick_t timeSinceLastTriggerEvent = nowNt - lastTriggerEventTimeNt; efitick_t timeSinceLastTriggerEvent = nowNt - lastTriggerToothEventTimeNt;
if (timeSinceLastTriggerEvent < US2NT(REVOLUTION_TIME_HIGH_THRESHOLD)) { if (timeSinceLastTriggerEvent < US2NT(REVOLUTION_TIME_HIGH_THRESHOLD)) {
return; return;
} }
@ -357,7 +359,7 @@ void Engine::watchdog() {
scheduleMsg(&logger, "engine has STOPPED"); scheduleMsg(&logger, "engine has STOPPED");
scheduleMsg(&logger, "templog engine has STOPPED [%x][%x] [%x][%x] %d", scheduleMsg(&logger, "templog engine has STOPPED [%x][%x] [%x][%x] %d",
(int)(nowNt >> 32), (int)nowNt, (int)(nowNt >> 32), (int)nowNt,
(int)(lastTriggerEventTimeNt >> 32), (int)lastTriggerEventTimeNt, (int)(lastTriggerToothEventTimeNt >> 32), (int)lastTriggerToothEventTimeNt,
(int)timeSinceLastTriggerEvent (int)timeSinceLastTriggerEvent
); );
triggerInfo(); triggerInfo();

View File

@ -415,10 +415,13 @@ public:
*/ */
int ignitionPin[IGNITION_PIN_COUNT]; int ignitionPin[IGNITION_PIN_COUNT];
void onTriggerEvent(efitick_t nowNt); /**
* this is invoked each time we register a trigger tooth signal
*/
void onTriggerSignalEvent(efitick_t nowNt);
EngineState engineState; EngineState engineState;
SensorsState sensors; SensorsState sensors;
efitick_t lastTriggerEventTimeNt; efitick_t lastTriggerToothEventTimeNt;
/** /**

View File

@ -252,7 +252,7 @@ void TriggerCentral::handleShaftSignal(trigger_event_e signal DECLARE_ENGINE_PAR
nowNt = getTimeNowNt(); nowNt = getTimeNowNt();
engine->onTriggerEvent(nowNt); engine->onTriggerSignalEvent(nowNt);
#if EFI_HISTOGRAMS && EFI_PROD_CODE #if EFI_HISTOGRAMS && EFI_PROD_CODE
int beforeCallback = hal_lld_get_counter_value(); int beforeCallback = hal_lld_get_counter_value();