Hello again...
Background:
I've had a few good discussions with folks (stan2004, gunrunnerjohn,...others...) about the best way to do block occupancy detection for signal lights and whatever else needs to be controlled. Several people suggested using current sensing (magnetic-inductive or Hall effect) but as many people pointed out on the forum... this doesn't work for long trains that don't draw current in their cars/caboose, or LED lit trains where the current is tiny.
Alternatively use of an isolated rail with a relay is pretty good but sometimes small trains can struggle because it isn't necessary touching both rails all the time, and when the track is AC-powered you can't really put a diode across the coil to shunt the reverse current when it releases, and when you touch the track you can get a zap.
Both of these are actually pretty satisfactory solutions, but I wanted to challenge myself to see if I could come up with a circuit that
1. Has no moving parts
2. Has both outer rails grounded all the time (at least at 60 Hz power and for DCS/TMCC signals)
3. Doesn't interfere with DCS/TMCC operation
This is probably overkill, but it's a good circuit design problem to practice those analog fundamentals....
============================
UHF Block Train Detector
============================
Okay so the idea is conceptually simple. We exploit reactance (imaginary resistance) to provide different grounding conditions at different frequencies. We do this by putting a small inductor of about 1uH across the two outer rails of the track, meaning they are basically connected at low frequencies, while still open circuit at high frequencies. We then use the high-frequency conditions to trigger the signal lights or whatever else.
Quick Frequency Analysis:
So at 60 Hz (track power) the impedance between the two outer rails is X = 6.28 * 60 * 1uH = 0.003j ohm (basically a short) so no problem here.
At the highest frequency we need to worry about (DCS's 3rd harmonic at 11 MHz) its X = 6.28 * 11M * 1uH = 69j which is still a much lower impedance than the engines are at this frequency (about 400 ohms). We actually measured this on a VNA and posted it here (Train Impedance). Note: we consider the 3rd harmonic and not the fundamental because we want the DCS waveform to be nice and square looking (square waveforms have dominant energy in harmonics 1 and 3) otherwise the receiver in the engine will struggle to detect the spread codes properly.
Since this is like 1/5th the train impedance it's still providing an adequate ground for the DCS signal. Keep in mind the other rail connected directly (not through the inductor) is still in parallel with this too. Just to make sure I checked anyways, and the DCS signal can go through a 1uH inductor without issue. To test this I just put the inductor in series with the TIU output and ran a the train and did the built-in signal test....
=============
Implementation:
==============
Rectifier:
Right so the first thing we want is for the circuits to run of the track power so we don't need extra power lines (which are unpleasant to add to a layout). While normally you would use a full wave rectifier, for this particular application a half-wave rectifier is a better choice... becasue it has the advantage of ground that is common with the input. This is good to know for many many train projects.
If you use a full wave rectifier your common node is neither track terminal, but in fact something in-between, while in half-wave version... one of the track terminals can act as "ground" to all your DC circuitry.
It goes like this...
UHF portion:
Next we use a 74HCT04 which is just a CMOS logic gate chip with 6 inverters on it (does anyone else call them "not" gates?). So we form a basic ring oscillator with 3 of the gates, then use a 4th one as an output buffer. The manufacturing variation of the chip along with soldering will set the exact frequency, but it should be in the range of 100 MHz (well beyond DCS or TMCC or anything else train). It's important to do this setup well out of band so the block sensor doesn't jam or interfere with control signals. Both TMCC and DCS use matched filters in the controllers and engine, so they will filter out this 100 MHz signal and not let it go into the control circuits for the trains.
Okay so basically we take the oscillator output and form a voltage divider between the inductor and a 50 ohm resistor in series with the buffer output. When there's no train the impedance at 100 MHz is quite high:
X = 6.28 * 100 MHz * 1uH = 628 ohms
so the voltage divider output is roughly 628/(628+50) = 92% of the 5V / 100 MHz waveform.
When the train comes into the block, the impedance of the inductor drops due to the parallel short, and so the AC voltage at the node falls dramatically (I think in my prototype, the oscillator actually stalls from too much loading).
Next we just used a diode envelope detector to turn the AC waveform into a rectified DC format. We set the time constant of the envelope detector to about 0.5 seconds as a means of debouncing, so if the train looses contact with either rail momentarily it won't affect the output, and only 3-time constants or longer disconnects (so like 1.5s) will actually change the signal light or whatever you're controlling. Finally we use a comparator stage (LF358n in my case becasue it supports single rail operation) to detect if the envelope detector is up or down. Since the peak voltage at the env-detector output is about 4.5V with no train and below 100mV with train, the swing at the comparator input is quite dramatic and so the reference for the comparator doesn't have to be terribly precise. I just went with 2 resistors as a divider to give you 5V/2 = 2.5V (mid-point between supply and gnd).
=============
Testing
=============
We went ahead and made a simple prototype board to try out the design concept and in testing the circuit works quite well. I don't have a TMCC setup, but my DCS engine doesn't notice it at all (checked by running a train, and with the built in signal test).
Here's a short video showing the setup with a piece of test track. In this case I don't even have the center rail wired and I am just experimenting with a boxcar (it doesn't have a center-rail pickup). First when I hit it with the DMM you can see the resistance across the two outer rails is basically 0 ohm (just wire resistances). Then when I drop the boxcar there (hard to do while holding my phone)... the train detector lights up... Anyways pretty-much everything costs about $16 from digikey.
Again maybe a little overkill, but analog circuit design is fun. I'm thinking this may end up being a project for like a 1st or 2nd year undergraduate analog class in the near future....
~Adrian