ping sensor help!!
Rontopia
Posts: 139
I have a boe bot and just bought a brand new shiny ping sensor. I carefully entered the example code for the bs2 in to my editor. problem is the syntax checker seems to have a problem with some of the syntax. I have searched the boards and found nothing helpful.
here is a copy, the syntax checker is having a problem with the "Main:" statement. just for kicks I commented it out. The syntax checker then had a problem with the "DO" statement.
any help would be much appreciated
thanks
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
Ping PIN 15
'
[noparse][[/noparse] Constants ]
#SELECT $STAMP
#CASE BS2, BS2E
Trigger CON 5
Scale CON $200
#CASE BS2SX, BS2P, BS2PX
Trigger CON 13
Scale CON $0CD
#CASE BS2PE
Trigger CON 5
Scale CON $1E1
#ENDSELECT
RawToIn CON 889
RawToCm CON 2257
IsHigh CON 1
IsLow CON 0
'
[noparse][[/noparse] Variables ]
rawDist VAR Word
inches VAR Word
cm VAR Word
'
[noparse][[/noparse] Initialization ]
reset:
DEBUG CLS,
"Parallax Ping))) Sonar", CR, 'Setup Report screen
"======================", CR,
CR,
"Time (uS).... ", CR,
"Inches........ ", CR,
"Centimeters... ",
'
[noparse][[/noparse] Program Code ]
Main:
DO
GOSUB Get_Sonar
inches = rawDist ** RawToIn
cm = rawDist ** RawToCm
DEBUG CRSRXY, 15, 3,
DEC rawDist, CLREOL,
CRSRXY, 15, 4,
DEC inches, CLREOL,
CRSRXY, 15, 5,
DEC cm, CLREOL
PAUSE 100
LOOP
END
'
[noparse][[/noparse] subroutines ]
Get_Sonar:
Ping = IsLow
PULSOUT Ping, Trigger
PULSOUT Ping, IsHigh, rawDist
rawDist = rawDist */ Scale
rawDist = rawDist /2
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Muahdib
IC layout designer
Phoenix Arizona
here is a copy, the syntax checker is having a problem with the "Main:" statement. just for kicks I commented it out. The syntax checker then had a problem with the "DO" statement.
any help would be much appreciated
thanks
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] I/O Definitions ]
Ping PIN 15
'
[noparse][[/noparse] Constants ]
#SELECT $STAMP
#CASE BS2, BS2E
Trigger CON 5
Scale CON $200
#CASE BS2SX, BS2P, BS2PX
Trigger CON 13
Scale CON $0CD
#CASE BS2PE
Trigger CON 5
Scale CON $1E1
#ENDSELECT
RawToIn CON 889
RawToCm CON 2257
IsHigh CON 1
IsLow CON 0
'
[noparse][[/noparse] Variables ]
rawDist VAR Word
inches VAR Word
cm VAR Word
'
[noparse][[/noparse] Initialization ]
reset:
DEBUG CLS,
"Parallax Ping))) Sonar", CR, 'Setup Report screen
"======================", CR,
CR,
"Time (uS).... ", CR,
"Inches........ ", CR,
"Centimeters... ",
'
[noparse][[/noparse] Program Code ]
Main:
DO
GOSUB Get_Sonar
inches = rawDist ** RawToIn
cm = rawDist ** RawToCm
DEBUG CRSRXY, 15, 3,
DEC rawDist, CLREOL,
CRSRXY, 15, 4,
DEC inches, CLREOL,
CRSRXY, 15, 5,
DEC cm, CLREOL
PAUSE 100
LOOP
END
'
[noparse][[/noparse] subroutines ]
Get_Sonar:
Ping = IsLow
PULSOUT Ping, Trigger
PULSOUT Ping, IsHigh, rawDist
rawDist = rawDist */ Scale
rawDist = rawDist /2
RETURN
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Muahdib
IC layout designer
Phoenix Arizona
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
thanks
I will be back to let you know how it comes out
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Muahdib
IC layout designer
Phoenix Arizona
I have one other question. do I need to use a resistor on the sig connection of the sensor itself? if so what size?
thanks for your help
Muahdib
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Muahdib
IC layout designer
Phoenix Arizona
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
do you know where I might find some example code for using ping sensors on my boe bot to roam with? I have some ideas but it helps to see some code to start with. Im new to any kind of programing... if you cant tell[noparse];)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Muahdib
IC layout designer
Phoenix Arizona
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
http://www.parallax.com/detail.asp?product_id=28015