PING))) programing
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
·· 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
' 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 Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (SciTech02) : 3/2/2006 8:27:09 PM GMT