srf005

rob nash

Senior Member
hi,
i,ve been using srf005 in my robot project finally getting around to programming lots of fun the srf005 is on a servo panning lft to rgt working brill, now the 0v line breaks off put the srf005 still work?. can it be left this way? or is impending doom waiting round the corner.
advice please rob.
 

Dippy

Moderator
pls rob, quit the txt spk ;)

"..now the 0v line breaks off put the srf005 still work?. "
- please translate into English.
 

rob nash

Senior Member
hello dippy and all.
i have wired the srf005 module as described in the data sheets
all works well, connected by four wires now the negative 0- line the solder joint broke of from the connector but the srf005 module still works started writing this short program for the bot to roam around

main: pause 100

pulsout trig,2 ' produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range ' measures the range in 10uS steps
pause 10 ' recharge period after ranging completes
let range = range * 10 / 58 ' now convert range to cm (divide by 5.8) or inches (divide by 14.8)

if range < 30 then gosub rgt180
if range < 45 then gosub rgt90

servopos r, r_forward_slow
servopos l, l_forward_slow

for b1 =rgt to lft step 2
servopos pan,b1
pause 10
pulsout trig,2 ' produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range ' measures the range in 10uS steps
pause 10 ' recharge period after ranging completes
let range = range * 10 / 58 ' now convert range to cm (divide by 5.8) or inches (divide by 14.8)

if range < 30 then gosub rgt180
if range < 45 then gosub lft90


next b1
for b1 =lft to rgt step -2
servopos pan,b1
pause 10
pulsout trig,2 ' produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range ' measures the range in 10uS steps
pause 10 ' recharge period after ranging completes
let range = range * 10 / 58 ' now convert range to cm (divide by 5.8) or inches (divide by 14.8)

if range < 30 then gosub lft180
if range < 45 then gosub lft90
next b1







goto main

now i fought with the srf005 0-line disconnected the program would'nt get past if range < 30 then gosub rgt180 and be stuck for ever in the gosub.
but that is not the case and the whole programme runs
 

Dippy

Moderator
Are you saying that with the ground line broken it doesn't work and with the ground line in place then it works OK?

Excellent news!
 

westaust55

Moderator
The SRF is possibly still operating because of a scenario like the pulse bing normally low acts as a ground/reference for the circuit and maybe capacitors hold sufficient charge to keep the circuit operating for the brief period of a pulse.

What program you are running is virtually irrelevant.

You say the 0V wire is broken but it is still working with 4 wires.
Do you have a wire to the mode terminal? :confused:

But think of it this way....
Q. why is the 0V connection provided in the first place ?
A. to be used (as a reference line, current return path, etc)


So to recapitulate - FIX IT!

before the module fails or whatever.
 

rob nash

Senior Member
thanks dippy,tech and westaust
sorry for the wrong use of terminology i should know the basic by now. I FIXED IT. dippy i was saying the ground line broken and it still worked. westaust thanks for the reply not sure what you mean "Do you have a wire to the mode terminal". if you are refering to srf input hole by the led then no. I was thinking along those line of your Q&A

thanks again rob
 

slimplynth

Senior Member
Hey R kid...

Hi Rob, you might want to consider renaming your symbol names to something easier to understand when you're debugging.

servopos r, r_forward_slow
servopos l, l_forward_slow

They confused me..

Code:
main: pause 100

pulsout trig,2 ' produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range ' measures the range in 10uS steps
pause 10 ' recharge period after ranging completes
let range = range * 10 / 58 ' now convert range to cm (divide by 5.8) or inches (divide by 14.8) 

if range < 30 then gosub rgt180
if range < 45 then gosub rgt90

servopos r, r_forward_slow
servopos l, l_forward_slow

for b1 =rgt to lft step 2
servopos pan,b1
pause 10
pulsout trig,2 ' produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range ' measures the range in 10uS steps
pause 10 ' recharge period after ranging completes
let range = range * 10 / 58 ' now convert range to cm (divide by 5.8) or inches (divide by 14.8) 

if range < 30 then gosub rgt180
if range < 45 then gosub lft90 


next b1 
for b1 =lft to rgt step -2
servopos pan,b1
pause 10
pulsout trig,2 ' produce 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range ' measures the range in 10uS steps
pause 10 ' recharge period after ranging completes
let range = range * 10 / 58 ' now convert range to cm (divide by 5.8) or inches (divide by 14.8) 

if range < 30 then gosub lft180
if range < 45 then gosub lft90
next b1

goto main
The code is missing the symbols declarations so I started putting them in myself, realising the rule of not doing course work for anyone I won't post my version of your code.. sorry, if it's not course work.

How does your servo pan and tilt operate? is it is jerky at all.. i had to include some well placed short pause commands to get my ptz free of jerky action. Which picaxe and servo's are you using?
 

BeanieBots

Moderator
Many circuits will continue to work with either a broken 0v or even a broken power supply line. This is because power (or current sinking) is derived via any input signals connected to the device. This is known as "parasitic power".

It could easily destroy your PICAXE:eek:
Fix the broken wire. It serves a purpose.
 

rob nash

