Timing, while reading from HCSR04 sensors

Forums:

Hi Team,
I am having a little trouble with three HCSR04 sensors and the Ultraborg. Most of the time I am getting readings that seem to be off by 10-15 cms (100-150mm). The sensors in the Front, Left, Right formation. The left and right are at 90 degrees to the front (facing outwards ofc ourse). Accuracy is nearly spot on, when only one is attached.

I was wondering if there are some best practice guidelines on how much we should delay calling UB.GetDistanceX() where X = 1, 2 or 3. It happens with the ubReadDistances.py code as well.

I have for now put in a time.sleep(0.05) for now between each getGetDistanceX() call, and that seems to improve things a bit.

Any other reasons anyone can think off as to why the sensors readings are off by this much?
Cheers,
Sumit.

piborg's picture

Ultrasonic readings can be a bit tricky to get right. Hopefully we can figure out what is going on and get things sorted :)

The first thing to try would be using the unfiltered distance readings instead:

usm1 = UB.GetRawDistance1()
usm2 = UB.GetRawDistance2()
usm3 = UB.GetRawDistance3()

If there are large variations in the readings then the filtering may not be filtering the values out enough and has strange values as a result. If they just seem larger then the problem is probably to do with the actual sensor data itself.

I am guessing that the sensors are seeing echos from each other, reflected from other objects. This can confuse the sensors into getting false readings. From my observations this tends to cause readings which are smaller than they should be most of the time.

Yes, it does seem like I was getting echoes due to positioning of the sensor.
Also getting Raw readings seems to work much faster.

Cheers

Subscribe to Comments for "Timing, while reading from HCSR04 sensors"