mat janssen>>
Thank yoiu very much for the code snip..but i cant understand whats going on in the code ,esp the "&~" part
I tried using the code...however ,whatever maybe the direction the motor is running ....i get the same reading ,say always "left"



Luciano>>
Thanks for the links..
i ported the foll code from nv8 [http://www.parallax.com/dl/docs/col...ol1/col/nv8.pdf --pg7]
Code:
    let new = pins & %11000000 ' Mask off all but bits 6 & 7
start:
   let old = new & %11000000 ' Mask bits and copy new into old.
again:
   let new = pins & %11000000 ' Copy encoder bits to new.
   if new = old then again ' If no change, try again.
   let directn = bit6 ^ bit15 ' XOR right bit of new w/ left bit of old.
   if directn = 1 then CW ' If result=1, encoder turned clockwise.
   serout 0,n2400,(I,left) ' If result=0, counterclock (scroll left).
   goto start ' Do it again.
CW:
   serout 0,n2400,(I,right) ' Clockwise (scroll right).
   goto start ' Do it again.

To pbp


Code:
old VAR BYTE
new VAR BYTE
direct VAR BIT

quad:
	new= PORTC && %00000011
	
start:
	old=new && %00000011

again:
	new= PORTC && %00000011
	Pause 10
	LCDOut $fe,1,"no movement"	
	IF new=old Then again
	direct=new.bit1 ^ old.bit0	
	IF direct=0 Then GoTo cw
	LCDOut $fe,1,"one dir"
	Pause 10
	GoTo start
		
cw:
	LCDOut $fe,1,"2nd dir"
	Pause 10
	GoTo start
with the above code...there is alot of fluctuation between the 2 directions..

..anything going wrong in my code?.i sat on it the whole day..still cant figure out the problem