linefollower_0.3gp (1409615Bytes)
ALL_MY_LINEDANCERS.zip (7444Bytes)
tHIS POST IS A MESS. iT IS EDITED SEVERAL TIMES AND MAKES NO MORE SENCE. i HAVE NO TIME TO DO MORE ABOUT IT: bOTTOM LINE IS THAT THERE IS ATTACHED A ZIP-FILE WITH ALL i EVER DID INlINE-SENSORING FOR pICAXE!
Chris the carpenter asked for picaxe code to line follower.
First you have to hook up the sensors to the analouge in. That is a chapter for itself, but in the end you will have a value for each sensor; 0-255
I have tried some different line-sonsors, once JIP and I was playing around with them.
Opposite what JIP believes in, I think that a man only needs 2 sensors to make it work.
Fur fun, I made the smallest routine I could. I cannot remember the correct syntax, but it goes something like this:
main:
readadc 0, b0
readadc 1,b1
pulsout 0, b0
pulsout 1, b1
goto main
It actually worked quite fine! The more white on one side, the more throttle. Only, motors only ran with 50% in average, which is not optimalk ;)
So I wrote some other code, and looking at it now, I cannot find head or tale in it, I must admit - but you asked for it, Chris, and here it is. Erh - here is some code, I made a thousand versions.
The line-follower on the picture & video does have 4 sensors, but that was just because I was testing what that line-sensoring-thing was all about, only 2 spaced just a little wider than the black line is used. Erh.. the code, I can see is using 4 .. Whatever - it is so goddamn easy to make that code, use mine as an example, my robot no longer exists ;)
As you can see, even if the robot is held in one side, it just insists on stauing on track, and there is no wobbeling on straight tracks - mision completed IMHO ;)
symbol tolerence = 25
main:
readadc 0, b0
readadc 1, b1
readadc 2, b2
readadc 3, b3
if b1 > b2 then gosub H
if b1 < b2 then gosub V
goto main
H:
b4 = b1-b2
if b4 > tolerence then
low 5: low 4
low 7: high 6
else
gosub L
end if
return
V:
b4 = b2-b1
if b4 > tolerence then
high 4: low 5
low 6: low 7
else
gosub L
end if
return
L:
high 4: low 5
low 7: high 6
return
Yeke! Google video does not like videos from my old phone, pretty slow framerate it makes out of it. So I also attach as a file, see below - you should download it before viewing - on my PC I get the movie in ascii if I just click