# sensor to identify locomotive



## ClarkW (Mar 14, 2017)

Crazy idea, I know, but is there a way to install a sensor in the layout and on a locomotive that I can then program turnouts depending on which loco is approaching?


----------



## fcwilt (Sep 27, 2013)

Hi,

Not crazy but it can be a lot of work - depending on the complexity of your layout, the number of locomotives, etc.

My layout is fully automated and I am very glad I invested the time and money.

Frederick


----------



## wvgca (Jan 21, 2013)

yes....
and has been done [by other members, not myself ]
you need readable sensors at each turnout and locomotives


----------



## Mark VerMurlen (Aug 15, 2015)

Can you say more about what you want to accomplish? I may be reading more into your question than you are intending. Are you thinking about something simple, like you want freight trains to take the track around a passenger station and passenger trains to take the track that stops at the station?

Or are you wanting something more complex like you want to set a full route (involving multiple turnouts) around your layout based on the locomotive?

If its the second, you really need a full computer automation system to accomplish that. That involves a computer with train automation software on it like JMRI or TrainController. You need to buy hardware that can detect where the train is on your layout and report it back to the computer. You'll need to break your layout into blocks so that the computer can track where the train is as at any time. You also need hardware that can change the state of a turnout as commanded by the computer control. There are multiple hardware suppliers that make and sell the electronic boards that can do all this. As you've probably guessed, this is fairly complicated and somewhat expensive, but it can also be very gratifying.

Let us know what you're thinking and we can better steer you in the right direction.

Mark


----------



## ClarkW (Mar 14, 2017)

*crazy idea followup..*

My ultimate goal is to have routes that each train would follow. This requires train A to have 2 turnouts engaged and for train B to have those turnouts straight. Train C will engage 2 other turnouts that overlap with Train A's route, so yes, some block detection will probably be required there...


----------



## JerryH (Nov 18, 2012)

In TrainController, I set up schedules to route the trains. The trains are set to use or not use a schedule. The turnouts are set as needed for a schedule. You might look at what it takes to do this automation as it is a lot more planning, work, and expense. I am a lone operator and do not belong to a club, so it is perfect for me.

http://www.modeltrainforum.com/showthread.php?t=14852


----------



## Mark VerMurlen (Aug 15, 2015)

Like Jerry, I'm also using Digitrax hardware for most of my train automation needs. See the Digitrax website (http://www.digitrax.com) for more complete information about what they offer. 

Look first at a "starter set" that will have a command station and throttle. This is the basics needed to power and control your DCC locomotives.

For detecting trains and managing power to the rails (like short circuit protection), Digitrax now makes the BXP88. This is a new product that combines the functions of multiple older boards, such as the PM42 and BDL168 that Jerry and I are using.

For controlling the motors for your turnouts, look at the DS64 or SE8C.

For connecting the Digitrax system up to a Windows computer, I'm using a product from RR-Circuits called the Loconet USB adapter. And then using TrainController software on the computer to run everything (see http://www.freiwald.com/pages/index.html). The TrainController software website also has a forum where people ask questions about the specifics of using the software and hardware with it. I'd encourage you to do some browsing there to get some familiarity with issues that come up with this complex of a system.

RR-Circuits (http://www.rr-cirkits.com/index.html) also makes other hardware that can also do detection and turnout motor control. I don't have any experience with them, but there are others here that do. I will leave it to them to provide some recommendations.

It will probably take some time to wrap your head around all of this. There are examples of layouts here and around the web that show what can be done. If you're really serious about going this route, I encourage you to take the time to study what other people have done and what the products do before you lay any track down. You'll specifically want to put rail insulators in certain key spots in order to make this all work and that's easier done when first laying the track than doing it later.

Mark


----------



## ClarkW (Mar 14, 2017)

Thanks Mark for your insight. I already have all my track laid and I'm using CTI-electronics for the turnout switches, so i'm somewhat committed to that system.


----------



## JerryH (Nov 18, 2012)

You can check your existing hardware compatibility with the software you might choose.


----------



## cid (Jul 3, 2014)

Here's my bar napkin design.
In the track approaching the swich, embed four or five magnetic sensors like hall effect switches or..?
On the bottom of your locos, install small magnets such that each loco will set a specific and unique pair of magnets. That will identify the loco in that location. 
The I/O, ID memory and logic/processor to set the routes, I'm assuming you already have a handle on. 
A higher tech solution would be a bar code scanner in the track with labels on the underside of the locos. That might be a bit much but its a proven method of ID. I think I would start hunting some small magnetic sensors. Cheers!


----------



## ClarkW (Mar 14, 2017)

*bar code reader...*

love that idea, how might I proceed and before I get too excited, how much might a bar code reader cost?


----------



## fcwilt (Sep 27, 2013)

ClarkW said:


> love that idea, how might I proceed and before I get too excited, how much might a bar code reader cost?


The ability to identify locos is already available with decoders that support RailCom.

Also programs like TrainController do not require RailCom (or the like) - tracking of train location works just fine without it.

And you will be wanting TrainController - it is the best choice by far - nothing else comes anywhere close.

Frederick


----------



## DonR (Oct 18, 2012)

ClarkW said:


> love that idea, how might I proceed and before I get too excited, how much might a bar code reader cost?


Check a good computer store. Bar code readers output
ASCII usable by most devices. They're not tiny though,
may not work under track, might be mounted in trackside
building.

Don


----------



## traction fan (Oct 5, 2014)

*Old school simple solution.*



ClarkW said:


> Crazy idea, I know, but is there a way to install a sensor in the layout and on a locomotive that I can then program turnouts depending on which loco is approaching?


ClarkW;

An old electronics for model railroads book had a simple detector circuit that might be adapted to you situation. The author wanted to select which sound came from trains approaching a grade crossing; a steam whistle for steam locomotives, or an air horn for diesels. He buried a small magnetic reed switch on either side of the approach tracks,entering either end of the crossing. He attached a tiny magnet to the right side of the steamers, and to the left side of the diesels. The magnet would trip the appropriate reed switch and it would trigger the proper sound. NOTE: The wiring of the two reed switches was reversed on one side of the crossing. With the loco approaching from the "West", instead of from the "East", its magnet-equipped side would be on the opposite side of the track. Thus diesel air horns were triggered by the "North" reed switch on the "West-to-East route, but by the "South" reed switch on the "East-to "West" route.
If your turnouts are thrown by a "Twin-coil" switch machine like Atlas, and Peco, turnouts use. You will not be able to use the reed switches to trigger that type of switch machine directly. The switch machines draw so much current that they would ruin the reed switches very quickly. You could use the reed switch to trigger a relay with contacts rated for enough current to operate the switch machine safely. You should also use a capacitive discharge system with any Twin-coil machine to protect the coils from burning out. This may, for a very brief burst, put out even higher current so use a relay with very heavy-duty contact designed to handle high current. 
If you are using a DC "stall-motor" type switch machine like Tortoise, or Switch Master, then you would need a latching relay, or some equivalent solid state circuit, to keep power on the switch machine's stall motor, until the next train came along. Reed switches are momentary contact like push buttons.

good luck;

Traction Fan:smilie_daumenpos:


----------



## Shdwdrgn (Dec 23, 2014)

If you plan to do computer work yourself with an arduino type of device, you might look into NFC tags. Same technology as RFID, but the NFC tags have a small bit of memory so you can enter your own information. I've found a lot of different sizes, and they're basically just stickers. The sensors are around $5. My understanding is they have a limited range of less than 4 inches, so there shouldn't be interference between parallel tracks if you are working with HO or larger. I actually have all the components on hand, but have never actually hooked anything up to see how well they would work. I'd like to tag every car on my layout and be able to verify each car as a train flies down the mainline.


----------



## gunrunnerjohn (Nov 10, 2010)

NFC tags do look very interesting for this application. They're certainly cheap enough.

10pcs Ntag213 14443A NFC Tags Sticker Universal Lable RFID Tag WF

A reader to interface to your favorite uP platform is cheap also.

NFC 13.56MHz Mifare RC522 Antenna Module RFID Reader Tags Read and Write


----------



## crusader27529 (Apr 3, 2016)

Those tags seem large for anything smaller tha O-gauge.

I thought that there were 2 different frequencies available for RFID type devices(not compatible with each other) for civilian use, and the higher frequency stuff was significantly smaller.

One was 125KHZ, and the other was 13MHZ or so.


----------



## cid (Jul 3, 2014)

The OP first requested differentiation of three routes.

So we suggested (and Traction Fan seemed to concur),
magnets in some pattern under the loco, in conjunction with
sensors embedded in the roadbed, be they reed switches, hall effect, or magnetoresistive, and a latching relay circuit with CDU and solenoids, or else digital inputs to a CPU like Arduino 
or Raspberry Pi.

Basic concept there was that decoding is mechanically achieved by the sensors and targets. 

The barcode balloon was floated more or less tongue-in-cheek
as a possible doable solution, a lot more hi-tech, but if you are using a computer anyway, then why not? Scanner can be beneath the roadbed and use a slit in the ties for the laser.
Maybe no proximity issues.

RFID (NFC) is obviously another possibility, as already put forth. 
I originally steered away from it as introducing another level of complexity. I also feel (my opinion only) that the size of the
tags and the proximity requirements make it difficult to achieve
from a physical standpoint. The reader antennae seem to be
larger than the track, or else require contact with the tag. I'm not sure about their response time and reading "on the fly", or interference/shielding from the metal track itself.

Maybe Shdwdrgn can hook up some of his components and 
give it a test? :thumbsup:

Mean while, I'd still be hunting the "old school" tiny magnets.
Just my $0.02
Good luck to all!!


----------



## gunrunnerjohn (Nov 10, 2010)

crusader27529 said:


> Those tags seem large for anything smaller tha O-gauge.
> 
> I thought that there were 2 different frequencies available for RFID type devices(not compatible with each other) for civilian use, and the higher frequency stuff was significantly smaller.
> 
> One was 125KHZ, and the other was 13MHZ or so.


I thought the same thing, but in my search 13mhz was all I found. I did find some smaller tags, 9mm.

HF 13.56mhz 9mm FPC rfid mini sticker small NFC tag


----------



## ClarkW (Mar 14, 2017)

*crazy idea followup..*

well I've learned about RFID and NFC over the past few days and that CTI-Electronics sells an RFID system for just what I seek. I will let you know if I proceed and how its working, but in a perfect world will open or close turnouts according to which engine is approaching!!

Please respond if you have any experience with this system.. good or bad.

Thanks, 
Clark


----------



## Shdwdrgn (Dec 23, 2014)

Nice find there John! The stickers I have are 9x18mm, twice the size of yours, but still small enough to stick to the underside of most of my HO cars. The one thing I do worry about is whether the metal weight plates inside the cars (and usually mounted low to the bottom frame) would have any affect on reading the stickers?

The reader that you linked to above is exactly the same kit I have here. Yes it is wider than the track, but it's easy enough to find flat spots to mount it, and then cover up with scenery. 

And as cid says... yeah I need to hook this stuff up and see how it works with passing trains. My initial hiccup is that I'm having trouble finding software for my cell phone that will program the stickers. I'll have to try some other software and see what I can get to work. THEN I'll have something to read when I set it up. If I can get it to read three cars in a row at full speed, I'll consider it a usable device and it will most likely work for any length of train (and my cars are only 35-footers, so they'll be zipping by pretty quick).

Oh, and as far as the tiny magnets? I've ordered the neodymium magnets in 3mm round and cube from Amazon and Ebay (still waiting for the cubes to arrive though). I think they usually run about 50 for $5? Nice strong magnets that will react with even a weak magnetic source.


----------



## gunrunnerjohn (Nov 10, 2010)

I'll be interested in your NFC experiences, that's something that I've thought about as well.


----------



## Shdwdrgn (Dec 23, 2014)

I also received a new board yesterday that will control up to 16 servos, which I'm hoping I can use for managing turnouts. And I got in some opto-isolators that were needed to read the DCC signal from the tracks. So I have a few things to try and test out soon.


----------

