Shop OBEX P1 Docs P2 Docs Learn Events
Wireless PING Network — Parallax Forums

Wireless PING Network

Chris CChris C Posts: 50
edited 2008-04-24 15:13 in BASIC Stamp
Long story short,·two PS1 Project Boards with a PING and an AppBee-SIP sending a value to one PS1 Project Board with an AppBee-SIP.· Both are hooked up to 12 1A wall supplies.

The wireless nodes are sending the value right, but watching the receiver through debug, nothing is outputting.

Node code (for only one of them)

'·· {$STAMP BS1}
'·· {$PBASIC 1.0}
'
[noparse][[/noparse] I/O Pins ]

SYMBOL· Ping··········· = 7
SYMBOL· TX············· = 2
SYMBOL· SLP············ = 4

'
[noparse][[/noparse] Constants ]

SYMBOL· Trigger········ = 1···················· ' 10 uS trigger pulse
SYMBOL· Scale·········· = 10··················· ' raw x 10.00 = uS
SYMBOL· RawToIn········ = 889·················· ' 1 / 73.746 (with **)
SYMBOL· IsHigh········· = 1···················· ' for PULSOUT
SYMBOL· IsLow·········· = 0

'
[noparse][[/noparse] Variables ]

SYMBOL· rawDist········ = W1··················· ' raw measurement
SYMBOL· inches········· = W2··················· ' inches conversion
SYMBOL· nodeInfo······· = W3··················· ' node presence

'
[noparse][[/noparse] Code ]

Main:
· PAUSE 2000
· HIGH SLP······ ' Put XBee to sleep
'· SLEEP 15······· ' Put BS2 to sleep for approx 15 seconds, uncomment later
· GOSUB Get_Sonar······························ ' get sensor value
· inches = rawDist ** RawToIn·················· ' convert to inches

· DEBUG CLS···································· ' report
· DEBUG "Time (uS)..... ", #rawDist, CR
· DEBUG "Inches........ ", #inches, CR

· nodeInfo = 1000
· nodeInfo = nodeInfo + inches

· IF nodeInfo > 1022 OR nodeInfo < 1002 THEN Main

· LOW SLP······· ' Wake XBee
· PAUSE 10······ ' Give XBee time to stretch and yawn
· SEROUT TX, T2400, (#nodeInfo) ' Transmit value
· PAUSE 10

· DEBUG "Node........ ", #nodeInfo, CR
· GOTO MAIN

END

'
[noparse][[/noparse] Subroutine ]

Get_Sonar:
· LOW Ping····································· ' make trigger 0-1-0
· PULSOUT Ping, Trigger························ ' activate sensor
· PULSIN· Ping, IsHigh, rawDist················ ' measure echo pulse
· rawDist = rawDist * Scale···················· ' convert to uS
· rawDist = rawDist / 2························ ' remove return trip
· RETURN
'

Receiver Code (dunno if this would even work)

' {$STAMP BS1}
' {$PBASIC 1.0}
SYMBOL· RX· = 0 ' Receive Pin
SYMBOL· TX· = 2 ' Transmit Pin
SYMBOL· RFin· = W3

Main:
· SERIN RX, T2400, #RFin ' Accept and view as character
· DEBUG "nodeInfo = ", #RFin, CR
· GOTO Main
· END

The "nodeInfo = " doesn't show up in the debug window.· The sensor nodes show everything in the debug window as desired.

Is the XBee not receiving the info properly?· One weird tidbit to add, the receiver XBee's RX LED does blink everytime the TX LED on the sensor node blinks.

Comments

  • FranklinFranklin Posts: 4,747
    edited 2008-04-13 00:38
    If "nodeInfo = " does not show up then the receiver code isn't running or the program is locked in the serin command. Try a timeout in the serin command to see if that changes anything.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Chris CChris C Posts: 50
    edited 2008-04-13 16:01
    Ah, didn't think about that, will do. Thanks!
  • Chris CChris C Posts: 50
    edited 2008-04-22 04:20
    I just realized that PBasic 1 doesn't support timeout in serin commands.· =(
  • FranklinFranklin Posts: 4,747
    edited 2008-04-23 02:19
    Any reason you need to use pBasic1?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Chris CChris C Posts: 50
    edited 2008-04-24 15:13
    I'm using BS1 Project Boards.· They only support PBasic1.
Sign In or Register to comment.