Maker Pro
Maker Pro

Use Capacitive Sensing to detect a train?

Stese

Dec 27, 2013
27
Joined
Dec 27, 2013
Messages
27
Hi All,

Is it possible to use capacitive sensing to detect the presence of a conductive object on a model railway?

How would such a setup be affected by changes in voltage, current and polarity?

For a bit of background, what I am trying to come up with is a system for detecting the presence of a train in a particular section of track, without the need to modify the locomotives or stock in anyway.

The common way to do this is to use reflective IR Beams, but our situation might make the unreliable, due to light interference, so I'm looking for another way.

I had thought about sensing load, but that would only work when a load present, with power, preventing rolling stock from being detected, if it's been left behind by a powered loco.

Any suggestions?
 

Arouse1973

Adam
Dec 18, 2013
5,178
Joined
Dec 18, 2013
Messages
5,178
Hello
Yes it could be done with capacitor sensing, but have you also considered a magnet and reed switch or hall effect device. You could also look at metal detectors this could also work it if the train had large enough metal parts.
Adam
 

Stese

Dec 27, 2013
27
Joined
Dec 27, 2013
Messages
27
Hi Adam,

Magnets have been considered, but in the scale (HO), have been known to be a bit unreliable. It's also not possible to detect things without motors, unless they are modified to contain one.

I doubt there is enough metal in the stock for accurate detection.

How would Capacitive sensing handle changes in Voltage, Current and Polarity?
 

KrisBlueNZ

Sadly passed away in 2015
Nov 28, 2011
8,393
Joined
Nov 28, 2011
Messages
8,393
How about using RFID tags? You would have to put an antenna coil under the "ground", and put an RFID transponder ("tag") in each locomotive. ICs are available to drive the antenna and receive the data from the tag. The IC that I've seen has a serial output that needs to be decoded by a microcontroller, but there may be more integrated options that would be easier to use. Just a thought.
 

Stese

Dec 27, 2013
27
Joined
Dec 27, 2013
Messages
27
RFID is also being considered... it does add the ability to tell which train, or consist has passed over the reader, and using a tag at either end, we can tell if that train is complete...

The capacitive idea allows us to detect if something is in that section, rather like 'track circuits' do on the full size railway.
 

hevans1944

Hop - AC8NS
Jun 21, 2012
4,889
Joined
Jun 21, 2012
Messages
4,889
Does your model railway use DC excitation on the tracks, with complex block switching, or does it use AC excitation on the tracks and Digital Command Control (DCC)? Block occupancy detection is almost trivial with DCC, or so I am told. Just need to add conductive axles to the rolling stock, about 40 kΩ per axle.

Differential capacitive sensors, which have been discussed elsewhere in this forum, could probably be applied to capacitive block sensing with some ingenuity. Well, okay, a lot of ingenuity. You would probably want to imbed one plate of the capacitor horizontaly between the rails. The other plate would be part of the car, but I doubt there is enough metal area to form a "good" capacitor when the rolling stock passes over the fixed plate imbedded between the tracks. You did say you did not want to modify the rolling stock or the locomotives, but with capacitance sensing you would probably have to glue a metal plate or thin foil to the bottom of the rolling stock.

An air-spaced capacitor that the stock rolls between is also a possibility, but I think that would detract from the visual appeal of the layout, even if it could somehow be made to work.

If I were into model railroading, I would look seriously at modulated IR LEDs paired with photo-transistors or photo-diodes in a synchronous detection circuit. The modulated emission is used as a "carrier" to allow ambient light effects to be canceled or greatly attenuated while synchronously detecting lR radiation at the modulation frequency. The photo-transistor or photo-diode does have to remain linear for all conditions of ambient illumination, i.e., not saturate, for this scheme to work. A reverse-biased photo-diode junction makes a fair current source that is linear over four or five decades of illumination intensity. If used in thermodynamically coupled pairs, with one shielded from ambient light, their dark current as a function of temperature can be made to virtually cancel. An FET op-amp connected as a transconductance amplifier is used to convert the photo-current to a suitable voltage for further processing.

I wish someone on this forum would look into video processing of an inexpensive CCD camera image to perform tasks such as this. Industry has already stepped up to the plate, using high-resolution cameras to control pick-and-place robots on a automobile assembly line. See attached file. Sensing the presence of a train of cars in a specified field-of-view (a block of track) should be trivial.
 

Attachments

  • Control Engineering October 2014 Issue pp 48-50.pdf
    570.2 KB · Views: 91

Arouse1973

Adam
Dec 18, 2013
5,178
Joined
Dec 18, 2013
Messages
5,178
Hi Adam,

Magnets have been considered, but in the scale (HO), have been known to be a bit unreliable. It's also not possible to detect things without motors, unless they are modified to contain one.

I doubt there is enough metal in the stock for accurate detection.

How would Capacitive sensing handle changes in Voltage, Current and Polarity?

You would have to add a small metal plate for it to detect. How much clearance do you have from the underside of the stock to the track?
Adam
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
I'm fond of @hevans1944's response for the modulated IR. This would allow any car or obstruction on the track to be detected with absolutely no modification to the cars.
I'm sure this could be operated in a break-beam or proximity setup, but it would be wise to work in some signal conditioning to prevent the circuit from flicking on/off as the train passes by.
(This method would also allow the train to stop on a segment of track and still have the circuit trip... any signalling method requiring modification to the individual car... ie, RFID or metal tags, will require that 'that' car is on the sensor, or would require a timer to turn off)
 

