Analog DC Reverse Loop Controller for Model Railway — Design Request

Thread Starter

oslosl

Joined Jan 13, 2023
270
Analog DC Reverse Loop Controller for Model Railway — Design Request

Background:
I am building a Z-scale analog DC model railway layout with 2 reverse loops. I need a controller circuit that automatically handles track polarity switching without DCC. The solution must work purely on analog DC track power.

The Problem:
A reverse loop on a 2-rail DC layout creates a polarity conflict at the isolation gap. The controller must resolve this by switching polarity in the correct section — either the reverse loop section or the main section — depending on whether the train is entering or exiting the loop.

Key Insight:
The system only needs one bit of state:
State OUTSIDE — train is on main section approaching loop → short circuit detected → flip reverse loop polarity → state becomes INSIDE
State INSIDE — train is in loop approaching main section → short circuit detected → flip main section polarity → state becomes OUTSIDE
This eliminates the need for optical sensors or directional detection.

Required Building Blocks:
Fast short circuit detector — must react faster than the analog power supply's own protection. Note: An LM393 dual comparator is suggested for the detection stage. If you know a better solution this is fine.
LM555 monostable — debounce/lockout timer after each trigger to ignore subsequent axle crossings. Timing adjustable, target 10-50ms
SR flip-flop or T flip-flop — holds one bit of state, toggles on each validated trigger
Two DPDT relays — one switches reverse loop section polarity, one switches main section polarity. Only one fires per trigger event, determined by flip-flop state
Relay driver transistors — to drive relay coils from logic level signals
Flyback diodes — across relay coils
Power-on reset — flip-flop must initialize to known state (OUTSIDE) at power-on

Operating Parameters:
Track voltage: 0-12V DC analog
Maximum track current: ~1A (Z scale)
Lockout time: adjustable 10-50 ms
Supply voltage for logic/relays: 12V DC separate from track power

Critical Design Constraints:
Short circuit detector must trip faster than power supply protection
After trigger, lockout must be long enough for all locomotive axles to clear the isolation gap at minimum running speed
Flip-flop state must be preserved during brief power fluctuations caused by the short circuit event itself.

If you notice any flaws in my logic, please let me know.

[CR] Human verified post.
Made with Claude assistance.
 
Last edited:

AnalogKid

Joined Aug 1, 2013
12,055
Critical Design Constraints:
Short circuit detector must trip faster than power supply protection
Starting with the small stuff, what is the supply (make/model/product page link) and what is its protection - current limiting or current foldback?

12 V / 1 A can be handled easily by a small supply based on the 7812 or LM317 3-terminal regulators. Both of these have non-latching overcurrent protection, so a brief short circuit will not cause a shutdown.

And yes, a comparator circuit based on the LM393 (dual) or LM339 (quad) comparator ICs will capture a brief short circuit of the 12 V supply. If the supply's output voltage sags sometimes due to motor inrush currents, the comparator trip point must be below the sag voltage value. For example, if the supply output sometime sags down to 9 V, then set the trip point at 6 V. The circuit needs only one comparator, so there will be extra stages available for other tasks.

If the 12 V short is the only signal to work with, then you will need a toggle flipflop. This can be down with two inverting gates of any kind (NAND, NOR, of NOT), two transistors, or 1/2 of a dual flipflop IC. If you use an LM339 for the comparator circuit above, two of the spare sections can be used for the flipflop (but that might be too cutesy).

ak
 

crutschow

Joined Mar 14, 2008
38,331
After trigger, lockout must be long enough for all locomotive axles to clear the isolation gap at minimum running speed
Don't understand that.
After the first short, the polarity is reversed, and there should be no subsequent shorts until train exits the loop.
So why the need for a "lockout"?
 

Thread Starter

oslosl

Joined Jan 13, 2023
270
Starting with the small stuff, what is the supply (make/model/product page link) and what is its protection - current limiting or current foldback?

12 V / 1 A can be handled easily by a small supply based on the 7812 or LM317 3-terminal regulators. Both of these have non-latching overcurrent protection, so a brief short circuit will not cause a shutdown.

And yes, a comparator circuit based on the LM393 (dual) or LM339 (quad) comparator ICs will capture a brief short circuit of the 12 V supply. If the supply's output voltage sags sometimes due to motor inrush currents, the comparator trip point must be below the sag voltage value. For example, if the supply output sometime sags down to 9 V, then set the trip point at 6 V. The circuit needs only one comparator, so there will be extra stages available for other tasks.

If the 12 V short is the only signal to work with, then you will need a toggle flipflop. This can be down with two inverting gates of any kind (NAND, NOR, of NOT), two transistors, or 1/2 of a dual flipflop IC. If you use an LM339 for the comparator circuit above, two of the spare sections can be used for the flipflop (but that might be too cutesy).

ak
The detection of the short curcuit is all I have to work with. Standard Märklin analog trafo.
 
Last edited:

Thread Starter

oslosl

