Skip to content

Latest commit

 

History

History
6 lines (6 loc) · 1.52 KB

File metadata and controls

6 lines (6 loc) · 1.52 KB

Interfacing-UltraSonic-Sensor-with-TIVA-C

Here we will use 2 Ultrasonic sensors. An ultrasonic sensor is a great tool for all kinds of projects that need distance measurements. Obstacle avoidance is one of the examples. Ultrasonic sensor HC-SR04 is used in this lab to measure distance in the range of 2 cm to 400 cm with an accuracy of 3 mm. The sensor module consists of the control circuit and two ultrasonic sensors — one is the transmitter, another is the receiver. The HC-SR04 sensor uses two signal pins, one is for trigger PA3-PA2 and another is for receiving echo signal PB2-PB0. The "trigger" pin is connected to the output pin of GPIO, and the "echo" pin is attached to the Input Capture pin of Timer in the Tiva LaunchPad. The HC-SR04 sensor must be "triggered" in order to enable pulsing. Therefore, you need to set the GPIO output pin high and then low. The sensor documentation discusses how long the trigger pulse should be. The echo signal received from the sensor will rise and then fall on the "echo" pin. The distance between these two edges is directly proportional to the round-trip distance between the sensor and the object. Input capture when properly configured to Edge-Time mode will identify the edges of the signal and set TIMERn_TAR_R to the current counter value when the events/edges are detected. The difference in counter values represents the signal's pulse width as time. The actual amount of time can be determined when the system clock frequency is used to compute the amount of time each counter value represents.