Line tracking sensors and algorithms

Discuss Ikalogic's featured articles, tutorials and projects

Moderators: ikalogic, cotto88

Line tracking sensors and algorithms

Postby ikalogic » Thu Feb 28, 2008 4:36 pm

Good tut..but i still didnt get that if there is an intersection of more than 4 lines say 7 to 8 lines all in different angles, how the robot will decide in which direction should i go26632663266326632663266326632663


Well in that situation, you would have to develope a special sensor, the one in this tutorial wont work for such complex intersections.. it is usually rare to see intersection between 8 lines, becuase usually a grid of perpendicular is drawn on the ground.. but in the case of an 8 lines intersection, a bigger more adapted line sensor could be developed...
User avatar
ikalogic
Site Admin
 
Posts: 2190
Joined: Wed Jan 02, 2008 2:00 pm
Location: Limoges, France

Re: Line tracking sensors and algorithms

Postby ikalogic » Thu Feb 28, 2008 4:37 pm

thats great...exactly what i need.
but since recevier is photosensor(LDR), why IR used there instead of sharp led light...i know IR's reflectivity is better but it has some problem in daylight...

For the following reason, stated in the article above, section 1, 3rd paragraph: "...relying on old physics rules that states that a colored surface will absorb the light of different colors, and reflect the light of the same color. For example, If you want to build a line sensor to detect white lines drawn on a light blue floor, you can send red light, as the blue will absorb all of it, and the white line will reflect all of it."
User avatar
ikalogic
Site Admin
 
Posts: 2190
Joined: Wed Jan 02, 2008 2:00 pm
Location: Limoges, France

Re: Line tracking sensors and algorithms

Postby ikalogic » Thu Feb 28, 2008 4:43 pm

Great job, Ibrahim clearly you have used HLL C to program your robot. Have you thought of using any other programming techniques like RTOS, Assembly as they are common approaches to embedded enviroment pgoramming. And the other question is if i am using a different PIC Microcontroller the code will then need to be altered and some other header files will need to be included in the source code to build correctly is that true if so can you let me know what might be critical to changes if i am using PIC 18F243. Let me know if possible the reason you choose to program in C other than any other programming technique.


hello, As for the choice of programming language, well, C is more advanced, and allows more sophisticated programming, that would be very difficult to conceive in a low lever language like assembly. For example, a simple task like making calculations with 16 bit variables on an 8-bit processor such as the 8051 is very complicated.. imagine the rest of the code! :D

Now about migrating to PIC18F, for the simple codes provided on this page, it should not be big problem. The main issue will be to change the ports and pins names, otherwize, it should be ok.
User avatar
ikalogic
Site Admin
 
Posts: 2190
Joined: Wed Jan 02, 2008 2:00 pm
Location: Limoges, France

Re: Line tracking sensors and algorithms

Postby moody_sh2006 » Sat Mar 01, 2008 7:04 pm

hi eng.Ibrahime :D
this is a very smart Line tracking sensors i did it on test board(two line test board)
it was very diffecult to put all component on it :D
but i face some problem!!!
1st the leds (i use high intensity white led to follow black line)
it make the ldr less senstive to light and changing on the line
so i surrounded it by small paper(the leds) so i canceled interferance of light whith LDR
then it work good
2nd the LDR it self
i found two parts big circle and small cirlce i use small by luck
3rd the voltage entered to op-amp have small diffrance and i adjust it many time
4th Are their a scientfic calculation for this circuit to improve their effciency
5th the leds and op-amps and resistor make a high power consuming
what can i do to impove the o/p volt which will enter the i/p ports for micro controller2663
thats all :D
and thanks for ur patience :)
moody_sh2006
 
Posts: 2
Joined: Sat Mar 01, 2008 6:19 pm

Re: Line tracking sensors and algorithms

Postby ikalogic » Sat Mar 01, 2008 7:27 pm

moody_sh2006 wrote:hi eng.Ibrahime :D
this is a very smart Line tracking sensors i did it on test board(two line test board)
it was very diffecult to put all component on it :D
but i face some problem!!!
1st the leds (i use high intensity white led to follow black line)
it make the ldr less senstive to light and changing on the line
so i surrounded it by small paper(the leds) so i canceled interferance of light whith LDR
then it work good
2nd the LDR it self
i found two parts big circle and small cirlce i use small by luck
3rd the voltage entered to op-amp have small diffrance and i adjust it many time

This is probably due to the fact that not all the LDRs behave the same way, sometimes, an LDR will be much more sensitive than the others, sometimes, the nearby emitting LEDs will be more powerfull than the others (this happens to bad quality LEDs). The solution i found was to put some transmarent paper on the LDR that is too sensitive, to reduce its sensitivity.

I agree it is dificult to get it well configured, but once it is configured correctly, it functions very well. this line sensor functioned in Egypt, and In vietnam, without changing the configuration or even touching a potentiometer.

moody_sh2006 wrote:4th Are their a scientfic calculation for this circuit to improve their effciency
There nothing more than calculations in electronics.. but for that sensor.. the best you can do is to calculate the best value of the resistor, to provide just the current needed by the LEDs
moody_sh2006 wrote:5th the leds and op-amps and resistor make a high power consuming
what can i do to impove the o/p volt which will enter the i/p ports for micro controller2663
thats all :D
and thanks for ur patience :)


I don't understand this last question...

good luck
User avatar
ikalogic
Site Admin
 
Posts: 2190
Joined: Wed Jan 02, 2008 2:00 pm
Location: Limoges, France

Line tracking sensors and algorithms

Postby phuanon » Fri Apr 04, 2008 7:20 am

hi ikalogic
i doing a project of line following robot use pic 16f84a or pic . I find google but dont find .
It is good if u can send for me 1 complete project of a Line following robot

Tk u
phuanon
 
Posts: 6
Joined: Fri Apr 04, 2008 6:56 am

Re: Line tracking sensors and algorithms

Postby phuanon » Fri Apr 04, 2008 7:21 am

EMAIL of me : phu_anon@yahoo.com
phuanon
 
Posts: 6
Joined: Fri Apr 04, 2008 6:56 am

Re: Line tracking sensors and algorithms

Postby ikalogic » Fri Apr 04, 2008 9:26 am

dear phuanon

If i had a line follower project ready, it would have been online and there would be no need nor reason to send it to you by mail!!

Did you take a look at this project:http://www.ikalogic.com/proj_mini_line_folower.php

Please don't ask me to send stuff over mail, there nothing that justifies that, this forum is made for SHARING, and CONTRIBUTION, helping and getting helped! and this is for all members that send me mails every day too! please ask your questions on the forum, and wait for the answer on the forum!
User avatar
ikalogic
Site Admin
 
Posts: 2190
Joined: Wed Jan 02, 2008 2:00 pm
Location: Limoges, France

Line tracking sensors and algorithms

Postby phuanon » Sat Apr 05, 2008 3:04 am

Hi ikalogi i just design 1 circuit about line follower use AT89CC2051 I Try to run but it more error
i think to u can help me
this is code C use Keil and circuit (design by PROTEUS)
Code: Select all
#include<AT892051.h>
   sbit m1 = P1^0;/*m=motor , s= sensor*/
   sbit m2 = P1^1;
   sbit s1 = P3^0;
   sbit s2 = P3^1;
   sbit s3 = P3^2;
   sbit s4 = P3^3;


void main()
   {
     while(1)
     {
        if (( s2 ==1 )&& (s3 ==1))
          { straight();
          
         }
       if(s1==1)
       {    
          unsigned int x=1;
         while(x==1)
          {
            left();
         
             if((s2==1 )&&(s3==1));x=0;
         }
       }
      if (s4==1)
        {
         unsigned int y=1;
         while(y==1)
           {
             right();
            
              if ((s2==1)&&(s3==1));y=0;
          }
        }
      
      
      }
   }
   
straight()
     {
       m1=20;
      m2=20;   
      return;
      }
left()
     {
       m1=0;
      m2=10;
      return;
      }
right()
       {
        m1=10;
        m2=0;
        return;
      }



and circiut
http://rapidshare.de/files/39024752/my_robot.DSN.html


I wish u will help
phuanon
 
Posts: 6
Joined: Fri Apr 04, 2008 6:56 am

Re: Line tracking sensors and algorithms

Postby ikalogic » Sat Apr 05, 2008 8:16 am

phuanon wrote:Hi ikalogi i just design 1 circuit about line follower use AT89CC2051 I Try to run but it more error
i think to u can help me
this is code C use Keil and circuit (design by PROTEUS)

I wish u will help


Hello, I cannot open the proteus file, can't you post a screen shot of the schematic2663

Anyway the problem seem to be from the code, using nested IF blocks, one inside the other, is the best way to end doing anything but what you wanted in the beginning. If you don't want to use the method described in this tutorial, and want to use only simple if blocks, you can always use this method:

Code: Select all
if ((s1 = 0)&(s2 = 0)&(s3 = 0)&(s4 = 0)){
..put some code..
}else if ((s1 = 1)&(s2 = 0)&(s3 = 0)&(s4 = 0)){
..put some code..
}else if ((s1 = 0)&(s2 =1)&(s3 = 0)&(s4 = 0)){
..put some code..
}else if ((s1 = 1)&(s2 = 1)&(s3 = 0)&(s4 = 0)){
..put some code..
}else if ((s1 = 0)&(s2 = 0)&(s3 =1)&(s4 = 0)){
..put some code..
}else if((s1 = 0)&(s2 = 0)&(s3 = 0)&(s4 = 0)){
...
...
...
}


And continue this example code, tryying to cover all the possible readings of the line with that method. Sure, a reading like "((s1 = 1)&(s2 = 0)&(s3 = 0)&(s4 = 1))" is impossible, so you don't need to implement it.

and by the way, tell me what is the problem of the robot exactly2663 what is its behavior while following a line2663 if you give more information, i'll be able to help you more. :)
User avatar
ikalogic
Site Admin
 
Posts: 2190
Joined: Wed Jan 02, 2008 2:00 pm
Location: Limoges, France

Re: Line tracking sensors and algorithms

Postby phuanon » Sat Apr 05, 2008 12:37 pm

today I try to post circuit
I need complete my project in tomorow
U can see image here
i try post image but dont it becase it too wide to post
http://i211.photobucket.com/albums/bb31 ... tled-1.jpg
phuanon
 
Posts: 6
Joined: Fri Apr 04, 2008 6:56 am

Re: Line tracking sensors and algorithms

Postby ikalogic » Sat Apr 05, 2008 9:58 pm

phuanon wrote:today I try to post circuit
I need complete my project in tomorow
U can see image here
i try post image but dont it becase it too wide to post
http://i211.photobucket.com/albums/bb31 ... tled-1.jpg


you still didn't tell me, what is the problem of the robot exactly2663 what is its behavior while following a line2663 did you try to modify the code as i suggested2663

by the way, if there is any good results, post them here! and share your results and experience.. :)
User avatar
ikalogic
Site Admin
 
Posts: 2190
Joined: Wed Jan 02, 2008 2:00 pm
Location: Limoges, France

Line tracking sensors and algorithms

Postby viccram » Wed Apr 16, 2008 10:22 am

hie...
i used the proportional algorithm in linetracking

i used six lineracking sensors (phototransistors) and modified the algorithm as required.
the problem i faced was when the distance between the sensors and wheel was 30cm the algorithm works fine
but when i had to use the same algorithm in the robot that has 19cm distance between sensor and the wheels the algorithm is not effective the there is oscillation in the motion of the robot

could u possibly suggest how can i solve this problem2665
what is the minimum distance between the wheels and the sensors2665

and also...i have been doing linetracking using sensors in front of the wheel
but can linetracking be possible when the sensors are behind the wheels26652665


here is the lintracking subroutine of the code i used:
Code: Select all
//Some Variables Used
//as_per_point -> dutycycle required (required speed)
//el,lt,cl, extreme left, left,central left sensors
//and similar for er,rt,cr


void linetrack()
   {
            temp=output& 0x0F;
           if(temp==0x00)
          return;
          else if(temp==0x0F)
          return;
          else{
                if(!(el|lt|cl|cr|rt|er)){}       
                  else{
                  elx=el;ltx=lt;clx=cl;crx=cr;rtx=rt;erx=er;
                     }
         
          output=RIGHT_F_LEFT_F;       
          value=(10*elx+20*ltx+30*clx+40*crx+50*rtx+60*erx);
         
          deviation=(value/(elx+ltx+clx+crx+rtx+erx)-35)/5;
                   
          correction_l=as_per_point+deviation*as_per_point/5;   
               correction_r=as_per_point-deviation*as_per_point/5;
         
          if(correction_l>=255) lval=255;
          else if(correction_l<=0)lval=0;
          else lval=correction_l;
         
          if(correction_r>=255) rval=255;
          else if(correction_r<=0) rval=0;
          else rval=correction_r;
         
           }
            
   }
viccram
 
Posts: 12
Joined: Wed Apr 16, 2008 9:49 am

Re: Line tracking sensors and algorithms

Postby ikalogic » Wed Apr 16, 2008 12:32 pm

viccram wrote:hie...
i used the proportional algorithm in linetracking

i used six lineracking sensors (phototransistors) and modified the algorithm as required.
the problem i faced was when the distance between the sensors and wheel was 30cm the algorithm works fine
but when i had to use the same algorithm in the robot that has 19cm distance between sensor and the wheels the algorithm is not effective the there is oscillation in the motion of the robot

could u possibly suggest how can i solve this problem2665
what is the minimum distance between the wheels and the sensors2665

and also...i have been doing linetracking using sensors in front of the wheel
but can linetracking be possible when the sensors are behind the wheels26652665


here is the lintracking subroutine of the code i used:


As i explain in this tutorial: http://www.ikalogic.com/tut_line_sens_algo.php It is always better to put the sensor as far as possible from the wheels. This has the effect of amplifying the detected error.

I case you cannot put the sensor that far from the wheels, you should try to find some mean of reorganizing the cells so that the smallest deviation angle cause the extreme left or extreme right cells to detect the line. In other words you should minimize the distance between the cells, If that's not enough, you can try the following configuration (see attached file)

Good luck and keep us posted with the results!

EDIT:I forgot to answer your last question.. YES it is possible to put the line sensor at the back of the robot, but you would simple have to invert the line directions of the robot (but i guess that's obvious!) :)
You do not have the required permissions to view the files attached to this post.
User avatar
ikalogic
Site Admin
 
Posts: 2190
Joined: Wed Jan 02, 2008 2:00 pm
Location: Limoges, France

Re: Line tracking sensors and algorithms

Postby viccram » Wed Apr 16, 2008 3:34 pm

the third figure which is supposed to be the best one looks like has a little less range of sensors to detect the line... this may cause the robot to leave the track easily
is that the case or wat2665
and is it possible to use a PID control for linetracking using the only 6 tracking sensors...i hav port deficiency to add more linetracking sensors and also i am not clear at what angle should i align the sensors(as shown in fig. you suggested)

thanx for your reply!!!
viccram
 
Posts: 12
Joined: Wed Apr 16, 2008 9:49 am

Next

Return to Ikalogic content related

Who is online

Users browsing this forum: No registered users and 1 guest

cron