Let's Make Robots!

SRF05 with common in/out pin

I'm trying to get the PICAXE-28x1 to work with the SRF05 usnig a common input and output pin. The reason is I want to conserve my input and output pins. I've seen discussions on this site about it, but I don't know if anyone ever succeded.

Since the 28x1 allows you to reconfigure digital inputs as digital outputs, I figured it should be possible to use "Mode 2" of the SRF05 with a commmon single input and output.

Here's the code I tried. I also tried some varations the timing, as noted.  No luck so far.

getdist2:            'testing SRF05 with single pin
low portc 6          'set digital Input 6 as an output and set low

pause 10            'pause to make sure the port has switched
high portc 6         'raise the pin high
pause 20                     'tried using 10, 15, 20, and 25 uS to produce 20uS trigger pulse (must be minimum of 10uS)
low portc 6                     'lower the pin
pulsin echo,1,range                 'measures the range in 10uS steps
pause 10                        'recharge period after ranging completes
                            'now convert range to cm as picaxe cannot use 5.8,
                            'multiply by 10 then divide by 58 instead
let range = range * 10 / 58 'multiply by 10 then divide by 58
debug range

I can see the little red LED on the back of the SRF05 flashing, indicating that it received a pulse. I get no indication from the debug command that it is receiving anything for the range.

I think this approach won't work. However, since I can reconfigure an Input as an Output, I may just use one of the digital Outputs as recommended, and when I need more output pins, I'll just convert an available input pin. That way I don't need to switch back and forth.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Did you see this code for the Ping sonar? The SRF05 in 1 pin mode operates similarly to the Ping, so it should work.
I read that a long while back and forgot about it. I will try that.
Good thought, I did try that.  The pulsout command on the PICAXE only works with the default outputs. There does not appear to be a way to get it to work with a re-configured Input port.
I use pulsout commands to work my ping sensor. if you turn it high, is it not just like an led flashing? try a pulse command.