The general formula for Distance to Time conversion or vice versa is,
Velocity = Distance / Time
I have been implementing HCSR04 Distance Sensor,
Datasheet: https://docs.google.com/document/d/1Y-yZnNhMYy7rwhAgyL_pfa39RsB-x2qR4vP8saG73rE/edit
and according to Datashheet,
To start measurement, Trig of SR04 must receive a pulse of high (5V) for at least 10us, this will initiate the sensor will transmit out 8 cycle of ultrasonic burst at 40kHz and wait for the reflected ultrasonic burst. When the sensor detected ultrasonic from receiver, it will set the Echo pin to high (5V) and delay for a period (width) which proportion to distance. To obtain the distance, measure the width (Ton) of Echo pin.
This is how i am calculating the Distance right now,
Distance = Velocity of Sound * Time
But according to datasheet,
Time = Width of Echo pulse, in uS (micro second),
Distance in centimeters = Time / 58
Distance in inches = Time / 148
Or you can utilize the speed of sound, which is 340m/s
How come Time divided by either 58
or 148
gives Distance ?
Also,
Some code on the internet (http://www.bytecreation.com/blog/2013/10/13/raspberry-pi-ultrasonic-sensor-hc-sr04) suggests that,
Distance = time * 17000 (in cm),
Here is what this page says.
# work out the difference in the two recorded times above to # calculate the distance of an object in front of the sensor timepassed = signalon - signaloff
# we now have our distance but it's not in a useful unit of
# measurement. So now we convert this distance into centimetres
distance = timepassed * 17000
How come multiplying time with 17000 gives the distance.
Answer
If you take 340 m/sec (approximate speed of sound through air) and convert to cm/sec you get 34000 cm/sec. For pulse-echo, the sound travels twice the measured distance so you need to divide the conversion factor by 2 so you get 17000 cm/sec. When you multiply by the measured time, you get distance from the transducer to the object in cm.
The other two conversions are converting from time measured in microseconds at the same time so the formua for Distance in centimeters is the same as: Distance (cm) = Time (seconds) * 1000000 (microseconds per second) / 58 which comes out to (approximately) Distance (cm) = Time (seconds) * 17241 which is nearly the same as the formula in your question.
As Andy said, the speeds of sound used in the formulas are approximations. The actual speed of sound through air varies with temperature and (to a lesser extent) with humidity (and a little due to other factors).
No comments:
Post a Comment