Distance sensors sharp comparison. Infrared laser rangefinder

All about sockets

In this article, we will consider connecting and working with the SHARP GP2Y0A02YK0F IR distance measurement sensor.
Unlike the same, this sensor has a much more modest measurement range, but still has a number of useful distinctive properties. For example, this sensor allows you to measure the distance even through transparent surfaces (although losing the accuracy of the readings, but still).

Sensor connection:

GND to any of the GND pins --- arduino

OUT to any of the analog inputs of the arduino (connected to A0 in the examples)

VCC at + 5 volts on arduino

Main technical characteristics:

Distance measurement range: 20 to 150 cm

analog output

Dimensions: 29.5x13x21.6mm

Current consumption: 33mA

Supply voltage: 4.5 to 5.5 V

It must be unpacked and added to the "libraries" folder in the Arduino IDE folder. Don't forget to restart the environment if the IDE was open when you added it.

What is the peculiarity of this library and why is it recommended for use? The answer is simple and lies in the principle of its work. To measure the distance, many measurements are used, from which erroneous ones are discarded, which are very different from neighboring ones. According to the authors, 12% of all readings contribute 42% of the error to the final distance value, if erroneous measurements are not discarded.

Let's move on to the program code - an example of working with a sensor (the example is also suitable for the GP2Y0A21Y sensor, in the code you will need to change the model value to 1080):

Program code example

#include #define ir A0 //pin to which the sensor is connected. Definitely analog!#define model 20150 //sensor model. 1080 for GP2Y0A21Y, 20150 for GP2Y0A02Y SharpIR SharpIR(ir, model); void setup () { Serial.begin(9600); ) void loop() ( delay(2000); unsigned long pepe1=millis (); // note the time before the start of measurements int dis=SharpIR .distance(); // get the distance from the sensor Serial.print("Mean distance: "); // print the distance to the port monitor Serial.println(dis); unsigned long pepe2=millis()-pepe1; // count the time spent on the measurement Serial.print("Time taken (ms): "); // and output it Serial.println(pepe2); )

An infrared laser rangefinder emits energy in a range invisible to the human eye. It is a Class 1 laser device as required by the US Food and Drug Administration, 21 CFR 1040.10-11. The FDA Laser Compliance Mark is affixed to the CMS Wireless chassis. This marking also indicates the model, serial number and date of manufacture.

Class 1 includes lasers that, under normal operating conditions, cannot harm a person. In normal installation, a person can look into the laser beam without glasses or with their normal glasses (Do not look into the laser beam when the system is on - standard precaution).

The laser remains in the excited state as long as the LASER TEST or START SURVEY commands continue to be selected in the controller software. When the laser is in an excited state, distances and other data are displayed on the controller screen.

The red LED on the control panel located in the controller box is constantly lit when the system is on, whether the laser is energized or not.

The laser scanning head includes a laser range finder and a capture unit (Figure 7.2, Figure 7.3).

Figure 7.2 - Scanning head

Figure 7.3 - External view of the laser scanning head

Figure 7.4 - VIP installation in underground conditions

Figure 7.5 - Installation of rods and masts in underground conditions

Figure 7.6 - Entering the scanner into the cavity in underground conditions

Table 33 - Specifications

Laser scanning head
Target measurement range with 20% reflection 350 m
Measuring range to white wall 650 m
Rotation angle range 0 - 360º
Tilt range 0 - 145º
Linear measurement accuracy -+2 cm in the operating temperature range
Resolution 1 cm
Angular measurement accuracy -+ 0.3º
Maximum rotation speed 21º/s
Wavelength 905 nm (infrared), 635 nm (optical).
Deflection of the laser beam 5 mrad
Max number of readings 100,000 (per shoot)
support structure
materials CFRP, high-density polyethylene docking stations, stainless steel clamps.
Rod length 2-9 m, adjustable
Number of rod sections 5 conical 2 m each
Length of mast supports (2 pcs) 2-5 m, adjustable
Number of mast extensions 5 (various lengths)
Power (external batteries)
Voltage Rated 24 V
Capacity 7.2 Ah, nominal 24 V
Power consumption 2.5 A, nominal 24 V
External conditions
Working temperature Distance meter (-10º to +50º), pointer (0º to 40º)
Storage temperature From -20 to +50º
Air humidity 0 to 95% non-condensing
Dimensions
Power supply (mm) 270 * 247 * 175
Weight, kg 8.3
Mast (mm) 2290*230*250
Rod section (mm) 1930*200*250
Weight, kg 44.5
Eye safety
Pointer Grade 2
Rangefinder 1 class
Vertical Insertion Device (VIP)
Components 25 aluminum rods (about 1.5 meters each)
1 scan head adapter
2 centering spring systems
1 connecting cable, about 41 meters

