Author Topic: Low power optical displacement sensor - XY plane  (Read 2229 times)

0 Members and 1 Guest are viewing this topic.

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Low power optical displacement sensor - XY plane
« on: May 22, 2023, 09:50:56 am »
Hello.

I have a small project on my hands, which is turning out to be a little more complicated than I anticipated and I need your help.

The goal is to measure the X and Y displacement relative to a fixed point.
Ideally there can be no contact (but it's not imperative). We are talking about displacements on the order of +-100um over ~1month.

Thinking simply and stupidly, it reminded me of the optical sensors in computer optical mouse.
The problem is that they are made for huge frame rates (12k fps  :o), and comparing them to calculate the displacements.

Since the big manufacturer of this stuff - PIXART - does not make the complete datasheet available online, my question is:
Does anyone know if it is possible for the sensor to capture a frame, save it, go into deep sleep (command sent by an external MCU), after 10 days (for example) wakeup the sensor and capture a new frame to compare with the one already in memory, read the XY displacement calculation, repeat the whole loop again

I know that the answer to my question depends a lot on whether someone has access to the complete datasheet of some of these sensors and we are just theorizing... but it is worth a try  ;D.

Anyway, if anyone has another idea that can be used here I would greatly appreciate it!


Thanks.

 

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6511
  • Country: ro
Re: Low power optical displacement sensor - XY plane
« Reply #1 on: May 22, 2023, 10:21:41 am »
What's the total length over which the 100um resolution is needed?



For the mouse sensor, you can buy an entire mouse and modify only the optics.  If the project is a one off only, then use an old PS/2 mouse, that would be easier to read with any microcontroller.  If not use a SBC like Raspberry Pi, and read an USB mouse from Linux.

For reading the raw sensor data, you may find examples if you search for "mouse camera" or "mouse scanner".



Another solution might be to use a digital caliper.  Most of the digital calipers have a digital output that can be easily read and interpreted with any microcontroller.
 
The following users thanked this post: Dave_PT

Offline Marco

  • Super Contributor
  • ***
  • Posts: 6822
  • Country: nl
Re: Low power optical displacement sensor - XY plane
« Reply #2 on: May 22, 2023, 10:49:40 am »
Arducam has a CS mount microscope lens and CS mount camera modules for STM32 microcontrollers or ESP32. Though even a macro lens might be good enough with good image processing.
 
The following users thanked this post: Dave_PT

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Low power optical displacement sensor - XY plane
« Reply #3 on: May 22, 2023, 11:23:53 am »
Hi.
Thank you both.

@RoGeorge
The resolution will have to be on the order of 1um (but I admit ~10um) over a total displacement of max 5mm.

What I referred above is the displacement rate vs time, which is expected to be measured.

Connecting the mouse to anything raspberry related etc... will not meet my low power specs.
I have to have an average consumption of only a few tens of uA, given that the equipment will have to run over +-3 years powered by a small battery.

My first idea would be to adapt 2 calipers at an angle to get the X+Y shift. But that would add the use of a motion joint that might add extra backlash.



@Marco
I also thought about using a cheap omnivision camera. Implementing everything in an STM32 is not a very complex task... but before going that route I wanted to try other approaches.

The use of a mouse sensor would be more attractive to me because, although I want very low reading rates now, in the future it would be easy to increase to hundreds or thousands of readings per second. It would be something that could be used in other projects without redesigning the electronic project.

But if there are no other breakthroughs, the camera+processing solution is starting to gain some momentum...


 

Offline jmelson

  • Super Contributor
  • ***
  • Posts: 2797
  • Country: us
Re: Low power optical displacement sensor - XY plane
« Reply #4 on: May 22, 2023, 03:46:14 pm »
I think the mouse idea is the wrong way to go.  Get a microscope camera and have it hooked to suitable lenses so it looks at a "dot" on the moving part.  Then, every once in a while the light source turns on and the camera takes an image, or maybe several and averages them.  Then, common image processing software locates the centroid of the dot and records that data point.  The problem with the mouse is it is designed to detect MOVEMENT, ie. CHANGE of position, rather than absolute position.  I have an optical mouse, and the cursor randomly jumps halfway across the screen.  Using one of these would require no loss of absolute position for the entire duration of the measurement.  Recording the position of the dot would not have potential to lose the zero at some point in time, unless the camera/microscope was bumped.
Jon
 
The following users thanked this post: Dave_PT

Offline Martinn

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: ch
Re: Low power optical displacement sensor - XY plane
« Reply #5 on: May 23, 2023, 05:46:09 pm »
My first guess for this would be a 2D PSD: https://www.hamamatsu.com/us/en/product/optical-sensors/distance-position-sensor/psd/two-dimensional-psd.html
You did not specify the required accuracy, but I darkly remember they can resolve submicron motion (resolution, not accuracy), which perhaps might work for you. They'd be ideal for low power usage - just switch on the amplifier and LED (you use a small LED with lens to illuminate the PSD) and read the two values with two ADC channels.

Then of course as mentioned a camera. I'd use a pseudo random dot pattern with structure size about 20 um; chrome on glass, lithography film, PCB or printed paper with decreasing cost and accuracy.
Note that low power finite-corrrected microscope objectives (example https://www.aliexpress.com/item/33000366185.html) make great macro lenses, for best image quality use them at their design image distance (160 mm in this example). Use subpixel calculations for the fine and matching the pseudo random dot pattern for coarse positioning (if your range of movement is larger than your FOV).

For much better accuracy you could use LVDTs like those https://tesatechnology.com/en-gb/products/palpeurs-de-mesure/standard-axial-probes_f49281.htm with a flexure stage for decoupling although power for the amplifiers might be excessive. Maybe design your own?

Regarding calipers: Most are not "low power" as they have incremental sensors hence are switched on continuously. Current consumption is around 20-50 uA depending on model, switching off the LC display saves only 1 uA and is purely cosmetic. The single (patented) exception are Mitutoyo absolute calipers - they use two additional quadrature data tracks to read absolute position even after powered off completely. However calipers are specified to about 30 um accuracy, although you might get lucky and have 10 um (full readout) accuracy over a few mm.
 
The following users thanked this post: Dave_PT

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6511
  • Country: ro
Re: Low power optical displacement sensor - XY plane
« Reply #6 on: May 23, 2023, 06:05:42 pm »
5mm and 1um means 5000steps.  There are capacitive or inductive sensors that might work over such distance.

For example, this inductive to digital sensor from TI, some are 16-24 bits, and very low power, e.g. from the LDC family, like https://www.ti.com/product/LDC1041
 
The following users thanked this post: Dave_PT

Offline Conrad Hoffman

  • Super Contributor
  • ***
  • Posts: 1962
  • Country: us
    • The Messy Basement
Re: Low power optical displacement sensor - XY plane
« Reply #7 on: May 23, 2023, 07:34:42 pm »
Look at Allegro hall effect sensors. Usually a better choice than optical if size and simplicity are important. There may be others as well.
https://www.allegromicro.com/en/products/sense/linear-and-angular-position/3d-magnetic/a31315
 
The following users thanked this post: Dave_PT

Offline Georgy.Moshkin

  • Regular Contributor
  • *
  • Posts: 161
  • Country: hk
  • R&D Engineer
    • How to become a Tech Sponsor
Re: Low power optical displacement sensor - XY plane
« Reply #8 on: May 24, 2023, 10:28:41 am »
If you use camera approach, look into subpixel curves extraction algorithms. Some time ago I tried to perfect image processing algorithm to use in accessibility product, and later for accelerometer and gyroscope-less quadrocopter (used in case of failure or camera-only approach). There are a lot of papers on curve tracing/extraction with subpixel resolution. I've done feasibility tests using algorithm based on Hessian matrix calculations. When done in integer, it is very fast, and I think that much better approach than Hough transform. You can generate two images, perform thresholding, calculate Hessian matrix, and have angle at each point encoded in colors (red,green). Then you compare offsets between those two images using some other algorithm. Because angular information at each point is pretty unique (red/green channels for x/y coordinates of normal or tangent vector), it is very robust and filters out erroneous offset estimations naturally. I haven't done subpixel calculations, but maybe simple parabola algorithm through three pixels will provide acceptable results.
« Last Edit: May 24, 2023, 10:31:15 am by Georgy.Moshkin »
Disappointed with crowdfunding projects? Make a lasting, meaningful impact by becoming a Tech Sponsor today. Visit TechSponsor.io to Start Your Journey!
 
The following users thanked this post: Dave_PT

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Low power optical displacement sensor - XY plane
« Reply #9 on: May 25, 2023, 07:22:21 pm »
Thanks for the suggestions!  :-+ :-+ :-+


@jmelson
You are completely right and I couldn't agree more.
However I was hoping that there would be a variant of these sensors that would allow you to trade speed for resolution and accuracy.


@Martinn
I didn't know 2D PSD. Is Hamamatsu the only one that has this type of sensor?
From what I know of Hamamatsu, they are very good...but quality comes with a price.

The use of the lens + camera is solidifying as an excellent medium-cost idea.
Using artificial light and controlling what the camera sees (a cupola in 3D printing for example), you won't even need to do much processing. Just run the pixels and find the coordinate of the DOT.
Actually I hadn't thought of using a cheap PCB, but it will be easy to find a small silver circle on the green soldermask.


@RoGeorge
My problem with capacitive sensors (and other similar like hall, eddy current, etc...) is that they depend on my sensor construction.
There will always be a problem related to calibration: capacitance vs distance.
Since the surface can move in X+Y I would have to mount 2 sensors (e.g. LDC1612) and I am not sure how the geometry of the object would affect the result of the readings (in order to have a correspondence with X+Y distances).
It is not something that is ruled out. I have to study further the configuration of the object to be detected and the response of the sensor in a 2 direction movement.


@Conrad Hoffman
I had given up on Hall sensors at first, because I have to do a calibration that might be difficult to do, especially if the sensor response vs distance is not linear.
One thing I was concerned about with these sensors is that the magnet and the sensor will not be in a temperature controlled environment. This represents changes in the magnetic field and also induces error in the sensor measurement.
This is the most cost-effective solution if the error tolerance is acceptable.
However, this sensor from Alegro is much more complete than any other I've seen (I've seen some from Melexis and Infineon) and so I'll have to take another look!


@Georgy.Moshkin
I don't have much background in those topics, but I'll give it a study too. We are always learning.
I found this article "Sub-Pixel Waterline Extraction: Characterising Accuracy and Sensitivity to Indices and Spectra" and it will merit a read later today.
 

Offline Georgy.Moshkin

  • Regular Contributor
  • *
  • Posts: 161
  • Country: hk
  • R&D Engineer
    • How to become a Tech Sponsor
Re: Low power optical displacement sensor - XY plane
« Reply #10 on: May 26, 2023, 12:41:16 am »
@Dave_PT
My bad, I should have given you a link. Here is a paper and a thesis explaining Hessian matrix application, this would be enough to make an algorithm. Very practical. Use this, believe me I've tried many algorithm to do the same thing different ways. It is MCU friendly if done in fixed point (32bit integers with left/right shifting when needed):
1) CURVE TRACING AND CURVE DETECTION IN IMAGES.pdf
2) Extraction of Curved Lines from Images.pdf

