Electronic – arduino – Incremental Encoder and Arduino

arduinoencoder

I have wired a 600 p/r incremental encoder to an Arduino Uno.

My question is this:

Given that the Arduino has a clock speed of 16Mhz and I really do not want to miss a single pulse I am creating a CMOS hard copy of the logic. I have:

Inc Encoder -> firing edge trigger (by propogation delay) through xor and nxor cmos (acting as clock) -> 16bit binary up/down counter -> d flop register

The inc encoder also has a logic block which denotes which direction it is turning (it sets the up/down pin of the binary counter.

My problem is this – how would you deal with the Arduino reading the current count. I do not like directly reading the counter as it can change during read i.e. if it is 9, the arduino reads LSB and during time taken to read next the counter increment to 10 then I could end up with a reading of 19. I thought about a buffer but if I use the edge trigger logic then it appears that by the time the counter has done its logic the flip flop register will have read the revious value.

I am looking at async Preset with data hold but this type of d-flop / other flip-flop are rare(ish)

Any other scheme I should think about?

Best Answer

This one is easy. Even if you don't want to throw a microcontroller at this, I would most definitely NOT reinvent the wheel by making a hardware quad encoder system, especially as if you're designing for the UNO, you're probably not talking about production.

Use a purpose-built IC, like the HCTL-2022. As you've realized, you've just hit a bugaboo having to do with how the output is latched for a read. Before you're done, you'll hit three or four more, maybe having to do with something like noisy transistions. These purpose-built ICs are pretty good. I've used them and recommend them.