9

for my current project I'm planning to use an input "device" like this in the photo (don't know its real name):

alt text

It is used in a lot of musical instruments and it is like a potentiometer that can be rotated as many times as you want. I think it isn't read like an analog value. Can someone give me some hints?

Thank you very much.

stevenvh
  • 145,145
  • 21
  • 455
  • 667
3mpty
  • 317
  • 1
  • 4

1 Answers1

22

It's a rotary encoder. It has two outputs giving pulses in quadrature (see image), as to determine the way it's rotated.

enter image description here

In the image you can see that the level of the B channel is low on the rising edge of the A channel if the knob is rotated clockwise, but high if rotated counterclockwise.
Differences in models are the number of pulses per rotation, often between 15 and 20, and the number of channels. More than 2 channels are used to obtain the absolute position of the knob. E.g. 10 channels give 1024 unique codes per rotation. Gray coding is used.
edit
Another parameter is the detent. Detents are click-positions, which require a certain momentum to overcome. Some models have 2 detents per pulse, others don't have detents and rotate rather smoothly, so that it feels like a potmeter without stops.


Further reading
"Control Shaft Encoders" \$-\$ Circuit Cellar issue 250, May 2011, p.28 ff

stevenvh
  • 145,145
  • 21
  • 455
  • 667
  • thank you! do you know if it is possible to buy it with the plastic part attached? – 3mpty Dec 25 '10 at 15:05
  • 1
    The encoder as sold is like a potmeter, i.e. with a plastic or metal 6mm axis. You'll have to purchase the knob separately. In the past I've had trouble finding knobs with greater than 40mm diameter, esp. ones with an index like in your picture may be hard to find. – stevenvh Dec 25 '10 at 15:11
  • 3
    great answer! sometime it seems like half the challenge is finding out the names of things. – Mark Harrison Dec 25 '10 at 23:13
  • 2
    Another note, they sell these type of encoders as quadrature (as shown above) and pulse. Pulse encoders pulse two lines every detent, with one trailing the other depending on direction. I like the pulse better because you don't need a state machine to implement, just a couple interrupt inputs. But it's important to know what you get or you could run into problems interfacing with them. I'd also check out CUI, they have good encoder prices. One other thing to look for, mechanical versus optical. Mechanical is cheap, optical have long life. – bt2 Dec 26 '10 at 15:57
  • @Federico, you're right. The image server was down. I don't know if it's necessary to rollback. But now at least we have a backup :-) Thanks. – Daniel Grillo Jun 15 '11 at 17:06
  • CUI has a presentation about their encoders [here](http://products.cui.com/CUI_C14_Series_Product_Training_Presentations.pdf?fileID=6204), which has a good overview of the terminology. – Kevin Vermeer Jun 16 '11 at 12:13
  • 1
    @bt2 I'm pretty sure standard quadrature encoders don't require a state machine to implement -- just set an interrupt on one of the lines, and when it goes high, check the value on the other line. If it's high, it's going one way, if it's low, it's going the other. – Evan Krall Jan 21 '12 at 10:44
  • @EvanKrall The state machine is one possible way of debouncing the input. – Isvara Jul 20 '13 at 00:50