> if B <> SaveB then > > if A is high then increment the controlled value > else decrement the controlled value > > Set B to SaveB > > endif > > It is really that simple. Not quite. This doesn't take into account which B edge it was. I you were constantly going back and forth over a single B edge without any A edge occurring, this algorithm would count in one direction instead of going back and forth. ***************************************************************** 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