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.
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.
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 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 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…
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?
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…
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.
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.
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…