Browse Source

Improved speed sensor filter

Excluding bounces that are incoherent, if the resulting acceleration
would exceed 10m/s/s
master
Youen Toupin 2 years ago
parent
commit
7ada49cb5b
  1. 6
      ESP32/src/vehicle-monitor.cpp

6
ESP32/src/vehicle-monitor.cpp

@ -69,7 +69,11 @@ void IRAM_ATTR onSpeedSensorChange(bool newState)
if(impulseDuration > 500) return; // impulse was too long, ignore it (maybe magnet stopped near the sensor)
unsigned long timeSinceLastImpulse = utils::elapsed(speedSensorLastImpulseTime, now);
if(timeSinceLastImpulse < 30)
// TODO: find a simple formula that works for any wheel diameter and number of magnets
unsigned long minInterval = speedSensorLastImpulseInterval == (unsigned long)-1 ? 200 : std::min((unsigned long)200, (unsigned long)30 + speedSensorLastImpulseInterval / 2);
if(timeSinceLastImpulse < minInterval)
{
// too little time between impulses, probably some bouncing, ignore it
}

Loading…
Cancel
Save