en:netzer:hc-sr04

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
en:netzer:hc-sr04 [2014/08/17 17:05] sveschen:netzer:hc-sr04 [2025/06/11 20:42] (current) – external edit 127.0.0.1
Line 3: Line 3:
 With the capture capability of Netzer a simple ultrasonic sensor like the HC-SR04 module can be used. With the capture capability of Netzer a simple ultrasonic sensor like the HC-SR04 module can be used.
  
-{{:en:netzer:hc-sr04_front.jpg?direct |}}  +<imgcaption sensor_photo|Ultrasonic sensor HC-SR04>{{hc-sr04_front.jpg}}{{hc-sr04_back.jpg|}}</imgcaption>
-{{:en:netzer:hc-sr04_back.jpg?direct|}}+
  
 For that reason the sensor shall be connected like: For that reason the sensor shall be connected like:
Line 18: Line 17:
  
 IO3 is used for generating the trigger signal. IO3 is used for generating the trigger signal.
-Datasheet of the sensor stats that at least 10 µs pulse must be generated to start the measurement.+Datasheet of the sensor states that at least 10 µs pulse must be generated to start the measurement.
  
-{{:en:netzer:io3config_ultrasonic.gif?direct|}}+<imgcaption io3_config|Configuration of IO3 for trigger>{{io3config_ultrasonic.gif}}</imgcaption>
  
-The image shows how to configure IO3.+Due to the ultrasonic sensor has a resolution of about 0.3 cm it is sufficient to configure the resolution to 800 ns. The maximum values to measure (18 meters) are more than enough for the maximum of 3 meters the sensor will return.
  
-Depending on the configured unit the following value must be written to IO3 to get the 10 µs impulse:+At 800 ns the value 0x0D must be written to IO3 to get the 10 µs impulse. The easiest way is to configure the impulse as startup value like shown in image above. 
 + 
 + 
 + 
 + 
 +===== IO0 ===== 
 + 
 +IO0 is triggered by the rising edge of the sensor capture signal ECHO. 
 + 
 +<imgcaption io0config|IO0 configure for starting measurement>{{io0config_ultrasonic.gif}}</imgcaption> 
 + 
 +Important is to mark the "Impulse timer Reset" checkbox. 
 +Configured like this the rising edge of the ECHO signal will start the capture timer. 
 + 
 + 
 +===== SPI_INT ===== 
 + 
 +SPI_INT is connected to the ECHO pin, too. 
 + 
 +<imgcaption spiint_config|Config of SPI_INT>{{spiint_config_ultrasonic.gif|}}</imgcaption> 
 + 
 +The falling edge of the ECHO signal will stop the capture timer and finally show the result on the GPIO webpage. 
 + 
 + 
 +===== Result ===== 
 + 
 +Depending on set time resolution the measured value must be multiplied with the appropriate unit. 
 + 
 +If the result is //0x1234// at resolution //800ns// the measured pulse width is //3.728 ms//. 
 + 
 +The velocity of sound in dry air is 343 m/s (at 20°C) or //34.3 cm / ms//. 
 + 
 +3.728 ms x 34.3 cm / ms = //127.87 cm // is the propagation the signal takes. Due to the echo two ways are measured so the result must be divided in halves//63.94 cm//
  
-^ Unit ^ Value ^ 
-| 100ns |  100 (0x64) | 
-| 200ns |  50 (0x32) | 
-| 400ns |  25 (0x19) | 
-| 800ns |  13 (0x0D) |