CMS survey is used in cases where human access is dangerous and visual control is not possible. The survey provides an absolutely accurate position of the voids tied to the coordinate system, which in turn makes it possible to rationally, accurately and correctly design the further use or repayment of these voids.

The infrared rangefinder allows you to determine the distance to objects. This is Sharp's model GP2Y0A021. The sensor determines the distance by the reflected beam of light in the infrared spectrum. The rangefinder can be used to avoid obstacles and navigate the terrain.

The output is an analog signal, with a voltage level dependent on the distance to the target in the set direction.

The sensor is connected to the control electronics via 3 wires. When connected to an Arduino, it will be extremely convenient to use the Troyka Shield. The cable for connection is included in the package.

Attention! The power pinout for this sensor may vary. Before turning on the module, familiarize yourself with the features of connecting DFRobot modules.

To securely install the rangefinder anywhere, there is a special mount.

Characteristics

  • Supply voltage: 4.5-5.5 V
  • Current consumption: 30-40 mA
  • Distance range: 10cm - 80cm

Restrictions

Since the device is based on light, the sensor is not well suited for determining the distance to light-absorbing objects. The rangefinder will not even feel a transparent surface, such as plastic or plexiglass. To determine distances in such an environment, the URM37 or HC-SR04 ultrasonic rangefinder is suitable.

This infrared rangefinder has a small dead zone in front of it: 10 cm. If you need to consider obstacles at shorter distances, and the limit distance is not so important, consider a rangefinder for distances of 4-30 cm of the same line. If your device needs to see farther, look for a rangefinder for distances of 20-150 cm. You can achieve more flexibility by combining sensors with different ranges.

The Sharp GP2Y0A Infrared Distance Sensor is a popular choice for various Arduino-based projects that require accurate distance measurement.

Sharp sensors have an infrared (IR) light-emitting diode (LED) with a lens that emits a narrow beam of light. The beam reflected from the object is directed through another lens to a position-sensitive photocell (Position-Sensitive Detector, PSD). The location of the beam incident on the PSD determines its conductivity. Conductivity is converted to voltage and, for example, by digitizing it with a microcontroller analog-to-digital converter, you can calculate the distance.

The output of the Sharp infrared distance sensor is inversely proportional - as the distance increases, its value slowly decreases. View of the graph of the relationship between distance and voltage.

Sensors, depending on their type, have measurement limits within which their output can be considered reliable. The measurement of the maximum real distance is limited by two factors: the decrease in the intensity of the reflected light and the inability of the PSD to register small changes in the location of the imaged beam. In general, the plot between distance and voltage is not linear, but within allowable distances, the plot of the reciprocal of output voltage and distance is close enough to linearity that it is fairly easy to derive a formula for converting voltage to distance. To find such a formula, it is necessary to enter the points of this graph into any tabular data processing program and create a new graph from them. In a tabular data processing program, it is possible to automatically calculate a trend line based on the points of a graph. For example, for the GP2Y0A021YK0F sensor:


Sharp Infrared Rangefinder Specifications

Operating voltage: 4.5 - 5.5 V; Maximum current consumption: 40 mA (typical - 30 mA); Output signal type: analog; Differential voltage greater than distance recognition range: 2.0V; Response time: 38 ± 10 ms Operating range: Sensor GP2Y0A41SK0F: 4 - 30 cm; Sensor GP2Y0A021YK0F: 10 cm - 80 cm; Sensor GP2Y0A02YK0F: 20 cm - 150 cm;

Usage example