Bluejets

Oct 5, 2014
6,958
Joined
Oct 5, 2014
Messages
6,958
Small magnet on the carriage or whatever and hall switch beside the track...simple.
No need for any metal to detect.
 

Stese

Dec 27, 2013
27
Joined
Dec 27, 2013
Messages
27
Does your model railway use DC excitation on the tracks, with complex block switching, or does it use AC excitation on the tracks and Digital Command Control (DCC)? Block occupancy detection is almost trivial with DCC, or so I am told. Just need to add conductive axles to the rolling stock, about 40 kΩ per axle.

Differential capacitive sensors, which have been discussed elsewhere in this forum, could probably be applied to capacitive block sensing with some ingenuity. Well, okay, a lot of ingenuity. You would probably want to imbed one plate of the capacitor horizontaly between the rails. The other plate would be part of the car, but I doubt there is enough metal area to form a "good" capacitor when the rolling stock passes over the fixed plate imbedded between the tracks. You did say you did not want to modify the rolling stock or the locomotives, but with capacitance sensing you would probably have to glue a metal plate or thin foil to the bottom of the rolling stock.

An air-spaced capacitor that the stock rolls between is also a possibility, but I think that would detract from the visual appeal of the layout, even if it could somehow be made to work.

If I were into model railroading, I would look seriously at modulated IR LEDs paired with photo-transistors or photo-diodes in a synchronous detection circuit. The modulated emission is used as a "carrier" to allow ambient light effects to be canceled or greatly attenuated while synchronously detecting lR radiation at the modulation frequency. The photo-transistor or photo-diode does have to remain linear for all conditions of ambient illumination, i.e., not saturate, for this scheme to work. A reverse-biased photo-diode junction makes a fair current source that is linear over four or five decades of illumination intensity. If used in thermodynamically coupled pairs, with one shielded from ambient light, their dark current as a function of temperature can be made to virtually cancel. An FET op-amp connected as a transconductance amplifier is used to convert the photo-current to a suitable voltage for further processing.

I wish someone on this forum would look into video processing of an inexpensive CCD camera image to perform tasks such as this. Industry has already stepped up to the plate, using high-resolution cameras to control pick-and-place robots on a automobile assembly line. See attached file. Sensing the presence of a train of cars in a specified field-of-view (a block of track) should be trivial.

Thanks for the advice, hevans1944

The railway uses DC rather than DCC, as we find it allows for a more authentic setup, in the aspects we care about. Additionally, non DCC stock tends to be considerably cheaper.

I think block occupancy is only trivial in DCC for locos. Rolling stock doesn't normally carry a decoder, so wouldn't be visible to the system, but I may be wrong, I've never been seriously interested in DCC

Generally, however, most stock will carry metal wheels, albeit isolated from each other with a plastic bush between one wheel and the axle, to prevent short circuits. I was hoping this would have been enough of a capacitance change to be detected.

I've managed to get myself 3 of these on a sample order :- http://www.microchip.com/wwwproducts/Devices.aspx?product=CAP1208

I'm going to rig them up to a test track, and a Raspberry Pi (I2C Bus) and see what I can do with a minimum of stock alterations.

Interesting point about the cameras. I wonder if something can be done with a PiCam... i'll have a look into that.

Gryd3 - A product exists for this already, known as IRDoT. These can be expensive in larger numbers. I could create my own version cheaper, but I worry about the sensors being confused by natural light, as we run outdoors, plus, it'll only detect in one place. Thanks for the recommendation, tho!

BlueJets - magnets and hall sensors can only give me an in and out, and require modification to stock that i'd rather not do. IF i can get capacitive detection working, it would be ideal in my setup. Again, thanks for the input.
 

Gryd3

Jun 25, 2014
4,098
Joined
Jun 25, 2014
Messages
4,098
Interesting point about the cameras. I wonder if something can be done with a PiCam... i'll have a look into that.
http://opencv.org/
may have some additional info as far as image recognition is concerned.

Gryd3 - A product exists for this already, known as IRDoT. These can be expensive in larger numbers. I could create my own version cheaper, but I worry about the sensors being confused by natural light, as we run outdoors, plus, it'll only detect in one place. Thanks for the recommendation, tho!
Understood, I was thinking of a small sensor between the rails under the train, but sunlight can be a real bother, even with modulated IR
 

Bluejets

Oct 5, 2014
6,958
Joined
Oct 5, 2014
Messages
6,958
Ok....fair enough.
Another consideration when you talk about detecting the metal wheels, these are usually made from white metal (similar to lead) so will that have any effect on you capacitive approach.
 

Stese

Dec 27, 2013
27
Joined
Dec 27, 2013
Messages
27
As far as I understand this (and it's not really very far at al), as long as the material is conductive, then when it is close, or touching the 'detection' surface, in my case a rail, the capacitance of the rail will change. This change is measured, and responded to at a 'software' level of some kind. I'm assuming that i'll have to set the thresholds for the change, and calibrate them to detect a piece of rolling stock, or locomotive, but not respond to environmental changes.
 
Top