Shop OBEX P1 Docs P2 Docs Learn Events
ping sensor help!! — Parallax Forums

ping sensor help!!

RontopiaRontopia Posts: 139
edited 2005-10-28 05:05 in BASIC Stamp
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

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 04:33
    The problem is that you have a hanging comma at the end of the line that says "Centimeters" (just ahead of Main[noparse]:)[/noparse] -- doing this the compiler thinks that it should be seeing a constant or variable value, not a program label.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • RontopiaRontopia Posts: 139
    edited 2005-10-27 04:43
    you rock

    thanks

    I will be back to let you know how it comes out

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Muahdib


    IC layout designer
    Phoenix Arizona
  • RontopiaRontopia Posts: 139
    edited 2005-10-27 04:57
    there was one other problem but I would not have got this done without your help.. so thanks.. your a man among men[noparse]:)[/noparse]

    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 WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 05:29
    No, there is one onboard.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • RontopiaRontopia Posts: 139
    edited 2005-10-27 18:17
    thanks again.

    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 WilliamsJon Williams Posts: 6,491
    edited 2005-10-27 18:33
    I don't have any -- but I'm sure other forum members do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • metron9metron9 Posts: 1,100
    edited 2005-10-28 05:05
    Code examples links at bottom of page
    http://www.parallax.com/detail.asp?product_id=28015
Sign In or Register to comment.