In my opinion, these little modules are terrific!  With some modification, I use them in all of my robot projects.  They are widely available from several manufacturers for between $3 and $5US.  That said, this page is not affiliated with any particular manufacturer, does not endorse or guarantee the suitability of any product for any purpose and does not offer any product for sale.  All comments, corrections and complaints should be directed to bud@budryerson.com.

29 December, 2016

IR Sensor for Obstacle Avoidance KY-032 (AD-032)

This sensor is known variously as the Keyes, KeyesIR or Keyestudio KY-032.  It is the the functional equivalent of the IrBeady IR-08H, also known as the AD-032.  The sensor uses a four pin connector, The pins are labeled: EN (Enable), out (Output), + (Power) and GND (Ground).  There are also two potentiometers on the board and one jumper (see picture).

Manufacturer's Specifications:

anotated

At the heart of the sensor is an NE555 chip configured to generate a 38kHz square wave. (The IR-08H uses an SN74LS00.)  The 38kHz signal is used to illuminate an Infra Red (IR) LED.  Light reflected from the LED is detected by a Vishay HS0038B IR receiver module (see data sheet).  The receiver module incorporates an external, optical, 950nm IR filter and an internal, electronic, 38kHz band-pass filter that make the module receptive only to IR light pulsing at that frequency.

One of the potentiometers on the board (R6) is used to fine tune the signal to exactly 38kHz. The other (R5) adjusts the duty cycle of the signal, which controls the brightness of the IR LED.

Both adjustments together effect the sensitivity or range of the device.  Proper adjustment of R6 requires an oscilloscope or a frequency counter.  Otherwise it can be left centered or as it came from the manufacturer.

The receiver module also includes an AGC (Automatic Gain Control) that will suppress a continuous signal of any frequency, including 38kHz (see excerpt from data sheet, below).  Therefore, it is absolutley necessary to use the 'EN' or 'Enable' pin for proper operation of the device.  If the Enable function is used correctly, the device will achieve its maximum sensitivity.

On most versions of this device, the Infra Red (IR) LED is already covered with a small piece of black shrink tubing; but I find that additional optical shielding is required.  A small cardboard tube commonly used as packing material will work satisfactorily, as will a variety of other materials.

When the GREEN JUMPER is installed on the board (see picture), the IR LED will flicker continuously at 38kHz.  If the Enable (EN) function will not be used, the jumper must be installed .  When the jumper is removed, pin 4 of the 555 timer is held LOW (RESET) by R3, a 22K pull-down resistor. Then, if a HIGH condition is applied to the EN pin, the reset condition will be relieved and the 555 timer will begin to oscillate. The Enable function cannot be used if the GREEN JUMPER is in place.  You must remove the jumper on the board in order to use the EN (Enable) pin.

From the HS0038BD data sheet:

These products are designed to suppress spurious output pulses due to noise or disturbance signals. Data and disturbance signals can be distinguished by the devices according to:

  1. carrier frequency,
  2. burst length and
  3. envelope duty cycle.

The data signal should be close to the band-pass center frequency of 38 kHz and fulfill the following conditions.  After each burst of 10 to 70 cycles, a minimum gap time in the data stream of 10 cycles is needed.  For bursts greater than 70 cycles, a minimum gap time in the data stream of greater than 4x the burst length is needed.  When a data signal is applied to the IR receiver in the presence of a disturbance signal, the sensitivity of the receiver is reduced to insure that no spurious pulses are present at the output.  Some examples of disturbance signals which are suppressed are:

  1. DC light (e.g. from tungsten bulb or sunlight)
  2. Continuous signals at any frequency
  3. Strongly or weakly modulated noise from fluorescent lamps with electronic ballasts.

 

Sample C++ code to strobe the IR LED with a 600µs pulse and test for a return:

digitalWrite( enablePin, HIGH);     // Enable the internal 38kHz signal.
microDelay( 210);                   // Wait 210µs (8 pulses of 38kHz).
if( digitalRead( outputPin))        // If detector Output is HIGH,
{
    objectDetect = false;           // then no object was detected;
}
else                                // but if the Output is LOW,
{
    microDelay( 395);               // wait for another 15 pulses.
    if( digitalRead( outputPin))    // If the Output is now HIGH,
    {                               // then first Read was noise
        objectDetect = false;       // and no object was detected;
    }
    else                            // but if the Output is still LOW,
    {
        objectDetect = true;        // then an object was truly detected.
    }
}
digitalWrite( enablePin, LOW);      // Disable the internal 38kHz signal.

 

This schematic of the KY-032 was created by examining the circuit board.  This is my second attempt. I cannot guarantee its accuracy.  It was drawn using the EasyEDA online electronic circuit design tool.  The values of the two capacitors are not known.

I want to thank Arik Yavilevich for his valuable contribution.  Further comments and corrections will be appreciated.

schematic

 

Other sites of interest:


W3C Validated 13AUG2016

Valid XHTML 1.0 Transitional