I'm looking at a project that requires high resolution measurement of the rotational speed of a shaft, that is spinning at up to 15,000 rpm (250 revs per second). That shaft will have 6 (for now) trigger teeth on it (likely to be optical sensed), and so i need to provide a counter that can time the passing of those stream of teeth, and do so without gaps (ie every tooth interval is timed) That data will be spat out on a 1Mb serial link for recording and processing by a separate system.
Now, with 6 teeth, at 15krpm (ie 4ms per rev), that means a tooth interval will be 666.667 us. That is a decent time interval, certainly enough to spit out the data etc.
My current consideration is to gate the pulses from a 10MHz clock (OXO) into some form of counter, using the tooth pulses to open and close that gate. At each tooth edge, that counter will have accumulated counts of 100ns, making it easy to calculate the time interval between teeth, and hence the average velocity of the shaft.
The question, is really how to do the counter and gating?
With a 10MHz clock, a normal AVR can juuuust (if clocked at 20MHz) about count the incoming pulse stream, but with only a 16b counter, software will be required to keep track of overflows, and because each tooth interval must be counted, i think there could be significant jitter where the software has to access and reset the counter whilst new clock edges continue to stream in every 100ns (high time for a 50% duty will of course be just 50ns).
Alternatively i could use external counting hardware and latch on each incoming tooth edge a snap shot of the parallel output for the micro to grab? To get down to say 100rpm (which would be nice) i'd need a 20 bit counter assuming a 10 Mhz clock)
Anyone have any better ideas? (one option is to use a different micro, i could easily use a STM32, as i use those for other projects, but i'd have to go read up to see how it's counter work and the likely jitter etc)
(BTW, this is for a one or two off, non production/commercial solution)