> Better code: > > if B and not SaveB then > > if A is high then increment the controlled value > else decrement the controlled value > > endif > > Set SaveB to B > > It is really that simple (now that I got it right). I agree this works and is suitable for many applications. It should be noted, however, that this produces one count per complete quadrature cycle, and that the increment and decrement don't happen at the same point in the cycle. Again, no big deal in many circumstances. ***************************************************************** Embed Inc, embedded system specialists in Littleton Massachusetts (978) 742-9014, http://www.embedinc.com -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads