I got my little Octabot rover all wired up, and everything seems to be working fine except the IRPD (the only sensor I have at present). I am not sure the right (looking at the front of the sensor) IR LED is working properly even though I see the status LED pulse on and off.
One problem I had is the code I based my program on seems to have an error in it from what I see in the IRPD manual. The original code was using pulseout but the IRPD code in the manual sets the line high, checks the sensor, pause 1, then sets the line low again.
Anyway, no matter how I adjust the pots on the IRPD, I can’t seem to get a trigger off the right IR LED. The left one triggers fine as far as I can tell.
Any ideas I may not have tried?
Here is my current code:
[code]’ Motors
leftm con p0
leftd var word
lefta var word
rightm con p1
rightd var word
righta var word
revdir var word
’ IRPD
rights con p12 'Change pin number to pin you are using for your right led Voilet wire
lefts con p13 'Change pin number to pin you are using for your left led Blue wire
sensor var in14 'Change pin number to pin you are using for your sensor Yellow wire
templ var bit
tempr var bit
left var sword
right var sword
speed var word
test var word
object var word
'========================================================================
'========================================================================
leftd = -1
lefta = -5
rightd = 1
righta = 35
revdir = -1
speed = 75
test = 1
while test <> 0
servo leftm, (speed + lefta) * leftd, 2
servo rightm, (speed + righta) * rightd, 2
gosub Check_IRPD
branch object, [Hit_Left, Hit_Right, Hit_Center]
goto Do_Again
Hit_Left:
while object <> 0
gosub Rotate_Right
gosub Check_IRPD
wend
goto Do_Again
Hit_Right:
while object <> 0
gosub Rotate_Left
gosub Check_IRPD
wend
goto Do_Again
Hit_Center:
’ Backup some
gosub Backup
branch object, [Turn_Right, Turn_Left, Turn_Left]
Turn_Right:
while object <> 0
gosub Rotate_Right
gosub Check_IRPD
wend
goto Do_Again
Turn_Left:
while object <> 0
gosub Rotate_Left
gosub Check_IRPD
wend
Do_Again:
gosub Check_IRPD
wend
goto Exit_Now
Rotate_Right:
gosub Backup
servo leftm, (speed + 350 + lefta) * leftd, 5
servo rightm, (speed + 350 + righta) * rightd * revdir, 5
return
Rotate_Left:
gosub Backup
servo leftm, (speed + 350 + lefta) * leftd * revdir, 5
servo rightm, (speed + 350 + righta) * rightd, 5
return
Backup:
servo leftm, (speed + 350 + lefta) * leftd * revdir, 5
servo rightm, (speed + 350 + righta) * rightd * revdir, 5
return
Check_IRPD
servo leftm, 0, 1
servo rightm, 0, 1
’ pulsout rights ,125 'Flash the right led.
high rights
pause 1
tempr = sensor 'Store the right value for templ.
low rights
’ pulsout lefts,75 'Flash the left led.
high lefts
pause 1
templ = sensor 'Store the left value for tempr.
low lefts
’ serout s_out, i9600, “templ =”, dec templ, 13]
’ serout s_out, i9600, " tempr = ++", dec tempr, 13]
object = 0
if templ then
object = object + 1
endif
if tempr then
object = object + 2
endif
return
Exit_Now:[/code]
I watched my robot run around my apartment for several hours last night, and the code that handles the left side of the IRPD works wonderfully. The robot just get stuck in corners at all now. The more I watched it, the more I think that half of the IRPD is not working, or is not working right.
I think if the IRPD was working 100%, this code of mine would be working as well as any code could with just an IRPD as a sensor. I can actually observe it doing all the moves programmed to handle each input (and some surprising moves I did not specifically program). I still need to smooth out the Backup routine a bit.
8-Dale