Basic Atom Pro code for PING

Here is good working code for the Atom Pro and the PING. The values are converted to inches before display. This is for the IDE 8.0.1.7 and will work with the Mini-ABB and the Bot Board II.

[code]wdist var word

main:
low p4
pulsout p4, 5
input p4
pulsin p4, 0, toolong, 40000, wdist
wdist = wdist / 148 ;convert for inches
serout s_out, i9600, "Distance: ", sdec wdist, 13, 10] ;display result in terminal
goto main

toolong: ; if the program gets here the sensor is not functioning, or wired wrong
serout s_out, i9600, “Timeout, sensor is not working”, 13]
goto main[/code]

New here, just sharing some code for the Bot Board and PING:

This sub code “getping” works for a Parallax PING))) utrasonic sensor on a bot board with Basic Atom Pro (based on code by Stef van den Elzen):

getping:
low ping
high ping
pulsin ping, 0, pingRaw 'read the ping
low ping
pingRaw = pingRaw / 2 'adj for per sec since reading are every 0.5 sec
pingRange = pingRaw / 29 'convert to cm
return

where,
pingRaw var word
pingRange var word
ping CON P1

The parameters of interest can be monitored in the terminal window by inserting this sub:

debuggery:
serout S_OUT, i57600, "pingRaw: ",dec pingRaw,"pingRange: ",dec pingRange, 13]
return

Add this sub for sound feedback (sonar)

sonarnoise:
pingRawS = pingRaw * 20 'adjust sound tone
pingRangeS = pingRange * 20
sound P9,[10\pingRangeS,10\pingRangeS]
low P9
return

mental-escher.net/images/bot-board-ping-thumb.jpg

Why is the ping wired to the breadboard (picture in post above)? I’d like to wire mine up to the Bot Board II directly and can’t find any wiring diagrams on how to wire it to the pins. I know this is simple but I don’t want to fry anything. Can anyone direct me to a picture of a ping wired directly to the Bot Board II?

http://www.otherrobots.com/lynxmotion/bap_ping.jpg

All you need to do is buy s servo extender cable and remove the pins from one end. This makes it into a female / female cable. One end goes to the Ping and the other plugs directly into the Bot Board. You must make sure the power for that group is set to 5vdc not VS.

lynxmotion.com/Product.aspx? … egoryID=44

So to hook it up I’d wire it just like a servo.

Yellow to SIG
Red 5V
Black to GND

and in the sample code above I’d use 4 on #14. My only power in is #5 to a 9 volt battery but with the jumper in #13 over to 5V not VS it takes it down to 5 volts from 9 volts.

I’ll give it a shot! 8)


works :smiley:

Win! 8)

hi,

i try out the code you have provide on pin 4, pin 5, pin 6 and pin 7, it works, but i doesn’t work when i connect it to
pin 1, pin 2 and pin 3.
why is it so?

kim

Not sure, you might try to verify the voltage jumper going to pins 0-3, to make sure it is there and is is set for +5v and not VS.

Kurt

hi,

yeah, the jumper is missing. thx.
and where can i find this kind of jumper? the jumper for that pin is missing…

Any old computer boards should have them. Anything laying around?

hi,

is there a method to make the sensor work slower? like 1 cycle/sec? or 2 sec?

You code it, you are in control!

Alan KM6VV

Hi,

is this the line that the processor read from the sensor?

if it is… then

I recommend taking a look at it.

thx~ ur code is very helpful!
:slight_smile: