Line Following Robot With Color Detection€¦ · Line Following Robot With Color Detection Authors...

10
Line Following Robot With Color Detection Authors : Md. Risat Abedin, Faysal Alam, Ajwad Muhtasim Dip Department of Electrical & Electronic Engineering Ahsanullah University of Science & Technology Email: [email protected] Abstract: A line following robot is a robot that basically follows a specific line. This line following robot is sensor based. Sensor based approach uses various kinds of sensors such as IR sensors and ultrasonic sensors. IR sensors are generally used for measuring the difference in reflectivity of surfaces depending on the properties like color, roughness etc. Which is this line follower is based on. The path can be visible like a black line on a white surface (or vice-versa). Sensing a line and maneuvering the robot to stay on course, while constantly correcting wrong moves using feedback mechanism forms a simple yet effective closed loop system. This bot was developed based on a vision based system to navigate the robot through a black line marked in the white surface. It also extracted some features in the sensor to follow a line with automatic color detection and follow that color in white surface. This report is intended to describe the information regarding the project. It explains the requirements, the techniques and technologies used, design and implementation, details, problems faced, and future improvements of the project. Keywords : Line follower, Microcontroller , Color detector , IR sensor . Introduction Robotics has greatly advanced in the developed countries. High performance, high accuracy, lower labor cost and the ability to work in hazardous places have put robotics in an advantageous position over many other such technologies But as for developing countries like Bangladesh it is still quite out of reach. But it is one of the most fascinating and interesting aspects to the new generations and a lot of development in robotics has been done in last couple of years. On this note is this effort to make a relatively cheap line follower Equipment List Arduino Uno R3. Photoresistor. IR Transmitter. DC Gear Motor with Wheels. DC Power Adapter (9V,2A) Ball Castor 7805 IC L293D IC Breadboard & Jumper wires Project Development & Background We researched a little bit to select our hardware and preferable methods to accomplish this task. We selected our preferences based on availability and price range to build this robot. Microcontroller: Microcontrollers are the preferred method for endowing a robot with smarts. The reasons for this include their low costs, simple power requirements (usually 5 to 9 V), and ability of most, to be programmed using software and a simple hardware interface on the PC. Once programmed, the microcontroller is disconnected from the PC and operates on its own. These are programmed either in an assembly language or in a high level language such as C or C++.Here we use Arduino UNO R3. The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. The ATmega328 on the Arduino Uno comes preburned with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. Besides it is cheap and almost available in electronics hardware stores.

