Very Low Cost Linear Position Sensor - Page 1
Forum section: electronics / projects

author: Dubbie
author_rank: Unknown
timestamp: May 13, 2018, 09:17:38 pm
content: Hi,I have a situation where I need a very low cost ($1-2) way to measure the linear position of a drawer type of object.The amount of movement is about 300mm and I need to detect the position with about 25mm accuracy.The drawer itself is removable, so it cannot be wired to anything. There are many narrow (50mm) drawers, so a solution that can work without interfering with its neighbor is necessary.I have looked into many solutions including IR position sensing(large board to hold many IR transceivers too expensive), Sonar (beam too wide, transducers too expensive), Laser rangefinding (actually surprisingly cheap using VL53L0X!)None of these solutions really hit the pricepoint.One thing I was wondering about, was is there some way that I could make flexible circuitboards with some sort of coil and measure their offset? Problem is, there may be metal objects inside the plastic drawers.If anyone has any ideas I'd be interested to hear!R

author: Gyro
author_rank: Super Contributor
timestamp: May 13, 2018, 09:48:55 pm
content: A bell crank and an ordinary rotary pot?

author: branadic
author_rank: Super Contributor
timestamp: May 13, 2018, 09:55:41 pm
content: Only a few ideas:- a simple differential, capacitive sensor based on electrodes on a printed ciruit board- a printed circuit board based LVDT- optical sensor based on the CCD of an old scanner- a simple linear potentiometer- transfer linear movement into a rotation and use a rotary encoder- use a cheap caliper- make yourself a linear optical encoder with some black/wite stripes on a paper and a light barrier-branadic-

author: Dubbie
author_rank: Unknown
timestamp: May 13, 2018, 10:05:34 pm
content: Thanks for the ideas branadic and gyro- a simple differential, capacitive sensor based on electrodes on a printed ciruit boardThis is something I'm interested in. Not 100% how this works.- a printed circuit board based LVDTAlso interested in this. Again, not 100% on how this would work practically- optical sensor based on the CCD of an old scannerI need thousands of these. Surplus is not an option.- a simple linear potentiometerNone I've found come remotely close to my pricepoint.- transfer linear movement into a rotation and use a rotary encoderToo expensive and difficult to design around a removable drawer.- use a cheap caliperGot any links for 50c calipers?- make yourself a linear optical encoder with some black/wite stripes on a paper and a light barrierThis is something I have considered. Some sort of gray code on a sticker and a row of IR TXRX This is probably my leading solution at the moment.

author: sokoloff
author_rank: Super Contributor
timestamp: May 13, 2018, 10:22:53 pm
content: Outside the box: could you treat it as a computer vision problem and sense all the drawers at once using a webcam and Raspberry Pi (or similar price and performance computer)?Then, you might be able to arrange a target of known size and high contrast on the back of drawers and sense position and size of each target found. Computer vision has come a long, long way in the last couple years.

author: Dubbie
author_rank: Unknown
timestamp: May 13, 2018, 10:48:50 pm
content: Good idea sokoloff, One I had considered before.Unfortunately the physical construction of the cabinet precludes seeing the drawers all at once.

author: Conrad Hoffman
author_rank: Super Contributor
timestamp: May 14, 2018, 12:15:11 am
content: Can you do anything to the drawers? I'm thinking paint the back sides some consistent light color, or put a sticker on them. Then do a photo detector based on nothing more than return signal. There was the old Polaroid sonic distance sensor, and you can buy the necessary transducers, but I think cost might be an issue. It can be done with a single transducer too, basically sonar. Ping it and look for the reflection. If you have access to the sides or bottom, convert the long motion to something short with a wedge, then sense that with any number of things, maybe an optointerruptor, a cam follower on a pot, an inductive sensor (needs a metal wedge) or even capacitance. For any of the optical methods, modulate it and use IR so ambient light doesn't interfere.

