Electronics  Section

                                                                                                                           <Back to Topics

Detecting Obstacle with IR (Infrared) Sensor

The 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.


    Hope you enjoy making it!

    Best Viewed in Internet Explorer

    With other browsers you may experience improper view

    List of Topics --> Electronics

    Controlling  a Stepper Motor

    Drive a Stepper Motor (using IC STA401A)

    Detecting obstacle with IR (Infrared) Sensor

    Use Motor as Dynamo, Motor as a Brake, Dynamometer Test


    List of Topics --> Software

    Simple Program to Blink an LED (using embedded C language)

    Code to Control a Stepper Motor

    Code to Detect Obstacle using IR(Infrared) Sensor

    Articles on ‘C

    Data types (under construction)


    [Home] [Robotics] [Electronics] [Software] [Contact Me]