Instead of just relying on the number of ticks between PID invocations, we can also rely in the period between ticks. Although period is proportional to the inverse of speed, it is still more accurante compared to the number of ticks at slow speeds.
Consider a realistic case where a system expects about 1000 ticks per second. This translated to one tick of millisecond. However, as the system slows down to rely on friction to come to a complete stop, the speed can be down to a small number (such as one) of ticks per second. It becomes impossible to know the actual speed. Using a timer, however, we can track the period between ticks and use the period to deduce the actual speed.
If we consider the worst case of a 16 count timer for a 50Hz
PID invocation frequency, the lowest frequency is 50Hz, while the
next lowest frequency (due to digitization) is
, which
translates to 53.3Hz. This resolution is better than 7%, even when
the tick count per time method fails. While 7% may not sound like a
lot, it makes a lot of difference when there is nothing lese to rely on.