I am developing on a beaglebone black and want to include a rotary knob to Control cursors on my display in user space etc.
The selected quadrature encoder is here : http://www.mouser.com/ds/2/54/EL12T-777462.pdf
I need to convert the pulses into a direction and count up or down accordingly so I plan on using an external low cost micro controller to count up or down and send the value out onto the bus.
I then plan to send the value as it is updated onto the i2c bus to the beaglebone. The beaglebone will then react accordingly to the events.
So the order of hardware/software from end to end will be:
Rotary encoder -> External PIC - > i2c bus -> userspace
Am I attacking this from the wrong direction?
Does anybody have a better recommendation on how to interface a rotary Control knob into linux user space?
For reference, I will also be interfacing a keypad using the Ti TCA8418 keypad scanner which will also be hooked onto the i2c bus.
Beaglebone has a hardware quadrature decoder called eQEP.
There is also a gpio quadrature encoder driver in the input subsystem of the mainline linux kernel. If you don’t want to spend time on software, this may be the way to go.
Brilliant, thanks both.
Where can I find the driver?
Looks good to me, I imagine I will be able to use. Any of the gpio’s for that? Feel free not to answer such a simple question as I haven't read the documentation yet.
I’m trying to offload work such as this as I am fast running out of gpio.
Next I need to learn how to convert the information from the encoder driver into an interrupt based action to the user space software.
I’m thinking about polling the “position” entry in the filesystem using a timer thread instead of using interrupts.
My reasoning for this is that the rotary knob will be changed by hand and I do not expect to update the GUI cursors that this knob will control any faster than 100ms.
So a 100ms poll really shouldn’t load my cpu too much, any reason I shouldn’t use this approach? Have I missed anything?
The driver uses the linux input subsystem, so it will appear as a relative axis. Basically, if you have two knobs, linux will think it is a mouse with no buttons. You can use libinput or any libevdev or any other library that knows about linux input devices.