hi,
Am still exploring the use of servos using techs factory modified servos for continuous rotation for a differential drive system and a micro servo for panning an srf005. Am using a picaxe 20 x 2 am using a program that is put together from the forum and an Evil genius. If you are a newbie to picaxe then have read of “picaxe microcontroller project for the evil genius” It has some great projects to get u started for those of us on a tight budget here the ISBN 978-0-07-170326 if u still have a local library UK members go request a copy.
So to the problem most of the programme works as I expected that is I send it fwd,back,lft,rgt its fine but when it goes “go sub roam” which it does and completes the routine then the code returns to the main part and I give the command say turn left or go fwd the panning servo starts twitching and it doesn’t appear to complete roam routine when asked again i.e. It acknowledges an obstacle turns once and stops returning to the main part of the code. Am not sure if this is software or hardware issue the servos are on a separate power supply and placed I have 100uf cap on the servo power line.
Anyone got any ideas where am going wrong please say
Cheers rob
Am still exploring the use of servos using techs factory modified servos for continuous rotation for a differential drive system and a micro servo for panning an srf005. Am using a picaxe 20 x 2 am using a program that is put together from the forum and an Evil genius. If you are a newbie to picaxe then have read of “picaxe microcontroller project for the evil genius” It has some great projects to get u started for those of us on a tight budget here the ISBN 978-0-07-170326 if u still have a local library UK members go request a copy.
So to the problem most of the programme works as I expected that is I send it fwd,back,lft,rgt its fine but when it goes “go sub roam” which it does and completes the routine then the code returns to the main part and I give the command say turn left or go fwd the panning servo starts twitching and it doesn’t appear to complete roam routine when asked again i.e. It acknowledges an obstacle turns once and stops returning to the main part of the code. Am not sure if this is software or hardware issue the servos are on a separate power supply and placed I have 100uf cap on the servo power line.
Code:
#picaxe 20x2
'############SRF005#######################################
symbol ping = c.7 ' Define output pin for Trigger pulse
symbol echo = b.2 ' Define input pin for Echo pulse
symbol range = w10
'############IR control 08M###############################
symbol fromIR = C.2 '
symbol toIR = C.5
symbol cmnd = b0
symbol IRflag = pinC.2 ' as usual, this is a var
symbol l_led = c.0
symbol r_led = c.4
'*******************************************************************
' servo speed control
'*******************************************************************
symbol l_back_slow = 153
symbol l_back_fast = 200
symbol l_off = 148
symbol l_forward_slow = 137
symbol l_forward_fast = 128
symbol r_back_fast = 95
symbol r_back_slow = 135
symbol r_off = 142
symbol r_forward_slow = 156
symbol r_forward_fast = 220
symbol r = b.3
symbol l = b.4
symbol scan = b.6
symbol lft = 85
symbol rgt = 210
symbol cen = 150
'#####################################################################
symbol counter = b8
init:
pause 100
servo scan,150
servo r, r_off
servo l, l_off
pause 100
main:
do
high r_led
high l_led ' pretend to be busy
if IRflag = 1 then ' data available
gosub getData ' so go get it
select case cmnd ' and move accordingly
'case 1
' gosub bacllft
case 2
gosub bck
'case 3
' gosub bckrgt
case 4
gosub rgt90
case 5
gosub allstop
case 6
gosub lft90
case 7
gosub ro_rgt
case 8
gosub fward
case 9
gosub ro_lft
' case 0
' gosub roam
case 11
gosub roam
' case 12
' gosub
end select
endif
loop
' ======== End Main Program - Subroutines Follow ========
getData:
pulsout toIR,10 '50uS "send it" pulse
serin fromIR,N2400_8,cmnd
'sertxd (#cmnd,cr,lf)
return
roam:
for counter = 1 to 4
for b1 =lft to rgt step 2
servopos scan,b1
pause 10
pulsout ping,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
next b1
for b1 =rgt to lft step -2
servopos scan,b1
pause 10
pulsout ping,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
servopos r, r_forward_slow
servopos l, l_forward_slow
next b1
next counter
servo scan,150
pause 30
return
lft90:
gosub allstop
'servopos l,l_back_slow
'servopos r,r_back_slow
pause 30
servopos l,l_back_slow
servopos r,r_forward_slow
pause 1350
gosub allstop
goto main
lft180:
gosub allstop
pause 30
'servopos l,l_back_slow
'servopos r,r_back_slow
servopos l,l_back_slow
servopos r,r_forward_slow
pause 3200
gosub allstop
return
rgt90:
gosub allstop
pause 30
'servopos l,l_back_slow
'servopos r,r_back_slow
servopos l,l_forward_slow
servopos r,r_back_slow
pause 1350
gosub allstop
return
rgt180:
gosub allstop
pause 30
'servopos l,l_back_slow
'servopos r,r_back_slow
servopos l,l_forward_slow
servopos r,r_back_slow
pause 3300
gosub allstop
return
fward:
gosub allstop
pause 30
servopos r, r_forward_slow
servopos l, l_forward_slow
pause 30
return
bck:
gosub allstop
pause 30
servopos l,l_back_slow
servopos r,r_back_slow
pause 30
return
allstop:
servo r, r_off
servo l, l_off
pause 30
return
ro_rgt:
gosub allstop
servopos l,l_forward_slow
servopos r,r_back_slow
pause 30
return
ro_lft: gosub allstop
servopos l,l_back_slow
servopos r,r_forward_slow
pause 30
return
Cheers rob