signal circuit for model railroad

I am a model railroader. My model trains are controlled by a DC voltage from -12 to +12. I need a circuit that will compare the power assigned to two sections of track and determine if they are the same or different. This will be used to display a green or red signal. What makes this difficult is that the power sources do not have a common ground.

by mshanslip
July 25, 2022

It is "easy" to detect a relatively large difference of voltage (note that a voltage is ALWAYS a difference of electrical tension between two points).

On the other hand, does 11.9V equal, or not, 12.0V ? How much can you tolerate or, if you prefer, what is the maximum (difference of) voltage which is allowed to KEEP a green LED on, telling it is OK?

Note about the circuit: I use different FREQUENCY for each source, to simulate the 4 possible conditions (each rail can be at 12 V or at 0 V, independently, at SOME moment in time).

by vanderghast
July 26, 2022

I am not quite sure of what you mean by "not sharing a common ground". Sure, if you have two FLOATING devices, like a cellphone and a portable PC, they don't share a common ground. But if you plug the cellphone into the USB port of the portable, they make ONE circuit and so, have a common reference where the voltage is zero, or which can be taken as such, and that become a common "ground", floating, about the universe, but common among themselves.

Here, I am not sure if the circuit is relevant or not, since I define a "common ground" for three "sources", the third source being the one lighting the LED, or not, if the voltage of Rail1 is more or less the same as the voltage of Rail2 with respect of the "common ground". For the specific components, the LED turns on if the difference is about 5 volt or less.

You can run the simulation to see the result. The top blue voltage of the result of the simulation is the assumed voltage for Rail1, which is either 0V either 12 volt (in comparison to the common ground, as always) and the triangular form voltage, in a golden trace, is to determine at which voltage the LED turns on (the blue trace of the simulation at the bottom). Since the LED turns on at around a voltage of 7 Volt (click on the start of the bottom blue trace, read the value on the golden trace), the announced 5 volt difference being the accepted difference of voltage between the rails to turn the LED ON, or OFF when that difference is more than 5 volt.

by vanderghast
July 26, 2022

I forgot to explain the circuit. It is basically a logical AND gate (the bottom left part with the two rails sources with their diode) where the output is directed to the gate of the NMOS used as a switch. Note that commercial AND gate on an IC are generally limited to much lower voltage than 12 volt. If you use reverse polarity for a rail source, you may have to check if the NMOS allows the negative voltage in that particular situation.

Removing R3, you can see that now, the LED turns on as long as the difference of voltage is 6.5 volt or less.

by vanderghast
July 26, 2022

1 Answer

Answer by mshanslip

I appreciate your response. However, I do not have a common ground between the two power sources. And the voltages can vary from -12 to +12.

I realize what you are saying about difference in voltage. If one is +11.7 and the other is +12, I would not be able to determine the difference. But if one was +6 and the other was +0 (zero) or -5, I would be more obvious that the two voltages are not the same.

+1 vote
by mshanslip
July 26, 2022

The ground in the simulation is more a requirement for the computation that a physical necessity. See each Vsource as possibly be there, or not, or with reverse polarity, in that simulation.

The idea is that the voltage difference between the two rails is high enough to be able to light on a red LED. Without turning LED into smoke in "adverse" situations.

I think that a simple PMOS should do the job to identify if there is just a small voltage difference, or not ( through Vgs(th) ). I will come back when I am satisfied with the circuit.

by vanderghast
July 26, 2022

While I was trying to debug a circuit which could detect a difference of voltage between -2V and +2V from the rails (where a negative voltage can be, or not, present, at any rail), someone made me the observation that it is much simpler to come with a split of a single rail into a bipolar rails system since then, you could have the + and -12V in fixed and well known positions, with a single DC source.

More details, if you are interested, at Texas Instruments site.

by vanderghast
July 28, 2022

Your Answer

You must log in or create an account (free!) to answer a question.

Log in Create an account


Go Ad-Free. Activate your CircuitLab membership. No more ads. Save unlimited circuits. Run unlimited simulations.

Search Questions & Answers


Ask a Question

Anyone can ask a question.

Did you already search (see above) to see if a similar question has already been answered? If you can't find the answer, you may ask a question.


About This Site

CircuitLab's Q&A site is a FREE questions and answers forum for electronics and electrical engineering students, hobbyists, and professionals.

We encourage you to use our built-in schematic & simulation software to add more detail to your questions and answers.

Acceptable Questions:

  • Concept or theory questions
  • Practical engineering questions
  • “Homework” questions
  • Software/hardware intersection
  • Best practices
  • Design choices & component selection
  • Troubleshooting

Unacceptable Questions:

  • Non-English language content
  • Non-question discussion
  • Non-electronics questions
  • Vendor-specific topics
  • Pure software questions
  • CircuitLab software support

Please respect that there are both seasoned experts and total newbies here: please be nice, be constructive, and be specific!

About CircuitLab

CircuitLab is an in-browser schematic capture and circuit simulation software tool to help you rapidly design and analyze analog and digital electronics systems.