Bourns rotary encoder with detents - no gray code? - Page 1
Forum section: electronics / projects

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 20, 2012, 11:50:55 pm
content: Hi,I recently bought a few Bourns PEC16 2215F-S0024 rotary encoders on eBay since I'm toying with the idea for a project where I could use some rotary knob as input. Anyway, according to the data sheet, they should have a "2-bit gray code" output. Which would mean that turning the knob left or right should cycle through patterns which differ only by one bit:I.e. for the one directionA 0 1 1 0B 0 0 1 1 ...There's also a little figure in the datasheet which looks exactly as you would expect.However, when I test the encoders, I can observe a behavior that is quite a bit different:A 0 1 1B 0 1 0 ...And for the other direction:A 0 1 1B 0 0 1 ...It looks like at the detents, both outputs are open and when turning left/right there are high pulses created on both outputs, where in the one direction, the rising edges are synchronous (but not the falling edges), while in the other direction the falling edges are synchronous (but not he rising edges).So this should make it possible to detect the direction, but this is clearly no gray code and not nearly the behavior shown in the figure. My guess is that the figure in the datasheet is only valid for the version without detents, but there is no remark and the datasheet is for both versions.Any hints?

author: Bored@Work
author_rank: Super Contributor
timestamp: February 21, 2012, 12:57:47 am
content: You mixed up the ground pin and a switch pin.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 21, 2012, 05:38:08 pm
content: In my understanding, there is no such thing as a ground pin. There are just switches which are either closed or open.But indeed, when I connect 5V to the 1st pin instead of the middle pin, the behavior looks much more grayish.The weird thing is that the data sheet call the middle pin C and the outer pins A and B and A/B are also used as output names in the diagrams.I'm beginning to think that either the datasheet was made my madmen or I got completely different encoders than what I ordered...

author: slateraptor
author_rank: Frequent Contributor
timestamp: February 21, 2012, 06:25:45 pm
content: Quote from: 0xdeadbeef on February 21, 2012, 05:38:08 pmI'd be cussing up a storm.

author: Bored@Work
author_rank: Super Contributor
timestamp: February 21, 2012, 07:06:04 pm
content: Unnecessary rudeness removed !

author: nessatse
author_rank: Regular Contributor
timestamp: February 21, 2012, 09:30:17 pm
content: Quote from: 0xdeadbeef on February 21, 2012, 05:38:08 pmThere appears to be a mistake in earlier versions of the datasheet. The one on the Bourns website [size=78%]http://www.bourns.com/pdfs/pec16.pdf is REV 05/11 and shows the pin order as A-B-C, whereas the older version on one of the datasheet archives [size=78%]http://pdf1.alldatasheet.net/datasheet-pdf/view/221373/BOURNS/PEC16-2215F-S0024.html, is REV 07/07 and shows the pin order as A-C-B.I guess it's a good idea to always try and find the latest version of the datasheet.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 21, 2012, 10:06:24 pm
content: Honestly I took more or less the 1st datasheet I found as I couldn't imagine that someone could screw up something as basic as the naming of the three connectors of the base functionality. But ok, I learned now that this is possible as well.Thanks guys...

author: SgtRock
author_rank: Unknown
timestamp: February 22, 2012, 02:14:09 am
content: Dear Oxdeadbeef:--Indeed Nessatse is correct (see the attached pictures below), the older version of the data sheet has mislabeled the pins. The pin "C" is the one that gets Vs. And indeed you did not even need to look at the effing data sheet to tell that there was no "ground pin". If you had taken the advice you were so rudely hand down from the high horse, you would still be searching for this figmentary ground pin. If he says there is a ground pin, you had better agree right away, else you are going to treated to some clever profanity.--I always wondered how rotary encoders worked, and your mention of the Grey Code put me on to some very good information about rotary encoders, and 2 digit Grey encoding (quadrature). My ignorance in these matters is now somewhat lessened. Thank to everyone for the good posts."There once was a worker, so bored.That when his posts were ignored.He'd strive on inanely,And most times profanely.But seldom, if ever he scored."Gator Dundee 1948 -Best RegardsClear Ether

author: sacherjj
author_rank: Frequent Contributor
timestamp: February 22, 2012, 02:40:05 am
content: Quote from: slateraptor on February 21, 2012, 06:25:45 pmWe leave that to BoredAtWork.

author: slateraptor
author_rank: Frequent Contributor
timestamp: February 22, 2012, 03:27:38 am
content: Quote from: SgtRock on February 22, 2012, 02:14:09 amCommon, ground. Tomato, tomato.

author: Wartex
author_rank: Frequent Contributor
timestamp: February 22, 2012, 03:42:52 am
content: Quote from: BoredAtWork on February 21, 2012, 07:06:04 pmSomeone has anger management issues. Passive aggressive anger, the best kind of anger.

author: Bored@Work
author_rank: Super Contributor
timestamp: February 22, 2012, 09:56:09 am
content: Quote from: Wartex on February 22, 2012, 03:42:52 amNo, I have issues with idiots who can't even hold a multimeter in continuous mode to three pins in the right order after told they got the wrong order. How hard is it really? How much time would this take? One minute? And maybe another minute to draw a, I dare to say "schematic", of two switches and figure out what happens if you get it wrong?** Unnecessary rudeness removed **

author: Simon
author_rank: Unknown
timestamp: February 22, 2012, 10:00:03 am
content: if you feel the original poster is not heeding your advice properly just ignore the thread and stop replying if you feel its a waste of time.

author: 0xdeadbeef
author_rank: Super Contributor
timestamp: February 22, 2012, 08:12:09 pm
content: Quote from: BoredAtWork on February 22, 2012, 09:56:09 amApart from being rude, you also didn't really seem to understand the issue. Letting aside that non-existing ground pin, this kind of rotary encoder leaves both switches open when a detent is reached. And it cycles through the whole gray code between two detents (meaning that at least for some time, all three pins are shorted). Thus measuring with a continuity tester is absolutely and completely futile. Before you insult other people based on your misconceptions, you should maybe take a deep breath first and consider the fact that you're maybe not as incredibly clever an other people not as incredibly dumb as you think.Anyway, as an engineer you have to be able to trust a datasheet and a good datasheet should contain all information about a device, not erratic and sketchy pieces of information. Reverse engineering each and every piece of equipment due to nonprofessional datasheets might be ok for the hobbyist but is certainly unacceptable in a commercial environment.