Sunday, January 5, 2014

HC-SR04: beats phenomenon?





In this post we argued that the beats phenomenon takes place when using the HC-SR04 sensor. We start from the initial experiments and we plot the measures obtained from the sensor against their occurrence time (see Figure 1 below). 


Figure 1. Recollecting data from the previous experiments.
What we remark from the figure is that for the first about 1700 time units the measured value oscillates between the value 982 and 984 (with very few errors). After 1700 time units, the sensor starts oscillating mainly between values 1002  and 1003 in most cases (remark that there are still many oscillations between 982 and 984).

So we have two thing to explain:
  1. why the measures oscillate (mainly) between two values?
  2. is there a truly beats phenomenon for explaining the oscillations after time 1700? Or is it simply due to some characteristics of the sensor ? Or is due to some interference with Arduino, for example with IRQ service?
Answering the first question is easy. Indeed, according to Arduino specs, the precision is up to 3us. Answering the second question is more complicated and requires a series of experiments. We start from the very last one since it is the easiest one. We just restart our main experiment (see this post) disabling interrupts.

Figure 2 below illustrates the results of this second batch of experiments.


Figure 2. The second batch of experiments.
And here is the surprise! We only remark oscillations between the value 984 (the correct value) and 982 with practically negligible exceptions!

Conclusions.
There is no beats phenomenon going on. The second oscillation observed in early experiments (see Figure 1) is due to the interaction between IRQ service and the HC-SR04 sensor. The oscillations between value 984 and 982 (see Figure 2) are compatible with the approximation error in Arduino specs.

What's next
We are going to test the US-020 ultrasonic sensor. So, as usual, stay tuned!


See also

No comments :

Post a Comment