Line detection routine too slow PICAXE 18X chip setfreq m8

Hi All,

I am currently working on code for my latest project being a sumobot style line detector. its actually my first wave before implementing a full scale sumobot. I have one issue currently that is bugging me and that has to do with the speed at which i am detecting and responding to the presence of a line. I have included my code below for general review and hints as to what I can change to make the line detection almost immediate.

 

Here is my code

 

setfreq m8

symbol LeftEye = 2

symbol RightEye = 1

 

symbol LeftWheelA = 7

symbol LeftWheelB = 6

 

symbol RightWheelA = 5

symbol RightWheelB = 4

 

; initialize default forward movement

low LeftWheelA

high LeftWheelB

low RightWheelA

high RightWheelB

pause 5000 ;5 second wait before starting up

main:

 

readadc  LeftEye,b1

readadc RightEye,b2

 

sertxd("L (",#b1,") R (",#b2,")",13,10)

pause 500

 

if b1<50 OR b2 < 50 then ; determine if left eye or right eye sees a black line

gosub StopMoving

wait 1

gosub gobackward

wait 3

gosub StopMoving

wait 1

if b1 > b2 then

gosub turnleft

else

gosub turnright

end if

wait 2

gosub StopMoving

wait 1

gosub goforward

end if

goto main

 

 

StopMoving:

low LeftWheelA

low LeftWheelB

low RightWheelA

low RightWheelB

return 

 

goforward:

low LeftWheelA

high LeftWheelB

low RightWheelA

high RightWheelB

return

 

gobackward:

high LeftWheelA

low LeftWheelB

high RightWheelA

low RightWheelB

return

 

turnleft:

high LeftWheelA

low LeftWheelB

low RightWheelA

high RightWheelB

return

 

turnright:

low LeftWheelA

high LeftWheelB

high RightWheelA

low RightWheelB

return

 

 

 

 

May have to do with those huge pauses

First off, I would get rid of the sertxd stuff. Great for testing, but no need if the bot is performing (and not plugged into a computer). But the main thing here is just after that sertxd command, you have a 1/2 second pause. Even at 8mhz, you are looking at a 1/4 second pause, everytime through the loop. That means at best, you are taking less than 4 readings (well, 8 really --two sensors) every second. Get rid of that <pause 500>, my friend.

Any chance we could get more information?

You say you want your robot to react faster, but, you don’t say how long it takes to react now. A video would proably be helpful.

Sorry no video yet, but the
Sorry no video yet, but the response time was such that it would pass the line without registering . I did a stationary test by placing a finger over the eyes and it took almost 2 seconds before responding.

I removed the pause 500 and
I removed the pause 500 and the code to display the text and
That worked . Thanks a lot chris