« Last Edit: May 26, 2023, 12:44:23 am by Georgy.Moshkin »
Disappointed with crowdfunding projects? Make a lasting, meaningful impact by becoming a Tech Sponsor today. Visit TechSponsor.io to Start Your Journey!
 
The following users thanked this post: Dave_PT

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6511
  • Country: ro
Re: Low power optical displacement sensor - XY plane
« Reply #11 on: May 26, 2023, 07:25:55 am »
How does the curve detection compares with the Optical Flow algorithm?
https://en.wikipedia.org/wiki/Optical_flow

Asking because I've read the optical-flow algorithm is the one used in a computer mouse, and not the curve detection.  I've heard about optical-flow as being the most simple and efficient, for example it's being used by insects for vision.  Their eyes resembles a low resolution camera.  Never went into details, so I was curious if you have had the opportunity to compare the two, optical flow vs curve detection.
 
The following users thanked this post: Dave_PT

Offline Georgy.Moshkin

  • Regular Contributor
  • *
  • Posts: 161
  • Country: hk
  • R&D Engineer
    • How to become a Tech Sponsor
Re: Low power optical displacement sensor - XY plane
« Reply #12 on: May 27, 2023, 08:03:19 am »
I have no experience with optical flow. I personally see subpixel curve extraction more straightforward, you extract geometry for two frames, then measure rotation/ translation. High tolerancy againsy lighting conditions and image noise/dust. Easier to understand how many pixels do you need and what accuracy do you get. With optical flow probably safer to accumulate over days. Big advantage is that optical flow is easy to test, many open source projects and tutorials.  What do you think?
Disappointed with crowdfunding projects? Make a lasting, meaningful impact by becoming a Tech Sponsor today. Visit TechSponsor.io to Start Your Journey!
 
The following users thanked this post: Dave_PT

Online RoGeorge

  • Super Contributor
  • ***
  • Posts: 6511
  • Country: ro
Re: Low power optical displacement sensor - XY plane
« Reply #13 on: May 27, 2023, 08:34:25 am »
I didn't study and didn't try to implement any of the two, so can not draw any conclusion.  That's why I was asking, in the hope you or somebody else already compared the two, and can sum up the pros and cons for each.
 
The following users thanked this post: Dave_PT

Offline Georgy.Moshkin

  • Regular Contributor
  • *
  • Posts: 161
  • Country: hk
  • R&D Engineer
    • How to become a Tech Sponsor
Re: Low power optical displacement sensor - XY plane
« Reply #14 on: May 27, 2023, 11:57:18 am »
Optical flow
Pros:
- A lot of information available, easy to experiment, e.g. with OpenCV
- Probably will work better on a grainy surface (no scratches for line extraction)
Cons:
- needs more processing time for large displacements
- brightness changes may accumulate as wrong speed V, this error will contribute to displacement S=V*t

"Vectorization" of edges
Pros:
- Two images enough for displacement estimation. Even for large displacement and rotation by some arbitrary angle, e.g. by 185°
- Processed data size is very small
Cons:
- Probably fail on grainy surfaces, needs some edges/scratches
- Sensitive to image scale (there is optimal scale at which Hessian matrix will give best result). Or need to use larger processing time.
Disappointed with crowdfunding projects? Make a lasting, meaningful impact by becoming a Tech Sponsor today. Visit TechSponsor.io to Start Your Journey!
 
