1

I have a rotary encoder with a very high resolution (5000 pulses per rotation). I used what I believe to be a fairly optimized rotary pulse counter program written in C found here but the faster I turn the encoder the more pulses are missed. Where should I go from here? Do I need a dedicated microcontroller to handle the pulse events and if so what specs should the microcontroller have to perform the task successfully?

Edit: I suppose that it's not so much the resolution that matters but pulses/sec and so let's say at most 10,000 pulses per second.

  • Welcome. It would be much better if you edited in one of the scripts you mention. – goldilocks Jan 9 at 17:18
  • If you haven't already, please Google this: encoder raspberrypi stack exchange. Read the results you feel are pertinent & edit your question accordingly. – Seamus Jan 9 at 17:52
1

For an encoder with that many steps, you might want a separate microcontroller to handle it. The Raspberry Pi isn't as good at real-time stuff because Linux gets in the way sometimes and interrupts your C code, causing missed steps. The process will be different depending on the microcontroller.

You could really go with any real-time microcontroller - something like an ATtiny85 would be the cheapest option, but it requires an external programmer board. Any Arduino or Arduino compatible board would also work great. You could even use a Cortex M0 based board as they run at very high clock speeds.

You'll need to connect the microcontroller to the Pi somehow also. You could use USB, I2C, UART, or any other protocol. There are plenty of tutorials on how to interface a Raspberry Pi and an Arduino.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.