EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: 0xdeadbeef on February 20, 2012, 11:50:55 pm

Title: Bourns rotary encoder with detents - no gray code?
Post by: 0xdeadbeef on February 20, 2012, 11:50:55 pm
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 direction
A 0 1 1 0
B 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 1
B 0 1 0 ...

And for the other direction:
A 0 1 1
B 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?
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: Bored@Work on February 21, 2012, 12:57:47 am
You mixed up the ground pin and a switch pin.
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: 0xdeadbeef on February 21, 2012, 05:38:08 pm
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...
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: slateraptor on February 21, 2012, 06:25:45 pm
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'd be cussing up a storm. :P
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: Bored@Work on February 21, 2012, 07:06:04 pm
Unnecessary rudeness removed !
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: nessatse on February 21, 2012, 09:30:17 pm
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...


There 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 (http://www.bourns.com/pdfs/pec16.pdf)[/size] 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 (http://pdf1.alldatasheet.net/datasheet-pdf/view/221373/BOURNS/PEC16-2215F-S0024.html)[/size], 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.  :)
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: 0xdeadbeef on February 21, 2012, 10:06:24 pm
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...
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: SgtRock on February 22, 2012, 02:14:09 am
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 Regards
Clear Ether
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: sacherjj on February 22, 2012, 02:40:05 am
I'd be cussing up a storm. :P

We leave that to BoredAtWork.    ;D
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: slateraptor on February 22, 2012, 03:27:38 am
...you would still be searching for this figmentary ground pin.

Common, ground. Tomato, tomato.
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: Wartex on February 22, 2012, 03:42:52 am
I don't care what is in the fucking datasheet. I don't even have to look at the datasheet to know that you mixed up pins.

I delete PMs unread. If you have something to say, say it in public. I love the sound of a "you are not helpful" whining in the morning.

Someone has anger management issues. Passive aggressive anger, the best kind of anger.
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: Bored@Work on February 22, 2012, 09:56:09 am
Someone has anger management issues. Passive aggressive anger, the best kind of anger.

No, 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 **
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: Simon on February 22, 2012, 10:00:03 am
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.
Title: Re: Bourns rotary encoder with detents - no gray code?
Post by: 0xdeadbeef on February 22, 2012, 08:12:09 pm
No, 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?
Apart 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.