Hi I am using Ultrasonic waves sensor for detecting distance of object from my device.
As I understand the formula for calculating the distance is :
distance = (speed of sound * reflection time)/2
Now with arduino library's we are using function pulseIn() for getting Pulse Width
(which is happens when pin changes from high to low , waves comes back from reflection )
and then :
distance = Pulse Width * 0.0001657 .
Questions :
What is the meaning of pulse Width and how it connects to related to reflection time ?
from where this factor comes from 0.0001657 and how it related to speed of sound ?
Instead of dividing by 2 and then multiplying by 0,03434 some code (for centimeters) uses a division by 58,24 which is mathematically the same. This saves one floating point operation and makes the code much harder to understand.
Thus 0,0001657 is a value I cannot understand, just like you.
jremington:
Where did you find this?
If it was somewhere on the internet, you are too trusting. Use the correct number instead.
Just google ultrasonic 0.0001657 ,
You can find it in many posts/tutorials...but none of them explain what it is ,
That's why I try'd to ask here .
What do you mean use the correct number please? it is the correct number ,
As writing on all tutorials and its working , distance = pulseIn() * 0.0001657 .
jremington:
Just because it appears several places on the internet does not mean that it is correct.
I agree, it's like Celcius instead of the correct Celsius.
Anyway I believe that the difference in the range of 4m is small, about 20cm, compared to the precision and accuracy of this sensor.