Model train layout: how to turrn on/off sections of track

Hello. I'm helping a friend build a garden railroad. We want to run multiple trains on the same track and make it so they don't run into each other. The track will be divided electrically into sections or "blocks".
If a train is in a block, the block behind it should be turned off so another train can come up from behind the first train.
Could this be done w/ something like a MOSFET? Max voltage i think will be around 30v DC, amps around 10A. I know little about them. I understand they can be used for switching, but in the case i don't know what the "trigger" or "sensor" would be. I ran a train this morning hoping that there would be more of a voltage drop on track when train is not running and when it is, and the drop could be used as a trigger somehow. Minimum drop was about a volt.
We want to keep this simple if possible. I know this an Arduino forum, but would like to keep them out of this.
Thanks.
Marty

If you don't need to switch fast I suggest you use a relay module. They are easier to work with than MOSFETs specially at 30V/10A and with your amount of knowledge.

As for how to trigger the on/off switch I didn't quite understand what needs to happen. Are the trains getting their electricity from the tracks?
In any case if you want to sense if a train has entered a "block" you can use some kind of sensor like an infrared sensor.

Would a comparitor work as a "test" to check for voltage difference in the 2 blocks? The output could go to the gate on the mosfet?
Thx.

Hi,
You have to consider if you are going to switch the current to each block, that the current although DC, will be reversed in polarity when you change directions.

I would recommend the simplicity of a relay.

Tom..... :slight_smile:

Rats! Didn't think of that.
Thx for you replies.

Basically every block has to be able to detect the presence of the train, whether or not it is moving. You also need to detect whether the end of the train encroaches on the block behind. If so, the block behind that one has to be isolated as well. This is actually quite complicated for single direction running, and becomes really complicated for bi-directional running, but is do-able. This could well be a good project for an arduino, but it is rather hardware hungry, as you need to duplicate detection and control for every block you want to have.

Simplest might be to add a TOF sensor to the front of each locomotive and a Arduino. If it detects it’s about to collide you can program a variety of options from follow to pause ect. Might even help keep you garden train from colliding with cats/squirrels and other garden creatures that may be on the track.

The track will be divided electrically into sections or "blocks".

How do plan to accomplish that ?
A map of the layout showing these blocks would help. Standard procedure when proposing a uProcessor application is to create a Design Criteria, and a subset of that is an algorithm defining what actions should
take place under what circumstances. So far , this project is somewhat nebulous. If you at least define it in
terms on input, outputs , and a Truth Table defining the output states based on the inputs then it would be
at least something someone else could review. Simply stating that you are going to have blocks without
explaining how that would be accomplished isn't really enough to work with. I submit that your intent to
to proceed implies an obligation to generate a list of inputs , outputs and a Truth Table, and ideally, an
algorithm, but that's just me. I have been accused of being too harsh, but I call it like I see it. The way I see
it right now: We can go back and forth for 50 posts or you can just post the needed information.
"INSUFFICIENT DATA"

I also think it is easier to place some (most/all?) cleverness on the trains. You can for example have some transmitter and detector on the trains so they "see" each other.

They could use ESP8266 communication to tell each other which block they are on

raschemmel:
They could use ESP8266 communication to tell each other which block they are on

How would they know which block they are on?

OP- You have described multiple issues that you need to solve. Most significantly, locating the trains.
How big is the layout? What gauge?

How would they know which block they are on?

I don't see why that would be an issue unless there is no wifi covering the area, in which case it would be.
If there is wifi, they could use ESP8266s , each with an ID and when a light beam is interrupted by the train,
a bright led inside a tube flashes briefly directing a beam of ordinary visible light at the photocell mounted
on the side of the train at the same height using coded flashes, where the first sequence of flashes is the MSB
of the block and 'n' mS later a second sequences of flashes with the LSB of the block number. That train
then broadcasts (via wifi) "I am train# 3 and I am in block 6 !"
The result is the value '3' is stored in block 6 register for reading.

It has been common practice to break up model railways into separate blocks electrically for control purposes for many years. What is not so common is to extend the idea to provide detection. One method I have played with involves breaking both rails at section breaks, and feeding the common return to each section via a pair of back to back diodes. The voltage drop across the diode is then measured, and used to give an empty/occupied signal as the loco moves into and out of the section. These days I might try using a hall effect chip instead of back to back diodes. This only works with moving locos, as when stopped there is no supply voltage so they draw no current. A quiescent current can be fed to the switched rail via a resistor and diode to provide enough current to trigger the detector when the loco is stationary. You can combine this with light beams across the track which can detect the presence of any vehicle, not just the loco. This can tell you when the whole train has left the section. In a garden setting though, any beams could be inadvertently interrupted by things like leaves being blown around with possible unexpected consequences. Most railway modellers are very loath to modify their expensive rolling stock, and greatly prefer all train detection and control to be layout based rather than train based. Having said that, a common practice for many years has been to attach a magnet to the underside of a loco, and use reed switches embedded in the track to detect the loco. This is a single point type of detection rather than a whole block.

Totally understand. It would be sacrilege to modify the rolling stock.

The hardware to detect model trains in a block is cheap and readily available. I won't post any links in order to avoid endorsement. You can even buy the PCB's alone and build them up yourself for a few bucks. Here is a really great DIY site, though. You should be able to find many useful circuits:

http://www.circuitous.ca/CircuitIndex.html

In particular, here is an appropriate detection circuit for your application:
http://www.circuitous.ca/BODGP.html

I have a shelf reversing unit, commercially made, that has a welcome feature. The power doesn't switch abruptly on and off. Instead, it ramps up/down over the period of about a second to perform a smooth start and stop. I recommend it, as trains really lurch if the power is just cut on/off. I know because I built my own reverser in the 1990's that did that.

jonathan105:
These days I might try using a hall effect chip instead of back to back diodes.

Been there, done that. The sensitivity is way too low. I had high anticipation when I began trying hall modules for this, but it is a no-go without subsequent amplification (I gave up before that point because it destroys the whole advantage of simplicity). What really worked well in my experiments, was a current transformer with an AC bias on the rails. But the diode method is reliable, and versatile for a beginner. That's what my reverser uses, and it is always solid and reliable and "just works". The garden railway is probably DC operated and so will require the AC bias on the supply rail no matter what current detector is used.

aarg:
What really worked well in my experiments, was a current transformer with an AC bias on the rails.

Kind of like the real thing! :grinning:

aarg:
In particular, here is an appropriate detection circuit for your application:
http://www.circuitous.ca/BODGP.html

Lots of good stuff here. Thx.
I don't need the east/west sensing. Could i delete these parts?
IC2
IC3
R9,10,12,7,11
D5,6,7,4
The upper rail is +5v and the blue rail is 0v?
Could it be powered by 12v? And would that require some changes to the resistors?
Thx.
Marty

It seems to work! I can't believe it. Until the little diodes i have blew.
This will control some big trains. I'd like to try some 15amp diodes. Does someone have a recommendation for a good choice?
Thx for your help!
Marty

Hi,
What diodes are you using at the moment?
How many amps load does the loco draw under load?

Tom... :slight_smile: