Hi Randy I've posted this code several times in this list, and got no comments on it. I hope this help you ; Encoder read #define encx PORTA,1 ; Encoder inputs #define ency PORTA,2 ; ; ; Inic (usually needless) clrf auxint ; Clear aux var btfsc encx ; and get encoder inputs bsf auxint,0 ; in bit 0... btfsc ency bsf auxint,1 ; ...and 1 ; ; Here starts the hard work movf auxint,W ; encod <- (actual state) xor (previous one) xorwf encod,F ; (only bits 0 and 1 affected) ; rrf auxint,F ; XOR results, reordered, get rlf encod,F ; into encod, in bits 0 and 1. rrf auxint,F ; This bits are the motion indicators rlf encod,F ; At this point you have a new read of the encoder. Bits 2 and 3 of 'encod' have the information about the direction of movement of the encoder. If you have to translate this information into a variable, then you can do something like this: ; btfsc encod,2 ; Direction 'X' motion incf posenc,F btfsc encod,3 ; ...or 'Y' decf posenc,F ; Bits 4,5 and 6,7 of 'encod' have the previous reads. I place this routine in an time based interrupt (about 20ms time period). The frequency of the interruption have to deal with the speed of the incoming changes in the encoder signals. Hope this helps, ēlvaro. ----- Mensaje original ----- De: Randy A. Para: Enviado: viernes, 01 de octubre de 1999 18:08 Asunto: Reading Quadrature Incremental Encoders > Does anyone have information regarding how to read the Quadrature signals > from an incremental encoder such as those used for feedback loops on servo > motors on CNC machinery. In fact I am working on a low cost controller for a > single axis machine. > > Any and all suggestions will be GREATLY appreciated. > > Randy A. >