Distance Measuring

Hi, I was wondering if an arduino would be an ideal candidate for this operation.

I am in need of measuring an object that in a perfect world is 20cm away from my sensor. The sensor should measure a difference within a 5mm with a resolution of .1mm

we are measuring the height of a cart from a fixed point. The carts are moving in a line and a cart has multiple variables like wheels and cams that fail that cause it to "sag" and we need to measure the amount of sag to verify if the cart needs repair.

Can the arduino do this and which sensor would be recommended. IR or US?

Thank you.

That's not an easy one. Getting 0.1mm resolution out of an ultrasonic sensor will require measuring the air temperature and correcting for the speed of sound changing.

Does it have to be an Arduino? I'm thinking that aiming two lasers so that they cross at the threshold height and just looking at the dots will be more accurate for your workers. If it must be an Arduino, then a light sensor does the same job as one of the lasers. Put a barrier so it can't see the dot when it goes above or below your threshold.

0.1mm accuracy using sound implies a timing resoution of about 290 ns, or about 4 or 5 clock cycles of a 16 MHz Arduino.

Echo ranging might be out of the question, but continuous measurement of changes in distance using phase comparison of the reflected signal might be more feasible, and would be less susceptible to temperature changes. However, this would either require more analogue electronics, or faster data capture and DSP than the standard Arduino.

Optical non-contact displacement sensors based on lasers and parallax are readily available.

A Sharp IR distance sensor might work in your case. The model with a 10 cm to 80 cm range (https://www.pololu.com/product/136) would be your best bet for measurements at 20 cm. Getting 0.1 mm resolution will be difficult. Because you would be measuring a very small range of output voltages you would probably have to use analog comparators to turn the output voltage into a GO/NO GO signal that the Arduino could then read as digital. The distance range of 17 cm to 27 cm produces an output voltage range of about 1.5V to 1.0V. That's 0.05V/cm or 500 microvolts per 0.1 mm. The A/D on the Arduino can't do that but an external A/D might.

The sensor should measure a difference within a 5mm with a resolution of .1mm

First just what do you mean by the above it makes no sense. Do you want a difference of 5mm which is a resolution or do you want a resolution of 0.1mm Which is it?

Second you have it backward - first find a sensor that can do the job (which ever it is) then ask if that can work with the Arduino. If the sensor has the right inerface (eg SPI/I2C) then you can doit. BUT FIRST FIND THE RIGHT SENSOR!.