Microcontroller › 8051 › Interfacing AT89S51 with ultrasonic sensor and LCD › Interfacing Ultrasonic sensor
March 7, 2017 at 7:13 am
#14509
Participant
Ultrasonic sensor uses a technique called ECHO in which you somthing reflecting back after striking from the surface. sensor provides an output signal proportional to distance based on the echo. The sensor here generates a sound vibration in ultrasonic range upon giving a trigger, after that it waits for the sound vibration to return.
steps to calculate distance:
1. Triggering the sensor by pulling up the trigger pin for atleast 12uS.
2. Once echo goes high we get an external interrupt and we are going to start a counter (enabling a counter) in the ISR (Interrupt Service Routine) which is executed right after an interrupt triggered.
3. Once echo goes low again an interrupt is generated, this time we are going to stop the counter (disabling the counter).
4. So for a pulse high to low at echo pin, we have started a counter and stopped it. This count is updated to memory for getting the distance, as we have the width of echo in count now.
5. We are going to do further calculations in the memory to get the distance in cm
6. The distance is displayed on 16×2 LCD display.