I am reading RPM from a hall effect sensor in a flow meter using interrupts and a moving average (I may adopt a better algorithm to smooth the bumps later on). Everything works great, but I'm a but unsure how to detect when the RPM has hit zero. The first problem is that if the thing stops turning, there are no more interrupts so the RPM calculation stops. I fixed that by having another function that can be run periodically to do the calculation and adjust the average RPM downward if there's a clear slowing trend. This helps the RPM number fall off a lot more rapidly, but it won't quite hit zero in a timely manner. Since the lowest practical speed I'll ever see is just over 50 RPM, if the calculation falls below that point (it's basically a timeout), my helper function just makes the RPM zero. These two techniques make it work pretty well, though not perfectly.

Is there a better way to do this? Is there a standard technique or algorithm for doing this sort of calculation. I can think of dozens of cases where commercial products are calculating a rate based on discrete signals over intervals. How do they calculate it such that it detects a zero speed in a timely manner?