author: Dubbie
author_rank: Unknown
timestamp: May 14, 2018, 01:35:48 am
content: Yes, I can put a sticker on the bottom of the drawer.I'm thinking of using 5bit grey code and a row of 5 IR phototransistors. I think I may be able to use probably two IR LEDs for illumination so long as the receivers are shielded somehow.This board could run from one side of the cabinet to the other but only be 10mm wide so would be relatively cheap. The challange will be driving and reading all the diodes for under the budget. I'm thinking sharing a single $2 uC between 10 drawers and doing all the driving and reading on that. I could use some sort of serial to report to the main controller all the positions.Something like the STM32F058R8H6 would do.

author: Conrad Hoffman
author_rank: Super Contributor
timestamp: May 14, 2018, 02:29:10 am
content: That should work. You can usually find flat phototransistors molded in black IR transmitting plastic. Just don't design it for 5 bits and later discover they wanted it just a tiny bit better. It happens every time.

author: Kleinstein
author_rank: Super Contributor
timestamp: May 14, 2018, 04:28:59 pm
content: 300 mm with 25 mm resolution is just 12 positions. This might work with a simple analog intensity coding after a learning / adjustment (e.g. with drawers all the way in). So on could get away with a single graded gray reflector.The capacitive sensing is also still an option. Some µC (e.g. some PICs) have hardware for detecting capacitive keys or similar sensors. There are several options to make the drawer to change a capacitance in the 10-50 pF range, or cross capacitance in the 1-10 pF range.

author: 2N3055
author_rank: Super Contributor
timestamp: May 14, 2018, 04:50:13 pm
content: Photointerrupter or reflective sensor and linear gray code line (reflective or transparent or comb one). It can be absolute encoder.Also begin and end sensor and relative encoder. You can use encoders used for wheeled mice....

author: james_s
author_rank: Super Contributor
timestamp: May 14, 2018, 05:06:54 pm
content: I like the capacitive sensor idea. Essentially you attach one plate to the drawer and the other plate near it. The further the thing is opened, the less the plates overlap and the lower the capacitance. Think of it as an old style variable capacitor as used to tune a radio but stretched out into a line.

author: Dubbie
author_rank: Unknown
timestamp: May 14, 2018, 09:32:02 pm
content: I'm going to play around a bit with the STM32 touch functionality.Thanks to everyone for their contributions.R

author: NiHaoMike
author_rank: Super Contributor
timestamp: May 15, 2018, 03:15:28 am
content: Read a little about how digital calipers work and then design an easy to DIY, less precise version?

author: Doctorandus_P
author_rank: Super Contributor
timestamp: May 21, 2018, 08:07:09 am
content: I would also start experimenting with a capacitive sensor.If you want the drawer to be "removable" I assume this means you do not want wires connected to it.You can glue a big piece of aluminimum foil in the bottom or side of the drawer.Then use two wide conductive strips for your "electrodes".One couples the signal into the alu foil, the other coples the signal from the alu foil back into your "electrode".Then measure the capacitance of these 2 capacitors in series.Note: The capacitance will also depend a lot on the distance between the electrodes, not only on the "overlap".Therefore the bottom is better suited than the side of the drawer, gravity will take up your slop.Alternatively, you can use a row of short sensor electrodes on one side.Then the capacitance of each of these sensors will increase if the drawer is closed.This is becoming a bit similar to how capacitively coupled callipers work.What kind of reliability are you looking for?You could use some push pins and something that rubs over it to make a row of mechanical switches.

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 21, 2018, 06:06:10 pm
content: Quote from: Dubbie on May 13, 2018, 10:05:34 pmIf you used four channels, with 0000/1111 reserved for "completely outside", you'd have 15 positions for 300 mm, or 20mm per position. If you used US Letter printable sticker paper, with about 10mm margins, you have 260mm of printable length, so 18mm per position, or about ±9mm accuracy.Perhaps you could use a common sample/latch signal, and each set of IR/optical sensors tied to a shift register, so you'd simply trigger the common sample/latch to latche all optical sensors, then shift them one bit at a time? You'd need just three data lines (two outputs: sample/latch, and clock; and one input, data), one latching parallel to serial shift register and up to eight optical sensors per drawer. Maybe 74HC165 series? The optical sensors seem to be the most expensive part. Might have to do your own using a LED and fototransistors?If you do the drawers in pairs, with 15 positions (with 0000 or 1111 reserved for "out", depending on which pattern you get when there is no strip detected at all), you could use a single 8-bit shift register per pair of drawers, and halve the number of cycles needed to shift all the bits to the microcontroller.At 500 kHz clock rate (I have no idea whether that is realistic!) you could then read 62500 drawers per second. Something like a Teensy 3.2 which has 64k of RAM, could remember the positions of each drawer, and only provide the changes to the consumer (and all states if requested, or at specific intervals, like once every few seconds).This would be what I'd try, with no guarantees of it working.

