To convert speed into cm/sec, multiply 340 with 100. The speed of sound in air is 340 m/sec meters per second.īut as per the datasheet of the HC-SR04 ultrasonic sensor, the value of speed should be in units of a centimeter per second (cm/s). If you studied physics in high school, you may remember that ultrasonic waves travel with the speed of sound. But how do we find the speed of ultrasonic waves? That’s pretty easy. Here time (t) is the pulse duration of the ultrasonic output signal. In this equation, S, t, and v are distance, time, and speed respectively. Once we measured the output pulse duration, the distance can be calculated by using distance speed and time relationship that is: S = v x t In short, by measuring the time of this output pulse with TM4C123 timers, we can measure the distance.Ĭonvert HC-SR04 Ouput Pulse Duration into Distance Pulse Duration Measurement using TM4C123 Timer in input-edge Time mode.In the previous tutorial, we have posted an in-depth guide to measure pulse duration using TM4C123 Timers. After that takes the difference of two measured timer values, it will give you pulse duration. For example, read the TM4C123 timer value when the rising edge is captured by the GPIO pin of TM4C123 microcontroller and also read the timer value when the falling edge is detected. In this mode, timers can measure time between events such as rising or falling edges. TM4C123 microcontroller timers can be in input edge timer capture mode. Therefore, the time between two consecutive rising and falling edges gives us the pulse duration. After that as soon as the ultrasonic wave is detected by the receiver circuit, echo output goes low which means a falling edge occurs. That means a rising edge occurs at the echo pin. In response, the HC-SR04 sensor produces a burst of 8 sonar wave pulses and raises its echo output pin active high. When we want to measure the distance, we apply a 10us pulse to the trigger input. In idle condition, when the sensor is not initiated by applying a trigger signal, the echo output signal remains active low. Measure HC-SR04 Output Pulse width using TM4C123 The figure below shows the timing diagram and it illustrates all the steps metioned above. Hence, the measured distance will be zero. Hence, if the width of the output pulse is 38ms, that means there is no object in the range of the obstacle sensor. In this case, the echo output signal will go high for 38ms. Note: If there is no obstacle or out of the range of the maximum range of the sonar sensor ( 400cm), the transmitted signal will not reflect back. More the distance, the more time the sonar sound wave takes to receive after reflecting back. The pulse width can vary between 150 µS to 25 mS depending on the distance between the sensor and the obstacle.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |