Advertisement
Atdiy

Untitled

Mar 11th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. CON
  2. _clkmode = xtal1 + pll16x
  3. _xinfreq = 5_000_000
  4.  
  5. ' Set pins and Baud rate for XBee comms
  6. XB_Rx = 0 ' XBee DOUT
  7. XB_Tx = 1 ' XBee DIN
  8. XB_Baud = 9600 ' XBee Baud Rate
  9.  
  10. RCServo = 7
  11.  
  12. CR = 13
  13.  
  14. OBJ
  15. XB : "XBee_Object_2"
  16.  
  17. Pub Start | DataIn, tInc
  18. XB.start(XB_Rx, XB_Tx, 0, XB_Baud) ' Initialize comms for XBee
  19.  
  20. repeat
  21. DataIn := XB.Rx ' Accept incoming byte
  22. If DataIn == "!" ' If start delimiter
  23. DataIn := XB.RxDecTime(500) ' Accept value for Frequency
  24. if DataIn <> -1 ' If wasn't timeout, hand data to Servo
  25. Servo(DataIn)
  26.  
  27. Pub Servo(pulse) | tInc, tC, tPulse, t
  28.  
  29. ctra [30..26] := %00100
  30. ctra [8..0] := RCServo
  31.  
  32. frqa := 1
  33. dira[RCServo]~~
  34.  
  35. tInc := clkfreq/1_000_000
  36. tC := tInc * 20_000
  37. tPulse := tInc * pulse
  38. t := cnt
  39.  
  40. repeat 100
  41. phsa := -tPulse
  42. t += tC
  43. waitcnt(t)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement