Exercise: Read Ultrasonic Ranger¶
Objective¶
Measure distance using a time-based process. Use the serial port for debugging.
Some processes we measure in the world involve measuring time. A sonar ranger emits a pulse of sound and measures the time it takes to reflect from an object back to the source. The distance is not itself a temporal quantity, but the dynamic process maps that distance to a time interval.
Steps and observations¶
Wire the circuit on the breadboard using the HC-SR04 ultrasonic ranger. Note that this module has one digital trigger input and one digital echo output.
Load and run the ReadSonar sketch.
Within the Arduino IDE, open the serial monitor console and make sure it is set to 9600 baud.
Observe the numbers printed in the serial monitor as you place a hard object a short distance in front of the sensor. It may take some time to find an object and orientation which yields a reliable signal.
Estimate the precision of the measurement. Is the scaling correct? Is there an offset error?
Comments¶
This exercise is a good opportunity to learn to use an oscilloscope. The DMM excels at measuring constant voltages, but cannot show how a signal varies over time. The oscilloscope plots voltage versus time at a wide range of time scales. It includes many controls designed to help select the specific intervals of interest from a waveform, in particular, triggering each sweep at a particular voltage and slope.
Arduino Code¶
Documentation: ReadSonar Arduino Sketch
Sketch Folder: ReadSonar
Other Files¶
EAGLE file:
read-sonar.sch