Measuring Distances with Ultrasonic Sensors

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!

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.

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

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

oric_dan(333):
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!

Johny1212:
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.

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;)

Johny1212:
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.

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!

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.

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

AWOL:
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

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.

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

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-

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!

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 :-).

oric_dan(333):
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 :-).

Good point. I am actually testing with that and also trying the Ping. I hear you on the China thing. I am trying to find an alternative to my iPhone that is made in the US but it seems like every one is made in China, specifically Foxconn. I just feel guilty knowing the conditions and pay those people endure. If anyone knows good sensors manufactured here I would be happy to pay the extra money;)
Here is the guide for the ping-
http://www.parallax.com/Portals/0/Downloads/docs/prod/acc/28015-PING-v1.6.pdf
More than anything I was referencing this type of sensor. Also, if anyone knows of any cheap laser sensors that would be great. 2D is fine as this will be a single static point being measured;)

We all know where the Ping info can be had. The question is how to find the data
on an offbrand device made in China.

knows of any cheap laser sensors

I'm not sure 'cheap' belongs in a reference like this. Parallax does sell a laser device you
can check about.

Thanks, I do have a Parallax on order. As far as the US-100 it was more of a question on ultrasonic sensors being capable of measuring in mm;) I will be testing with all of these to see if any fit the bill. I really appreciate everyone's input!

Alright, I have this setup and working with the Ping sensor and 16x2 serial dispay. Currently I get a reading in mm showing the actual distance to an object and it seems fairly accurate so I want to move on to my next need.

I need to display the difference of an initail value minus the current value. Basically I would turn the unit on and point it at the object. I would like to capture that value and then use it to subtract the real time value from that initial reading. If the value is 200mm I would want to subtract that from all future readings so looking at the same distance it would read 0 (200-200=0 and print 0 to the LCD rather than 200) and as the object comes closer it would read the difference i.e. 200-150=50 and print 50 to the LCD. I figure if I could have a button to capture the intitial value then use it to produce results from there it would do what I am trying to accomplish. I am just not sure how to accomplish this. If anyone has any input on how to do this,code or command examples or a better way of looking at this I would greatly appreciate it;)

Johny1212:
200-150=50

What you're looking for is called 'subtraction'. You need to store your reference value in a variable, and then 'subtract' the reference value from your measured value to get the display value. You need some way to tell the Arduino to store the reference value, for example using a button.