Line Maze Solving Robot with Color Detection

7
Line Maze Solving Robot with Color Detection Author: Ishrak Ahmed, Noman Siddique, Sanjan Rahman, Xabir Hossain Department of EEE, Ahsanullah University of Science and Technology, Dhaka, Bangladesh. E-mail of corresponding author: [email protected] Working Principle: The working principle of this robot is to perform a line follow in white surface with maze solving and also detect color (black, red, yellow). 1. Equipment -An Arduino R3 with ATmega328p surface mounted micro controller. - IR LEDs - IR Receiver (Photodiodes) - Resistors - DC Gear Motors + Wheels - Batteries (3V) -DC power supply (9V) -BD135 BJT for switching Basic function in block diagram: 2. Connection Diagram

Transcript of Line Maze Solving Robot with Color Detection

Line Maze Solving Robot with Color Detection Author: Ishrak Ahmed, Noman Siddique, Sanjan Rahman, Xabir Hossain

Department of EEE, Ahsanullah University of Science and Technology, Dhaka, Bangladesh.

E-mail of corresponding author: [email protected]

Working Principle: The working principle of this robot is

to perform a line follow in white surface with maze solving

and also detect color (black, red, yellow).

1. Equipment

-An Arduino R3 with ATmega328p surface mounted

micro controller.

- IR LEDs

- IR Receiver (Photodiodes)

- Resistors

- DC Gear Motors + Wheels

- Batteries (3V)

-DC power supply (9V)

-BD135 BJT for switching

Basic function in block diagram:

2. Connection Diagram

3. Circuit Diagram

4. Application

Sensor:

The sensors consist of infrared LEDS and IR photodiodes

or known as IR receiver. IR Sensors work by using a

specific light sensor to detect a select light wavelength in

the Infra-Red (IR) spectrum. By using an LED which

produces light at the same wavelength as what the sensor

is looking for, you can look at the intensity of the

received light. Since the sensor works by looking for

reflected light, it is possible to have a sensor that can

return the value of the reflected light. This type of sensor

can then be used to measure how "bright" the object is.

In addition the IR sensor has a higher sensitivity that

gives a quicker response. In IR sensor if the photodiode is

on a white surface all the IR rays get reflected from the

surface back to the photodiode, making its resistance very

low, hence making the photodiode behave like a short

circuit and giving the output low. And when on a black

surface the IR rays does not reflect back, making the

photodiode‘s resistance very high, hence making it

behave like an open circuit and giving the output high.

Micro-controller:

Arduino is a single board controller. intended to make

the application of interactive objects or environments

more accessible. The hardware consists of an open-source

hardware board designed around an 8-bit Atmel

AVR microcontroller, or a 32-bit Atmel ARM. Pre-

programmed into the on-board Micro-controller chip is

a boot-loader that allows uploading programs into the

microcontroller memory without needing a chip (device)

programmer. An important aspect of the Arduino is the

standard way that connectors are exposed, allowing the

CPU board to be connected to a variety of

interchangeable add-on modules known as shields.

Application of the project along with the future work:

Line following robot based health care management

system can play a vital role in the field of hospitality.

Robotics is a grooming technology. By using robot in the

government and private hospitals the cost for the cure can

be reduced. It can be very beneficially for the patients. In

Bangladesh many people hesitate to admit in the hospital

because of costly medical practitioner. Monitoring of

every patient is very difficult for the nurses in the

hospital. So a camera can be placed in the line following

robot, from which the status for every patients can be

handle from a single room. In the bed of the patient an

accelerometer can be placed from which if a patient have

a heart attack then that device can operate an alarm

circuit. Line following robot's application over electronics

engineering can't be underestimated. This line following

robot can be used as carrying the load and many more

applications.

BJT switching:

Most of microcontrollers work within 5 volt environment

and the I/O port can only handle current up to 20mA;

therefore if we want to attach the microcontroller‘s I/O

port to different voltage level circuit or to drive devices

with more than 20mA; we need to use the

interface circuit. One of the popular method is to use the

Bipolar Junction transistor (BJT) or we just called it

transistor in this tutorial. I have to make clear on this BJT

type to differentiate among the other types of

transistors family such as FET (Field effect Transistors),

MOSFET (Metal Oxide Semiconductor FET), VMOS

