sku: COM-09117
Description: This is a 12-step rotary encoder with a nice 'clicking' feel. It's breadboard friendly, and has a pretty handy select switch (by pushing in on the knob). The encoder is different from a potentiometer in that an encoder has full rotation without limits. The unit outputs gray code so that you can tell how much and in which direction the encoder has been turned.
This unit does not come with a knob, but a working knob is related below.
Documents:
COM-09941
Rotary Potentiometer - 4.7k Ohm, LinearCOM-09939
Rotary Potentiometer - 10k Ohm, LinearCOM-10790
Rotary Encoder - 200 P/RCOM-10932
Rotary Encoder - 200 P/R (Quadrature)COM-10001
Silver Metal Knob - 14x24mmCOM-09997
Red Knob - 15x19mmCOM-10595
Circular LED BargraphsCOM-10000
Black Chicken Head Knob - 14x20mmCOM-09999
Red Chicken Head Knob - 14x20mmCOM-09998
Black Knob - 15x19mm
Comments 43 comments
hi – so i am using the 3 pins on one side to read-in the rotary data no problem. and actually there is little to no bounce, which is uncommon for such a cheap little unit! but also i have a question, i can’t figure out how to read in the push button data … it doesn’t seem to be the two pins on the other side … am i missing something?
cuzincuz,
I’ve got one in front of me and the two pins are to the push button. Momentary, normally open.
I have the some example code for the Arduino that does a decent job figuring out where and how much is being turned on the encoder.
Take a look here:
http://gist.github.com/154809
(if you can help improve the code please fork it)
Made it into a library:
http://github.com/medecau/QuadEncoder
The Rotary Encoder sku: COM-09117 is missing its PDF data sheet. http://www.sparkfun.com/datasheets/Components/TW-700198.pdf fails.
Wouldn’t most say this is a quadrature encoder? Gray code implies absolute, and this would need four bits of Gray to be that. Yes, quadrature is a two-bit Gray code, but still…
I think they key idea of gray code is that only one bit changes between adjacent states so there is less guessing about the state during a transition.
This is true of a quadrature encoding, as you said.
Yes, I agree with skelso that quadrature would have been more descriptive. The datasheet also does not fully describe which pins the push switch connects to, but I assume that they are the two unlabeled pins. I also assume that they meant to describe the switch as a momentary, normally open type which goes to closed when the shaft is pressed down.
Clarity in datasheets is becoming rare nowadays…
I have the push working nicely.
But cannot make sense of the rotary encoding. The values the device reports seem very arbitrary. It is frustrating; I am going to need to re-think the interface to this project. If I had been able to make this work as expected it would have been a perfect choice for this control interface.
Take a look at this, it may be relevant to your interests: http://en.wikipedia.org/wiki/Rotary_encoder#Incremental_rotary_encoder
Anyone have an eagle part for this?
Yeah, just verified the footprint. I’ll upload it as soon as I test the board.
Uploaded the footprint, etc, to http://www.ste-marie.net/RotaryEncoder.lbr
See my cooking timer example (link above) – it has a verified eagle part for download.
Be warned! This one only has 12 steps per cycle instead of the usual 20.
Very easy to use. I have written some introduction on how to do so here: http://bit.ly/cNdzV7
A word of warning about using these in an enclosure. There is very little room between the bottom of the knob (sold seperately) and the encoder case. Without pressing the “button” there is 1.0mm (assuming you make holes for the two small bumps on top of the encoder case). With the button pressed you’re down to about 0.5mm (I couldn’t get my calipers in between to measure).
I ended up cutting holes in my enclosure large enough for the knobs to fit inside. My case would have looked cleaner if I could have had holes just big enough for the shafts.
any tips on using this with COM-10001? I ordered two of each and, alas, the knob doesn’t really fit. I am loath to use glue but I suppose I will if I must.
Otherwise MANY thanks to all the helpful links! with the info here I got it up and running in about as much time as it took to open the box. =-D
It works best with knobs that have set screws.
I am using this with COM-08828 and had problems with the button sliding down the shaft so far that the select switch would not work. I solved the problem by putting a small wad of paper in the knob so that it could not slide all the way down, but is still secure on the shaft.
BTW, I am using this with a parallax propeller and it works nicely with the article/code from Jon William for Nuts and Volts Magazine:
Article:
http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp6.pdf
Code:
http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/code/nvp6.zip
Tactile feedback is kind of weak, more bumpy than snappy. Still noticeable though. Good enough for prototyping. Might want to try a wider range of alternatives if you’re considering deployment or building something permanent.
I agree with fluidic on the feel of this encoder. it is very weak, and unstable. but for 3 bucks, it is a great deal for proto work. if you need anything with single-click precision, this model won’t work very well. I used Oleg’s code and it ran first build, as advertised.
Here’s the Arduino code I ended up using.
Here’s a slick, 2-wire interrupt-driven Arduino solution (which should be easily adaptable elsewhere) that I saw over at Ayars' Hardware Hacks:
http://hacks.ayars.org/2009/12/using-quadrature-encoder-rotary-switch.html
It only determines direction, but that’s all I’m going to be using this for.
Does anybody know of a knob that fits this? I tried the silver metal knob (COM-10001) and it definitely does not fit – the shaft is too big. I tried a knob off another piece of equipment (perhaps similar to the black knob, COM-09998) and it didn’t fit either. It’s pictured with COM-08828, is that the only one that fits?
Thanks.
Saccade, if you check the data sheet, you will see that this has a 6mm shaft as opposed to the more common (in the US) ¼" shaft. You can find many knobs on the web for a 6mm shaft – Google “6mm shaft knob” for a zillion of them. The biggest problem you’ll have is finding one that doesn’t cost as much as two of these encoders! You can sometimes make a ¼" inch knob fit very nicely by shimming with a split ring made from an aluminum soda can.
Thanks; actually I just didn’t push hard enough. Once I got the encoder mounted, I was able to Push Pretty Hard on the COM-10001 silver knob, and it did fit on the encoder’s shaft.
For whoever may find it useful: I used a bunch of these rotary encoders for a prototyping project and I wrote a simple wrapper library around them.
You can find the code on GitHub:
https://github.com/micheljansen/arduino-rotary-knob
These are definitely quadrature encoders. You can multiply the counts by using edge detection. So you can increase the counts to a maximum of 48 counts easily.
That sounds great! Could you share a cade for this? I use a Wiring board.
Thanks!
First, I can’t believe that someone does not make an I2C decoder for an Rotary Encoder. YES, I have ran across people making PICs that can do it, but I am still surprised that no one has made a 12 pin chip that can fit the bill.
What I did find, that I thought was interesting, was a made from two 74HC132 chips with some passive glue >> http://archive.electronicdesign.com/files/29/21422/fig_02.gif Full article is here >> http://electronicdesign.com/article/analog-and-mixed-signal/simple-quadrature-decoder-suits-rotary-encoders214.aspx.
What caught my eye was that there were only two outputs: INC, and DIR.
My frustration with tying a rotary encoder to an Arduino is that you’re wasting resources of the Arduino. Also you have to make sure whatever code you are writing never hangs so to prevent the Arduino from seeing a INT or changed state from the Rotary Encoder. Yes, I do realize that most Arduino are fast. But there always some type of code that takes it’s sweet time to get through that prevents the processor from seeing the INT or a changed state.
I see this exactly the other way around. I like to use the Arduino for this and do everything in software (which I can change if I find out it does not work), instead of using 10 external components and a custom PCB. If you look at the code – it takes only a few lines. Also, you would not free up any pins Enc A and Enc B with one solution and INC and DIR with the other. I guess it comes down to preference and what you are more comfortable hardware vs software…
I agree with your assessment with INC and DIR. But what would really be cool is if the Rotary Encoder could be hooked up to something like a PCA9555 {http://www.nxp.com/documents/data_sheet/PCA9555.pdf } and let the PCA9555 do the monitoring of the Rotary Encoder- no software for monitoring the Rotary Encoder, just software that talks I2C, and responds to a INT. Then all you have is two wires for I2C, and an INT. Everything is addressable.
I think the next step for the Mayhew Labs Rotary Encoder LED Ring Breakout Board is to add RGB LEDs, and Maybe three PCA9635 chips that does all the mixing/dimming on the chips for the LEDs (NO-resistor networks), again all I2C bus (-two wires and the INT, plus VCC and Vss). And all the PCA9xxx chips are addressable meaning you can have a number of I2C chips on the same I2C buss. The PCA96xx can run around 1MHZ and the PCA9555 runs around 400 KHZ. That means the I2C bus has to run at the lower speed unless you can MUX it so they see the speed they like. I just like the thought that you could have the color you want, at the brightness you want, and it does not mean that your locked into one set of colors. HECK you could have the UV meter style output, or maybe one color where everybody else is another color. If the PCA9555 cant trap and help with decoding, then I guess we are stuck with having the Arduino do it.
I have designed my own simple rotary encoder breakout board for this part out of necessity. You can check it out here: http://www.inmojo.com/store/disassemble-reassemble/item/rotary-encoder-breakout-pcb-only/
I have created a library that works with this encoder. See it here:
http://code.google.com/p/adaencoder
It differs from most other code by being interrupt-driven and easy to use on any pair of Arduino pins (with caveats that the pins must share an ATmega PORT [see the source code for more info]).
Enjoy!
I found the example code pretty confusing. For more understandable, no library and rock steady decoding check out this page.
Worth Noting that these are 48 steps/Revolution not 12, there are 12 DETENTS, each detent counts as 4 steps electrically.
it depends on how you’re reading the code. they are 12 steps per revolution. you’re code is just outputting 4 signals per step. try some of the other example codes.
This is true, and it allows code to be a lot shorter than other people have it. If it is being used by each click at a time, then connecting the common to 5v and the other to 2 input pins(with some pull-down resistors), you can see which way it was turned by seeing which pin goes high first(it will be all messed up if you keep it in a position between clicks, however).
“It’s breadboard friendly,”
Not really. DO NOT PUT THIS IN YOUR BREADBOARD!!!! It bends the leads and then they snap off. You have two options:
baum
Looking at the data sheet this has quadrature outputs and not gray code. There is a big difference. Sparkfun can you comment on this and / or change the description.
-Sam K
I ordered a few of these inexpensive rotary encoders to play with and electrically they work fine. I have some simple PIC test code to inc/dec a 7-segment LED and seems pretty reliable. What I don’t like about this part is the action… it’s too easy to get stuck in the middle of the 12 indents, especially when turning slow. I’m assuming a higher quality part would do a better job of only stopping on the 12 position indent and not in the middle of two positions.
:( Mine came with a pin broken and I have contacted sparkfun,but I was really hoping i could get this project done :(
You REALLY need to “pad” the boxes you use…