Joined Jan 13, 2023
270
Don't understand that.
After the first short, the polarity is reversed, and there should be no subsequent shorts until train exits the loop.
So why the need for a "lockout"?
You are right. It might not be necessary, if the module triggers the polarity reversal fast enough.
 
Last edited:

eetech00

Joined Jun 8, 2013
4,704
Analog DC Reverse Loop Controller for Model Railway — Design Request

Background:
I am building a Z-scale analog DC model railway layout with reverse loops. I need a controller circuit that automatically handles track polarity switching without DCC. The solution must work purely on analog DC track power.

The Problem:
A reverse loop on a 2-rail DC layout creates a polarity conflict at the isolation gap. The controller must resolve this by switching polarity in the correct section — either the reverse loop section or the main section — depending on whether the train is entering or exiting the loop.

Key Insight:
The system only needs one bit of state:
State OUTSIDE — train is on main section approaching loop → short circuit detected → flip reverse loop polarity → state becomes INSIDE
State INSIDE — train is in loop approaching main section → short circuit detected → flip main section polarity → state becomes OUTSIDE
This eliminates the need for optical sensors or directional detection.

Required Building Blocks:
Fast short circuit detector — must react faster than the analog power supply's own protection. Note: An LM393 dual comparator is suggested for the detection stage. If you know a better solution this is fine.
LM555 monostable — debounce/lockout timer after each trigger to ignore subsequent axle crossings. Timing adjustable, target 10-50ms
SR flip-flop or T flip-flop — holds one bit of state, toggles on each validated trigger
Two DPDT relays — one switches reverse loop section polarity, one switches main section polarity. Only one fires per trigger event, determined by flip-flop state
Relay driver transistors — to drive relay coils from logic level signals
Flyback diodes — across relay coils
Power-on reset — flip-flop must initialize to known state (OUTSIDE) at power-on

Operating Parameters:
Track voltage: 0-12V DC analog
Maximum track current: ~1A (Z scale)
Lockout time: adjustable 10-50ms to accommodate multiple axles at slow speed.
Supply voltage for logic/relays: 12V DC separate from track power

Critical Design Constraints:
Short circuit detector must trip faster than power supply protection
After trigger, lockout must be long enough for all locomotive axles to clear the isolation gap at minimum running speed
Flip-flop state must be preserved during brief power fluctuations caused by the short circuit event itself.

If you notice any flaws in my logic, please let me know.

[CR] Human verified post.
Made with Claude assistance.
It will help if you provide a track layout diagram detailing the DC circuit connections ( and polarities) to the rails on the track.
 

MisterBill2

Joined Jan 23, 2018
27,197
REally, trigger on a current spike during the instant of the short circuit. A SHORT power lockout while sensing the track polarity, since, assuming it is a DC motor, after entering the reversed section, the motor will still be generating the correct polarity. Sense the polarity, either with a comparator or just a pair of transistors. then apply the correct polarity. The power lockout time will need to be longer than the time of sequential wheel shorts.
Idon't see how the track layout matters, assuming that there does exist a reversed polarity point. There might be multiple polarity flip points.
 

Thread Starter

oslosl

Joined Jan 13, 2023
270
REally, trigger on a current spike during the instant of the short circuit. A SHORT power lockout while sensing the track polarity, since, assuming it is a DC motor, after entering the reversed section, the motor will still be generating the correct polarity. Sense the polarity, either with a comparator or just a pair of transistors. then apply the correct polarity. The power lockout time will need to be longer than the time of sequential wheel shorts.
Idon't see how the track layout matters, assuming that there does exist a reversed polarity point. There might be multiple polarity flip points.
Thanks. Please elaborate ?
 

AnalogKid

Joined Aug 1, 2013
12,055
It might not be necessary, but as far as I understand each wheel could produce multiple, rapid trigger events (and not just one that we are dependent on) hence the threshold for the entire train length.
Because you are triggering a toggle flipflop, you are correct. After the first trigger, the flipflop or the trigger circuit must be locked out so that each subsequent axle doesn't cause another toggle. This means that the lockout period must be longer than the time span between axles crossing the trigger point at the slowest anticipated train speed. SO, what is the longest time period between axle crossings? You mention 50 ms. That seems short to me, but I'm not a train guy.

This can be done with a retriggerable monostable circuit, something the standard 555 monostable circuit can not do. Other things, such as two sections of an LM339, can. In fact, the input part of the retriggerable circuit can be the short circuit detection comparator, so now you get the comparator and retriggerable lockout in just two comparator sections, or as in one LM393. For the toggle flipflop, better to use actual logic parts like 1/2 of a CD4013 dual D flipflop..

Note that while a linear power supply can tolerate brief short circuits all day long, the point on the track where the short happens will see multiple arcs and sparks. Over time this might build up an oxidation layer that acts as a resistance or insulator. Again, no feel for how long it might take for this to turn into an issue.

ak
 
Last edited:

Thread Starter

oslosl

