Let's Make Robots!

Picaxe 18 and Ping

I just picked up a Parallax Ping distance sensor from my local Radio Shack and am trying to figure out to how hook it into my Picaxe 18 project board.

The ping uses a single pin for both input and output.  It first requires a trigger pulse to be sent and then it responds with a variable length pulse that determines the distance.  Can a Picaxe pin be switched from output to input?  If not, can I connect 2 pins to the single Ping pin?  Normally I would jut go ahead and try it, but I don't want to fry my Picaxe or the sensor.

The only examples I could find on here were for the Ardiuno and Google didn't turn anything up either. 

Thanks.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Here's the other discussion regarding using a Ping))) with PICAXE, read the commets below.

http://letsmakerobots.com/node/66

I'm in the same boat, i bought a Ping))) from Radioshack for my 1st robot and am still studying how to connect it. Did you get anywhere with your attempt jgillick?

Damn you, guys!

A) The code only has 1 place where the ultra-sensors are called

B) It is not as easy as turning on a LED to make an in become an out. It is easier.

C) There is plenty support for using une-wire ping-thingeys for the Picaxe; Look at documentation for SRF05; It is clearly described on how to  use it with only 1 wire. picaxe.co.uk / manuals / SRF05 

Wow I didn't want this thread to become a flame war. I looked for the discussion about Ping vs. SRF05 bug couldn't find it using the serach -- but perhaps I was using the wrong keywords.

I think I'll try to use 2 pins with diodes to prevent the output from feeding the input.

I would have ordered a SRF05, but the local Radio Shack carries the Ping and I'm impatient. :)

Diodes? Look: depending on the pin, you can just use it as in / Out.. and it will configure itself!

Some instances, with some certain commands and some certain pins and in some special code-situations, you may want to write something as "toggle 2" to make pin 2 In/out..

No diodes, mate :)

BASIC Commands Datasheet (pdf)

Really, It can't be that hard to get the ping working with anything else than stamp. I succesfully made it work with an atom basic and bot board II. The code that I use for it is this:

Ping is the I/O pin P0. It can be turned both into input and output. By the statement low / high P0, the P0 pin is turned into an output. By the pulsin statement it is turned into an input pin, automatically. So by low ping, high ping, I trigger the ping to measure. It measures. I turn the pin into an input and put the measured value into the variable rawdist. And then I turn the input pin into an output again. The distance is then divided by 2 because the sound traveled first forward and then backward. I think the code to get the ping working on picaxe is very similar. Provided that you can turn an input pin to an output pin, but this should not be a problem.

 ping       CON P0

'------------------------------------------------------------------------------
'-- Getping
'-- returns the distance measured by the ping))) ultrasonic sound sensor
'-- rawDist is the raw distance measured by the ping
'-- to get the distance in centimeters, rawdist is divided by 29.034
'------------------------------------------------------------------------------
getping:
  low ping
  high ping
  pulsin ping, 0, rawDist
  low ping
  rawDist = rawDist / 2
return

Hey J,

I had the exact same problem.. It seems the ping sensors are a lot more friendly with the stamp controllers. I tried a bunch of different stuff to get my ping to talk to a picaxe, with no results. I have heard talk of using one of the picaxes that can switch a pin from I to O and also I have heard of the use of diodes so the trigger does not back feed into the input pin. I will not say this can't be done, but i am an idiot and in the end decided to wait the week while a propper FR05 was ordered. I have had no problems since I received the  4-pin FR05. Also --if you are using any of Fritz's code, it is all based on the 4-pin --It seems it will be confusing to convert everything to a funky set-up.

Thanks, I think I'll try the diodes when I get a chance.  For now I've rigged it up to my Arduino board and it seems to be working pretty well.
There is a thread about excectly this somewhere, answering all. It was me VS Chris The carpenter..