Help reading simple four quadrant encoder disk with BS2
I could use some help. I've created a simple four quadrant encoder disk (attached) that I can use with the QTI IR sensor to debug 1's and 0's. Circuitry is good, and manually moving the disk past the sensor works perfectly. But I'd like to take the bit read from the encoder to pulse a servo one quarter turn (which is why the encoder disk is so simple), then stop and wait for the next command to make a quarter turn, and so on.
My thought is to monitor the bit and tell the servo to stop turning when the bit changes from a "1" to a "0" (or vice versa). Conceptually, it seems simple (isn't that always the case!), but my lack of coding experience is killing me. I could use some help with the section below. What am I doing wrong? Do I need a write/read command? Any help for a newbie would be most appreciated!
Motor PIN 12
'
[noparse][[/noparse] Constants ]
Motorstop CON 750
'
[noparse][[/noparse] Variables ]
qti VAR BIT
old VAR BIT
DO
HIGH 5
PAUSE 1
qti = IN3
INPUT 5
qti = old
PULSOUT motor, 850
IF (qti <> old) THEN
PULSOUT motor, motorstop
ENDIF
LOOP
My thought is to monitor the bit and tell the servo to stop turning when the bit changes from a "1" to a "0" (or vice versa). Conceptually, it seems simple (isn't that always the case!), but my lack of coding experience is killing me. I could use some help with the section below. What am I doing wrong? Do I need a write/read command? Any help for a newbie would be most appreciated!
Motor PIN 12
'
[noparse][[/noparse] Constants ]
Motorstop CON 750
'
[noparse][[/noparse] Variables ]
qti VAR BIT
old VAR BIT
DO
HIGH 5
PAUSE 1
qti = IN3
INPUT 5
qti = old
PULSOUT motor, 850
IF (qti <> old) THEN
PULSOUT motor, motorstop
ENDIF
LOOP
Comments
http://forums.parallax.com/showthread.php?p=893416
I hope this helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
·Now wanting to learn Spin· Thanks for any·
·
·
·
·
Sam
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Post Edited (Zoot) : 4/20/2010 10:05:02 PM GMT