This is an old revision of the document!
Detecting the distance to an object with an ultransonic sensor
With the capture capability of Netzer a simple ultrasonic sensor like the HC-SR04 module can be used.
For that reason the sensor shall be connected like:
Sensor signal | Netzer signal | Further descriptions |
---|---|---|
VCC | - | Connect the sensor to +5V |
GND | GND | Ground signal |
TRIG (I) | IO3 | The trigger signal |
ECHO (O) | IO0, SPI_INT | The echo signal. Due to the Netzer pins are +5V tolerant, no voltage divider is needed! |
IO3
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.
The image shows how to configure IO3.
Depending on the configured unit the following value must be written to IO3 to get the 10 µs impulse:
Unit | Value |
---|---|
100ns | 100 (0x64) |
200ns | 50 (0x32) |
400ns | 25 (0x19) |
800ns | 13 (0x0D) |
The easiest way is to configure the impulse as startup value like shown in image above.