Joined Jan 13, 2023
270
Because you are triggering a toggle flipflop, you are correct. After the first trigger, the flipflop or the trigger circuit must be locked out so that each subsequent axle doesn't cause another toggle. This means that the lockout period must be longer than the time span between axles crossing the trigger point at the slowest anticipated train speed. SO, what is the longest time period between axle crossings? You mention 50 ms. That seems short to me, but I'm not a train guy.

This can be done with a retriggerable monostable circuit, something the standard 555 monostable circuit can not do. Other things, such as two sections of an LM339, can. In fact, the input part of the retriggerable circuit can be the short circuit detection comparator, so now you get the comparator and retriggerable lockout in just two comparator sections, or as in one LM393. For the toggle flipflop, better to use actual logic parts like 1/2 of a CD4013 dual D flipflop..

Note that while a linear power supply can tolerate brief short circuits all day long, the point on the track where the short happens will see multiple arcs and sparks. Over time this might build up an oxidation layer that acts as a resistance or insulator. Again, no feel for how long it might take for this to turn into an issue.

ak
Hate to admit it, but I think my logic here was flawed. I think when the first wheel (or whatever) generates a short curcuit, the polarity change happens so fast that none of the following wheels generate a short curcuit or trigger.
 

sagor

Joined Mar 10, 2019
1,047
Do any of the rail cars have metal wheels? If so, your shorting algorithm may not work as you expect. I would look at current draw of the loop and the polarity at both ends of the loop as another option.
But the real issue is whether any other car has metal wheels that can short out over the gap. A gap spacer (with nylon tab) may be wide enough to prevent a short, but that is hard to determine without experimentation. Such a insulated gap spacer may also affect the engine wheel shorting or not...
 

Thread Starter

oslosl

Joined Jan 13, 2023
270
Do any of the rail cars have metal wheels? If so, your shorting algorithm may not work as you expect. I would look at current draw of the loop and the polarity at both ends of the loop as another option.
But the real issue is whether any other car has metal wheels that can short out over the gap. A gap spacer (with nylon tab) may be wide enough to prevent a short, but that is hard to determine without experimentation. Such a insulated gap spacer may also affect the engine wheel shorting or not...
That was exactly my worry first, untill I realized that the reversal of polarity might happen so fast that there are no more short curcuits to worry about. Now I am actually more worried about getting a short curcuit in the first place as you mention. But as far as I understand that is how reverse loop modules work, with or without DCC.
 
Last edited:

eetech00

Joined Jun 8, 2013
4,704
The diagram is still incomplete.
Show, on the diagram in post #7, the DC polarities on the rails for the DC track circuits and insulated joint locations (where each track circuit begins and ends).
 

eetech00

Joined Jun 8, 2013
4,704
On real railroad diagram, each track circuit is identified with a label, like 1, 2, etc., so there is no ambiguity.
Do the same on your diagram.
 

Thread Starter

oslosl

Joined Jan 13, 2023
270
On real railroad diagram, each track circuit is identified with a label, like 1, 2, etc., so there is no ambiguity.
Do the same on your diagram.
Look closely. All dark red is connected and one curcuit (2).
Curcuit 3. is optional and only nice-to-have.
Note that this is not DCC, but analog.
 

Attachments

Last edited:

KeithWalker

Joined Jul 10, 2017
3,603
I am trying to understand the logic of your layout. Do you plan on running more than one train at a time? Why do you want to run a train in either direction on the track? If you remove the double crossover, your problem is completely solved.
Relying on detecting a short circuit in the supply to change polarity will certainly damage the wheels, the wheel pickup contacts and the rails. The locomotive will not have a very long life. It will have to be travelling at a high enough speed to get over the insulated junction to avoid stalls and continuous shorts.
If you really need to reverse the direction on this layout, you will probably have to use a block system to power the track, and detect the presence and direction of the locomotive to switch the blocks at the right time.
 
Last edited:

Thread Starter

oslosl

Joined Jan 13, 2023
270
I am trying to understand the logic of your layout. Do you plan on running more than one train at a time? Why do you want to run a train in either direction on the track? If you remove the double crossover, your problem is completely solved.
Relying on detecting a short circuit in the supply to change polarity will certainly damage the wheels, the wheel pickup contacts and the rails. The locomotive will not have a very long life. It will have to be travelling at a high enough speed to get over the insulated junction to avoid stalls and continuous shorts.
If you really need to reverse the direction on this layout, you will probably have to use a block system to power the track, and detect the presence and direction of the locomotive to switch the blocks at the right time.
True. I could simply remove the 4 turnouts in front and it would all just be one section.
I guess there is no simple solution for reverse loop handling. I assumed fast short curcuit detection was pretty safe. If you are right and it is unsafe, I guess the short curcuit detection at the 4 isolation points could be replaced by 4 bridge sensors (optocouplers) placed across the isolation points using exactly the same logic.
 
Last edited:

crutschow

Joined Mar 14, 2008
38,331
The problem I see is knowing whether the train is outside or inside the reversing loop, since that's needed to know which side to reverse polarity.

One way, of course, is an added sensor, such as photoelectric, to sense where the trains is.
I think all you need is one to sense when it enters the loop.
 
Last edited:
Top