Project to read the Paralax Ultrasonic sensor

A forum where Flowcode v6 user created components can be shared, discussed and reviewed.

Moderator: Benj

Post Reply
User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Project to read the Paralax Ultrasonic sensor

Post by QMESAR »

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

Code: Select all

 mSecTime = (((ReceiveDataBuffer(2) * 256) + ReceiveDataBuffer(3)) * 0.0000004) * 1000
          Distance = ((mSecTime * 1000) / 29) / 2
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
Attachments
Parallax UltraSonic Sensor.zip
(201.47 KiB) Downloaded 393 times
15.11.png
my PC application view
(34.47 KiB) Downloaded 3717 times

Post Reply