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

PING))) programing

SciTech02SciTech02 Posts: 154
edited 2006-03-01 23:21 in Robotics
Hello, this is my first post here.· Okay, I just bought the PING))) ultrasonic senser, and the mounting bracket for it.· I have had great sucess with the "Roaming with the PING)))" program, and I wanted to make it follow with the PING))) to.· Also, if there is a program for that, I would also like to hear some guidlines on how to convert it to make it solve a maze (I know that it just has to follow the wall of the maze to solve it.).· Any help will be great.

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-28 05:00
    Hello,

    ·· There are no ready made programs for doing this, but with a little experimentation and using the program you have as a guideline you could write one.·· For following you may need two PING))) units unless you have a fast pan/scan routine because a single PING will be unable to tell which direction something moved out of its view.· With two you would be able to detect direction of movement.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com


    Post Edited (Chris Savage (Parallax)) : 2/28/2006 7:34:25 PM GMT
  • SciTech02SciTech02 Posts: 154
    edited 2006-02-28 17:54
    Thank you for your help so far.· Now I'm stumped on making a maze-solving program.· I have an idea for the program to go somthing like this; "IF ( PingDistance < 25 ) AND ( PingDistance > 15) THEN Forward pulse.", then if these rules change, I can make it turn.· Also, I would turn the PING))) sensor about 68 degres to ether side.· But I don't know how to begin, I don't know how many variables and constants I'll need, I don't know how to make the PING))) get that distance and utilize it,·and I don't know how to organize it so that it would do that.··Any help will be great.
  • SciTech02SciTech02 Posts: 154
    edited 2006-02-28 21:22
    Don't bother answering my question.· I was tinkering with a program and I developed a program for maze-solving with the PING))) and it works!jumpin.gif·smilewinkgrin.gifturn.gif·You can play with the distance values to get it where you want it.· Here's the program that I made:





    ' Robotics with the Boe-Bot - MazeSolvingWithThePing.bs2

    ' Boe-Bot follows a wall with the PING))) turned at a 68 degre angle to the left.
    ·
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ·
    Ping············· PIN···· 11
    ·
    distance······· VAR···· Word················· ' Variables.
    pulseLeft······ VAR···· Word
    pulseRight···· VAR···· Word
    PingServo····· VAR···· Word
    counter········· VAR···· Word
    ·
    FREQOUT 4, 2000, 3000···················· ' Initialization.
    ·
    DO················· ···································' Main loop.
    ·
    · GOSUB Get_Distance
    ·
    · IF (distance > 25) THEN···················· ' If wall is further then set distance
    ··· PingServo = 1000···························· ' could mean a turn so, turn until wall
    ··· pulseLeft = 650······························· ' is detected again.
    ··· pulseRight = 650
    · ELSEIF (distance < 15) THEN············ ' If wall is closer then set distance
    ··· PingServo = 1000···························· ' could mean a turn so, turn until wall
    ··· pulseLeft = 850······························· ' is in range again.
    ··· pulseRight = 850
    · ELSE··············································· ' If conditions are met, continue forward.
    ··· PingServo = 1000
    ··· pulseLeft = 820
    ··· pulseRight = 650
    · ENDIF
    ·
    · counter = counter + 1
    ·
    · IF counter > 8 THEN
    ··· GOSUB Get_Distance
    · ENDIF
    ·
    · PULSOUT 14,PingServo
    · PULSOUT 13,pulseLeft
    · PULSOUT 12,pulseRight
    · PAUSE 15
    ·
    LOOP··················································· ' Repeat routine.
    ·
    Get_Distance:
    ·· LOW Ping
    ·· PULSOUT Ping, 5
    ·· PULSIN· Ping, 1, distance
    ·· distance = distance ** 2257
    ·· RETURN



    What do you think?

    Post Edited (SciTech02) : 2/28/2006 9:25:10 PM GMT
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-02-28 22:37
    You should attach your code rather than pasting it into the message.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • SciTech02SciTech02 Posts: 154
    edited 2006-02-28 22:53
    I know, but I could not get it to work.· But it's water under the bridge now.
  • neotericneoteric Posts: 144
    edited 2006-03-01 02:19
    Nice program.· Could you explain th 68 degrees.· Why 68?
  • SciTech02SciTech02 Posts: 154
    edited 2006-03-01 23:21
    Well, I knew I could not use 90 degrees because it could not see the wall ahead of it, and I thought 45 degrees would be to much so, I did 68 degrees.· I have played with it a little, and I discoved that 68 degrees was not the right angle.· The beter angle is·barely more then 45 degrees, closer to 90 degrees is the way to go·depending on your PING))) senser.·· Also, if you don't have a maze, you can make it follow a wall, just wach out for doorstopsfreaked.gif .· Also,·if you make·the PING)))·turn to the right, you can make it follow the wall to the right of it (Mine follows the left wall).· One more funny project you could do is put it by a box (I used an ice chest) and it will go around it continulisly smile.gif .

    Post Edited (SciTech02) : 3/2/2006 8:27:09 PM GMT
Sign In or Register to comment.