author: Dubbie
author_rank: Unknown
timestamp: May 21, 2018, 07:11:30 pm
content: Good idea regarding the shift register!I will try that. I have had good success using a phototransistor with led illumination for the reading. Because the channels are adjacent, it’s easy to find the 1/0 levels as long as there is at least one zero or one.

author: janoc
author_rank: Super Contributor
timestamp: May 21, 2018, 07:20:06 pm
content: Guys, don't over-complicate things.Just pick one of these:http://www.st.com/en/imaging-and-photonics-solutions/vl53l0x.htmlOr a simple ultrasonic ranger - modules can be had for a buck or two in the usual places,e.g.:https://www.aliexpress.com/item/US-015-Ultrasonic-Module-Distance-Measuring-Transducer-Sensor-Detector-Ranging-Module-DC/32811614766.htmlIf the accuracy needed is only 25mm, then these would be even an overkill - but the advantage is robustness, it is simple to interface (serial output) and being contact-less/wireless (no need to install anything on the moving part).

author: JohnnyMalaria
author_rank: Super Contributor
timestamp: May 21, 2018, 07:28:19 pm
content: Tapered reflective strip down the side of the drawer and an LED and photodiode at a fixed position on the cabinet. The output from the photodiode will be proportional to the width of the strip and, hence, position. (I designed an optical guitar pick-up with separate sensors for each string using this concept. It was stupidly cheap.)

author: metrologist
author_rank: Super Contributor
timestamp: May 21, 2018, 07:30:48 pm
content: I got an easy solution, unless I missed a requirement... It even has redundancy

author: Marco
author_rank: Super Contributor
timestamp: May 21, 2018, 08:13:54 pm
content: I doubt you will be able to beat reflective gray code sensing for ease of engineering and cost.That said, the main problem with sonar seems to me the width of the beam ... piezo discs cost next to nothing. I wonder if you could make some kind of passive backscatter modulator. That way the sender wouldn't be listening for a reflection (which could come from the sides) but for the modulated response from something attached to the drawer.

author: janoc
author_rank: Super Contributor
timestamp: May 21, 2018, 08:17:09 pm
content: Quote from: Marco on May 21, 2018, 08:13:54 pmThe width of the beam of these cheap sensors is about 15-30 degrees. If you mount in the middle, there is little chance for it to get confused by another echo.

author: Dubbie
author_rank: Unknown
timestamp: May 21, 2018, 09:03:24 pm
content: thats an intriguing idea regarding the backscatter modulation. although I worry that if you have one drawer at say 30% position, and the other at 100% open, the closer one (they are only 50mm wide remember) will overwhelm the far one. The drawers are made of plastic.

author: janoc
author_rank: Super Contributor
timestamp: May 21, 2018, 09:22:23 pm
content: Well, why don't you buy one of those sensors and test it? They cost next to nothing so even if it doesn't work, you didn't waste money.The optical time of flight sensor from ST I have linked would work for sure, with no interference. There are breakouts for it available on AliExpress and elsewhere too if you don't want to make your own board (it is a PITA to solder).

author: Dubbie
author_rank: Unknown
timestamp: May 21, 2018, 09:45:25 pm
content: I will buy one.I bought the laser sensor from ST to test.It's a bit fiddly to set up but it works fine. It's just a bit more expensive than I would like.

author: janoc
author_rank: Super Contributor
timestamp: May 21, 2018, 10:33:50 pm
content: Yeah the laser rangefinder is a bit of an overkill for your needs also.Another idea that may work is simply installing an IR diode and a phototransistor and measuring the intensity of the reflection. It is not super accurate and likely won't work for more than 50cm distance but for a drawer that is likely plenty enough already. I have seen this used for some novelty MIDI instruments in the past and it works reasonably OK.