(Vertical MOSFET) and UJT (Uni-Junction Transistor).

A. The Switch

The transistor actually works as a current gainer; any

current applied to the base terminal will be multiplied by

the current gain factor of the transistor which known

as hFE. Therefore transistor can be used as amplifier; any

small signal (very small current) applied to the base

terminal will be amplified by the factor of hFE and

reflected as a collector current on the collector terminal

side.

All the transistors have three state of operation:

1. Off state: in this state there is no base current

applied or IB = 0.

2. On active state: in this state any changes in

IB will cause changes in IC as well or IC = IB x

hFE. This type of state is suitable when we use

transistor as a serial amplifier because transistor

is said is in the linear state. For example if we

have a transistor with gain of 100 and we

increase the IB from 10uA to 100uA; this will

cause the IC to swing from 1000uA to 10000uA

(1 mA to 10 mA).

3. On saturate state: in this state any changes in

IB will not cause changes in IC anymore (not

linear) or we could say IC is nearly constant. We

never use this state to run the transistor as a

signal amplifier (class A amplifier) because the

output signal will be clamped when the transistor

is saturate. This is the type of state that we are

looking for on this tutorial.

From the picture above we could see the voltage and

current condition of transistor on each state; if you notice

when transistor is in off state the voltage across collector

and emitter terminal is equal to the supplied voltage, this

is equivalent to the open circuit and when transistor is in

saturate state the collector to emitter voltage is equal or

less than 0.2 Volt which is equivalent to the close circuit.

Therefore to use transistor as a switch we have to make

transistor OFF which equivalent to the logical ―0‖

and SATURATE which is equivalent to the logical ―1―.

One of the famous diagrams that show the transistor

operating state is called the transistor static characteristic

curve as shown on this following picture:

When we operate transistor as the class A common

emitter amplifier usually we choose to bias the transistor

(apply voltage on VBE and VCE) in such a way (Q-Point)

that IC and VCE (output) will swing to its maximum or

minimum value without any distortion (swing into the

saturation or cut-off region) when the IB (input) swing to

its maximum or minimum value; but when we operate the

transistor as switch we intentionally push the transistor

into its saturation region to get the lowest possible

VCE (i.e. near 0.2 volt) when we need to make the

transistor ON (switch ON) and into its cut-off region

when we need to make the transistor OFF (switch OFF).

The above diagram show a typical microcontroller

interface circuit using NPN transistor; the RB resistor is

used to control the current on base terminal that make

transistor OFF and ON (saturate); while the Resistor is

the current limiter for the load. if the load operate with the

same voltage as the supplied power (Vcc) you can bypass

the RC (not use).

Motors & Battery:

DC Gear motor Inner RPM 300, Outer RPM 500

operating at 12V. Excellent condition just like new. These

motors can carry heavy weight. Cost: 3500Rs.

Two 12 Volt Batteries and One 6volt Battery. we have

used these batteries for not more than 4 hours. Cost

1500Rs.

Battery: This robot is powered by a battery.

One 9V battery is enough to perform this

process. For more usages, four 9V batteries may

be required.

12V DC motor: If a DC power is passed on

a DC motor, it will produce torque. The torque

created will lead to the rotation of the wheels. It

will only operate on the direct current. Here, two

12V DC motors are used.

Two plastic wheels: The plastic wheels will

be connected to the DC motors. As soon as

they create the torque, these wheels will

help the robot to move.

Castor wheel: The castor wheel is used to

make the movements easy and quick even it

has large components on its top. In this

process, a small stainless steel castor could

be the best one to use.

Color Detection:

Color Detection Sometimes it is handy to be able to detect

various colors, and have your robot make decisions

based on the color seen. Imagine you had a line

following course where there is a three way

intersection, then imagine that each ‗leg‘ of this

intersection had a different color box next to it as

shown in the following picture. Your robot when

reaching this switch could now determine which is the

preferred way by for example detecting ‗red‘ and

‗green‘ using a color sensor and then decide that only

the ‗green‘ identified leg of the road is the appropriate

path to follow. More complex examples could be a

color sorter, where a robot detects 4 or 5 different colors

and takes actions based on the color detected. In order

for your robot program to make these decisions, based

on a particular color detected, you can use a switch

statement, in a somewhat more advanced configuration

then you may be used to. You may know that the switch

