QTI software question
bstrom1953
Posts: 3
We mounted the QTI Line Follower hardware on the Boe-Bot. Now I am looking at the software that is supplied. Where can I learn about the command DIRB. I need to understand this code:
DIRB = %1111 ' P7..P4 -> output
PAUSE 0 ' Delay = 230 us
DIRB = %0000 ' P7..P4 -> input
PAUSE 0 ' Delay = 230 us
' PULSOUT UnusedPin, 0 ' Delays = 208 + (Duration*2) us
qtis = INB ' Store QTI outputs in INB
Thanks, bstrom1953
DIRB = %1111 ' P7..P4 -> output
PAUSE 0 ' Delay = 230 us
DIRB = %0000 ' P7..P4 -> input
PAUSE 0 ' Delay = 230 us
' PULSOUT UnusedPin, 0 ' Delays = 208 + (Duration*2) us
qtis = INB ' Store QTI outputs in INB
Thanks, bstrom1953
Comments
https://www.parallax.com/sites/default/files/downloads/27218-Web-BASICStampManual-v2.2.pdf
The older QTI documentation explains that program a little on page 5.
https://www.parallax.com/sites/default/files/downloads/28108-QTI-Line-Follower-Guide-v2.1.pdf
There is a very good explanation of that program here, starting in the middle of the page.
http://learn.parallax.com/project/boe-bot-line-following-four-qti-sensors/test-qti-sensors
DIRB controls the direction of P4 through P7, but remember that in binary the bit go from right to left. A 1 sets that pin to output, while a 0 sets it to input.
DIRB = %1111 ' P7, P6, P5, P4 ---> output
DIRB = %0000 ' P7, P6, P5, P4 ---> output
You can also have mixed values such as 1010 which would make P7 and P5 outputs while P6 and P4 would be inputs.
The value could be in decimal or hex, in which case you would need to convert it binary to see what pin is being set to what.
INB returns the state of P4 through P7. Again, in binary the order will be P7 on the left and P4 on the right.
Say for example INB returns 0101, that means P7 was 0 or Low, P6 was 1 or High, P5 was 0 or Low, and P4 was 1 or High.