Line follower on changing contrast

I am making a line follower using an ATmega8

Now the problem is the testing of line follower, there is a black line over a white surface and then after a while, there is a white line over a black surface....

The robot will make a start on any of the corners...so it is impossible to tell whether it is a white line or black line...and also in middle, the contrast will change...

I have to make the program in such a way that it will detect the change in contrast and continue its work

I thot this can be done in programming part..so posted here...

hoping for help soon

Perhaps you could have 3
Perhaps you could have 3 sensors. 1 in the center, and 2 on either side about 3/4 away from center as the width of the line is wide. As long as the 2 outside ones are the same and the middle is different it should stay on track. You can tell if the line is left or right of the bot by comparing the left and center data against the right, and then the right and center against the left.

Although ezekiel’s
Although ezekiel’s suggestion is in my opinion the best balance of hardware/software complexity, you could potentially complete this project with as little as one optical sensor.
Do you have flexibility in terms of hardware? Some sort of budget limit? Robot size and weight? Battery capacity? Competition/project restrictions?
The more info you can give us the better our advice will be =D

i have got time till 10th

i have got time till 10th september…I ofcourse will be using three sensors for line following

what i cant do is that when the contrast changes, the robot will go haywire…i want something to do with this problem

layout_of_track.jpg

This a rough idea of how the track will be… if you observe, after half the length, the contrast of the line and background changes…i want some way so that the robot will detect this change and continue its operation in opposite way.

Oh dear

Line trackers tend to track the EDGE of a line. So, in their simplest form, they’ll track teh black/white interface. The only reason YOU (as a human) can perceive that the image above is a “track” is because you can see the whole thing, and choose to interpret it that way.

I think the only way to do what you propose is with multiple light sensors spaced at least as far apart as the line is wide. In fact, ezekiel181 proposes this. However, you have to program an “awareness” of the possibility of a contrast inversion. Sometimes the line with be the light bit between two dark bits and sometimes it’ll be the dark bit between two light bits.

 

 

The only serious problem I

The only serious problem I forsee is that the robot probably won’t hit the sharp white/black switching point at a flat angle, so there will be a range of unusual sensor readings that the bot has to account for, ie:
• [WHITE - BLACK - WHITE] Bot is on white surface, middle sensor over block line. If your bot is off course it could also mean that the left sensor is on a white surface, the middle sensor is on the other side on the black surface, and the right sensor is on the white line on the black surface…
Fortunately that’s going to be a rare problem assuming the bot will start well inside one ‘zone’ or the other, and has time to lock onto the line before hitting the switching point.

Maybe you could code the controller such that if the bot has been correctly following the line for a little while, but suddenly the left and right sensors are disagreeing, the bot should just go straight ahead until the left and right sensors match up again after which the line following routine is started again.

okay i get what u mean…so

okay i get what u mean…so the algo should be something like this

 

//this will work for both contrasts…

if(left_sensor=right_sensor)

move forward

 

//while on white line

if(middle_sensor=white&(left_sensor is more white than right_sensor))

turn left

if(middle_sensor=white&(right_sensor is more white than left_sensor))

turn right

 

//while on black line

if(middle_sensor=black&(left_sensor is more white than right_sensor))

turn right

if(middle_sensor=black&(right_sensor is more white than left_sensor))

turn left

 

Please comment on whether this algo is right or not…and will this work on the edges(where the line turns but doesnt change colour).

 

Edit: And to add to this, icould mount a fourth sensor on top of the middle sensor so that both are in straight line…if bothof this sensors show whitereading, the robot is surely on a whiteline and vice versa

Idea
I have sort of a weird idea, but it might work. How about two big pieces of plastic on the sides of the bot. Sort of like wings on an airplane. On each “wing” a photo resistor pointing downward. These “wings” would stretch far away enough that they wouldn’t come near the line. They would be used only for seeing if the surrounding area was dark or light. E.G. if you are starting out with a dark line on a white surface set the photoresistors on the wings so if they detect dark, change the robots line following mode to follow white lines instead. If the way I described this doesn’t make any sense, let me know. I will draw a picture or something. P.S. I have never tried this so I don’t know if it works or not, it is just an idea.

Novelty

Actually, I can’t find an example of THIS having done before, so I’m declaring it novel.

We typically imagine that the light detectors have to be in a line at the fron to f the bot. Why not arrange three in a triangle? Two at the front and one at the back.
Even better, FOUR sensors (two at the back).

That wa you know what shade you’re headin into by comparison to the shade you;re heading out of.

 

Hmmm, how about this as an

Hmmm, how about this as an extension of that idea?

If there were 4 sensors total, one of the 2 middle sensors could be placed exactly along the vertical axis of rotation during sharp left/right turns. Then if that sensor was over the line, the bot could turn left or right until the other middle sensor was also lined up, which would put the bot directly on course.
If neither of the middle 2 sensors was mounted along the axis of rotation then when you turned it’d eventually fall off the line again and you’d have to shuffle back and forth to get both middle sensors on the line.

here is an idea
3 sensors if the middle one is the same as the one outside one it turns in that direction opposite from that sensor

Possible to have 2 sensors

Possible to have 2 sensors near the line, with the third placed linearly a bit to one side. The third changes the "polarity of the detection scheme. The program would have the 2 close line sensors following their respective colors, and generate slowing commands for each wheel to turn the robot to where the line is estimated to be. Could be :

  • if right = white and left = black then forward ’ black line on white back inside follower
  • if right = black and left = white then right ’ sharp turn
  • if right = black and left = black then slow_right ’ easy turn
  • if right = white and left = white then left ’ sharp turn

then have before this group a line that tests the far sensor for white or black, that inverts the above tests. might place this sensor on the far outside to prevent false early triggering.

I was almost thinking a single sensor could be used, that would use the same logic to follow the inside border between white and black in the top black line area, then could follow the outside edge of then white line on black area. Would be a glitchy bit with just one, but the other 2 could be added to change the polarity of detection too.