Author Topic: Stand alone rotary encoder  (Read 4912 times)

0 Members and 1 Guest are viewing this topic.

Offline SidusNare

  • Thread Starter
  • Posts: 75
  • Location: Sol System
  • Do, or do not; there is no try.
Stand alone rotary encoder
« on: Mon, 22 June 2015, 11:40:09 »
I have seen several "gamer keyboards" and other miscellaneous devices with large rotary encoders bolted to their side. Presumably as a HID Z-Axis (Mouse wheel). 

I would like to make a stand alone rotary encoder that can be programed to be anything HID. Z-Axis, arrow keys, page up / down, etc...

I have a pretty good idea about how to do the PCB, code a Teensy for HID with something like TMK's firmware.

What I have no idea about is an actual rotary encoder to use. I would like something that is high resolution for things like video editing and also does well at high speed, such as flicking it with your thumb to make a sudden movement in a game without the slow backwards effect, (what would you call that, rolling shutter? harmonic interference between optical sensor and disk?)

Does anyone know about rotary encoders and able to give me recommendations?

What I think I want is a relative rotary encoder with PWM output. But I don't know what other qualities would best fit this use case?
To doubt everything or to believe everything are two equally convenient solutions; both dispense with the necessity of reflection. -- H. Poincare

Offline Findecanor

  • Posts: 5035
  • Location: Koriko
Re: Stand alone rotary encoder
« Reply #1 on: Mon, 22 June 2015, 12:18:29 »
A regular rotary encoder has three pins: A, B and ground. When the encoder is rotating, each pin produces a "pulse train" but 90° out of phase with the other. In other words, when it is rotating you get a sequence like: A followed by A+B followed by B followed by no signal - and in the other direction the sequence would be in reverse.

Arduino uses the same microcontroller as the Teensy, and there is a whole lot of simple Arduino code out there for reading rotary encoders. A lot of code is triggering an interrupt when a pin goes low, but I think that would be overkill - that kind of code is intended for controlling motors.
For an input device, the encoder is not going to rotate that fast so it would be more than sufficient to just poll the two pins fairly often. A lot of keyboard firmware is based on a main loop or interrupt that is triggered every ms - put the polling there!

Edit: The code described above is the 2-bit version of Gray code. There are rotary encoders that produce gray codes with three or more bits but they are not as common.
« Last Edit: Tue, 23 June 2015, 17:00:24 by Findecanor »

Offline hasu

  • Posts: 3471
  • Location: Tokyo, Japan
  • @tmk
    • tmk keyboard firmware project
Re: Stand alone rotary encoder
« Reply #2 on: Mon, 22 June 2015, 20:32:50 »
It would be hilarious to assign two encoders to X and Y movement respectively and do a Etch A Sketch with MS Paint. Though I believe someone had already made these things definitely.

The other day I learned about rotary encoder and its quadrature output, I mean, just read Wikipedia and did some search with Google :D And I took apart my defictive encoder to see inside of the device,  it was not what I expected, mmm, clever mecha indeed.



Unfortunately I couldn't see quadrature wave of it because the encoder was from my cheap oscilloscope, lol. I'm waiting for new encoder arrival.



Sorry for talking to myself long :D


As with coding with encoder  I think you can PJRC library, they did great job again here.

https://github.com/PaulStoffregen/Encoder


Offline tufty

  • Posts: 347
  • Location: French Alps
Re: Stand alone rotary encoder
« Reply #3 on: Tue, 23 June 2015, 10:51:10 »
What I have no idea about is an actual rotary encoder to use.
A motor assembly from a dead hard disk, maybe?  They're lots of fun, although you'll need to connect a couple of opamps to make the signals usable.

Offline Charger

  • Posts: 168
Re: Stand alone rotary encoder
« Reply #4 on: Tue, 23 June 2015, 11:09:51 »
It would be hilarious to assign two encoders to X and Y movement respectively and do a Etch A Sketch with MS Paint. Though I believe someone had already made these things definitely.

The other day I learned about rotary encoder and its quadrature output, I mean, just read Wikipedia and did some search with Google :D And I took apart my defictive encoder to see inside of the device,  it was not what I expected, mmm, clever mecha indeed.

you looking into rotary encoders seems like a good thing to me since i have wanted to set up a volume knob on a keyboard for some time so that gives me hope that it may be added to tmk at some point lol.