The following users thanked this post: Dave_PT, RoGeorge

Offline Dave_PTTopic starter

  • Frequent Contributor
  • **
  • Posts: 315
  • Country: pt
    • DavidMartinsEngineering
Re: Low power optical displacement sensor - XY plane
« Reply #15 on: May 27, 2023, 04:10:40 pm »
I will be moving forward with the design of a simple board to test some of the options discussed here.

The optical analysis is getting me very interested... but it may take a longer development.
There is still the possibility of the magnetic 3D sensor, despite some drawbacks.

I want to test both.

But since we are discussing this, I wanted to ask your opinion about the following:
Instead of using just one magnetic 3D sensor, I've been thinking about using 2 or 3 such sensors.
Please consider the attached image (3 sensors separated 120º in a circle).
If the magnet is always in the middle of the sensors it will be possible to calculate the angle of the magnet on each sensor and cross check the measurement of the 2 sensors to know the position of the magnet.

But I have many doubts about the degree of error accumulated due to measurement errors. On the other hand, with more sensors the error is reduced a bit.
Trying to visualize the magnetic field is not easy.
For example a neodymium magnet (disk 6mm x 3mm) in a 16-bit sensor (pe MLX90392), I can not calculate how much corresponds to a displacement of 1mm for example.
Although the full scale is 16bit, I can just as easily have variations below 8bit...
Any suggestions for simulation?