Transcript of Line Following Robot With Color Detection€¦ · Line Following Robot With Color Detection Authors...

  • Line Following Robot With Color Detection Authors : Md. Risat Abedin, Faysal Alam, Ajwad Muhtasim Dip

    Department of Electrical & Electronic Engineering Ahsanullah University of Science & Technology

    Email: [email protected] Abstract: A line following robot is a robot that basically follows a specific line. This line following robot is sensor based. Sensor based approach uses various kinds of sensors such as IR sensors and ultrasonic sensors. IR sensors are generally used for measuring the difference in reflectivity of surfaces depending on the properties like color, roughness etc. Which is this line follower is based on. The path can be visible like a black line on a white surface (or vice-versa). Sensing a line and maneuvering the robot to stay on course, while constantly correcting wrong moves using feedback mechanism forms a simple yet effective closed loop system. This bot was developed based on a vision based system to navigate the robot through a black line marked in the white surface. It also extracted some features in the sensor to follow a line with automatic color detection and follow that color in white surface. This report is intended to describe the information regarding the project. It explains the requirements, the techniques and technologies used, design and implementation, details, problems faced, and future improvements of the project. Keywords : Line follower, Microcontroller , Color detector , IR sensor . Introduction

    Robotics has greatly advanced in the developed countries. High performance, high accuracy, lower labor cost and the ability to work in hazardous places have put robotics in an advantageous position over many other such technologies But as for developing countries like Bangladesh it is still quite out of reach. But it is one of the most fascinating and interesting aspects to the new generations and a lot of development in robotics has been done in last couple of years. On this note is this effort to make a relatively cheap line follower Equipment List

    Arduino Uno R3. Photoresistor. IR Transmitter. DC Gear Motor with Wheels.

    DC Power Adapter (9V,2A) Ball Castor 7805 IC L293D IC Breadboard & Jumper wires

    Project Development & Background

    We researched a little bit to select our hardware and preferable methods to accomplish this task. We selected our preferences based on availability and price range to build this robot. Microcontroller:

    Microcontrollers are the preferred method for endowing a robot with smarts. The reasons for this include their low costs, simple power requirements (usually 5 to 9 V), and ability of most, to be programmed using software and a simple hardware interface on the PC. Once programmed, the microcontroller is disconnected from the PC and operates on its own. These are programmed either in an assembly language or in a high level language such as C or C++.Here we use Arduino UNO R3. The Arduino Uno is a microcontroller board based on the ATmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. The ATmega328 on the Arduino Uno comes preburned with a bootloader that allows you to upload new code to it without the use of an external hardware programmer. Besides it is cheap and almost available in electronics hardware stores.

  • Sensor Circuit:

    For Sensor Circuit we have used a pair of IR Sensors. One is IR LED i.e. transmitter another is an IR Sensor i.e. photoreciever. The basic principle of IR sensor is based on an IR emitter and an IR receiver. IR emitter will emit infrared continuously when power is supplied to it. On the other hand, the IR receiver will be connected and perform the task of a voltage divider. IR receiver can be imagined as a transistor with its base current determined by the intensity of IR light received. The lower the intensity of IR light cause higher resistance between collector-emitter terminals of transistor, and limiting current from collector to emiiter. This change of resistance will further change the voltage at the output of voltage divider. In others word, the greater the intensity of IR light hitting IR receiver, the lower the resistance of IR receiver and hence the output voltage of voltage divider will decreased. Usually the IR emitter and IR receiver will be mounted side by side. Since the output voltage from voltage divider varies with the intensity of IR light pointing to a reflective surface. The further distance away between emitter and receiver decrease the amount of infrared light hitting the receiver if the distance between the sensor and a reflective surface is fixed. Since the output voltage from voltage

    divider varies with the intensity of IR light we have used analog arduino input to measure the results to

    make the sensor take the readings.

    The values of the resistors are calibrated for better reading differences. These voltage differences readings are analog readings. Ardunio has built in ADC which it converts to Digital.

    When the IR emitter falls on a white surface it gets reflected and the IR receiver receives the full IR intensity thus lower resistance between emitter and collector terminal causing flowing of current and resulting a larger voltage. But when it falls on a black or similar surface IR is absorbed and the receiver receives a lot less IR resulting increase of resistance between the emitter and collector terminal causing limiting of current thus the output voltage. These voltage changes are ranged between (1-1024) as the analog outputs of arduino are 10 bit resolutions. We differentiated the analog values in order to get our required results

  • We have used 3 sensors in an array for the line detection. The middle sensor will always read black while the other two will read white surface. And it is programmed to move or rotate on basis of readings that it is getting from the readings from the sensor array.

    IC L293D :

    The most common method to drive DC motors in two directions under control of a computer is with an H-bridge motor driver. H-bridges can be built from scratch with bi-polar junction transistors (BJT) or with field effect transistors (FET), or can be purchased as an integrated unit in a single integrated circuit package such as the L293. The L293 is simplest and inexpensive for low current motors, For high current motors, it is less expensive to build your own H-bridge from scratch. Motor driver is basically a current amplifier which takes a low-current signal from the microcontroller and gives out a proportionally higher current signal which can control and drive a motor. In most cases, a transistor can act as a switch and perform this task which drives the motor in a single direction. Turning a motor ON and OFF requires only one switch to control a single motor in a single direction. But by reversing its polarity motor control in both direction is achievable. This can be achieved by using four switches that are arranged in an intelligent manner such that the circuit not only drives the motor, but also controls its direction. Out of many, one of the most common and clever design is a H-bridge circuit where transistors are arranged in a shape that resembles the English alphabet "H".

    The circuit has four switches A, B, C and D. Turning these switches ON and OFF can drive a motor in different ways.

    1. Turning on Switches A and D makes the

    motor rotate clockwise 2. Turning on Switches B and C makes the

    motor rotate anti-clockwise 3. Turning on Switches A and B will stop the

    motor (Brakes) 4. Turning off all the switches gives the motor

    a free wheel drive 5. Lastly turning on A & C at the same time

    or B & D at the same time shorts your entire circuit. So, do not attempt this.

    L293D IC generally comes as a standard 16-pin DIP (dual-in line package). This motor driver IC can simultaneously control two small motors in either direction; forward and reverse with just 4 microcontroller pins.

  • Connections:

    The circuit shown to the right is the most basic implementation of L293D IC. There are 16 pins sticking out of this IC and we have to understand the functionality of each pin before implementing this in a circuit.

    1. Pin1 and Pin9 are "Enable" pins. They should be connected to +5V for the drivers

    to function. If they pulled low (GND), then the outputs will be turned off regardless of the input states, stopping the motors. If you have two spare pins in your microcontroller, connect these pins to the microcontroller, or just connect them to regulated positive 5 Volts.

    2. Pin4, Pin5, Pin12 and Pin13 are ground pins which should ideally be connected to microcontroller's ground.

    3. Pin2, Pin7, Pin10 and Pin15 are logic input pins. These are control pins which should be connected to microcontroller pins. Pin2 and Pin7 control the first motor (left); Pin10 and Pin15 control the second motor(right).

    4. Pin3, Pin6, Pin11, and Pin14 are output pins. Tie Pin3 and Pin6 to the first motor, Pin11 and Pin14 to second motor

    5. Pin16 powers the IC and it should be connected to regulated +5Volts

    6. Pin8 powers the two motors and should be connected to positive lead of a secondary battery. As per the datasheet, supply voltage can be as high as 36 Volts.

    Truth Table :

    Pin 1 Pin 2 Pin 7 Function

    High High Low Turn Anti-clockwise (Reverse)

    High Low High Turn clockwise (Forward)

    High High High Stop

    High Low Low Stop

    Low X X Stop High ~+5V, Low ~0V, X=either high or low.

    DC Motor with Wheels & Ball Caster:

    Motor Specifications Operating voltage: 3V ~ 6V DC (recommended value 5V) Maximum torque: 800g.cm Speed without load: 90±10rpm Reduction ratio: 1:48

  • No Load current: 190mA (max.250mA) Stall Current: ~1A

    Working Procedure

    With the supply from an 9V DC power adapter the whole sensor and the motor driver IC and the motors and arduino are powered. Making the setup less prone to power failures. With the help of IC7805 a regulate 5V is supplied to the sensor circuits and same 5V is supplied to the enables of motor driver IC L293D. The outputs of the sensor circuits are connected as in the analog inputs of the arduino board. The motor driver IC inputs are taken from four arduino digital PWM pins and the outputs are connected to the motors. Taking analog based (1-1024) readings from the sensors the arduino is programmed to control the motor based on the readings.

    Line following Algorithm:

    If we give the analog readings of sensor into some digitalized values, then For White surface, Sensor reading =1 For Black surface, Sensor reading =0 Right Sensor

    Mid Sensor

    Left Sensor

    Motor Command

    1 0 1 Forward 1 0 0 Left 0 0 1 Right

    1 1 1 Stop

  • Color Detection:

    This line follower is programmed to follow any color line within a white surface, provided it not same as white color. Which means while it is following a black line and there is another colored line to follow. It will also follow that track differentiating white surface and that color surface. This was simply done by managing the range of analog readings under various colors.

    Applications

    This line following robotics has various types of applications in both home and industrial sectors.

    o Industrial Applications: These robots can be used as automated equipment carriers in industries replacing traditional conveyer belts.

    o Automobile applications: These robots can also be used as automatic cars running on roads with embedded magnets.

    o Domestic applications: These can also be used at homes for domestic purposes like floor cleaning etc.

    o Guidance applications: These can be used in public places like shopping malls, museums etc to provide path guidance.

    Besides there will be much more applications which we do not know now but can be done this type of robots.

    Troubleshooting

    The road towards making this robot was not a smooth one. We faced various problems each day and at each single aspects and had to troubleshoot it one by one.

    One problem we had was mismatch of two motor speeds with was controlled by PWM pulses to control the speed of two motors in same range. We had a problem in power distribution as typical 9V battery could not supply for our robot. We switched to a 9V,500mA DC power adapter which solved the problem but for a better performance and range we finally opted a 9V,2A adapter for this robot. Our sensor reading was not according to a standard where we could tell the robot to detect color. So we had to acquire a better lead coated IR sensor pairs for large regions of data. Our Ball caster was kind of stiff so we had to make sure it does not hamper the smooth movement of the robot. Lastly we had to reduce the weight of the chassis so that it can move faster.

    Possible Improvements:

    -Use of differential steering with gradual change in wheel speeds.

    -Use of Hysteresis in sensor circuit using LM339

    -Use of PD Controlled codes to the movement of the robot.

    -Use of Four wheels drive to reduce traction of ball caster and for better turning.

    -General improvements like using a low dropout voltage regulator, lighter chassis etc.

  • -Using stepper motors instead of the DC motors would have improved control.

    Conclusion

    The line following robot project challenged the group to cooperate, communicate, and expand understanding of electronics, mechanical systems, and their integration with programming. This project would not have been successful without every member of the group contributing and communicating during the problem-solving process, and without the knowledge and advice of Mr. HAMID. Overall, the line following robot was an incredible learning opportunity for everyone involved.

    Block Diagram of the Project

    Final Design:

    Circuit Diagram: (Final)

  • Sensor Circuit:

    Motor Diver IC L293D:

    Line Following Code:

    int rightsen = A0; int midsen = A1; int leftsen = A2; int lmf = 10; int lmr = 9; int rmf = 11; int rmr = 6; int ledpin = 5; void setup() { Serial.begin(9600); pinMode(lmf, OUTPUT); pinMode(lmr, OUTPUT); pinMode(rmf, OUTPUT); pinMode(rmr, OUTPUT); } void loop() { analogWrite(ledpin, 255); int rightread = analogRead(rightsen); int midread = analogRead(midsen); int leftread = analogRead(leftsen); Serial.print("Right Sensor :"); Serial.println(rightread); Serial.print("Mid Sensor :"); Serial.println(midread); Serial.print("Left Sensor :"); Serial.println(leftread); if ((rightread>400)&&(midread400)) forward(); else if ((rightread400)&&(midread

  • analogWrite(rmf, 0); } void halt() { analogWrite(lmf, 0); analogWrite(rmf, 0); } void reverse() { analogWrite(lmr, 150); analogWrite(rmr, 200); } Refernce [1] http://robotsreloaded.blogspot.com/p/line-following-robot-without.html

    [2] http://www.roboticsbible.com/simple-line-following-robot.html

    [3] http://abhitechstrong.blogspot.com/2013/01/robotics-project-1-making-line-follower.html

    [4 ]http://legendtronics.blogspot.com/2013/10/line-follower-robot-with-and-without.html

    [5] http://www.elprocus.com/line-follower-robot-basics-controlling/

    [6] http://embedded-electronics.blogspot.com/2013/06/line-follower-robot-without.html

    [7] http://circuit-diagram.hqew.net/Analog-Line-Follower-Robot_11907.html

    [8] http://letslearnelectronics.blogspot.com/2012/08/make-line-follower-robot-from-basics.html

    [9] http://letslearnelectronics.blogspot.in/2012/06/playing-with-sensors-making-decision.html

    [10] http://www.techshopbd.com/tutorial-categories/robotics/line-following-robot

    [11] http://www.patrickmccabemakes.com/PatrickMccabeMakes/Mazev3.html

    [12] http://www.richardvannoy.info/line-maze-part-05.php#5-4

    [13] http://www.electronicsforu.com/electronicsforu/circuitarchives/view_article.asp?sno=491&title%20=%20Automated+Line+Following+Robot&id=4679&article_type=2&b_type=new&ss=%20398812

    [14] http://linefollower-robot.blogspot.com/

    [15] http://www.instructables.com/id/Arduino-and-L293D-Robot-Part-1-/?ALLSTEPS

    [16] http://www.richardvannoy.info/my-line-follower.php

    [17] http://embedjournal.com/2013/06/line-follower-robot/

    [18] http://www.tinkerhobby.com/motion-and-light-sensors-with-arduino-and-without/

    [19 http://extremeelectronics.co.in/robotics/making-a-line-sensor-using-ir-receiver/

    [20] http://www.buildcircuit.com/test-your-sensors-for-line-following-robots/

    [21] http://tetalab.org/blog/23

    [22] https://www.inkling.com/read/arduino-cookbook-michael-margolis-2nd/chapter-8/recipe-8-11

    [23] http://garagelab.com/profiles/blogs/tutorial-l293d-h-bridge-dc-motor-controller-with-arduino

    [24 ]http://www.robotplatform.com/howto/L293/motor_driver_1.html

    [25 ]http://42bots.com/competitions/arduino-line-following-code-video/

    [26] http://www.societyofrobots.com/schematics_infraredemitdet.shtml

  • [27] https://gist.github.com/whyisjake/2354277