Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

JAN

14
Obstacle Avoider using Atmega 8,IR sensor ,Embedded c
programming on AVR tutorial

This demo cum tutorial is basically to show and explain the functioning of one of the most basic
robotic projects that is the Obstacle avoider robot.

We've basically used an Atmega 8 microcontoller and programmed it in Embedded c


as you can see the developing board has the Atmega IC on it we see some motors below the car
chasis and the motor driver ics are in built on the developing board and
infrared sensors infront , the code that we've written basically gets the input from the IR sensors and
makes the output pins go high or low
accordingly and those pins are connected to the L239 driver ic which has its own battery which
drives the motors .

How IR sensors work?

Now coming back to the IR sensors these sensors as you can see there are two led like structures
in the front, one of them is basically an IR led which transmits infra-red radiation and
the other is the receiver or more commonly known as photo diode ,the photo diode is basically diode
or a PN junction which when receives any type of radiation not necessarily be infra-red forms
electron-hole pairs in the depletion region thereby allowing more current to pass so whenever there
is an obstacle in front the receiver gets the reflected radiation of the transmitter
from IR led and it starts allowing more current to pass and if we were to connect a resistor in series
with it the voltage across the resistor would rise as more and more current is passed
as a result of increasing IR radiation which is a result of decreasing distance between the bot and
the obstacle now if we put the increasing voltage across the resistor into a voltage
comparator built with an OP Amp where we compare the resistor voltage with a pre-adjusted voltage
it gives us a high output on the op amp whenever the obstacle comes too close to the bot.
and that my dear is supplied to the input pins of the micro-controller which are programmed to
respond accordingly.
The grounds are all connected the left one is the IR led the right one is the Photo diode op amp acts
as comparator comparing with the output of a voltage divider.

Now when the microcontroller gets these inputs lets say it gets a high from the the right sensor and a
low from the left sensor so that means there is an obstacle on the right so
the bot moves back nd then rotates towards
left and again moves forward and vice versa now whenever there is an obstacle directly in front the
bot moves back some paces and and the rotates at random left or right then the
whole process is repeated so there you have it an obstacle avoider.
he basic concept of IR(infrared) obstacle detection is to transmit the IR
signal(radiation) in a direction and a signal is received at the IR receiver when the IR
radiation bounces back from a surface of the object.

Here in the figure the object can be any thing which


has certain shape and size, the IR LED transmits the
IR signal on to the object and the signal is reflected
back from the surface of the object. The reflected
signals is received by an IR receiver. The IR receiver
can be a photodiode / phototransistor or a ready
made module which decodes the signal.

In order to implement the IR obstacle detection, we


need to understand the following

 We need to understand how to transmit IR signal using commercially available electronic


components.
 same way we also need to understand the IR receiver.

My main focus in this document is to explain the implementation of IR based obstacle


detection in detail.

IR Transmitter

In general, the basic building block of any IR transmitter is modulation of the


information signal with carrier signal, because the receiver modules which are
available off-the-shelf are made for a particular carrier frequency. So it is clear that
when you chose a particular IR receiver module, you also need to transmit the the
modulated wave with the same carrier frequency of that of a IR receiver module.

Modulating a 38 Khz carrier signal

ON state = 10ms

OFF state = 90ms


The figure above explains the modulation process, this is similar to OOK(ON-OFF
Keying) modulation, where the carrier signal is ON for certain period of time. When
transmitting a signal for obstacle detection, it is necessary that the carrier signal is
transmitted for a short while and remains OFF for longer period of time.

If the transmission of the carrier signal is prolonged, in other words, instead of having
a short transmission period(10 milliseconds in our case, as explained in the figure) of
carrier signal, if we have it for a long period of time then the receiver module will
treat it as a noise and ignores receiving the transmitted signal.

The implementation of IR transmitter can be done in various way, in this document


we will discuss two ways

 Using 7555(compatible with 555) timer IC to generate a 38 kHz carrier signal


 Using Micro controller(Atmel atmega8535) inbuilt wave generation module

Now let us have a look at the IR transmitter using 7555 timer IC

Here in the figure 5k ohms pot is used instead of 1200 ohms resister, so that it can be
adjusted for 38 kHz frequency. This adjustment is required because of the tolerance
value of the components used in the circuit. The best way to over come this is to
connect the circuit to the oscilloscope and trim the pot to get 38 kHz. In case you done
have access to oscilloscope, still you can check it with IR receiver circuit. Secondly
you can trim the 500 ohms pot depending on the distance you intend to operate the
sensor. Its observed that, by adjusting the 500 ohms pot to 200 ohms, it is possible to
detect obstacles with in 50 cms of range from the sensor.

Circuit using Micro controller(Atmel atmega8535) inbuilt wave generation module

This approach needs additional software and this software is referred as firmware /
embedded software because this software will be flashed / downloaded in to the
microcontroller.

The source code is provided in the “Software Section” of this web site. The steps
required to use the firmware are provided along with the source code.

IR Receiver

It is quite simple to construct a IR receiver with readily available off-the-shelf


modules. These modules are nothing but the IC packages, referred as TSOP(Thin
small-outline package). In this document, the receiver is designed for 38 kHz carrier
signal, hence the IC selected should work for the same frequency. The IC TSOP4838
will serve as a receiver module, which is compatible with both TTL and CMOS logic.
This means that we can directly get digital signal from the receiver module and then
connect it to the microcontroller.

The Implementation of IR receiver is explained using an LED as an indicator.


Here in the circuit the LED blinks when ever the TSOP4838 module receives a signal
from the transmitter. The same circuit can be altered to work with microcontroller, the
circuit below has both IR transmitter and IR receiver modules integrated with the
microcontroller.

Circuit for IR based obstacle detection using atmega8535 microcontroller &


TSOP4838

Code for IR based obstacle detection is provided in the software section, please go
through the link --> Code to detect obstacle using IR(Infrared) sensor
Once the transmitter and receiver is complete, both should be placed at a certain
angle, so that the obstacle detection happens in a proper way. This angle is nothing
but the directivity of the sensor, which is generally +/- 45 degrees.

Also remember, that a thick enclosure is necessary for both IR transmitter and IR
receiver, because the IR radiation may bounce back from the surrounding objects
which may not help when you want to detect obstacle in one direction. Some times, if
you don’t have a thick enclosure then the signal may directly reach the receiver even
without having an obstacle. The enclosure can be made out of plastic or even metal
materiel which is painted black in color.

You might also like