statement besides using a ‗true‘ / ‗false‘ logic switch

mode — the default method when using one of the

sensors directly to switch – can use number or text

input on one the data wire connector to switch. When

changing the ‗control‘ from ―sensor‘ to ‗Value‘ you are

then also able to select one of three modes which drive

the switch: Logic (Boolean), Number or Text. When

selecting either Number or Text you can build a list in

the conditions box based on the expected input on the

data wire. So let‘s look at the how we would switch

based on the color sensor data. In this case rather then

setting the switch to control = ‗Sensor‘ we will set it to

Control = ‗Number‘ (Or in our below example ‗text‘ so

that we can also display the value from the sensor on

the NXT LCD display). Then we can build in the

Conditions box a switch list. WE know the following

about the color sensor, when using the ‗Detected Color‘

data port as shown below: The following Color Values

will be transmitted on the Detected Color data port: 1 –

Black 2 – Blue 3 – Green 4 – Yellow 5 – Red 6 – White

These Numeric values can then be used to create switch

conditions of our switch and allow us to execute

different code based on which color we have detected.

So one could imagine that when we saw the red box

next to the line, we would turn in the opposite direction,

until we detected green. Or if we detected green next to

the line, we know that we are turning the right way.

Other examples where we may be able to sue this

detection method is in playing RoboCup Soccer –

where if we are on the green field we are o.k, and if we

detect the red ‗box‘ we are in our opponents scoring

area, while if we detect ‗yellow‘ we are in our own

scoring area. Likewise if we detect white, we have left

our field altogether! Other examples are detecting

various types of victims, where say a red color

identifies an adult, and a yellow color a baby, while a

green color may be a pet. In each case we can make

decisions based on the detected color. Here is an

example of how we can use a combination of a Color

Sensor and the Switch statement to execute conditional

code based on which color we may have detected. In

this example, we use Control = ‗Text‘ in that we take

the numeric Detected Color Value from the color

sensor, convert it into a Text value so that we can

display it on the NXT led panel, and then use the text

value to create switching conditions. You can imagine

the different ways you can use this example and how

you can further evolve it to create color based logic

path in your robot code.

5. Project Images

6. Working procedure

First we used two sensors the IR transmitter is in series

with 220 ohms and the receiver is in series with 10K.

Both of the sensors are completely identical and the IR

transmitter and the IR receiver are shorted. 5V is given

to the sensors from Arduino power portion and input is

given to the sensors through the microcontroller. Now

the outputs from the sensors are taken from the end

wire of the receivers since the receiver will work

mainly. The inputs are given in the 11 and 12 number

pin from digital portion and the output is then taken

from number 7 and 2 pins from the digital portion to a

1K resistance in series with a RED LED so here what is

done is when the sensor are getting a HIGH reflection

which is the white surface it lights up and when the

sensors are turned off the LEDs are turned off as well

so we can easily understand how the sensors are

working under. Now a 1k resistance is connected with

base of the BJT and the emitter is grounded and the

negative parts of the motors are connected with

collector and the external 3V is connected with the

motor. So when the sensor is receiving the LED are

lightened and the BJT is getting its turn on voltage and

the motors are moving when the receivers are not

receiving the LED are turned off so we know there is

not voltage so BJT is off so are the motors this is how

the circuit is performing its task perfectly.

7. Troubleshooting

First we faced some problem with motor power as we

powered it directly from Arduino but that wasn‘t right

so the voltage was not perfect then we added a external

source with the DC motors it got some speed. The

circuit is designed in such a way that the motor will

stop turning if the IR receiver stops working but when

the receiver stops receiving the circuit slows down but

doesn‘t shut down completely, Because the output was

working fine since we added a external source across

the motors it continuously give a fixed voltage which

keeps the motor running. So to get rid of this problem

we used two BD 135 model transistors as switch. Here

the setup is in such a way that the external voltage is

connected with common positive and negative of the

breadboard. The negative wire of the motors is

connected with the collector and the positive with

source positive. Here the working steps are like when

the sensor is sensing the white surface it is sending data

through the receiver and from the output the BJT gets

the turn on voltage and the motor is moving and with

the help of external power they are moving in

approximately 4.97V but unlike before when the

receiver stops there is no more output so the BJT stops

receiving any voltage so it switches off so does the

motor.