Dwayne Reid wrote: > The "proper" way to read those encoders is to set up a state machine > that looks at both lines and ignores illegal transitions. This > becomes a problem if you try to make it interrupt driven - simple > PICs have only 1 usable interrupt input (I'm deliberately ignoring > the port B Interrupt On Change because of its known > limitations). Huh? It's always worked very well for me, and I don't remember any errata on it. It's just about what you'd want for quadrature decoding, and I've used it for that. In one project I had a 16F876 do proper quadrature decoding as an in-line adapter to clean up the signal so that one of those dedicated quadrature decoder chips would work right. There were no issues related to any port B interrupt on change problem. In fact there were no issues at all. It worked great. > The easy way to fix that problem is to use an XOR gate > to combine the lines into the INT pin. But then you only get an interrupt every second state change, which misses out on resolution and makes noise and error detecting harder. Proper decoding software uses each new state change. There are 4 states, so 2 are adjacent to the current state. One is a 1/4 cycle one way and the other a 1/4 cycle the other way. In theory you can't jump straight to the remaining state, but things aren't always perfect. The problem then is that it can be interpreted as both +1/2 and -1/2 step. I had my software track the previous step direction and assume the 1/2 cycle step was in the same direction as the last step. This is a good assumption because the most likely cause for seeing a 1/2 cycle jump is that the input pulses are coming too fast for the processor to handle. By the way, some of the 30Fs have quadrature decoder modules, but I haven't had an opportunity to use one yet. ****************************************************************** Embed Inc, Littleton Massachusetts, (978) 742-9014. #1 PIC consultant in 2004 program year. http://www.embedinc.com/products -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist