Interfacing Ultrasonic Distance Sensor : ASCII Output with PIC Microcontroller




In some of our projects, we may want to measure the distance of an object from a point. Ultrasonic Distance Sensors are the best sensor which provides stable, accurate, precise, non-contact distance measurements from 2cm to 4m. Ultrasonic Sensors can be used to measure distance between moving or stationary objects. Being very accurate and stable, these devices find large number of applications in robotics fields. For example it can be used as an excellent replacement for IR sensors in  a Micromouse. In this tutorial we will lean to interface an Ultrasonic Distance Sensor with PIC Microcontroller.Interfacing Ultrasonic Distance Sensor ASCII Output with PIC MicrocontrollerHere for demonstration we are using Rhydolabz Ultrasonic Distance Sensor with ASCII Output. It can be easily interfaced with a PIC Microcontroller using USART by just connecting the output pin of the sensor to RX pin of the microcontroller. In every 500ms this sensor transmits an ultrasonic burst and listens for its echo. The sensor sends out ASCII value corresponds to the time required for the ultrasonic burst to return to the sensor. The UART of the sensor is operates at a baud rate 9600 and the sensor can be powered by  a 5V DC Supply. The ASCII output of the sensor will be equal to the distance to the obstacle in centimeter (cm).

The sensor has three pins…

  • Vcc  – +5V DC Supply to the Sensor
  • GND –  Ground Level of the Power Supply
  • SIG – Signal, Serial Data Out

Circuit DiagramSchematic Interfacing Ultrasonic Distance Sensor ASCII Output with PIC Microcontroller

The sensor outputs distance in centimeter (cm) via USART. The output format can be found from the datasheet of the sensor as follows.

For more detail: Interfacing Ultrasonic Distance Sensor : ASCII Output with PIC Microcontroller




Leave a Comment

*
= 3 + 9

Read previous post:
USB converter
Pic-Plot2 GPIB to USB converter

Pic-plot now goes to USB! A perfect low cost solution to quickly get screen plots of your GPIB instrument on...

Close
Scroll to top