Let's Make Robots!

HY-SRF05 // Again

Hi.

I have read this:

HY-SRF05 // http://letsmakerobots.com/node/34909

Start here robot ultrasonic sensor // http://letsmakerobots.com/node/27536

I want to build this bot:

Beta of Next generation "Start here robot" // http://letsmakerobots.com/node/33757

So, I bought this items:

  1. Picaxe 28x2 (Axe401)
  2. Instant robot shield (Axe408)
  3. HY-SRF05 ultrasonic sensor

I have tried to test the sensor but I don't know if really works, I can only hear one kind of sound, even if I bring my hand or anything else close of the sensor.

I have added a picture to have a better idea.

http://www.subirimagenes.cl/?v=2013012218.jpg

Also, I have read many datasheets and I found two modes of wires connection (single pin mode // dual pin mode).

So, ultra command is used with SINGLE pin mode connection (It also have 2 modes: 5 way header or 3 way header)...

And pulsin/pulsout commands are used with DUAL pin mode connection?

Am I right?

I noticed in SRF005 datasheet, the order of pins (Vcc / Echo / Trigger / Mode / Gnd).

Vs

The order of HY-SRF05 pins (Vcc / Trigger / Echo / OUT Gnd).

It matter?

 

I tried connecting the wires of sensor in the same order:

Sensor =  (Vcc / Trigger / Echo / OUT / Gnd)

To

Board =  (Vcc / Trigger / Echo / OUT / Gnd)

And, also I tried connecting, but following the SRF005 pin order (Out and Mode not connected):

Sensor =  (Vcc / Trigger / Echo / OUT Gnd)

To

Board =  (Vcc / Echo / Trigger / MODE Gnd)


And nothing of that works, I only hear one kind of sound.

My testing code is this:

 'symbol trig = 3            ; Define output pin for Trigger pulse (A, M, X, X1 parts)

'symbol echo  = 6           ; Define input pin for Echo pulse (A, M, X, X1 parts)

symbol trig = b.3        ; Define output pin for Trigger pulse (M2, X2 parts)

symbol echo  = b.6       ; Define input pin for Echo pulse (M2, X2 parts)

symbol range = w1          ; 16 bit word variable for range

main:

    pulsout trig,2         ; produce 20uS trigger pulse (must be minimum of 10uS)

    pulsin echo,1,range   ; measures the range in 10uS steps

    pause 20                ; recharge period after ranging completes

let range = range * 5 / 58

if range>20 then '**My Own Test**

sound S.12, (50, 20) 'One kind of sound, if something is far.

elseif range<10 then

sound S.12, (112, 1) 'Another kind of sound, if something is close.

endif

    goto main 'And around forever

 

I'll be honest, I don't know how to use the debug window in Axepad or Programming Editor.

So, What can I do? I just want the sensor work correctly.

 

Thks.

Jorge.

 

 

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JAX's picture
May I first say an excellent job of providing relevant links. It helped making the diagnosis easier. The only one I can add is this one for the SRF005s datasheet:
I have another post noting the differences in the HY-SRF05 and the SRF005 but I'll get deeper for this situation. You've already noted the pinout differences but I think your connections are still wrong.
Note on the first page of the above datasheet that the single-pin mode using the five way header (as used on the IRS as well) has a pinout:
5V : Not used : Signal (connect to PICAXE pin) : Mode (connect to ground) : 0V (ground)
Your pictured setup would indicate the trigger pin on your sensor is being grounded because it's hooked up the the mode header. I say grounded because I'm assuming the SRF005 was meant to run in single-pin mode off of the IRS with the prevalent use of the ULTRA command. Single-pin mode lets you use only one pin for both the echo and trigger pin. The mode pin needs to be connected to ground for this to happen. The HY-SRF05 has no such accomodations for a single-pin mode. 
So leave your red echo connection as it is but you need to connect your brown trigger to another output pin to work. Plug it into s.3 and give this code a shot:

 
symbol trig = b.0        ; Define output pin for Trigger pulse (M2, X2 parts). Change to port.pin you end up using. Note pin b.0 = s.3
symbol echo = b.5       ; Define input pin for Echo pulse (M2, X2 parts). Also note that on the IRS pin b.5 = s.5 as used with the SRF005 header/ULTRA command.
symbol range = w1 ; 16 bit word variable for range
main:
pulsout trig,2 ; produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range ; measures the range in 10uS steps
pause 20 ; recharge period after ranging completes
let range = range * 5 / 58
if range>20 then '**My Own Test**
sound S.12, (50, 20) 'One kind of sound, if something is far.
elseif range<10 then
sound S.12, (112, 1) 'Another kind of sound, if something is close.
endif
debug
goto main 'And around forever

Sorry about the lack of line breaks but something went wonko during editing :shrug: 
falconunknown's picture

Thks a lot.

Finally my bot it's working!

Just do I have to check out the code, understand it and go ahead.

Thks again JAX.

Chris the Carpenter's picture

I would use the debug window to see what value is actually in W1. I have a feeling there is some math being done funny here.

Yes. Debug window --what are your actual numbers contained in W1 (and do they change the way you think they should with distance)?

falconunknown's picture

Hi.

Add a pic with debug windows as you wish.

http://www.subirimagenes.cl/?v=capturadepantallade2.png

But it doesn't show anything (I can be wrong).

I repeat... I don't know about debug window in Axepad, I just know that show values of the all variables, etc, etc. 

I thought if placed some object close to sensor, the values of the variables could change on debug window.

But didn't change, this is right?

I still think the "issue" could be the pins on Axe408 (Instant robot shield) vs HY-SRF05 pins.

Are they (wires) well connected?

Or just follow this instructions:

How to connect SRF05 to picaxe 28 pin project board (by Fritsl) // http://letsmakerobots.com/node/66

http://www.subirimagenes.cl/?v=howtoconnectto28x.jpg

 

 

 

 

falconunknown's picture

Hi ChuckCrunch.

Modifying your code, I tried with:

main:

pulsout 1,1

pulsin 3,1,w1

let w1= w1  * 34 /2 /10

if  w1>20 then               'Added line

sound S.12, (50, 20)      'Added line

elseif w1<10 then       'Added line

sound S.12, (112, 1)      'Added line

endif        'Added line

       debug w1    

       pause 20

goto main

But, still no hear other sound, just one kind of sound.

Add this link:

http://youtu.be/JWtCjYZTe28

Thks.

ChuckCrunch's picture

pulsout 1,1
pulsin 3,1,w1
let w1= w1  * 34 /2 /10

debug w1   
       pause 20
       goto main