A hall sensor and a 20MHz timer just won't cut it I fear…
The easiest and most optimal method is to use the DDA algorithm – an extension of Bresenham's line draw method.
It's simple, works for ANY combination of encoder count value ( sensible encoder values, that is – use at least a 1000PPS encoder) and any number of gear teeth on the blank. Very easy to implement in software, but a 16MHz Arduino will not cut it either! Hence my use of the Nucleo with a small STM processor @ 120MHz – The Nucleo module cost around US$15.00. I can give you all that software if you wish Michael.
A PLL implementation 'does' work, but it's a nightmare working out all the diveders, etc, if done in discrete logic. Also, PLL's are a pain to make stable – phase lead and lag can kill it. A digital PLL is better, easier to stabilise, but needs a really fast processor to up the sample rate.
The DDA method is used in all modern CNC threading and gear cutting implementations.
Joe
Edited By Joseph Noci 1 on 07/08/2018 20:33:13