Shop OBEX P1 Docs P2 Docs Learn Events
PING))) — Parallax Forums

PING)))

andy11667andy11667 Posts: 26
edited 2006-05-24 14:16 in Robotics
does anybody know the codes for the PING))) ultrasound sensor in terms of roaming like avoiding objectswhile moving about

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-05-24 02:18
    Hello,

    ·· There are no codes for the PING))) to do this.· You must write a program to get the data from the PING))) and navigate based on that data.· The PING))) isn't going to send back codes saying there's something in front, turn left.· You must write this into your software.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • andy11667andy11667 Posts: 26
    edited 2005-05-24 02:36
    i cannot figure out how to write the program and i need some. help, please post your codes
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-05-24 02:39
    The Ping))) documentation had demos for the BS1 and BS2 family -- that should get you started. What the demo program will tell you is the distance from the Ping))) to the target right in front of it.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • edited 2005-05-24 03:46
    Here is a program that will get you on the road toward roaming with the Ping))) Ultrasonic Sensor.· This program makes the Boe-Bot spin in place until it detects an object closer than 30 cm.· After it detects the object, it spins for another 5 pulses, then travels toward the object until it is less than 4 cm away.· I tested it with my hand facing the Boe-Bot.· You may need to adjust the numbers for different objects, particularly the counter variable.

    Before running this example program:

    Ö······· Make sure to go through Detect Distance with the Ping))) Sensor (.pdf).· It's a Stamps in Class activity that's available for download from the Ping)))TM Ultrasonic Sensor product page.·
    Ö······· Also make sure your Boe-Bot servos are connected as shown in Robotics with the Boe-Bot v2.2, which is available for download from www.parallax.com -> Downloads -> Stamps in Class Tutorials.

    [color=#008000]' -----[noparse][[/noparse] Title ]--------------------------------------------------------------[/color]
    [color=#008000]' FindClosupObject.bs2[/color]
     
    [color=#008000]' Place an object 20 cm from the Boe-Bot.  The Boe-Bot will rotate[/color]
    [color=#008000]' in place until it detects the oject, and then move toward it.[/color]
     
    [color=#008000]' {$STAMP BS2}[/color]
    [color=#008000]' {$PBASIC 2.5}[/color]
     
    [color=#008000]' -----[noparse][[/noparse] Declarations ]-------------------------------------------------------[/color]
     
    time     VAR Word
    distance VAR time
    counter  VAR Byte
     
    [color=#008000]' -----[noparse][[/noparse] Initialization ]-----------------------------------------------------[/color]
     
    distance = 65535
     
    [color=#008000]' -----[noparse][[/noparse] Main Routine ]-------------------------------------------------------[/color]
     
    [color=#008000]' Spin in place until object detected, then[/color]
    [color=#008000]' spin for 10 more pulses.[/color]
     
    [color=#0000ff]DO[/color] [color=#0000ff]UNTIL[/color] (distance < 30) [color=#0000ff]AND[/color] (counter > 5)
     
      [color=#0000ff]GOSUB[/color] Get_Distance
      [color=#0000ff]GOSUB[/color] Turn_In_Place
     
      [color=#0000ff]IF[/color] distance < 30 THEN counter = counter + 1
     
    [color=#0000ff]LOOP[/color]
     
    [color=#008000]'Move toward the object until distance is < 5 cm.[/color]
     
    [color=#0000ff]DO UNTIL[/color] distance < 5
     
      [color=#0000ff]GOSUB[/color] Get_Distance
      [color=#0000ff]GOSUB[/color] Forward
     
    [color=#0000ff]LOOP[/color]
     
    [color=#0000ff]END[/color]
     
    [color=#008000]' -----[noparse][[/noparse] Subroutines ]--------------------------------------------------------[/color]
     
    Get_Distance:
     
      [color=#0000ff]PULSOUT[/color] 15, 5
      [color=#0000ff]PULSIN[/color] 15, 1, time
      distance = time ** 2251
     
      [color=#0000ff]RETURN[/color]
     
    Turn_In_Place:
     
      [color=#0000ff]PULSOUT[/color] 12, 650
      [color=#0000ff]PULSOUT[/color] 13, 650
      [color=#0000ff]PAUSE[/color] 20
     
      [color=#0000ff]RETURN[/color]
     
    Forward:
     
      [color=#0000ff]PULSOUT[/color] 12, 650
      [color=#0000ff]PULSOUT[/color] 13, 850
      [color=#0000ff]PAUSE[/color] 20
     
      [color=#0000ff]RETURN[/color] 
    
    



    Post Edited (Andy Lindsay (Parallax)) : 5/24/2005 4:05:28 AM GMT
  • BenBen Posts: 9
    edited 2006-05-24 14:16
    Here is a program I put together today for my own Boe-Bot w/tank treads and the PING))) module that does what you are asking. It does a great job of navigating through a maze. I am new to programming, having started with the BS2 this winter, so hopefully Andy, Chris, and Jon who have also posted won't find too many objections. You may need to adjust the constant "sensitivity" and the conditionals that use the sanDist values in order to fit your particular roaming environment. I left my DEBUG lines that I used to see what was happening.

    Hope this helps!

    --Ben
Sign In or Register to comment.