The decoder I used (Bournes) had a specified contact bounce time of 5 ms. That was a good reason not to connect it a an interupt pin! Seriously I did think about thihs method and was warned against it by someone else on the list becuase of this. I guess if you are using a super optical encoder with no bounce it would be ok. Regards Mike Rigby-Jones > -----Original Message----- > From: < Patric Anvegard [SMTP:patric.anvegard@ARCOMA.SE] > Sent: Tuesday, April 20, 1999 1:10 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: Quadrature decoder > > Hi everybody! > > Thanks for the good advises to solve my problem with the quadrature > decoding. > I'll try some of the routines I got from Walter Banks and Alvaro and see > how they work... > > The solution that I had some thoughts about before I sent this message to > the list > was that this problem could be solved by having one of the channels(A) > connected > to the Capture input and the other one to an "ordinary" input. > The Capture module is initialized to interrupt on rising edge. When I get > an interrupt I > put the processor in "state 1" if the B-channel is 1 or in "state 0" if > the B-channel is 0 > and when changes the CCP module to interrupt on falling edge. > When I get the next interrupt I read the B channel and detects the > direction. If the > previous state was 0 I should now get a 1 on the B-channel or if the > previous state was 0 I should now get a 0. If I get two 0 states (or two 1 > states) I ignore it (this could > accure if I get noise on the A channel or if the direction has changed on > the encoder. > > Does anyone have an argument why this should'nt work or should I put some > effort to try this solution too. > > Patric AnvegŒrd