0
\$\begingroup\$

How does an ultrasonic distance sensor work?

My thoughts:

A microcontroller (Arduino nano) sends a signal to an amplifier that makes it into a 40kHz pulse, which then goes to the transmitter which sends it out. After some time the receiver get the pulse, where it runs it though an op amp (because of the loss in air?) and then sends it back to the Arduino.

If this is true, how does the Arduino / microcontroller convert this information into time?

\$\endgroup\$
  • \$\begingroup\$ "Some time" is linearly related to how far away the object reflected off with. \$\endgroup\$ – Scott Seidman Feb 28 at 11:57
  • \$\begingroup\$ How about watching some tutorials? For instance howtomechatronics.com/tutorials/arduino/… > how does the Arduino / microcontroller convert this information into time? With the sensor from the example above: Using an edge sensitive timer: Start counting when the rising edge occurs and stop at falling edge. <br> \$\endgroup\$ – mic Feb 28 at 12:08
  • \$\begingroup\$ Try reading this document from NXP. It explains how it works, and gives flow charts and program code for a specific microprocessor. Once you've got some idea what is going on, you can ask better questions about the details of how it works - and use the diagrams to illustrate the points you need help with. \$\endgroup\$ – JRE Feb 28 at 12:25
1
\$\begingroup\$

Ultrasonic sensors work by emitting sound waves at a frequency too high for humans to hear. They then wait for the sound to be reflected back, calculating distance based on the time required. This is similar to how radar measures the time it takes a radio wave to return after hitting an object.

In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled. enter image description here

For example, if the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 294 u seconds. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2.

enter image description here

\$\endgroup\$
0
\$\begingroup\$

Some US sensors send a continuous sinus signal, that is therefore reflected and received by US sensor. Due to the fact, that signal needs some time to travel, the received sinus will be phase-shifted.

enter image description here

Consider red sine wave as transmitted signal and blue sine wave as received. They are shifted related to each other.
This phase-shift can be computed using autocorrelation.

Other sensors may send single pulses and then calculate the difference between transmitted and received time. Then the distance can be computed as follows:

enter image description here

where v is the speed of sound. Computed distance is divided by 2 because the sound had to travel from the sensor to the object and then back from the object to the sensor.

\$\endgroup\$
  • 2
    \$\begingroup\$ The first part of your answer is way oversimplified. CW ultrasound, like CW radar, frequency-modulates the signal. The phase analysis is done on the modulation, not the carrier. Remember, the wavelength of 40 kHz sound in air is less than a centimeter! \$\endgroup\$ – Dave Tweed Feb 28 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.