Basic question about encoders

Hi,

A simple question. I'm looking for a way to produce a (interrupt) pulse when rotating a button clockwise or counterclockwise. That is called a "shaft encoder" right? However, I don't really see how such a device is connected. I would think it has 4 pins (5V, gnd, cw pulse, ccw pulse). The few encoders I've seen have 4 or 5 legs, but I can't really see how to connect them with a microconroller.

It's the first time I'm buying an encoder so I'd like to make sure I'm buying the right thing :)

Rick

Check this out

http://www.arduino.cc/playground/Main/RotaryEncoders

Well there are passive quaduature encoders, just switch contacts, and active quad encoders (usually optical) so they would wire different. You really have to look at the data sheet for the specific encoder in question.

Lefty

The encoder explained in the playground tutorial is exactly what I meant. But does that mechanism have a certain name? I'll have to buy one so I'm checking the sheets like Lefte suggested, but I don't know what to look at. Reading these sheets is also something I still have to learn!

At the moment I'm looking at http://nl.rs-online.com/web/search/searchBrowseAction.html?method=searchProducts&searchTerm=265-1723#header Except from the line "Output signal, channel A leads channel B by 54° ±30° with clockwise rotation 24 pulse" I'm not seeing information about howto wire it. I can't find the particular encoder on the Alps homepage either, as I don't know if this is a "absolute", "incremental", "magnetic" or "ring" type.

BTW, the encoder is used to rotate a disc on a hobby-thermostat. Zapping through menu's, changing temperature, that kind of stuff.

Thanks, Rick

Most all of these simple mechanical switch encoders are of the incremental type. Here is one typical one:

http://www.sparkfun.com/commerce/product_info.php?products_id=9117

I played with one for awhile but was not too pleased with it for the following reasons:

  1. Pretty bad contact bounce that has to be dealt with either in software or external components. It limits how fast you can turn the knob also without missing steps, etc.

  2. Most have a mechanical detent that makes a clicking sound as you turn the knob. Lots of times it seemed that the mechanical detent steps didn't line up well with the electrical phasing, it just didn't feel precise in it's mechanical detents Vs electrical steps.

I eventually found a surplus optical rotary encoders for a real bargain price, they sell for $50 new. These are really precise and feel great and no cheap clicking sound. Sometimes E-bay has some good deals on surplus optical encoders, but it is hit and miss.

Anyway whatever you get you just have to play around some with it and the code to get a good understanding. They are cool and make a great user interface. Some have a extra switch on the knob (and extra contacts) that you can press in, so it's like spin to select menu item, press knob in to select item, cool.

Good luck

Lefty

I found a link to a cheap optical rotary encoder awhile back on these forums. I never purchased one but I kept the link in case I might need one. It uses 2 channel quadrature encoding 128 pulses/rev. You might want to check it out. Its only $5.

Edit: Here is the link. http://www.bgmicro.com/index.asp?PageAction=VIEWPROD&ProdID=12916

Ill Mill, why do you say that's an optical encoder? I didn't see anything in the description that would make me think so, and $5 is an amazing price for an optical encoder. I would have guessed it's mechanical.

I've used the seeedstudio one with good results, but there is some pretty bad contact bounce. http://www.seeedstudio.com/depot/rotary-encoder-with-switch-p-117.html

why do you say that's an optical encoder?

That's the one and the firm I bought it from. It is indeed a optical encoder, has four wires, ground, +5vdc, channel A & B. At the time was able to find a data sheet on the web searching on "Oak/Grigsby(91Q128-43-0011)" or some part of that. It's really a nice unit with a great smooth feel, quality part. I just ordered two more, can't pass up a deal. ;)

EDIT: here is the link, I found it again: http://www.electro-nc.com/oak/p0104.pdf Here is a Mouser catalog page showing similar (series 90 Vs 91) for $51 each: http://www.mouser.com/catalog/catalogUSD/640/1596.pdf

Lefty

So with that optical encoder, bounce should not be an issue at all, right? If that's true, I should order some too; the seeedstudio ones are okay, but I never did get a completely reliable read because of the bouncing. I just used trial-and-error to get some decent results.

This might be all of what you want but it gives you the background:- http://www.thebox.myzen.co.uk/Workshop/Rotary_Max.html

So with that optical encoder, bounce should not be an issue at all, right?

That is correct.

Lefty

Thank you all! Enough reference materials. I think I'll go for a sexy encoder with a button on top. Saves me another hole/button in the device. The whole thing could be controlled with just 1 encoder and a potmeter in my case. The less buttons, the better. This thermostat also has to be "girlfriend-proof". Although... woman ussually keep adjusting the temperature between -5 and 70 degrees Celcius because it's too cold/hot. Maybe I need to add a password ;)

Rick