Shop OBEX P1 Docs P2 Docs Learn Events
Boebot shadow vehicle problem — Parallax Forums

Boebot shadow vehicle problem

zx1shadowzx1shadow Posts: 5
edited 2011-10-11 08:19 in Robotics
Hi guys , well iv been trying to get my boe bot to follow a piece of white paper, i used the example from the manuel of course but my boe bot insists on reversing constantly ,it does react when i put paper in front of it ,but it only tries to avoid it, any help would be nice.here is the code im using.





' {$STAMP BS2}
' {$PBASIC 2.5}
'
[ constants ]
kpl CON -35
kpr CON 35
setpoint CON 2
centerpulse CON 750
'
[ variables ]
freqselect VAR Nib
irfrequency VAR Word
irdetectleft VAR Bit
irdetectright VAR Bit
distanceleft VAR Nib
distanceright VAR Nib
pulseleft VAR Word
pulseright VAR Word
'
[ main routine ]
DO
GOSUB get_ir_distances
pulseleft = setpoint - distanceleft * kpl + centerpulse
pulseright = setpoint - distanceright * kpl + centerpulse
GOSUB send_pulse
LOOP
'
[ subroutine - get ir distances ]
get_ir_distances:
distanceleft = 0
distanceright = 0
FOR freqselect = 0 TO 4
LOOKUP freqselect, [37500,38250,39500,40500,41500], irfrequency
FREQOUT 8, 1, irfrequency
irdetectleft = IN9
distanceleft = distanceleft + irdetectleft
FREQOUT 2, 1, irfrequency
irdetectright = IN0
distanceright= distanceright + irdetectright
NEXT
RETURN
'
[ subroutine - get pulse ]
send_pulse:
PULSOUT 13,pulseleft
PULSOUT 12,pulseright
PAUSE 5
RETURN

Comments

Sign In or Register to comment.