Use synchronous detection software to eliminate noise sensitivity. I've done this to eliminate motor noise pickup from a homemade shaft encoder. It completely solved the problem. Mine was an incremental encoder (did not sense direction) but two photodetectors and synchrounous detectors will be required for quadrature detection. I can't give you my code, since it belongs to my employer, but I'll tell you a little about how a synchronous detector works. Preset two registers to the middle of their range (128, probably). Write your software to pulse the photodetector LEDs at different times, reading the detectors such that you increment the appropriate counter when the emitter associated with that counter is on, and decrement the counter when the associated emitter is off. Any noise or non-synchronous signals will be virtually cancelled out. Set your trigger threshold to half the total number of counts for each photodetector for max noise immunity. You don't need a lot of counts for excellent noise immunity. Experiment. More counts slows you down. Don't set your count number so high that it is possible to overflow or underflow the registers. You don't necessarily need a square wave at the emitters as long as you take the same number of samples while the LED is on as when it's off. Then, use the quadrature detection ideas of other respondants to realize a noise free quadrature decoder. I hopes this helps. It worked beautifully for me. At 12:10 PM 4/20/99 +0000, you wrote: >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 > >