Distance sensor 5cm - 30cm

Hi,

I am looking for a distance sensor that can accurately (within 2mm-3mm) detect the distance of various objects that will be anywhere between 5cm and 30cm away from the sensor.

Any help appreciated.

The client ism after several hundred units so I want to make sure I get it right

Thanks in advance

Dale.

I’ve got some ideas, what objects are you measuring and what’s the typical environment?

Measuring foot length from heel to big to when placed on a purpose built box. I had it working with ultra sonic sensors really accurately but they don’t work with socks on.

sorry, the area for the box the sensors are built into is 400mmX250mm and the toe goes up against one end and I want to measure how far the heel is from the back of the unit. So typical distances are 15-20cm. I need to get it within half a centimeter if possible.

With different types of socks in the mix, it could get difficult with sound or light-type distance sensors.

Thinking outside the box, what if you used a camera. A camera with a NoIR filter would offer better contrast of objects (use material on the base/bottom that absorbs IR, creating a strong visual highlight between the heel and the base).

Coupled with a Raspberry Pi (model A+ has fast boot speeds and good performance), you could analyse tens of images per second and count the number of pixels from the bottom to the first non-conforming dot. Compare that against a calibration of “pixels to millimetres” and you’ve got the size of someone’s foot (using the smallest value).

Low power mode could be entered (1 photo per 2 seconds, or something) if foot length is <Xmm for a period of time.

Using IR gives the added benefit of not being eye-visible if using an extra IR LED to provide flood lighting.

The main issue here is focal distance, for the RPi cameras that is about 50cm. However, there are so many ways to change that, the easiest is using a macro lens.

Some ideas that hit me after typing:

  • The number of pixels for RPi cameras is 3280 x 2464 (the first is the x-axis). You could orientate the camera so that the higher resolution is instead used for the y-axis (distance to heel).
  • Taking the single-smallest distance might be dangerous for dust, minor damage on the base etc. Perhaps measure the number of pixels of a typical back-of-the-heel (let’s say it’s 50 pixels) and then halve it (to accommodate different body types and unforeseeable situations). After the initial scan across the X-axis, from the Y-axis data, use the 25 (50/2) lowest values. Then take the median average (not mean average) of those. You’ll be left with data that is highly resistant to visual noise / small marks / etc.
  • The base material could be something with a smooth surface that reflects light, such as stainless steel, which bounces light off and into the heel (away from the camera). It may help with forming contrast with socks/heels/anything on the base.
  • The reciprocal is a base surface that absorbs IR, though it might not perform as well in some environments (or against wear and tear), but that’s just a hunch.