Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. ' LineFollowWithCheckQtis.bs2
  2. ' Navigates based on values acquired with the Check_Qtis subroutine.
  3.  
  4. ' {$STAMP BS2}
  5. ' {$PBASIC 2.5}
  6.  
  7. qtis VAR Nib ' qti black/white states
  8. OUTB = %1111 ' Set OUTB bits to 1
  9.  
  10. DO ' Main DO...LOOP
  11. GOSUB Check_Qtis ' Get QTI states
  12.  
  13. SELECT qtis ' Control servo speeds/directions
  14. CASE %1000 ' Rotate right
  15. PULSOUT 13, 650
  16. PULSOUT 12, 650
  17. CASE %1100 ' Pivot right
  18. PULSOUT 13, 750
  19. PULSOUT 12, 650
  20. CASE %0100 ' Curve right
  21. PULSOUT 13, 800
  22. PULSOUT 12, 650
  23. CASE %0110 ' Straight ahead
  24. PULSOUT 13, 850
  25. PULSOUT 12, 650
  26. CASE %0010 ' Curve left
  27. PULSOUT 13, 850
  28. PULSOUT 12, 700
  29. CASE %0011 ' Pivot left
  30. PULSOUT 13, 850
  31. PULSOUT 12, 750
  32. CASE %0001 ' Rotate left
  33. PULSOUT 13, 850
  34. PULSOUT 12, 850
  35. CASE ELSE ' Do nothing
  36. PAUSE 3
  37. ENDSELECT
  38. LOOP
  39.  
  40. Check_Qtis:
  41. ' Result -> qtis variable. 0 means white surface, 1 means black surface.
  42.  
  43. DIRB = %1111 ' P7..P4 -> output
  44. PAUSE 0 ' Delay = 230 us
  45. DIRB = %0000 ' P7..P4 -> input
  46. PAUSE 0 ' Delay = 230 us
  47. ' PULSOUT UnusedPin, 0 ' Delays = 208 + (Duration*2) us
  48. qtis = INB ' Store QTI outputs in INB
  49. RETURN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement