Go Down

Topic: LINE FOLLOWER (Read 949 times) previous topic - next topic

maharshigogu

I WANT TO KNOW HOW TO USE AN ARDUINO UNO AND L293D MOTOR DRIVER IC CHIP AND LINE SENSORS LM358 . COULD ANYONE TELL ME THE CONNECTIONS AND PROGRAM CODE. IT SHOULD WORK PERFRCTLY

Charkoteow


AWOL

Quote
IT SHOULD WORK PERFRCTLY
Oh, the irony.

jscottb

I WANT TO KNOW HOW TO USE AN ARDUINO UNO AND L293D MOTOR DRIVER IC CHIP AND LINE SENSORS LM358 . COULD ANYONE TELL ME THE CONNECTIONS AND PROGRAM CODE. IT SHOULD WORK PERFRCTLY

GOOGLE.

MarkT

And please dont SHOUT
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

MRMAINT62

I do not have your particular motor controller or line following module. Line following is typically a reflective light sensor connected to an analog input. It will produce some range of values between 0 and 1023. When seeing a black line, you might get a reading below 20 and when seeing white the reading might be as high as 1000. When doing line following, you will want your sensor to follow the edge of the line. If you are following the right edge of the line, then you will go forward and turn slightly right to try to keep the sensor on the edge of the line, when seeing the black line. When the eye sees white (value that is large) you will stop going forward and turn left until the eye sees black again. These two actions just repeat over and over.

If you wish to follow with more accuracy and less side to side motion, then divide your sensing of the line edge into more ranges. When right on the edge of the line the reading should be at 50% (approx 511) and the robot should go straight ahead. If the value is above 520 and below 580 the robot is slightly away from the line and should turn slightly left (while following the right side of the line). If the value is between 440 and 500 then it is more on the black than the white and should make a slightly right hand turn while going forward. For values above 580, the robot will make a sharper turn to the left, And for numbers under 440 the robot will make a sharper turn to the right.

This is easily accomplished by "Binning' your values then branching to the respective control routines. Binning is a term that means converting a wide range of values into a certain number of sequencial numerical groups. For example, if your sensor values are between 20 and 1020 and you want 5 Bins, you can take the largest value minus the smallest value to get the range. by dividing it by the number of bin divisions (5) then you get the constant that you will use to make your sensor readings fit nicely into one of your bins((1020-20)/5=200). So you read your sensor and divide that value by the 200 and you will get a result from 0 to 5. 0= sharp right, 1= slight right and forward, 2=straight, 3=slight left and forward, and 4= sharp left turn.

Your motor controller should have a method of controlling speed and direction of the motors. Speed is usually a set of numbers, one for the left motor and another for the right motor. These values are often between 0 and 100.

Direction is usually represented by a four bit binary variable. The 2 most significant bits are for the left motor and the two least significant bits are for the right motor. 0000 is stop, 1111 is brake, 0101 is both motors go forward, 1010 is both motors go in reverse. 0110 is left motor fwd. right motor rev.(right turn), and 1001 is left motor reverse and right motor forward(left turn). I'll let you determine the last four possibilities of one motor or the other stopped and the opposite motor either going forward or reverse.

example sudo code:

read sensor value.
divide sensor value into 5 bins by dividing by 200.
branch to each of the 5 values:
  0 . set direction and power for right turn dir=0110 power(40,40), break
  1 . set direction and power for slight right turn and forward. dir=0101 power(40,20), break
  2 . set direction and power for straight forward. dir=0101 power(40,40), break
  3 . set direction and power for slight left turn and forward. dir=0101 power(20,40), break
  4 . set direction and power for left turn dir=1001 power(40,40), break
return to beginning and do it all again! If your robot is only supposed to stop after so many wheel rotations, then this is where that decision would be made.

If you want your robot to follow the line with ultimate smoothness, then implement a PID controller to infinitely regulate the amount of turning to keep the sensor right over the edge of the line.

Life is short, Eat dessert First!
Build Robots at all other times.
Boards: UNOv3, Mega 2560, Mega ADK, Bugduino, Pro Mini 328 5v, LinkIt ONE, MKR1000, NXT, Printrbot Simple, MakeBlock laser engraver, Silhouette, Cricket Expression, Mill, Metal Lathe.

Go Up