# Sensors to detect engines



## Bobsbees (May 23, 2019)

I am implementing a layout using DCC. To automate the track am installing sensors to detect the location of engines. It is easy to install sensors to detect a passing engine without identifying the engine. My layout, however, has three engines on the same track, and I would like to know which engine is passing a sensor. The best I can think of is to use multiple Hall sensors. Since a Hall sensor will detect, say, N of a magnet, but not S, having two sensors next to each other, one to detect N, the other to detect S, will identify two engines. Just a matter of attaching magnets to the engines, one with N facing the sensor, the other with S facing the sensor, using different versions of Hall sensors. For the third engine, I can put a sensor on the other side of the track, so that it will only detect engine 3. Using small magnets, the magnetic field should not stray from one side of the track to the other, particularly if the sensors are offset. Has anybody implemented other solutions on N gauge, where I do not have much room?


----------



## Severn (May 13, 2016)

Check this out. This guy's super smart and I built his mth PC connector and helped a little with his mth sound player app.






Train Detection using PN532 RFID Modules


O-Gauge Train Layouts




www.silogic.com





But he is larger than ho... (O scale, us)


----------



## timlange3 (Jan 16, 2013)

I thought if you isolated sections of track (block) and used a certain block occupied detector and had decoders that would report their id you could then know exactly which engine was in which block along with speed and direction. I would think you would need a computer to read and display all this information meaningfully.


----------



## cv_acr (Oct 28, 2011)

Bobsbees said:


> For the third engine, I can put a sensor on the other side of the track, so that it will only detect engine 3.


So what happens when you turn that engine around?

The magnet idea seems to be not very useful for actually distinguishing different engines. You really need some sort of RFID type situation to do that.


----------



## Bobsbees (May 23, 2019)

Thanks for the replies. RFID sounds a good idea and will try it. Magnets will work, but are messy. I wrote my own DCC software from scratch, which I installed on an Arduino.




When the electronics and software are completed, I shall have 4 engines on the same layout crossing paths or going in opposite directions on the same track, that need to be coordinated by the program. I will not have any control over the layout when operating. Really for display, where I can leave it running while doing other tasks. Each of the engines will move randomly around the track, so the Arduino needs to keep track of their location and direction, and manage movements without a big crash.


----------



## Jscullans (Jul 8, 2019)

I know that there are decoders that offer transponding to your block detectors so you don’t have to reinvent the wheel. Just a thought


----------



## gregc (Apr 25, 2015)

Bobsbees said:


> so the Arduino needs to keep track of their location and direction, and manage movements without a big crash.


a common approach is to track a loco from block to block by assuming that a train moves to adjacent blocks with known IDs when a new block become occupied

Railcom compatible decoders can send an ID during a DCC "quiet" period but Railcom compatible detectors are needed in each block


----------



## OilValleyRy (Oct 3, 2021)

Yeah I was going to mention transponder decoders too; this situation is what they’re designed for.


----------



## Bobsbees (May 23, 2019)

Thanks. I was aware of transponder decoders, but I am writing the DCC base station software myself, and to implement a system that can receive messages from decoders installed on engines will add a lot of complexity. I may look at this later though. RFID seems the best solution so far, all the components can be bought ready made.


----------



## TheKenWiley (8 mo ago)

Bobsbees said:


> Thanks. I was aware of transponder decoders, but I am writing the DCC base station software myself, and to implement a system that can receive messages from decoders installed on engines will add a lot of complexity. I may look at this later though. RFID seems the best solution so far, all the components can be bought ready made.


I recently bought a "complete" starter set of RFID components from staRFIsh Rail, in the UK. It's a great plug and play system, and interfaces with JMRI. JMRI, unfortunately, has limited use for the information. I'm looking for windows software that will integrate into a database, or a spread sheet like Excel. As you say you are writing base station software, you might look into the system. I have mounted RFID tags on all my rolling stock. I'm using an LCC system from RR-Cirkits for block detection.


----------



## Bobsbees (May 23, 2019)

Thanks Ken. Sounds good.


----------

