SRF05 Doesnt work with Picaxe 28x1... :/

MaltiK

Member
I connect my Digital Input to port 6, and the digital output to port 3, and I run the code:

Code:
Symbol servopin = 0' Defines output pin to which the servo turning the head is connected

symbol trig = 3 ' Defines output pin for Trigger pulse of SRF05

symbol echo = 6 ' Defines input pin for Echo pulse of SRF05

symbol servohead = 0 'Defines outnput pin for servo to turn SRF05

 

symbol range = w1 ‘ 16 bit word variable for range

symbol oldrange = w2' 16 bit word variable for "Where were we last time?"

symbol calcrange = w3 ' 16 bit word variable for "The difference"

 

symbol differencebit = 50 ' sets how little difference we can tolerate to call this "an object"

symbol kopbit = b25 ' this is overkill and not really used in here, but if you get my way of coding, you may see that it can be used for further investigation to have this variable ;)

 

main:

for b0 = 75 to 205 step 10

servo servohead, b0

pause 20

 

gosub puls

range = range / 3

if range > 150 then

range = 150

end if

 

for b1 = 1 to range

sertxd ("|")

next b1

 

'''

if oldrange > range then

calcrange = oldrange - range

 

if calcrange > differencebit then

kopbit = 1

end if

 

end if

'''

if oldrange < range then

calcrange = range - oldrange

 

if calcrange > differencebit then

kopbit = 2

end if

 

end if

'''

if kopbit = 0 then

sertxd ("(+)")

end if

kopbit = 0

sertxd (13, 10)

 

next b0

sertxd (13, 10)

servo servohead, 75

wait 1

 

goto main

 

 

 

 

''''''''''PULS''''''''''''

{

puls:

pause 10 ' this should not be nesecary, but it was of some reason in my setup

low 0 ' this should not be nesecary, but if not, strange things hapened

pause 10 'this should not be nesecary, but that is what makes it all fun

 

pulsout trig,1 &#8216; produce 20uS trigger pulse (must be minimum of 10uS)

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

pause 10

return

}
And in the programmer I press F8, and I click "4800" you are supposed to see indents where your sonar sees an impediment, All I see is a series of "||(+)" it never gets bigger or smaller. And when I look at the SRF05 it does blink red, so it is getting power, what is the problem, is it the code?

 

Technical

Technical Support
Staff member
Your code is a bit confusing!
Try just this
Code:
main:
pulsout trig,1 &#8216; produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range &#8216; measures the range in 10uS steps
pause 1000
debug
goto main
to start with for testing.

If using the AXE020 project board are you connecting direct to output 3 (not the darlington buffered output header).
 

BeanieBots

Moderator
Confusing code indeed.
You move the servo in steps but don't activate or read the US during those steps.
You have routine which sends the chars shown in the picture, but that loop does not include any servo commands or US readings. Don't get it!

Get each bit working independantly first.
 

westaust55

Moderator
When you say the red LED on the SRF05 module is blinking,
is this just when you turn the power on or the entire time your program is running.

If it is blinking while the program is running then the trigger pulse from the PICAXE to the SRF05 is getting through.
 

hippy

Ex-Staff (retired)
As others have said, start simple, get that working, then build on it.

The code from Technical is a good starting point and you can use SERTXD(#range,CR,LF) instead of DEBUG if you wish. Make sure that you are getting consistent and expected readings, if not solve that problem before moving on. Until you have reliable input nothing else is going to work as expected.

Then, process your range value to whatever you want it to be, add your 'bar graph display' and get that working to your satisfaction.

Then put that within the main loop which servo scans the area.

I'm not sure what 'oldrange', 'differencebit' and 'kopbit' do or are meant to achieve and the best rule is take out everything which is unnecessary.
 

MaltiK

Member
When you say the red LED on the SRF05 module is blinking,
is this just when you turn the power on or the entire time your program is running.

If it is blinking while the program is running then the trigger pulse from the PICAXE to the SRF05 is getting through.
The red led blinks right when I connect everything (before I enter the code)

I have tried everyones suggestions, and still doesnt work, how do I verify that I soldered the input and output pins correctly?
 
Last edited:

westaust55

Moderator
The red led blinks right when I connect everything (before I enter the code)

I have tried everyones suggestions, and still doesnt work, how do I verify that I soldered the input and output pins correctly?
Okay so LED only flashes on power application,
but not when the program is running.

PLEASE upload your circuit schematic and a photo of how you have the PICAXE wired to the SRF05.
 

MaltiK

Member
Okay so LED only flashes on power application,
but not when the program is running.

PLEASE upload your circuit schematic and a photo of how you have the PICAXE wired to the SRF05.
No, it lights up during the program too... I never said it doesnt

 

westaust55

Moderator
Maltik,

You MUST learn to answer the questions asked. Otherwise we are left guessing what the situation is.


My question was:
When you say the red LED on the SRF05 module is blinking,
is this just when you turn the power on or the entire time your program is running.
You responded with:
The red led blinks right when I connect everything (before I enter the code)
That did not answer the question fully so I make the assumption:
Okay so LED only flashes on power application,
but not when the program is running.
Only to get further information that:
No, it lights up during the program too... I never said it doesn&#8217;t
Can you understand that clear information and complete answers to question will get your problems solved MUST FASTER
 
Last edited:

MaltiK

Member
As soon as I connect the 5v and G to the SRF05, REGARDLESS of whether or not I have uploaded any code to the board, the red light blinks
 

westaust55

Moderator
Your diagram is correct and matches the code in terms of the IO being used.

Namely:
symbol trig = 3 ' Defines output pin for Trigger pulse of SRF05

symbol echo = 6 ' Defines input pin for Echo pulse of SRF05


AS you inform us that the SRF05 LED IS flashing while the program is running, we know that the trigger pulse is getting from the PICAXE to the SRF05 trigger circuit.

Can you check and confirm with a multimeter that you have an electrical circuit from the SRF05 Echo Out pin to the PICAXE input 6 pin. (That is to physical pin 17 on the PICAXE 28X1)
 
Last edited:

MaltiK

Member
Your diagram is correct and matches the code in terms of the IO being used.

Namely:
symbol trig = 3 ' Defines output pin for Trigger pulse of SRF05

symbol echo = 6 ' Defines input pin for Echo pulse of SRF05


AS you inform us that the SRF05 LED IS flashing while the program is running, we know that the trigger pulse is getting from the PICAXE to the SRF05 trigger circuit.

Can you check and confirm with a multimeter that you have an electrical circuit from the SRF05 Echo Out pin to the PICAXE input 6 pin. (That is to physical pin 17 on the PICAXE 28X1)
I have a multimeter handy but I am a complete noob with it, what do I do, which setting do I set it to, what should I connect the red wire to? Black?
 

westaust55

Moderator
As soon as I connect the 5v and G to the SRF05, REGARDLESS of whether or not I have uploaded any code to the board, the red light blinks
Yes it will blink briefly on power up to indicate it has power.

But if the Trigger signal is working, then it will also blink one for each time a pulse is sent to the SRF05 to trigger and start a range measurement.

Does it, or does it not, blink when the program is runing?
 

westaust55

Moderator
I have a multimeter handy but I am a complete noob with it, what do I do, which setting do I set it to, what should I connect the red wire to? Black?
Set your multimeter to an Ohms range. Assuming you have a simpler meter with a rotary selector, that the the aerea with the Ohms &#937; symbol. There will be 3 or 4 setting in this part – suggest choose say 100.
With Ohms it is not so crucial to have the leads in a particular orientation unless checking diodes or across PN-type junctions.
With the meter on and lead not touching anything, it should read something like 99.99 for open circuit (high resistance).
Put one lead on the SRF05 module on the opposite side to the header pin for the Echo Out signal (where you show the yellow wire/line connecting).
Put the second lead on the physical pin 17 of the PICAXE or its socket. Tehre is no need to remove the PICAXE chip.
If there is a good circuit, the meter will show an extremely low reading like 0.00 Ohms or maybe 0.01 Ohms. If you get this reading then the wiring is okay.
If you see a high value like 1.00 it should work but a joint somewhere is not good quality. If you have a reading like 99.99 then suspect a dry joint. Then you should re-solder the joint.
With a dry joint, it can look good and my hold the wire but electrically is poor and will not work.

Then you should check this there is no solder bridge on the SRF05 between the ECHO OUT and the adjoining Trigger In pins (yellow wire to blue wire). The multimeter reading should be 99.99 indicating high resistance/ open circuit. If you have a low value then check for a solder bridge that would have the PICAXE output holding the echo signal low so the PICAXE does not “see” the Echo pulse from the SRF05..
 

Attachments

MaltiK

Member
Ok, I tried that and everything is successful/continuity/soldering is perfect, I am still trying to figure this out.

When I plug the power/all the cords from the sonar to the board (with batteries) I don't get red led blinks, but when I upload the right code I do, so it isnt the sonar thats the problem/connections (nothing physical) its the code?
 

westaust55

Moderator
Ok, I tried that and everything is successful/continuity/soldering is perfect, I am still trying to figure this out.

When I plug the power/all the cords from the sonar to the board (with batteries) I don't get red led blinks, but when I upload the right code I do, so it isnt the sonar that's the problem/connections (nothing physical) its the code?
I am not home to check my SRF05 (in fact I use an i2c SRF08 these days)
but going on memory, I am sure that the RED LED on the SRF05 should blink when power is first applied.

Thereafter it blinks one per trigger pulse.

But that said, if the LED is flashing while the program is running then seems to be an issue with the echo pulse back to the PICAXE.
 
Last edited:

MaltiK

Member
I am not home to check my SRF05 (in fact I use an i2c SRF08 these days)
but going on memory, I am sure that the RED LED on the SRF05 should blink when power is first applied.

Thereafter it blinks one per trigger pulse.

But that said, if the LED is flashing while the program is running then seems to be an issue with the echo pulse back to the PICAXE.

Alright, I am buying a new project board anyway, so I will update this thread if it yields more inconclusive results
 

westaust55

Moderator
MAltik,

looking back your information is conflicting:

in post 10 you stated:
As soon as I connect the 5v and G to the SRF05, REGARDLESS of whether or not I have uploaded any code to the board, the red light blinks
but then above you say:

When I plug the power/all the cords from the sonar to the board (with batteries) I don't get red led blinks. . . .
Hard to help when the info keeps changing . . . . .
 
Last edited:

MaltiK

Member
Well thats what happens mate, I cant change the fact that one time it works and the second it doesnt, I believe I did point out the fact that it was a second try though...
 
Top