Quadrature encoder input

Before I dig into the source, has anyone done this yet? I want to be able to use a cheap encoder with a switch as a selection device.

Oz (in DFW)

I do more software than hardware, but as far as I know, nobody has done anything like this. It would be helpful to know your application – do you want to use a rotary switch to choose patterns, or are you using the quadrature encoder to monitor some other device?

For use within a pattern, you could hook the output of your encoder to a couple of GPIO pins and make decisions in the pattern code based on that. Switching patterns via hardware might be harder.

Current Pixelblazes have a button attached to GPIO0 that, if pressed momentarily, increments the pattern and if pressed longer resets the Pixelblaze. To run through the patterns in one direction, you could replace that button with another controller, but I’m not aware of a hardware method for moving backwards through the list.

There’s good information on hardware switching in this thread:

Hi @ozindfw,

You are the first that I know of :slight_smile:

The best quadrature encoder systems on microcontrollers I’ve seen use either dedicated peripherals or GPIO interrupts to detect edge level changes. Unfortunately, these aren’t supported, and there isn’t first class encoder support.

You can poll the GPIO pin states in beforeRender() and with a small state machine decode the signals, but if you rotate it too fast compared to the frame rate, it can miss transitions.

1 Like