stoduk:
but is superior in terms of accuracy and precision
jremington:
There is no evidence for this assertion in the links you posted. The first link uses the wrong constant (331.4 m/s) for the speed of sound and fails to correct for individual offsets, while in the second link, the two sensors aren't even compared.
Did you see my comments on the second article? They give an idea of my experience to back up my assertions, more detail below. Here are the reasons for the inaccuracies:
- Inaccuracy in measuring the echo timings
I'll assume most people aren't using pulseIn() (it is blocking, and has accuracy issues of its own) - but instead NewPing's timer base polling or similar. This has a default polling period of 24us, so in the worst case we are adding 4mm to any measurement (24/1000 * 344).
This is a variable error as we might just poll at the point the echo pin is triggered, or we might not poll until the full 24us after the echo pin changed state. This impacts precision, rather than accuracy, as in the ideal best case we could still perfectly measure the distance. Realistically we'll have a 2mm±2mm variation on measurements.
So a simple lack of precision here, and one you could potentially avoid by using pin-change interrupts but only if you can guarantee your microcontroller cannot be delayed in handling that interrupt (ie. no other interrupts can block it).
- Temperature variation
Speed of sound (m/s) = 331.4 + 0.6 Tc; Tc is temperature in Celcius, and this is an approximation valid only around room temperature.
So this is a lack of accuracy, as the offset will be static at a given temperature.
US-100 avoids both of these issues. It has temperature compensation natively when used in serial mode. It avoids the need for precise measuring of the timing of pin state changed by sending the measured distance to a UART on the microcontroller. Result: improved accuracy and precision.
Background:
a) [not detailed in those comments:] I was originally using an HR-SR04 and found the numbers would jump all over the place so precision is obviously poor. As for accuracy - I didn't compare the measurements with a ruler so I can't say for sure.
Someone has already measured the accuracy of these devices (link below) and found both accuracy and precision issues compared to the device's specifications.
b) I did measure the accuracy/precision of US-100 in trigger/echo mode (which makes it similar to HR-SR04 realistically) and found that measurements were both inaccurate and imprecise.
The inaccuracy could be partly due to using the 0 degrees Celcius speed of sound (697mm measured would be corrected to 678mm assuming ambient was 15 degrees), but unless it was a very hot day in March (not possible in UK!) that is more inaccuracy than this temperature variation can explain.
The precision was ±3mm, when I'd expect 0-4mm based on the timing issues mentioned above. Could be that this is actually a precision of 0-6mm which some more inaccuracy offset.
c) I found that the measurements from US-100 were both far more accurate (correct to as accurate as I could measure with a tape measure) and precise (variation of under 1mm on 672mm measured).
http://forum.arduino.cc/index.php?topic=243076.msg1747862#msg1747862