Just relating my own experience here. In normal use, I find that the Phase B signal has done all the bouncing that it's likely to at the point when the Phase A transition happens. Once I made a routine that took a sample right after the Phase A transition, then waited a while (200 uSec? or so) and took another sample, waited again, and took a third sample. Then I took the "best 2 out of 3" as the answer. At the time it sounded elegant, but in reality didn't help very much. What electrical components are you using around your encoder? For me, a pullup of around 47K ohms to +5 and a bypass of around 680 pF from each contact to ground works pretty well. Brian Aase On 22 Jul 2001, at 19:32, SkinTech wrote: > Brian, > You may have a point here, but what about the chattering/bouncing of the > contact? Maybe I should process the change at the first indication of a > change, let the thing bounce away with maybe some delay AFTER processing > BEFORE polling again, what do you think? > > Jan Didden > > PS This thing has 15 detents and 30 steps over 360 deg. Even turning at 1 > rev/sec (which is pretty fast for a manually operated knob) gives some 33 > msec to leisurely process each change. > > ----- Original Message ----- > From: "Brian Aase" > To: > Sent: Sunday, July 22, 2001 7:09 PM > Subject: Re: [EE]: Stumped by rotary encoder > > > > I might just add that your initial 10 mS debounce delay should > > not be necessary. If you look at the rotary encoder data sheet, > > you will see that when Phase A "fires", Phase B is already at > > the 50% point of its (virtual) period. My experience has been > > that adding any additional delay here usually makes things less > > reliable. FWIW. > > Brian Aase > > > > On 23 Jul 2001, at 2:28, Roman Black wrote: > > > > > Hi Jan, I think your problem might be simple, the > > > standard way to do this is sense ONLY the 0-1 transition > > > of A, then checking B tells you the direction. > > > You just ignore the 1-0 transition on A. > > > > > > I'm sure that will fix it for you. :o) > > > -Roman > > > > > > > > > > First I check by polling if there is a change in the 'A' bit. If so, I > wait > > > > some 10mS (debounce) and then look again. If there is still a change, > I > > > > check if it is 1>0 or 0>1. In each case, I then check the 'B' bit to > > > > determine direction. For debugging I beep once (CW) or twice (CCW) the > > > > buzzer. > > > > When turning the encoder I get seemingly random results. Sometimes it > beeps > > > > 3 times, or 4 times, or 1 time, or not at all over half a revolution. > Then > > > > it starts again. I'm pretty sure it has to do with the debounce, but I > can't > > > > get it right. I must add that the beep adds another 10 or 30 mS delay > > > > between pollings. > > > > The encoders are spec'd at <5mS chatter. > > > > > > > > Has anyone experience with decoding rotary encoders? Any help or ideas > would > > > > be greatly appreciated. > > > > > > > > Jan Didden > > > > SkinTech > > > > > > > > ; The encoders output a 2-bit value: > > > > ; the A-bit signals rotation, > > > > ; the B-bit signals the direction of rotation. > > > > ; encoder movement is detected by polling and debouncing in the > b-port. > > > > ; > > > > ; --------------------->cw > > > > ; channel A ___ ___ ___ [channel A leads channel > B] > > > > ; ___| |___| |___| > > > > ; > > > > ; channel B ___ ___ ___ > > > > ; |___| |___| |___| > > > > > > -- > > > http://www.piclist.com hint: The list server can filter out subtopics > > > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > > > > > > > > > > > -- > > http://www.piclist.com hint: The list server can filter out subtopics > > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > > > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics