|
This is a circuit for a model rail way short detector and frog polarity switcher.
TL;DR: Press the pushbuttons on the right hand side of the circuit to mimic a short-circuit on the frog rail. The polarity of the frog will switch, as represented by the Green/Red LEDs.
(For the non-model-railroaders, a frog is a part of a turnout (or switch) in the track, which needs to have its polarity set correctly depending which way the turnout is thrown, otherwise it will short circuit when the locomotive passes it. This circuit automatically detects such condition and flips the polarity on the frog)
This is a DCC circuit only, as it relies on the switching frequency of the DCC bus. For a DC circuit, the bootstrap circuit would need to be re-designed.
(For the non-model-railroaders, DCC is a waveform that toggles the voltage back and forth across the two rails, essentially a 2-phase square-wave AC waveform. By varying the pulse widths, the controller can communicate with locomotives on the track)
For practical purposes, the gate delay time is higher than reality here, so the switching isn't quite as fast as it would be in a real circuit, but since the gate delay drives the simulation speed it's a tradeoff for visualization purposes.
Likewise, I'm still figuring out how to properly model the FETs, and in turn that will dictate the bootstrap and biasing on the NPN to be able to activate the FETs in a timely fashion. Don't use these component values in a real circuit.
Left to right the blocks are as follows:
- An H-Bridge toggling back and forth to mimic a DCC signal (Not part of the the frog switcher, but used for testing in this circuit). Set the period to 200us to accurately represent the DCC bus frequency. The two low-value resistors represent rail resistance.
- Next is a bridge rectifier, this is used to get a DC voltage from the DCC bus. For no particular reason at all, it is "upside down" in that negative is at the top, and positive is the bottom. NOTE: Technically "GND" should not be used after this, as after the bridge rectifier it is not properly referenced due to the diode's voltage drop. For the OpAmp circuits I opted to use GND, but in a real circuit the rectifier output will need to be filtered/regulated to provide a clean power supply for the circuitry.
- Following the bridge rectifier is the circuitry for detection and toggling at the bottom of the page. A voltage drop is measured across the 10mOhm current sense resistor by a differential Op Amp biased at 1.5v (Assuming a design using 3V regulated from the rectifier) to mimic a differential power sense amplifier. The output of this feeds a pair of comparators to detect when the detected short circuit is above/below a given threshold, indicating a short circuit.
The output of the comparators feeds a D-type flipflop with Qnot tied to D to act as a toggle when the clock raises high. The outputs Q and Qnot then drive FET switches in the next stage --- Note, the D-flipflop won't drive correct levels since the simulation uses the GND for '0', not the post-rectifier reference.
- The final stage are the FET switches. These are pairs of source-coupled N-FETs which act as solid-state relays in order to switch the DCC polarity to the center frog rail (via the current sense resistor). The FETs need a voltage higher than the source to turn on, which is delivered by the boot-strap circuit (the diode and capacitor) which takes advantage of the constant switching of the DCC bus to charge.
Note that since the FETs are turned off via the negative output from the bridge rectifier, the gate drive cannot achieve true ground as referenced by the DCC controller. Appropriate FETs with sufficient VTO (Vgs threshold voltage) need to be chosen so that they don't partially turn on in operation.
The diodes across the FETs represent the body diodes that aren't part of the "ideal" FET model on EveryCircuit. They help drain the source which would otherwise remain floating at odd voltages and do weird things.
- the two light bulbs on the right-hand side of the circuit are simply meant to represent a load (i.e. a locomotive) over the rails to provide a bit of steady-state current flow.
- The two pushbutton switches connecting the DCC bus to the frog current sense resistor are used to mimic shorts when a train crosses the frog.
To Do:
- Need to address shoot-through conditions on the two SSR circuits to ensure that they are not simultaneously activated. This needs to take into account real rise/fall times of real components.
- need to adjust the biasing so that the NPNs can switch at 3V. Currently the logic level is 5V in the simulation.
- The boot-strap circuit needs to be properly calculated.
- Adjust the SPICE parameters for the FETs and Diodes to more realistic/representative of actual components.
- Add de-bouncing / time-delay on the output of the OR gate to avoid flapping. This MUST have a very fast rise and slow decay.
|