Project to read the Paralax Ultrasonic sensor
Posted: Sat Nov 15, 2014 8:28 pm
Hi All
As before as I am working my way through FC ,I also thought that this might help some one who wish to work with the Parallax Ultrasonic sensor to read distance to objects
the code outputs the Timer cycle Time over serial ,you can easily read the data into a PC GUI and the formula to calculate the distance from the Timer time
is
The measured Time is the round trip time of the sonic signal there fore to get the distance we need to divide by two to get the singel time from the object back to the sensor
the 29 is to get the distance in cm as the sonic signal move @ 29usec / cm through air at room temperatures
Regards
QMESAR
As before as I am working my way through FC ,I also thought that this might help some one who wish to work with the Parallax Ultrasonic sensor to read distance to objects
the code outputs the Timer cycle Time over serial ,you can easily read the data into a PC GUI and the formula to calculate the distance from the Timer time
is
Code: Select all
mSecTime = (((ReceiveDataBuffer(2) * 256) + ReceiveDataBuffer(3)) * 0.0000004) * 1000
Distance = ((mSecTime * 1000) / 29) / 2
the 29 is to get the distance in cm as the sonic signal move @ 29usec / cm through air at room temperatures
Regards
QMESAR