SRF05 >>> Quick Question

slimplynth

Senior Member
Hi all

Just a quick Q...

My srf05's LED should flash with just the 0v and 5v pins connected. i.e. the flash isn't indicative of taking a reading and my lack of a flashy red light means i've destroyed my 2nd srf05?
 

slimplynth

Senior Member
Excellent!!! There was some hope, It works :D thought that was another 15 quid down the pan, fortunately not; though Jonny 4 & Three Quarters has a gammy looking eye, though hopefully can move on to sorting out object detection next.

(Sometimes people post asking for help on the forum but never post back explaining if all went well - so I don't apologise for wittering on)... below is an overly droning explanation of why/how i got it wrong.. thought it was important to post for the record given that Chavaquiah kindly/rapidly gave up his time to help.

Could have kicked myself... It was working fine the other day, then work started on the head (servos). Which were a real pain and I resisted, all day, asking the forum the question. "Please help, I'm going crazy trying to understand why my bot is IR deaf."

The motor test program worked fine when using Serrxd with an AXE027, but for some reason Irin just refused to initiate any movement.. as it happened the problem was the code... This little Asus Eee PC is brilliant for Picaxe work but seems I'm falling foul of the the slightly smaller keyboard, must have deleted a couple of digits, in error from an inconspicuous constant declaration; that constant is used for Pause commands between movement of the motors.. end result was the pause was so small you couldn't see the motor movement from my distance of 18" max.

Anyway, this was fixed then the head was started.. the head worked... yay! but the bird's nest grew on the breadboard.

That leads to the srf05 problem, admiteddly.. the panic reaction was to pull out J4&3/4's eyes... probably not the best course action but at least the scars don't have to heal. (Cardboard shell to protect everything but remain serviceable)

Mental note to self: "Don't follow advice, remember it!" Far too often I've waded in and cost myself time/money & frustration. This time however, the plug was pulled... checked the batteries and data sheets.. thought perhaps the 5V stated in SRF05 datasheet was an issue.. the 3x AA Maplin Alkaline's had dropped to 4.1V. (Though by this point I'd already removed components so knew the root cause might be difficult to prove)

To compound matters after this initial messin' about (removing Servo's), the power button then refused to show light, (LED pwr indicator switch)... sudden sinking feeling..

Fortunately, that was just a couple of dislodged wires.. decided to use an 08M, as was used the other day to test the srf05, copied the code straight from the data sheet.

Code:
symbol trig = 3 ‘ Define output pin for Trigger pulse (A, M, X, X1 parts)
; symbol trig = b.3 ‘ Define output pin for Trigger pulse (M2, X2 parts)
symbol echo = 6 ‘ Define input pin for Echo pulse (A, M, X, X1 parts)
; symbol echo = c.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
‘ now convert range to cm (divide by 5.8) or inches (divide by 14.8)
‘ 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 ‘ display range via debug command
goto main ‘ and around forever
‘ Note that X2 parts operate at 8MHz instead of 4MHz and so modify the calculation
‘ let range = range * 10 / 58 / 2 ‘ multiply by 10 then divide by 58 then divide by 2

This didn't work but setting up as per the Data sheet for the one wire config (for the 08M) did work.. well it got the light flashing again at least, which got a big sigh of relief (I must have got the echo and trigger lines mixed up)). Changed the code above to ...

Code:
symbol trig = 1 ‘Define output pin for Trigger pulse (A, M, X, X1 parts)
'symbol trig = b.3 'Define output pin for Trigger pulse (M2, X2 parts)
symbol echo = 2 ‘ Define input pin for Echo pulse (A, M, X, X1 parts)
'symbol echo = c.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
'now convert range to cm (divide by 5.8) or inches (divide by 14.8)
'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 'display range via debug command
goto main 'around forever
'Note that X2 parts operate at 8MHz instead of 4MHz and so modify the calculation
'let range = range * 10 / 58 / 2 ‘ multiply by 10 then divide by 58 then divide by 2
Changing the BB and code to the above worked.. not 100% sure why, just glad its sorted but still, feels like a wasted a night :eek: ... Can't believe i forgot to test the srf05 with the 20x2... but glad i didn't ruin anything when trying to resolve..
 
Last edited:

cactusface

Senior Member
Hi,
The LED on my SRF05 only flashes when taking a reading! and seems to work just fine.
Hope it helps..
Regards
Mel.
 

slimplynth

Senior Member
Thanks Cactus, yeah It was eventually flashing which is some relief.. if a new one was required then i'd have spent more on J4&TQ's eye's than i have on my own to date :) - mental note to self, buy SRF05 when 18M2 becomes available.

Just gutted I wasted the whole night because of a simple error... won't get to work on it now til the weekend.
 
Top