Thank you all!
 

Offline Martinn

  • Frequent Contributor
  • **
  • Posts: 324
  • Country: ch
Re: Low power optical displacement sensor - XY plane
« Reply #16 on: June 02, 2023, 07:19:57 pm »
I didn't know 2D PSD. Is Hamamatsu the only one that has this type of sensor?
From what I know of Hamamatsu, they are very good...but quality comes with a price.

The use of the lens + camera is solidifying as an excellent medium-cost idea.
Using artificial light and controlling what the camera sees (a cupola in 3D printing for example), you won't even need to do much processing. Just run the pixels and find the coordinate of the DOT.
Actually I hadn't thought of using a cheap PCB, but it will be easy to find a small silver circle on the green soldermask.
PCB: Soldermask is inaccurate, make your fiducials (dots) on a bare PCB surface. Don't use HASL, as it is imprecise as well, either ENIG or chemical tin.
Illumination wise the dots should be somehow matte, for a mirror-like reflective target you need coaxial illumination (beamsplitter), otherwise side illumination is simply reflected away.
I doubt you get away with a single dot. With 5 mm FOV and micrometer (precision, resolution?) you'd need a high resolution sensor and a macro lens that is razor sharp to the edges. Better have smaller FOV for which you need several markers. Using a non-regular (pseudorandom or maybe just varying distance) you can find out where the dot in the FOV belongs.

Anyway I think you need to somehow substantiate your accuracy requirement. A stable 1 um absolute precision is metrology grade and accordingly difficult. At that level, every component you add is a thermometer. So unless you are in a temperature controlled lab, you'll have to be very careful about your construction. A camera would be more difficult because of the overall size of the lens/sensor assembly.
Maybe a stable readout of like 5 um (RMS noise 1 um) with repeatability of 10 um and linearity 100 um sounds more realistic. You can linearize the measurements if the are stable enough.

It seems you don't intend to follow up on the PSD, so I need to do more advertising. They are kind of exotic and maybe a bit old school, but have very interesting properties useful for specialized uses.
I have only been aware of Hamamatsu, but a quick search yielded other manufacturers as well. They are not cheap (it seems $20-$50 is realistic), ask Hamamatsu for a quote. RS has them in stock (not sure about MOQ), also I found some on Aliexpress (fake?). However they are far less expensive than any decent machine vision lens.
We used them for measuring the settling time (XY) of a high speed precision positioner, to sub um resolution (I darkly remember, although I am not sure). Nice property here is you get easily kHz output bandwith, try this with a camera (1000 fps high speed camera!). Your use is the opposite of course.
They are ratiometric devices, a property very helpful for precision measurement. You just get a handful of voltages you need to digitize (12 to 16 bit, depending), giving you the "center of gravity" of the beam. No need for fancy illumination, we used a tiny THT LED with a lens, in your case I'd use a metal mount with a tiny hole drilled in front as aperture (I once asked the workshop to drill a 50 um hole for a similar application, which they did on their CNC machine without breaking off a single drill bit).
For better than 100 um accuracy I guess you will need to linearize the readout.

You'll need a solid positioning, most likely machined metal (watch TC), certainly nothing hot-glued or 3D printed as this woud drift far more than your measurement accuracy within a month.
Camera solution is more difficult, as depending on focal length the overall camera tube length might be > 100 mm, which means a tiny  tilt of the camera assembly (temperature!) might already give an offset.
PSDs are much easier here, as you can have LED (possibly within mount with aperture) very close to the surface of the chip (depending on expected Z movement), so tilt has a far lesser impact.
 
The following users thanked this post: Dave_PT


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf