In a message dated 10/3/99 6:08:38 AM Eastern Daylight Time, morgans.rt@TELIA.COM writes: > Well.. To be safe, the routine has to detect also when both phases has > changed (180¡ cycle rotation since last time) This will indicate overspeed > or hardware error, noise or other error. In a hardware error, most likely 1 or both outputs would not change at all. >W often has to now when/if the > routine fail so we dont tahe an erroneous cont for correct, especially in > machine positioning... > ChkEnc mov new,Enc ;get new input and new,#%00000011 ;get rid of all but 2 enc bits mov temp,new ;make copy xor temp,old ;is old = new jz ChkEnc ;then no change, go back cje temp,#3,err ;goto "error" if both bits changed clc ;get ready for right shift rl Old ;align bits xor old,new ;check for direction jb old.1,up ;if 1 then up direction, if 0 then down direction Error detected! I use scenix chips at 50-85MHz.The chances of missing a change are slim, however. As long as it is scanned every 1/(resolution of encoder*max changes per sec). Matt Ballinger