Saturday, March 12, 2011

Distance Measurement Sensor

Distance Measurement Sensor
GP2Y0A21YK is General Purpose Type Distance Measuring Sensors from Sharp. Sharp Infrared (IR) radiation Distance Measuring Sensor use Infrared signal to measure object distance from 10 to 80 cm with analog output.







Features
  • Less influence on the color of reflective objects, reflectivity
  • Line-up of distance output/distance judgement type
    Distance output type (analog voltage) : GP2Y0A21YK
    Detecting distance : 10 to 80cm
    Distance judgement type : GP2Y0D21YK
    Judgement distance : 24cm
    Adjustable within the range of 10 to 80cm [Optionally available])
  • External control circuit is unnecessary
  • Low cost
Applications

  1. TVs
  2. Personal computers
  3. Cars
  4. Copiers
  5. Robots

The output of this sensor is analog therefore it need Analog to Digital Converter (ADC) to interface the 8051. I use ads7841 as ADC.

The graph of Analog voltage output versus distance to reflective object are shown in Fig.1. When I plot Analog voltage output versus inverse number distance, I found the linear relation shown in Fig.2.
Distance Measurement Sensor
Fig. 1 Analog voltage output (V) versus distance to reflective object (cm).


Distance Measurement Sensor
Fig. 2 Analog voltage output (V) versus inverse number distance (1/cm)

The linear equation is y = 20.99x + 0.19, where y is voltage output and x invert distance. Notice that the voltage output I can trust are about 0.4 to 2.8 V.

This is an example code how to interface the distance sensor to 8051. I use SDCC as C Compiler.

#include <8051.h>
 #include "ads7841.h"
void main()
 {
     float x,y; // Distance and Analog voltage output
     y = analog(0); // Read volt out if the sensor connect to channel 0 of ADS7841
     y = 0.00122*y; // Convert BCD to DEC by multiply voltage by 5/4096
     if ( (y > 0.4) && (y < 2.8) ) {
        x = (y-0.19)/20.99; // Solve the linear equation
        x = 1/x; // Inverse back get distance in cm.
    }
 }


Source:
test_irsensor.c
characteristic.txt (For plot with Spreadsheet)

Related Links
GP2Y0A21YK/GP2Y0D21YK Datasheet
Analog to Digital (ADS7841) Interfacing

4 comments For Distance Measurement Sensor Article

What do you think about Distance Measurement Sensor article???
Please give your comments about Distance Measurement Sensor article in this Blog. give your comments about Distance Measurement Sensor article, either in the form of criticism and advice and support will be very meaningful for me to progress this blog

Less influence on the color of reflective objects, reflectivity.

distance measurement

This comment has been removed by the author.

Acuity laser measurement sensors include over seventeen varieties of laser triangulation sensors, five long-range laser rangefinders, versatile laser line scanners.

distance sensor

Post a Comment