Pages: [1] 2   Go Down
Author Topic: Measuring Distances with Ultrasonic Sensors  (Read 2695 times)
0 Members and 1 Guest are viewing this topic.
Flagstaff, AZ
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am new to arduino and am interested in using this with an LCD display and a US-100 ultrasonic sensor to measure distance. I would like to set this up to measure distances from 20-800mm in 1mm increments. I know this is within range for the sensor but need to know if it can be setup to display distance in mm not cm. is this possible? The next thing I would like to do is be able to point it at an object, zero it out to read 0mm then measure the distance of the object relative to the original location. I would be moving the object toward the sensor so if it moved 55mm closer I would get a reading of 55mm. This seems reasonable to me but I just started working with the arduino today and have to get up to speed on the code. If anyone has any ideas or feedback on the feasibility of this or has any examples/guidance I would be very grateful!
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Check the IDE "Files > Examples > Sensors" directory for Ping sonar code example,
and also the Arduino Playground for other sonar examples. I'm not familiar with US-100,
so it probably works differently.

The way the distance is displayed is determined by how you scale it and print it AFTER
you take the reading. See the Ping example above. 1" = 2.54 cm = 25.4 mm, it's just
a scalefactor.
Logged

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 24
Posts: 1766
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, some INFO and sample code on the ArduinoInfo WIKI here - http://arduinoinfo.info

http://arduino-info.wikispaces.com/UltraSonicDistance
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Flagstaff, AZ
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Check the IDE "Files > Examples > Sensors" directory for Ping sonar code example,
and also the Arduino Playground for other sonar examples. I'm not familiar with US-100,
so it probably works differently.

The way the distance is displayed is determined by how you scale it and print it AFTER
you take the reading. See the Ping example above. 1" = 2.54 cm = 25.4 mm, it's just
a scalefactor.
Thanks! I will check this out!
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11196
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

distances from 20-800mm in 1mm increments

Check that your sensor is capable of providing the range and resolution you're asking for before you worry about how to format the results.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Flagstaff, AZ
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Peter, I checked and it will do 2cm to 3m so I should be good. I will have the sensors this week hopefully. Does anyone have any input on the way I want to measure from a given point by zeroing out the reading and increment inn from there? Seems like it could work with the right code. Thanks for everyone's help, this is a great community and. M looking forward to the adventure;)
Logged

UK
Offline Offline
Shannon Member
****
Karma: 184
Posts: 11196
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anyone have any input on the way I want to measure from a given point by zeroing out the reading and increment inn from there?

You're talking about taking two measurements at different times and subtracting them. As long as you provide a way for the user to tell the Arduino when to capture the first measurement, the rest is very simple.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Flagstaff, AZ
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Peter, that is what I needed to know. It sounds like all of this is possible so I am going to proceed with the project. I just wanted to make sure I wasn't chasing my tail;) thank you for your input. I will be back later this week once I have had some time to set this up and start tweaking!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46291
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Thanks Peter, I checked and it will do 2cm to 3m so I should be good.
That's its range. Now, what about it's accuracy. 2 cm to 3 m +/- what? If the accuracy is only +/- 2 cm, displaying the value to 4 decimal places won't make it more precise.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 241
Posts: 24480
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You'll be very lucky to get anything like 1mm resolution, which equates to about 1/8th of a wavelength, or 3us at 40kHz.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Flagstaff, AZ
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You'll be very lucky to get anything like 1mm resolution, which equates to about 1/8th of a wavelength, or 3us at 40kHz.
Thanks AWOL. So you think being able to read at that resolution is not possible? Is there another sensor hat would be better for this application? I already eliminated IR as an option as it is affected by light and this would need to be used outside and inside. Cost is obviously an issue but I am open to whatever would be most accurate. The typical range would only span 10-30mm and I need to be able to read say 16mm reliably and not just 10,20,30mm increments if that makes sense:o
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 553
Posts: 46291
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Head over to the Robotics forum. There is a thread going there about a laser range finder. It might give you a sense, at least, of the difficulties that are involved in hands-free measuring distances.
Logged

Flagstaff, AZ
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Paul, I will do that. I really appreciate your input.
Logged

Flagstaff, AZ
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have ordered one of the Parallax laser range finders for $129 to test with. I am also going to test with the Ping and US-100 ultrasonic sensors to see what they can do. The wavelength issue makes a lot of sense with sound. I did find this video and he appears to get decent resolution with the ping but it may be misleading or just BS-
http://m.youtube.com/#/watch?v=0HqfN-JT4iw&desktop_uri=%2Fwatch%3Fv%3D0HqfN-JT4iw
I hope to test over the ext week and I will report any findings back here. If anyone else wants to chime in feel free!
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 149
Posts: 2790
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Johnny1212,

in retrospect, it would have helped if you had posted a good link to info on the US-100 sensor,
especially where to find the datasheet. All I've found so far are amazon and ebay ads for it,
which indicates it's yet another chinese knockoff, seling for about 1/4 the price of standard
sensors.

Pretty soon, we'll be able to buy EVERYTHING from china at huge discounts, and they'll own
all in sight :-).


Logged

Pages: [1] 2   Go Up
Jump to: