Measure short range (0 - 33cm ideal, 2-33cm acceptible) with up to 6mm accuracy

I'm looking around and it looks like its mostly about long range distances.

The stuff I find that will measure "shorter distances" can only detect the binary presence of an object up to a threshold distance, and will then begin to measure the actual distance.

Doing a forum search, everyone measuring comparable distances are looking for accuracy on the order of a couple hundred micron.

In my particular instance, I'm okay with accuracy up to 6mm (even 10mm is probably okay).

The issue is that threshold distance matters to me - I want to measure as close to point blank as possible. Could I live with 1cm to 033cm? Absolutely. 2cm - 33cm? Even if the only option gets me 3cm I could probably live with it as long as that accuracy is there. Anymore than that and it fails to be viable.

My main limitation is it needs to be some kind of laser/ultrasonic approach. I can't go a mechanical route.

If there is nothing off the shelf, but a great resource that will teach the design so one could try to build towards that I would be amenable to it as well.

So it really boils down to this - are there solutions that will work, or do I need to study up on some design and make it applicable for what I'm looking for.

Requirement: 2-33cm
Accuracy: 10mm

6 mm at the speed of sound 340,000 mm/sec => a reaction time of 6/340000 = 6000 / 340 usec = ~17 usec
that is pretty short.

most ping code uses an integer division to convert time to distance. You might take multiple measurements and average them and then convert to millimeters

unsigned long sum = 0;
for (byte i=0; i<8; i++) sum += ping();
distance = sum / 8.0 / 29 /2; 

distance = sum * 0.125 * 0.0034 * 0.5; // multiplication is faster than division

distance = sum * 0.0002125; // one multiplication is faster than 3

distance = sum * 0.002125; // to get millimeter iso cm

I expect you need 8 samples to get a reasonable average.

You can find off-the-shelf solutions - google "laser displacement sensor" and "laser distance sensor" - just don't expect them to be inexpensive.

robtillaart:
6 mm at the speed of sound 340,000 mm/sec => a reaction time of 6/340000 = 6000 / 340 usec = ~17 usec
that is pretty short.

most ping code uses an integer division to convert time to distance. You might take multiple measurements and average them and then convert to millimeters

unsigned long sum = 0;

for (byte i=0; i<8; i++) sum += ping();
distance = sum / 8.0 / 29 /2;

distance = sum * 0.125 * 0.0034 * 0.5; // multiplication is faster than division

distance = sum * 0.0002125; // one multiplication is faster than 3

distance = sum * 0.002125; // to get millimeter iso cm




I expect you need 8 samples to get a reasonable average.

This interests me; did you have one in particular mind? I was looking around the past few days, and the MaxSonar seems to be the most talked about item, yet based on some reviews I'm seeing that anything within ~6" is reported back as 6". Are you referring to something else, because even if I take 10 samples as an average, if all samples report 6" for 0< 6"...well that doesn't help me

I was thinking about one from sharp like this - https://www.sparkfun.com/products/12728 -

If object is really close you could use the steep curve on the left of the peek.
But yes the signal is ambiguous

Yeah I already ordered it once I looked through everything last night. I'm glad that it was the same item. We'll see how it performs and I'll do my best to try to provide some updates here.

I'm especially curious how big the beam is, and if I'm going to get a lot of false measurements as I'll be using it in a ~3.5" wide cylinder.