Senior Member
hi slimplynth,
which bit confused you! i did'nt add all the code because am nowhere near complete "just a start". here's the symbol declaration that am using at the moment the drive setup was advice from tech. which i think could'nt be any easier to debug
' set drive speed
'*************************************************************
symbol r_off = 140 'this is the drive paramitors
symbol r_back_slow = 135 'for the cont' servo
symbol r_back_fast = 75
symbol r_forward_slow = 150
symbol r_forward_fast = 222

symbol l_off = 148
symbol l_back_slow = 153
symbol l_back_fast = 172
symbol l_forward_slow = 140
symbol l_forward_fast = 123

symbol l = b.5
symbol r = b.4
'*************************************************************
' servo panning
symbol pan = b.3
symbol lft = 210
symbol rgt = 90
symbol cen = 150
'*************************************************************
' srf005
'*************************************************************
symbol trig = b.1 ' Define output pin for Trigger pulse
symbol echo = c.1 ' Define input pin for Echo pulse
symbol range = w6 ' 16 bit word variable for range

'*************************************************************
' floor sensors
'*************************************************************
symbol flled = B.2 'red led
symbol frled = d.7 'red led
symbol lftldr = A.0 'front lft ldr
symbol rgtldr = A.1 ' front rgt ldr


symbol lcd = b.7


As for the servo it's an its an dgservo 9g paning lft to right for now its powered by 4AA ni-mh 800mah " not much i know but does the job for now"
with the current code i get a smooth action lft to right. In fact the code worked better than i expected as the bot is rotating before it completed the turn the paning servo begins turning giving a very fluid look "hippy pointed me in the right direction for the paning".
now when i try having the servo start in the centre say 150=cen then pan left =90 well it was if the servo went into fit mode jerky,missed steps,awful
the code above works brill for me. the picaxe is a 40x2 with it own power supply 3AA

OOO this is not course work way past those days but..
thanks beaniebot am googelin parastic power
and i did fix the wire
cheers rob
 

BeanieBots

Moderator
Doubt you'll find much about that type of parasitic power on Google.

It's much easier to understand if you consider the case when the power line (rather than 0v) is broken but the principle is the same.

Scenario:-
Chip A has an output which connects to chip B's input.
Chip B now loses power.
Chip A output is logic high and still connected to the un-powered chip B.
The high on chip B's input starts to make the internal clamp diode conduct and push up the power rail. Chip B is now powered by the output of chip A.
This can overload the chip A output and/or destroy chip B input.
 

slimplynth

Senior Member
[Delted post], im not banging my head against a brick wall for anyone else today.

Code:
'PICAXE 20X2:
;need axe027
;	pwr Qs
;	hall effect
;	rtc

     
				 'JONNY 4 & THREE QUARTERS
				 
                         'All directions for 'HEAD' and Chasis movement 
		             'are based on looking at the bot from 
		             'behind (no pun intended:)
		 
Setfreq M32              'setfreq to M32 for the 20X2

Symbol pan             = B.1        'Replace 2(08M) with B.1 on the 20X2
Symbol tilt            = B.7        'Replace 1(08M) with B.7 on the 20X2
Symbol Background_RCV  = B.6
Symbol delay           = 2500     
                         'Experiment with this value, depending on the make of servo
				 'and pic (freq) speed, if this pause value is too low it
				 'may cause apparent jittering or miss position loci
				 'because the servopos command has been updated before
				 'the last command has had chance to be effected? i.e.
				 'before the servo horn has reached it's intended position ? 


let dirsB = %11111111
let adcsetup = 0

'******************************************************************************
'*                                                                            *
'* Key below:  Each number can be used during the ASSESS_IR Subroutine to     *
'*                                                                            *
'* control motor/direction, handy to scroll back here during debugging        *
'*                                                                            *
'******************************************************************************

'-------------------------------------------------------------------------------

'STANDSTILL = "1"

'ONWARDS = "2"

'BACKWARDS = "3"

'FWDRIGHTTURN = "4"

'FWDLEFTTURN = "5"

'BACKWARDSLEFTTURN = "6"

'BACKWARDSRIGHTTURN = "7"

'-------------------------------------------------------------------------------

'******************************************************************************
'*                                                                            *
'*                         Main Program to decide/select action               *
'*                                                                            *
'******************************************************************************

MAIN:

Goto AUTO_MODE

ASSESS_IR:

Gosub GETIR

Bintoascii b0,b1,b2,b3

'Debug b3 'remove the first apostrophe when debugging

Select Case b3

Case = "1"
Goto STANDSTILL

Case = "2"

Goto ONWARDS

Case = "3"

Goto BACKWARDS

Case = "4"

Goto FWDRIGHTTURN

Case = "5"

Goto FWDLEFTTURN

Case = "6"

Goto BACKWARDSLEFTTURN

Case = "7"

Goto BACKWARDSRIGHTTURN

Else Goto ASSESS_IR

End Select

Goto ASSESS_IR

'******************************************************************************
'*                                                                            *
'*                         Subroutine: AUTO MODE - NEED TO MOVE TO 28X2       *
'*                                                                            *
'*  move the servo commands to the 28x2                                       *                                                                            *
'******************************************************************************

