encoder BS2P
Bernard
Posts: 3
Hi, everbody
I start, I don't arrive to translate for BS2P in vers 2.5 the part of·PGM downloaded
on parallax site.
Can you help me, thanks
Bernard
' {$STAMP BS1}
' {$PBASIC 1.0}
' Stamp Applications no. 8, October 1995
' Program Listing Demonstrating Use Of a Rotary Encoder
' Program: Rotary.BAS (Read a rotary encoder and scroll a display)
SYMBOL old = B0
SYMBOL new = B1
SYMBOL directn = BIT0
······························· ' Before entering the main loop, the program stores
·the·beginning
································ ' state of the encoder bits into the variable 'new.'
· LET new = PINS & %11000000··· ' It ANDs the pins with %11000000 in order to strip off all bits except for
································ ' 6 and 7. (ANDing a bit with 0 always produces 0; ANDing with 1
································ ' copies the state of the bit.)
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.
································ ' If result=0, counterclock (scroll left).
· GOTO start
······························· ' Do it again.
CW:
······························· ' Clockwise (scroll right).
· GOTO start··················· ' Do it again.
I start, I don't arrive to translate for BS2P in vers 2.5 the part of·PGM downloaded
on parallax site.
Can you help me, thanks
Bernard
' {$STAMP BS1}
' {$PBASIC 1.0}
' Stamp Applications no. 8, October 1995
' Program Listing Demonstrating Use Of a Rotary Encoder
' Program: Rotary.BAS (Read a rotary encoder and scroll a display)
SYMBOL old = B0
SYMBOL new = B1
SYMBOL directn = BIT0
······························· ' Before entering the main loop, the program stores
·the·beginning
································ ' state of the encoder bits into the variable 'new.'
· LET new = PINS & %11000000··· ' It ANDs the pins with %11000000 in order to strip off all bits except for
································ ' 6 and 7. (ANDing a bit with 0 always produces 0; ANDing with 1
································ ' copies the state of the bit.)
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.
································ ' If result=0, counterclock (scroll left).
· GOTO start
······························· ' Do it again.
CW:
······························· ' Clockwise (scroll right).
· GOTO start··················· ' Do it again.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office