Wednesday, December 18, 2013

HC-SR04: what is the distribution law for the frequencies of values? (Part 2)





Recalling the conclusions of our last experiment with the HC-SR04 (you can find it here), we shall repeat the sampling batch leaving enough time to the HC-SR04 so to avoid errors given by oversampling. Recalling the computations made here, we know that maximal time for a round trip is 25000us, that is to say 25 milliseconds. We can overestimate to 26 millis to be absolutely sure.

Therefore we modify the setup function in our former program as follows:


void setup() {
  
  uint16_t i;
  
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  // wait for serial port to connect. Needed for Leonardo only
  while (!Serial); 

  Serial.println("*******************************");
  
  for(i=1; i<SAMPLESIZE;i++) {
    delay(26);
    Serial.println(readoutSensor());
  }
  Serial.println("*******************************");

  Serial.println("Sample generation terminated.");
}
(Remark that here output is on the Serial Monitor and no more on the SD card.)


The following picture illustrates the frequencies distribution of the new sampled data.


Making the same calculations as in the previous post we obtain:

Num of record processed: 12
Total number of elements: 2002
Mean= 984.5245
St. Dev.= 5.1863
Kurtosis= 7.7674
Skewness= 3.0169
St. err. kurtosis= 0.1094
St. err. skewness= 0.0547
Z-score kurtosis= 71.03
Z-score skewness= 55.15

Conclusions

Once again the distribution is not normal but at least there are no more zeroes. Hence, the delay was helpful

Analyzing the results further, we remark that there are two peaks at the beginning of measurements at 982 and 984 with frequency 897 and 923, respectively. The other values are mainly concentrated towards the end of the experiments. This fact confirms the impression that the beats phenomenon takes place.


New questions

Looking at these new data at least two question arise:

  1. What is the minimal delay for avoiding the oversampling problem? (ie having no occurrences of zero values).
  2. Can we determine at what time beats phenomenon takes place?
We will try to answer in the next posts. So, as usual, stay tuned and enjoy!

See also

HC-SR04: using a sonar sensor for motion detection
HC-SR04: what is the distribution law for the frequencies of values? (Part 1)
HC-SR04 : using multiple ultrasonic modules
Introduction to HC-SR04

1 comment :

  1. Thank you for sharing your thoughts and knowledge on this topic. This is really helpful and informative, as this gave me more insight to create more ideas and solutions for my plan. I would love to see more updates from you.

    Elcometer 510

    ReplyDelete