Electronic – Interfacing multiple rotary encoders to a microcontroller

encodermicrocontrollerrotary

What, in your opinion, would be the most efficient way to interface muptiple (let's say, >20) incremental rotary encoders to GPIO-limited microcontroller (for example, ATxmega128A4U, 44 pin)?

Requirements:

  • It should be possible to operate multiple encoders at the same time.
  • Encoders have integrated push switches.

What I have tried:

  • To search for multi-channel quadrature decoder IC. No luck.
  • To search quadrature decoder to serial IC (Encoder-to-SPI, I2C, etc). No luck.
  • To build a multiplexer-alike logic that would allow to connect as much encoders as possible while saving GPIO's. No luck.

Best Answer

I am assuming each rotary encoder will have two signals, and may have one more for a switch.

Use multiple microcontrollers (MCUs), with each one handling a subset of the rotary encoders.

Designate one microcontroller as the 'coordinator'. Have the other MCUs ('handlers') communicate with it. If the 'coordinator' actually runs as a communication slave for SPI, I2C or some other convenient interface, the 'handlers' can drive the communication interface interrupt. That way the 'coordinator' will only get triggered when something happens. (Otherwise, the 'coordinator' will have to repeatedly read the other MCU, called polling, which may be less convenient for your system)

You'll need to devise a simple protocol to communicate which encoder has changed, and by how much. That will very likely be more than one byte, which may add a bit of complexity.

Depending on your experience, you might look at microcontrollers which containe quadrature decoder hardware. As an example, ST Micros STM32F parts have timers which can also decode and track quadrature signals.