Rotary encoder - values aren't set to "notches"

I'm having an issue with rotary encoders - I've tried two rotary encoders (similar, from different manufacturers), and tried a few different code samples/examples, but I'm getting the same results... perhaps my understanding of a rotary encoder is incorrect... here's the issue...

When I turn a rotary encoder, there are divots or "notches", and the encoder locks into these notches as I turn. I'd like to get the value only when the dial is "in the notch". One notch equals one value. What I'm seeing however, is that as I turn the encoder, the value changes "between the notches" For example, lets say I have an int which keeps track of a value, and the value is changed when the rotary encoder is turned. If the current value is 7, as I turn the encoder, the value changes several times before the encoder stops at the next notch... usually 3 or 4 values, and the next notch has a value of 11. I'd like it to be only one per notch.

For referenced, I've tried the following tutorials:

http://www.circuitsathome.com/mcu/programming/reading-rotary-encoder-on-arduino
and
http://www.pjrc.com/teensy/td_libs_Encoder.html

I'm wired up to pin14 & pin15 (just like in the "reading-rotary-encoder-on-arduino" tutorial).
When I turn the encoder, it works, in the sense that I do get notified that the encoder has changed, and which direction, it's just that the value is changing not just when the encoder is at the notch, but several times between each notch.

Or am I misunderstanding how rotary encoders and graycode work is wrong (and this is standard and how they work)?

Thanks,

Jeff

What I'm seeing however, is that as I turn the encoder, the value changes "between the notches"

Many of the knob-type encoders work that way. They make electrical contacts only during the transition. Shaft encoders make electrical contacts at all times.

it's just that the value is changing not just when the encoder is at the notch, but several times between each notch.

You are probably experiencing contact bounce. With knob encoders, one usually adds a resistor/capacitor filter to each line as shown here https://www.oscsys.com/sites/default/files/1000003_encoder.JPG

Have a look at my "tutorial"- I use the word loosely....

The snippet from a datasheet bears out what you say, and the serial output and the LEDs agree with each other. That is, the switches A and B are off at a detent then as you turn CW, A goes on before B does- that's how it knows which way the knob is turning, If you went CCW from that first detent, B goes on before A.

As you turn the knob sloooowly between detents, you can see the LEDs react to the changes in A and B.

I don't know if you have the datasheet for your actual model, but I suspect it will have a "wave diagram" showing exactly how the outputs change as you turn the knob in either direction.

edit.... all of which might be irrelevant for your grey code device :~

As you know, there are four different logic states of the hi/low outputs of pins A and B. The relationship between the detents and the logic states varies from encoder to encoder. Some have a detent at every different state, some have two detents for the four positions, and some, like yours, have only one. If the code you are using counts each state change, then you will increment by four between notches. Some versions of code only count half the changes.

If you have only one detent per four states, you should be able to determine the pattern of A and B at the detent. It should be the same at each detent. You will change your count by plus or minus one each time you see that pattern. The direction of rotation to determines whether you are increasing or decreasing your count.

As JimboZA says, your data sheet should have a diagram of the pulse pattern. Study that, and you will see that for each direction of rotation one of the two pins changes first from the detent position. Find out which is first to change after the detent and you can determine direction of rotation and whether to increment or decrement at the next detent.

Thanks everyone! I've got it figured out - the value changes 4x per notch, and it's just something I'll have to accommodate for.

What was throwing me off was that with one of the examples I was referencing (at http://www.circuitsathome.com/mcu/programming/reading-rotary-encoder-on-arduino), when I turn my encoder the "delta" between each notch wasn't consistent. Sometimes it was 4, sometimes it was 3, and sometimes t was two.

The Encoder library (at Encoder Library, for Measuring Quadarature Encoded Position or Rotation Signals) seems to be more stable and consistent - the "delta" between each notch is always 4.

Again, thanks for the help!

Jeff