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.

There is a thread about
There is a thread about excectly this somewhere, answering all. It was me VS Chris The carpenter…

Yup, it was me and Fritz

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.

Damn you, guys!A) The code

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

Really, It can’t be that

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

Thanks, I think I’ll try the
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.

Wow

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. :slight_smile:

Diodes? Look: depending on

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 :slight_smile:

BASIC Commands Datasheet (pdf)

Here’s the other discussion

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

https://www.robotshop.com/letsmakerobots/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?

Ok, I am jumping back into this…

Ok, I am still the nay-sayer…

I still don’t think you can toggle I/O pins… I just did a little looking and I think it is only the 08m can use it’s pins for both I and O.

–I would love to be proved wrong but I must say… There doesn’t seem to be a post on this thread with the ping plugged in and working yet.

Good luck to all who are trying this, I would love to see this work.

www.rocketbrandcustom.com baby!!

Now this is the craziest!I

Now this is the craziest!

I have never seen such mis-information!

https://www.robotshop.com/letsmakerobots/node/113

yup…

Alright, damn… you got me. Did you see? I put "I think" in italics…

Ok, frits I am starting to think you are right… - I still want to see this thing in action!

www.rocketbrandcustom.com baby!!

Works!

i have my parallax ping and picaxe 28x1 working

 

here is the code i use to make it work:

LOW PORTC 0
HIGH PORTC 0
PAUSE 1
LOW PORTC 0
LET dirsc = %00000000
PULSIN 0, 1, W0

here are a couple of tips:

make sure it recieves 5v ±10%. after a looong time of debugging i found out it was underpowered and so now i feed it something close to 5.4v and it works

the digital input pins also double up for output, i have the Ping))) signal wire connected to input pin 0

pulsout does not work on input pins, even if you convert them to output. use the old fashon low-high-low

after you call the block of code above be sure to wait a bit, like a pause 100or similar

 

My issue right now is it seems the sensor only detects upto just a couple of inches infront of it (commonly uto 84 units) which is what im trying to troubleshoot at the moment. i hope my sensor is not faulty…

 

for more info read page 4 of http://www.eetasia.com/ARTICLES/2002MAR/2002MAR08_RFD_DA_AN.PDF

Cool - I really think you
Cool - I really think you should make a walkthrough on this, aparently many are fighting with it.

wow i think i figured outt

wow i think i figured outt he "short reading" problem. if i put cloth or foamy material (ex. spongy packing material) over the sensors it somehow dampens the premature reading and gives me a more accurate distance read. who wuda thunk… ill do more tests on this.

yup, ill make a walkthru when i iron out all the kinks and have the sensors working as intende.

I think this may be a wild

I think this may be a wild goose, but you may be right.

However - how wuld this code work:

 


HIGH PORTC 0
LOW PORTC 0
PAUSE 1
PULSIN 0, 1, W0

or this:

HIGH PORTC 0
LOW PORTC 0
PAUSE 2
PULSIN 0, 1, W0

or this:

LOW PORTC 0
HIGH PORTC 0
PAUSE 1
PULSIN 0, 1, W0

or this:

LOW PORTC 0
HIGH PORTC 0
PAUSE 2
PULSIN 0, 1, W0

or this:

inserting

TOGGLE 0

just before "Pulsin"

 

Comments:

  • My experience tells me that when using portC high is = low and the other way around
  • Pulsin automatically changes a port to input, so you will not have to do it (and so you can save valuable puls-time)
  • You may want more than 10 miliseconds of pause

documention on the ping

have you guys looked at the parallax site for docs on the ping))) sensor or on their forums?

I know that they have quite a few docs and some of the info could be useful in troubleshooting the issues, possibly having to do with timing.

From what I’ve gathered though they aren’t the most friendly towards the picaxe crowd on the forums, but no harm in reading them. :slight_smile:

I’ve got one of their pings, plus one of the vex robotics ones(4 pin) which seem to work fine on their stuff(I’ve run it on a bs2 and javalin proc)

I’ll try my hand at getting my 08m or the 18x(when it arrives) to work on it. I’m just starting with the picaxes but they are a lot of fun to try to get them to work with the limited resources…