An ultrasonic ranging module is a product used to measure distance. It sends and receives ultrasonic waves, and utilizes the time difference and the speed of sound propagation. The speed of sound propagation in air is given by the timer. Based on the time difference Δt recorded by the timer, the distance S from the transmitting point to the obstacle can be calculated, i.e., S = Δt/2. Thus, the distance from the module to the obstacle in front can be calculated.
Since ultrasound is also a type of sound wave, its speed of sound is related to temperature. Table 1 lists the speed of sound at several different temperatures. In practical applications, if the temperature change is small, the speed of sound can be considered essentially constant. The speed of sound at room temperature is 334 m/s, but it is easily affected by factors such as air temperature, humidity, and pressure, with temperature having a significant impact. For example, for every 1°C increase in temperature, the speed of sound increases by approximately 0.6 m/s. If high ranging accuracy is required, temperature compensation should be used for correction (this system employs this method). Given the ambient temperature T, the formula for calculating the speed of sound is: = 331.45 + 0.607T.
There are many types of ultrasonic ranging modules. Currently, the URM37 ultrasonic sensor is commonly used. It defaults to an RS232 interface but can be switched to a TTL interface. The URM05 high-power ultrasonic sensor can test up to 10 meters, which is considered to be one of the longest-range ultrasonic sensors currently available. Another commonly used module is the HG-C40U ultrasonic ranging sensor module from the Korean company Hagisonic.
The HG-C40U ultrasonic ranging sensor module is a 50x22x25 (mm) Φ16 sensor module capable of measuring obstacle distances of up to 3.5m (at5) and 5m (at12), with a resolution within 5mm. The HG-C40U also features two input voltages: 5V and 12V. The factory default is 12V. For communication, it uses UART to send data. In UART trigger mode, if the trigger command is generated by the UART, only data is sent: Send: #Mode|2 (changes to external trigger mode), Receive: !Mode|2->!DataSetComplement. Signal output uses an interface board (RS232, power regulator) for sensor-to-PC communication. Data display is handled by a monitoring program on the PC (using HyperTerminal). A high-performance ASIC chip ensures stable transmission and sensitive reception.
HG-C40U Ultrasonic Ranging Sensor Connector Configuration:
UART settings for the HG-C40U ultrasonic ranging sensor :
Communication protocol of HG-C40U ultrasonic ranging sensor :
The operating modes for the ultrasonic module are divided into three types: free-running, UART-triggered, and external triggering modes. Free-running mode triggers ultrasonic waves at regular intervals; UART-triggered mode uses a UART to periodically or randomly trigger external ultrasonic waves (trigger command); external triggering mode requires an external trigger signal for regular or irregular interval triggering. When in display operating mode, send: @mode, receive: !mode->@Mode|0. The operating mode setting (UART trigger) is set to %.Transmit:#Mode|1 (changes to UART trigger mode), %.Receive:!Mode|1->!DataSetComplement.
Accuracy class of the HG-C40U ultrasonic ranging sensor: