Accurate 2D Tracking Using Multiple HC-SR04 Ultrasound Sensor

About: I love making and flying RC planes.

Generally, an ultrasound sensor is used for the range of the target. where it sends the sound wave to target and reflected wave is captured by integrated receiver it measures an overall time of travel for the sound wave. As the speed of sound is known the distance from the target can be easily calculated. however, in my previous instructable, I tried to measure the location of the object in 2D by using two of this sensor. But the accuracy of the measurement was too poor for any practical use. this instructable can be accessed from below links:

https://www.instructables.com/id/Ultrasound-Sensor...

To solve the above problem using multiple sensors to make the measurement is proposed. This method I tried to implement in this instructable. Making hardware is very straightforward but making a code takes effort.

Step 1: Working

These methods make use of multiple sensors. Higher the number of the sensor can be useful for more accurate measurement. Let take an example of a setup with 4 sensors (as I am using for the tutorial). So after finishing measurement, we will have the distance to target from all of this sensor.

To calculate the position of the target in the lateral direction we need two measurements to complete a triangle and locate the target position. As we have 4 sensors we will have 6 combinations (4C2) of pairs. This pairs can be seen from the above images.

Once the pair is decided we have to calculate the target location for every combination of the sensor pair. In the end, there will be six number of measurements for the target location. By using all these six values relatively accurate measurement can be made. now all these data is fused with weightage as per accuracy. if we consider a triange than the higher distance between sensor will lead more accurate. So higher weightage is given to the pair having sensor far from each other.

This method is still not very accurate as we are not making the measurement from the single point target. as the target is a planner object sensor will measure the distance from the nearest point.

Step 2: Preparing Setup

This setup is very simple and similar to the previous tutorial on 2d tracking with two sensors. Ground supply and Vcc is connected to a common line and all Tx and Rx pin are connected to one of the Arduino pins. It can be connected to any of the Arduino pins that need to be defined in code. Above image can be referred for the overall connections.

After that, all these sensors need to be mounted with a fixed distance. similar to the previous case, higher separation will lead to better accuracy and vice versa. the sensor may face in any direction for best coverage. In this case higher the number of sensors will face the target better result we can obtain.

Step 3: Working of Code

There are basically 4 functions that work to get accurate output and avoid a false reading.

1. Raw_cap():
This function will simply take data from the available sensor, sensor number can be any number, as discussed higher number will give better accuracy. another point need to consider is that in the command
pulseIn(Rx[i], HIGH,5000);
value 5000 need to be changed as per object placement, once we had the approx operating range we can calculate the value of time taken (in microseconds) by the sound wave to travel through and back to the range and replace with 5000.
at the completion of the function, we will end up with an array having values measured by all sensors.

2. Position_calc():
This function will take various combinations (nC2 for n number of the sensor) and will calculate the position of the target in 2D,

3. check();
This function will check every combination taken by position_calc() function is possible to form a triangle or not. If this function concludes this test negative Position_calc() will simply make entry as 0 values,
this function is very avoided considering the wrong values of the sensor. This function makes use of property that summation of the length of any two sides of the triangle is always higher than the length of rest 3rd side of the triangle.

4. Fuse_data()
Above function will take the weighted average of all measurement, weigtage proportional to distance in between the pair of the sensor.

Step 4: Setting Up the Code and Testing the Output:

Values like the number of sensor and sizes of arrays as commented in code need to be updated. another important parameter is the distance between these sensor need to be defined. here distance from the leftmost sensor to all sensor is added in an array named Position [ ].

once everything is setup target can be placed in front of the sensors and check the output from the sensor. please refer the video below for check the working of the sensor.

Step 5: Conclusion:

These type of setup can be more useful to check a quick scan over the large angular area and also to get more accurate measurement. An angularly rotating servo (on the servo) is not very effective as the servo is not fast enough to do the measurement at the faster rate. For example in an autonomous car example, this type of sensor layout can be used to have a correct estimation of obstacles.

However, the following project can be taken up for the future:

- Ultrasound sensor for tracking in 3d;
- All sensor can be mounted on the separate servo motor to track the object properly and keep in always in the operating area of all sensor. and also to keep the wide area under the scanning zone.

Share

    Recommendations

    • Fandom Contest

      Fandom Contest
    • Classroom Science Contest

      Classroom Science Contest
    • 1 Hour Challenge

      1 Hour Challenge

    Discussions