1) Where do you get the formula v = SQRT((d/t)*(d/t)+(C*C)) - d/t ?
We can find the wind velocity from the equation: Vns = d/2 *( 1/tns - 1/tsn)
We can solve this(algebra) for the magnitude of the wind velocity when we have the time difference: V = SQRT((d/t)*(d/t) + C*C) - d/t Where t = largest tof - smallest tof.
1)Why the 300 samples ? I see you explain and show math about the 3 seconds and get 312 samples to produce 1 measure. You can use just 100 samples or even less and still get good results .
The wind gust peak is usually averaged over 3 seconds(historical from the time constant of cup anemometers). This gives a sample size of 300. Any smaller size can be used but you will get more noise in your result.
2) Why are you mention to get TOF in multiples of 25 usecs (instead of real time)? You send the pulses (actually 16 )and should be able to get the time to arrive. You could send the pulses , start timer and stop when it arrives .
This is the crux of the problem. To get precision of 0.1 usecs is impossible with TOF.
My solution is to use the coarse TOF to get the TOF to within a 25 usec range. I then use the phase shift to get the precise TOF within that 25 range.
3) I am not sure to understand why you use the 74HC368 drivers? Could you use just the I/O pins of the microcontroller directly?
You can drive the transducers direct as I did in my first prototype. I have given the code:
//PORTD is at 0x0b pin 6 controls NORTH HIGH pin 7 controls NORTH LOW asm volatile ("\n\t" "ldi r25 , 16 \n\t" //set pulse counter to 16 "pulse1%=:" "\n\t" //branch back here till 16 pulses sent "sbi %0 , 6 \n\t" //turn on NORTH HIGH "cbi %0 , 7 \n\t" //turn off NORTH LOW
This does not give a fine enough control of the pulse frequency. Timer0(Arduino millis() and PWM 5 & 6) is used as an exact frequency source for the ultrasonic. To get the differential feed requires that I had to use 2 74HC368 drivers, but it is not to extravagant to get the best S/N ratio.
4) What do you use zero detector and envelope for ?
The envelope detector is used to get the coarse TOF.
The zero crossing is used to get the phaseshift(fine detail) of the waveform.