Let's create an example of counting store visitors. Let's simplify the problem, assuming that the entrance is through a narrow door, and there are different doors for entry and exit. At the entrance, we put the Sharp GP2Y0A21YK0F infrared range finder (20-150 cm) so that when a person passes, the readings are 10 - 50 cm, in the absence of people 80 cm. When a visitor is detected, we increase the counter for counting visitors. We display the data on the Nokia 5110 graphic display. To display information from the sensors, we will use the Nokia 5110 LCD. This is a monochrome graphic display with a resolution of 84 × 48 pixels. The Nokia 5110 display comes on a board paired with a PCD8544 controller and a pin header. The power consumption of the display allows it to be powered from the +3.3 V output of the Arduino board.

For the project, we need the following details:
arduino uno board
breadboard (Breadboard Half)
infrared distance sensor sharp GP2Y0A21YK0F
Nokia 5110 display
connecting wires
Let's assemble the circuit shown in the figure.

Let's start the Arduino IDE. Let's create a new sketch and add the following content to it: //Infrared distance sensor //website // connecting libraries to work with the Nokia display #include #include // Nokia 5110 // pin 3 - Serial clock out (SCLK) // pin 4 - Serial data out (DIN) // pin 5 - Data/Command select (D/C) // pin 6 - LCD chip select (CS) // pin 7 - LCD reset (RST) Adafruit_PCD8544 display = Adafruit_PCD8544(3, 4, 5, 6, 7); // analog pin for connecting the Vo output of the sensor const int IRpin = A0; // variables int value1; // to store the analog value unsigned long timevisitors; // transit time int count_visitors=0; // visitor count variable void setup() ( // start the serial port Serial.begin(9600); Serial.println("start"); // initialize the display display.begin(); // set the screen background contrast display.setContrast(60); display.clearDisplay(); // clear the screen display.setTextSize(1); // font size display.setTextColor(BLACK); // color // splash screen display.setCursor(5,15); display.print("Vis itors: 0"); display.display(); delay(2000); ) void loop() ( // get the smoothed value and convert to voltage value1=irRead(); if(value1>50) // fix the passage ( timevisitors=millis(); while(irRead()>50) ; if(millis()-timevisitors>300) // > minimum transit time ( Serial.println("passage!!!"); count_visitors=count _visitors+1; // increment the counter // print to the serial port monitor Serial.print("count_visitors="); Serial.println(count_visitors); // print to the display display.clearDisplay(); display.setCursor(5,15); display.print("Visitors: "); display.print(count_visitors); display.display(); ) ) delay(200); ) // Averaging several values ​​for smoothing int irRead() ( int averaging = 0; // variable for summing data // Getting 5 values ​​for (int i=0; i<5; i++) { value1 = analogRead(IRpin); // значение сенсора переводим в напряжение float volts = analogRead(IRpin)*0.0048828125; // и в расстояние в см int distance=32*pow(volts,-1.10); averaging = averaging + distance; delay(55); // Ожидание 55 ms перед каждым чтением } value1 = averaging / 5; // усреднить значения return(value1); } Работать с сенсорами SHARP очень просто - достаточно подключить к нему питание и завести вывод Vo на аналоговый вход Arduino. Значение получаемой функции analogRead представляет собой целое число от 0 до 1023. Таким образом, чтобы узнать напряжение на выходе сенсора, необходимо значение на аналоговом входе Arduino умножить на 0,0048828125 (5 В / 1024). Расстояние вычисляем по формуле distance=volts*0.0001831-0.003097. При чтении данных, при каждой итерации цикла, иногда приходят разные значения сигнала при одном и том же расстоянии. Датчик передает сигнал на аналоговый порт с некоторой амплитудой и иногда в момент считывания данных значение оказывалось отличным от нормального, потому что итерация приходится на провал. Для сглаживания значений, получаемых с дальномера используем функцию irRead(). Датчик обнаруживает попадание объекта в дверной проем. Далее ожидаем окончания прохода. Если это время больше минимального времени прохода (отсечение взмаха руки, пролет предмета и пр.) инкрементируем счетчик посетителей и выводим данные в последовательный порт и на дисплей. Для работы с дисплеем Nokia 5110 нам понадобятся Arduino библиотеки Adafruit_GFX и Adafruit_PCD8544.

Frequently Asked Questions FAQ

1. No information is shown on the display
  • Check the correct connection of all wires, according to the diagram in Figure 5.
2. The distance sensor does not work
  • Check the connection of the sharp module;
  • Check if the sensor detection is triggered in the serial port monitor.