Detect short distance with very small sensor?

This may be totally impractical, but maybe someone has some bright ideas.

I would like to be able to drive a model train locomotive by computer control to couple with a wagon and it would be very useful for the loco to know when it was at the right distance for the coupling to have been made. Then it could stop and not push the wagon backwards.

The distance between the loco and the wagon would be about 10 mm and the area on the end of the loco (or wagon) where the sensor could be located would be about 20mm wide by 6mm high.

I don't think it would be practical to have any sensors on the baseboard because that would imply that coupling could only happen at specific locations

The locomotive has an Attiny84 and an nRF24 for wireless control but I could use an Attiny1634 if more capability is needed.

Logically the system needs to be able to send a message to the loco "move fwd at low speed and stop when the closeness sensor is triggered"

...R

Maybe something like this? It's available for different distances, too. Neuhold Elektronik die Fundgrube für den Hobby-Elektroniker Reflexions Lichtschranke OPB743

Vishay have some tiny proximity sensors which can register between 1mm and 200mm.

This one is I2C so You wont be able to use it with the ATTINY84 together with the SPI radio part, but maybe you can find another one which suits better:

Interesting problem. Distance sensors may work, if the wagons are the same shape so you have a proper distance reference. Or maybe you can go the "when the distance doesn't decrease any more, we're pushing" route.

Other wild ideas that may or may not work with this problem:

  • switch in the coupling, that closes as the wagon pushes back on it.
  • related to the first: pressure plate of sorts (piezo? FSR?) in the coupling.
  • some kind of torque sensor on the motor - torque required to move the locomotive increases upon coupling.
  • vibration sensor of sorts, that feels the impact of the connection being made, or a click of the couplings closing.
  • little magnet on the wagon's coupling, hall or reed switch on the locomotive's coupling.

Same maker as zwieblum's post but smaller: https://www.digikey.com/product-detail/en/tt-electronics-optek-technology/OPB9000/365-2083-1-ND/6569293 (SMD).

Many thanks for the suggestions so far - keep them coming.

The OPB743 mentioned in Reply #1 does not seem to have sufficient range.
The OPB9000 mentioned in Reply #4 does seem to have the range. However, thinking more about it, that sort of device is generally intended to detect a change from dark to light (or vice versa) as when a stripe on an object comes into view. I want something that can be facing the reflecting surface and gradually getting closer to it until it says "stop" at the right moment. I don't think simple reflective sensors are intended for that application.

The Vishay proximity sensor mentioned in Reply #2 looks interesting, although relatively complex to implement. And it is an SMD component.

I think the mass of any wagon would be so low that there would be no detectable force either within the motor or between the loco and the wagon - and ideally I want the loco to stop just before it moves the wagon.

Magnets are always an attractive idea.

The train is approximately 009 scale - 1:76 scale on 9mm track to represent narrow gauge trains.

...R

Sensors like that Vishay one are used in phones to detect when the phone is up against your ear so it can disable the backlight and buttons.

As such, they are relatively complex and may be looking at details like the blood flow under your skin.

A QRE1113 is good for this kind of short distance. It would be somewhat sensitive to the color of the wagon but maybe you can put a dot of paint on the matching spot on every wagon so they have a simulated decal that is consistent on all of them.

MorganS:
A QRE1113 is good for this kind of short distance.

I have some of them which I have used to detect rotations of a small DC motor they are nice and small but easy to work with. However they are only effective at a range of about 1mm which is much too short for what I want.

Maybe a clearer way to describe the requirement is that I want a signal when the distance changes by about 0.5mm from (say) 10.5 mm to 10mm. The variation of 0.5mm between not-detected and detected is approximate but I think it's a good indication. I don't know yet whether the bigger part of the measurement is 10mm or 12mm or maybe even a bit more.

...R

What about measuring the inductivity of an air coil? When the coupling is made of steel, it's quite easy.

Like a metal detector?

Hall effect "prox sensors" can be analog and can probably operate satisfactorily at that range. Depending on the exact type chosen you may or may not require a magnet on the other side. The "no magnet" sensors have a built-in magnet and they are detecting the metal object by how it distorts that magnetic field.

Hall effect was my first thought also....

Hall effect, then thinker with magnet to get the exact distance

or
Sharp GP2Y0D805Z0F IR Range Sensor - 0.5cm to 5cm or such for analog distance read so it slows at 5cm to a stop at 0.5 XD...

Thanks all. I'll have a look at the datasheets later today when I have more time.

I've concluded that the Vishay device (Reply #2) would be too complex to hook up - all the external components would make it almost as much trouble as connecting the Attiny84 to the nRF24. And I would probably need to use an Attiny 1634 rather than the '84

The couplings are small 3D printed plastic items.

...R

Robin2:
The couplings are small 3D printed plastic items.

Interesting. Does that imply that your rolling stock are hand built too?

Watch how they did it, about the Dam Busters and crossing light to get an exact height over water.

wildbill:
Interesting. Does that imply that your rolling stock are hand built too?

Pretty much. The locos use Kato n-gauge tram chassis and the rolling stock is built on Peco n-gauge wagon chassis. The bodies of locos and rolling stock is made from card cut with a Silhouette Portrait computer cutter.

It's much more satisfying to make your own stuff, even if it is crude, compared with using commercial products made in a factory.

...R

:smiley:

How about not a hall sensor, which are a bit insensitive, but one of those magnetometer chips (HMC5883L). I used one in this project and was able to detect the magnet over a 1 foot range.

Vimeo is not working for me.

Looking at the datasheet I can't make out if the device would work the way I want it to. Imagine that it is slowly approaching the magnet head-on from a distance of (say) 30mm. Could it tell me when the distance had reduced to (say) 10mm +/- 0.25mm ?

...R

Micro switch of some kind.

Light reflection at a focused point.