Skip to content

Commit e15ef34

Browse files
committed
trigger central: slice 9007 to 9007/9008 erorrs
CUSTOM_PRIMARY_BAD_TOOTH_TIMING_EARLY CUSTOM_PRIMARY_BAD_TOOTH_TIMING_LATE
1 parent 0d98f87 commit e15ef34

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

firmware/controllers/algo/obd_error_codes.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2150,7 +2150,9 @@ enum class ObdCode : uint16_t {
21502150
CUSTOM_PRIMARY_DOUBLED_EDGE = 9006,
21512151

21522152
// A trigger tooth arrived at an unexpected time
2153-
CUSTOM_PRIMARY_BAD_TOOTH_TIMING = 9007,
2153+
CUSTOM_PRIMARY_BAD_TOOTH_TIMING_EARLY = 9007,
2154+
CUSTOM_PRIMARY_BAD_TOOTH_TIMING_LATE = 9008,
2155+
21542156

21552157
/**
21562158
* This is not engine miss detection - this is only internal scheduler state validation

firmware/controllers/trigger/trigger_central.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,8 @@ bool TriggerCentral::isToothExpectedNow(efitick_t timestamp) {
739739
angleError += cycle;
740740
}
741741

742+
// positive value - tooth received earlier than expected
743+
// negative value - tooth received later than expected
742744
triggerToothAngleError = angleError;
743745

744746
// Only perform checks if engine is spinning quickly
@@ -768,7 +770,8 @@ bool TriggerCentral::isToothExpectedNow(efitick_t timestamp) {
768770
// TODO: configurable threshold
769771
if (isRpmEnough && absError > 10 && absError < 180) {
770772
// This tooth came at a very unexpected time, ignore it
771-
warning(ObdCode::CUSTOM_PRIMARY_BAD_TOOTH_TIMING, "tooth #%d error of %.1f", triggerState.currentCycle.current_index, angleError);
773+
warning((angleError > 0) ? ObdCode::CUSTOM_PRIMARY_BAD_TOOTH_TIMING_EARLY : ObdCode::CUSTOM_PRIMARY_BAD_TOOTH_TIMING_LATE,
774+
"tooth #%d error of %.1f", triggerState.currentCycle.current_index, angleError);
772775

773776
// TODO: this causes issues with some real engine logs, should it?
774777
// return false;

0 commit comments

Comments
 (0)