I was trying to test my ultrasonic sensor by measuring a distance of 10cm until 100cm and using an oscilloscope to look at the echo pin output signal. My oscilloscope is set at 0.5 time/div.
At first, my ultrasonic sensor couldn't work properly, but after some tweaking around, I can finally get my ultrasonic sensor working. But the strange thing was, the measured distance I got was always less than a half of the real distance value. For example, for a distance of 70 cm, I got 27.2 cm from the calculation. This is the output signal for a distance of 70 cm (3.2 DIV * 0.5 ms/DIV = 1.6 ms).
Basically, all I do is, I calculate the HIGH time by multiplying how many DIVs appeared and then I multiply it by TIME/DIV (I set TIME/DIV = 0.5 for all measurement). Then I multiply the time with velocity of sound (340 m/s)and then divide it by 2. Because the HIGH time appeared in oscilloscope is the time to travel back and forth.
Distance = (T*Vsound)/2
Why did I got such a large discrepancy between the experiment result and the actual value? I've followed the standard procedure. I connected the Trig pin with function generator of 40 kHz frequency, the Vcc pin with 5 Volt, GND pin with ground, and the echo pin with the oscilloscope. Also my ultrasonic sensor is a brand new one, never used before.
So what possibly I did wrong?