Rotary quadrature encoder

54 views
Skip to first unread message

bodete...@gmail.com

unread,
Dec 1, 2017, 2:32:13 PM12/1/17
to BeagleBoard
Hi all

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.

Thanks again

Przemek Klosowski

unread,
Dec 1, 2017, 2:59:20 PM12/1/17
to beagl...@googlegroups.com
On Fri, Dec 1, 2017 at 1:53 PM, <bodete...@gmail.com> wrote:
Hi all

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.
 
Beaglebone has a hardware quadrature decoder called eQEP. http://beagleboard.org/project/eqep_rotary_encoder.

David Lechner

unread,
Dec 2, 2017, 12:39:23 PM12/2/17
to beagl...@googlegroups.com
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.

bodete...@gmail.com

unread,
Dec 24, 2017, 5:22:45 PM12/24/17
to BeagleBoard
Brilliant, thanks both.

Where can I find the driver?

Bode

David Lechner

unread,
Dec 26, 2017, 12:05:15 PM12/26/17
to beagl...@googlegroups.com, bodete...@gmail.com
On 12/24/2017 03:22 PM, bodete...@gmail.com wrote:
> Brilliant, thanks both.
>
> Where can I find the driver?
>
This is the driver, but you probably don't need to look at it:
https://github.com/torvalds/linux/blob/master/drivers/input/misc/rotary_encoder.c

This is the info you need to configure a device tree overlay:
https://github.com/torvalds/linux/blob/master/Documentation/devicetree/bindings/input/rotary-encoder.txt

bodete...@gmail.com

unread,
Dec 27, 2017, 8:23:12 AM12/27/17
to BeagleBoard
Hi David

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.

Thanks

bodete...@gmail.com

unread,
Dec 27, 2017, 8:23:13 AM12/27/17
to BeagleBoard
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?

Thanks

Scott

David Lechner

unread,
Dec 27, 2017, 2:59:00 PM12/27/17
to beagl...@googlegroups.com, bodete...@gmail.com
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.

Reply all
Reply to author
Forward
0 new messages