AUTO_MODE:
Gosub SRF05


Servo pan, 150
Servo tilt, 220

Gosub SRF05
Select Case w1

Case > 25 

Gosub ONWARDS

Case < 25

Gosub STANDSTILL

End Select

Goto SCAN

'******************************************************************************
'*                                                                            *
'*                         Subroutine: STOPS THE BOT TO LOOK AROUND           *
'*                                                                            *
'******************************************************************************

SCAN:

Gosub Look_Up_Left
Pause delay
Gosub SRF05
w2=w1
Gosub Look_Up_Right
Pause delay
Gosub SRF05
w3=w1
Gosub Look_Down_Right:
Pause delay
Gosub SRF05
w4=w1
Gosub Look_Down_Left:
Gosub SRF05
w5=w1
Pause delay

If w4<10 or w5<10 Then Gosub BACKWARDS

if w4>10 or w5>10 Then Gosub ONWARDS

Goto SCAN
'Goto ASSESS_GROUND

'******************************************************************************
'*                                                                            *
'*                         Subroutine: ASSESS THE GROUND IN FRONT OF BOT      *
'*                                                                            *
'******************************************************************************

ASSESS_GROUND:
if w6<25 Then Gosub BACKWARDSLEFTTURN
if w7<25 Then Gosub BACKWARDSRIGHTTURN
Gosub BACKWARDS
Goto SCAN


'******************************************************************************
'*                                                                            *
'*                         Subroutine: Collect SRF05 DATA FROM 08M            *
'*                                                                            *
'******************************************************************************


GETIR:
irin [5000,AUTO_MODE], c.5,b0
'debug b0
'bintoascii w4,b0,b0,b0,b0,b0
'setfreq M64
Return



'******************************************************************************
'*                                                                            *
'*                         Subroutine: Collect SRF05 DATA                     *
'*                                                                            *
'******************************************************************************
		
SRF05: 'Waits for the 08M picaxe to send the range finder result
Setfreq m4
serin B.6,N2400_4,w1
'debug w1
Setfreq m32
Return

'******************************************************************************
'*                                                                            *
'*                         Subroutines To Control Motors - NEEDS PWMing       *
'*                                                                            *
'******************************************************************************

ONWARDS: 'works
'Sertxd("Onwards",13,10)
High B.4,B.3
Pause 1500
Low B.4,B.3
Return

FWDRIGHTTURN: 'works
'Sertxd("Forward Right Turn",13,10)
High B.4 'B.3
Pause 7
Low B.4 'B.3
Return

FWDLEFTTURN: 'works
'Sertxd("Forward Right Turn",13,10)
High B.3
Pause 7
Low B.3
Return

BACKWARDS: 'works
'Sertxd("Reverse",13,10)

High B.5,B.2
Pause 1
High B.4,B.3
Pause 11
Low B.4,B.3
Low B.5,B.2
Return

BACKWARDSLEFTTURN: 'works
'Sertxd("Reverse Left",13,10)

High B.2
Pause 1
High B.3
Pause 7
Low B.3
Low B.2
Return

BACKWARDSRIGHTTURN: 'works
'Sertxd("Reverse Left",13,10)

High B.4
Pause 1
High B.5
Pause 7
Low B.5
Low B.4
Return


STANDSTILL: 'works
'Sertxd("Standstill",13,10)
low B.2,B.3,B.4,B.5
'b0=5
'Debug b0
pause 39
Return

'******************************************************************************
'*                                                                            *
'*                         Subroutines To Control Servos - Move to 28x2       *
'*                                                                            *
'******************************************************************************


	Centre:
	
		Servopos pan, 150 'Pan centre
		Servopos tilt,150 'Tiltcentre
		Return
	
	Look_Up_Left:
	
		Servopos pan, 80 'Pan Left
		Servopos tilt, 80 'Tilt Up
		Return
	
	Look_Up_Right:
	
		Servopos pan, 220 'Pan Right
		Servopos tilt, 80 'Tilt Up
		Return
	
	Look_Down_Right:
	
		Servopos pan, 220 'Pan Right
		Servopos tilt, 220 'Tilt Down
		Return
	
	Look_Down_Left:
	
		Servopos pan, 80 'Pan Left
		Servopos tilt, 220 'Tilt Down
		Return
 
Last edited:

rob nash

Senior Member
hello, sorry it taken a while to reply, i installed IE9 beta messed up my machine. beaniebot thank you for your explanation very helpful but world this mean i have a problem with my circuit as a whole.attempting to use diptrace to provide diagram but it,s proving a little difficult at the momument.
slimplynth sorry for your head banging sesson.I appreciated your input and you have givin me some food for thought.
cheers rob.
 

Dippy

Moderator
if u cnnct it per spec then y wud u hv a prblm?

You'll only get potential problems re parasitic power if a wire drops off. That's down to your design and construction skill.
The only other time it really crops up is if there are seperate power supplies for chips that talk.
Parasitic powering issues can usually nullified by a series resistor - low enough so chips can talk but high enough to prevent enough power getting to the other chip or module.
 
Top