Shop OBEX P1 Docs P2 Docs Learn Events
help me! problem — Parallax Forums

help me! problem

chris chancechris chance Posts: 5
edited 2004-08-19 21:26 in BASIC Stamp
jumpin.gif·i found some cool stuff for the·SRT04 sensor but nothing for a robot.
i have a bs2e and i try to use this code :
'{$STAMP BS2e}
'
' Devantech SRF04 Example
'
wDist·· VAR·· Word
INIT·· CON·· 14
ECHO·· CON·· 15

' CONVERSION FACTORS:
'
' The PULSIN command returns the round-trip echo time in 2us units
' which is equivalent to the one-way trip time in 1us units.
'
' distance = (echo time) / (conversion factor)
'
' use 74 for inches······ (73.746us per 1 in)
' use 29 for centimeters· (29.033us per 1 cm)

'
main
·· GOSUB sr_sonar
·· DEBUG HOME, DEC wDist, CR
·· PAUSE 100
·· GOTO main

sr_sonar:
·· PAUSE 100
·· PULSOUT INIT,5····· ' 10us init pulse
·· PULSIN ECHO,1,wDist·· ' measure echo time
·· PAUSE 10
·· RETURN
sr_sonar_2:
·· PULSOUT INIT,5····· ' 10us init pulse
·· OUTPUT INIT····· ' dummy command (delay)
·· RCTIME ECHO,1,wDist·· ' measure echo time
·· PAUSE 10
·· RETURN
i want to a simple code that i could use for my robot, as of now i just it mount to a servo on pin 13
the sensor is on pins 14 and 15

please help me

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-18 23:00
    I've attached the Parallax demo fro the SRF-04 (I've found the SRF-04 is more reliable when using P0 and P1).· Once you have distance to an object, it's up to you to do something with it.· If you mount it on a servo horn, you can scan the terrain in front of your robot and navigate around things (I've seen this done by a Dallas Personal Robotics Group member using a BS2-controlled robot).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • chris chancechris chance Posts: 5
    edited 2004-08-18 23:48
    the demo work, but not on pins 1 and 2, i not sure why. but i dont know how to break down that code
    i need something smaller and easy to make in to a if..... then command
  • cabojoecabojoe Posts: 72
    edited 2004-08-19 02:15
    Here's a pic of my old robot "Joebot". He had an SRF-04 on a pan tilt. Worked ok, but on new robot I use 2 SRF-08's statically mounted. I find it's way easier to use the rangers as "headlights" in much the same way as the boebot uses it's infrared sensors to gauge left, middle, and right.

    http://www.lynxmotion.com/images/jpg/cameron4.jpg

    As for code to make the ranger scan, you would insert a routine that would move the servo a bit, then call up your main ranger code, take a reading, stuff the reading somewhere if you want, then move the servo again, range again, etc. The code I have is for a servo controller so it wouldn't be much help to you.


    Post Edited (cabojoe) : 8/19/2004 2:21:39 AM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-19 02:28
    I like the SRF-08 as well -- still just two wires but you can have a bunch of them (well, 16).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • chris chancechris chance Posts: 5
    edited 2004-08-19 11:23
    you should try out the code and tell if you get an odd felx
  • chris chancechris chance Posts: 5
    edited 2004-08-19 11:26
    i make i miss up on it, could someone try it and tell my its not working right
  • cabojoecabojoe Posts: 72
    edited 2004-08-19 20:52
    I abused my SRF-04 to death, otherwise I'd try to help.mad.gif
  • chris chancechris chance Posts: 5
    edited 2004-08-19 21:26
    lol
Sign In or Register to comment.