Model Train-related Notes (a.k.a. “blog”)

These are personal notes and musings on the subject of model train control or automation or whatever I find interesting.

[s:2016-04-09] Use an NCE AIU and IR sensors

Since I have IR reflective sensors, the idea would be to connect them to an NCE AIU to detect position in 2 or 3 spots for speed control and automation.

(Also I got an NCE Q-Snap to control 4 twin-coils, This would cover the front cross-over (2 turnouts), the yard entrance Y1 and the Y1/Y2 yard turnout. Really the point is learning and see what it’s good for since I can already control these turnouts with the Arduino/DigiX).

One idea is for speed matching, using one NCE AIU and 2 sensors.

  • Embed the sensors in the EZTrack pointing up rather than side mounted.
  • Use these directly using JMRI/jython.
  • This leaves 12 unused inputs on the AIU.

How do I connect my IR sensors to the NCE AIU?

This is how I use the IR sensors with an Arduino using the internal pull-up and next to it is the AIU input circuitry:


There's a good match here: connecting the IR receiver collector to the 5V/pull-up side of the AIU should do exactly what we want with the AIU input driven low when an IR reflection occurs.

I can get 5 V to drive the LEDs out of the DigiX.

[s:2016-08-04] Yard Design Links

Yard Design 10 Rules: very good intro.

        Somewhat unrelated, very interesting read on Housatonic Railroad Design Philosophy.

Tips of Freight Yard design:

Yard Operations and Design:

Many LayoutVision pages relevant: 

        Love for the yard: 

        How to classification yard:

        Ops on a classic 4x8:

        Beware of CAD: (agreed on the S curves!)

Interesting design. Note that according to LayoutVison, typical west yards don't have an A/D.

[s:2016-08-22] Home Control Panel

DigiX: 11 x 6 in

Q-Snap : 4 x 3 in (DCC bus)

AIU-01: 4 x 3 (2 RJ12, comes with one cable)

Oscillo + board: 2 x 3 // 3.5 x 3

UTP: 3 x 2 x 2 Deep


  • QSnap really needs 3 outputs per turnouts, it carries its own common per twin-coil. It's not clear whether I can share the commons since each one has its own condensator.
  • The DigiX relays OTOH work by sharing the AC common so I have 2 outputs per turnouts plus one common.

[s:2016-08-25] NCE QSnap and EZTrack #6 Crossovers

Experiment from tonight: control the EZTrack #6 crossovers using the NCE QSnap. ⇒ Failed.

I have 2 EZTrack #6 turnouts mounted in cross-over configuration. The idea was to power them from a single QSnap output to save one output for each cross-over.

The QSnap has no problem driving a single #6. But ever the largest timing I tried does not make the crossover (2 turnouts in parallel) toggle properly. They either bounce or switch half-way.

I also tried using a 9V DC power brick instead of the DCC power. That didn't help. Supposedly that way the turnout should get 9x2-2 = 16 VDC. However from experience I remember I always failed to trigger them in DC, which is why I previously used the AC from the EZTrack ACC power brick.

[s:2016-09-26] Direct Access to NCE QSnap Mk2

From both the NCE USB v7 doc (see NCE web site) or from

Example: 0xAD is for switching an Accy/Signal. There is no provision to read the state.

  • E.g. 0xAD 0x00 0x03 0x03 0x00 ⇒ throw 0x0003 in normal direction
  • E.g. 0xAD 0x00 0x03 0x04 0x00 ⇒ throw 0x0003 in reverse direction
  • 0 is an invalid address.
  • Max address is 2044 (0x7FC) which is a broadcast address for Accy.

Note: when trying in JMRI > NCE Command, "Binary" means hex without x, seriously \o/ ?

Lockout CV 556:

  • Use on Address of input #1, which is 4 for my home one.
  • 556 = 0x022C
  • 0xAF is Ops ACCY programming.
    • AF 00 04 02 2C [0=unlocked | 1=locked]
  • This works. It locks buttons out.
  • ACCY on controller can still be used to throw turnouts.

That means I can trivially command that from an Arduino and bypass JMRI if needed.

[s:2016-10-07] NCE Switch-8

I got an NCE Switch-8 to learn what I can (and cannot) do with it for Randall.

Looking at the electronics on the board… If there’s one thing I like about the NCE electronics, it is that they are not fancy. This is the tech I grew up with and I can look at the board and recognize the components and understand what they do. I hope it will stay like that.

Microproc: PIC16F1936

Pin 1 = Vpp (programing voltage)

Pin 8 = Vss (-)

Pin 20 = Vdd (+)

Power: MCC 7805CT

Front Left to Right : Pin 1 / 2 / 3

Pin 1 = Input / Left

Pin 2 = GND

Pin 3 = Output / Right

On the Switch-8, the large programming header can be used to get the +5 from the 7805.

From top, #2 is the +5 and #3 is the Gnd from 7805 (shared with the GND headers).

NCE AIU-01: there's a similar 7805. A +5V can be soldered on the little through-hole just on top of the 7805 on the board. Measures 5V. For a single IR sensor, use a 220 Ω resistor.

[s:2016-10-08] NCE Limitations 

  • The PowerCab / Twin can only use cab bus addresses up to 10.
    • 0-1 are the internal twin cabs.
    • 2-7 are for throttles.
    • 8-9-10 are for cab devices.
  • The AIU-01 can use only cab bus address 4 or 48-63. That means effectively on a PowerCab bus it can only use address 4, there can't be more than one on the whole bus. Quite disappointing but OK enough for home since I had no plan to have more.

I’ll repeat this in case it’s useful for others:

  • On an NCE PowerCab or NCE Twin command station, only one NCE AIU board is supported and at only cab bus address 4.

Regarding the NCE cab bus and the NCE USB interface, I realized I have two of them at home (one straight, and one modified for the direct serial-to-Arduino). They are both on address 63. I just realized the other day they were on the same address and it’s somehow not a problem, although only one polls the NCE AIU, the other one just sends commands.

On the NCE Power Pro: highly recommended to ditch USB and use the RS232, otherwise will have limited functionality ⇒ it was OK for pure cab command as I was doing before at Randall but all indications say it is not suitable to get the AIU stuff. Oddly enough, AIU status works with the Twin but the pages all say it will probably not work with the higher end Power Pro.

Update: Tried it with the Power Pro and I can confirm.

  • The PowerCab / Twin can query one NCE AIU. I connect JMRI to the cab bus via an NCE USB interface and I can read the NCE IAU status. The refresh rate is appalling but it works.
  • I plug the same NCE AIU on a Power Pro, and the same NCE USB on the cab bus of the Power Pro. JMRI cannot read the data back from the AIU.
  • I plug the same NCE AIU on a Power Pro and this time use an USB-to-RS232 adapter on the computer. JMRI can now read the data back from the AIU.

Of course, now I remember that I read about this a while ago:

Bottom line for Randall I'm going to have to switch to RS232 with a USB adapter.

All forums and sites point to the same Keyspan USA-19HS adapter:  … $25

Cable: Straight (not null modem) RS232 cable. 50 ft one … $8 from monoprice.

RS232 max length is 50 feet. That cable worked fine for me.

If the AIU had turned to be a dead end, the fallback plan B would have been to get an arduino with a wifi or ethernet shield, wire sensors directly to it and have a Go program generate NCE AIU status like at home. This is similar to the Translate project where I have a local program on the computer that simulates an NCE bus protocol and JMRI just thinks it’s connected to some NCE thingy over ethernet. Works like a charm.

[s:2016-10-11] JMRI Logix

Looking at JMRI Logix, this is a non-script click-o-drome if-this-then-that.

Conditions range from block, sensors. Actions are signals, turnouts, scripts or warrants.

Conditions can act when set or on change.

No direct throttle control, maybe indirectly via warrant scripts to run "auto trains".

One possibility is starting a script when some condition happen.

Seems interesting for people who don't want to write scripts. Tons of clicking to get things done.

Seems ideally suited for simple linear decision trees, not for free-form scripting.

Examples would be signals or turnouts set depending on block usage.

For my automation purposes, it seems fairly weak and I’ll design my own software that uses a text file for configuration. Somehow it makes non-tech people very nervous and Windows users especially seem to enjoy clicking ad nauseum in poorly designed modal dialog boxes instead of having a single text file script they can look at quickly.

[s:2016-12-01] IR Sensors

The IR reflective TCRT5000 sensors (specs) are being somewhat obnoxious. Original planning was to mount them under track, pointing upwards, in reflective mode.


  • As planned, they are easily hidden between ties.
  • Current usage is reasonable enough to tap it from the NCE AIU01's 5V supply.
  • Data sheet indicates that in reflective mode, distance is ideally up to 2-15 mm. That does not seem to be a problem when the reflective surface is a truck or tank, assuming the surface is reflective to IR.

In practice, I found the following issues:

  • Bottom black plastic on engines is not reflective enough.
  • Some gray plastic work, others seem to not be to efficient.
  • One workaround is placing some kind of reflective tape or paint under the engines. Good success using ducting metallic tape under the engine's tank.
  • However they don't trigger long enough. E.g. a strip of 2 inches will trigger for about 1 second as the engine moves, which might not be enough to be detected in time. Too much potential for NCE or JMRI to miss it depending on their own scan timing.
  • The length will depend on the shape of the engine's under body.

Possible solutions to try:

  • 1- Bump the emitter current. I'm running mine with a 220 Ω resistor on 5 V. That should be around 17 mA using a typical 1.25 V forward voltage.
  • I thought that was on the upper range of that emitter by according to the Vishay specs about, the max forward current is 60 mA. For 5 V / 1.25 VF, that would be 62 Ω resistor. Choices I have are 22, 47 or 100 Ω.
    • 5 V / 1.25 VF / 47 Ω = 80 mA
    • 5 V / 1.25 VF / (47+22) Ω = 55 mA
    • 5 V / 1.25 VF / 100 Ω = 37.5 mA
  • Running it towards the height of its range will reduce its lifetime.


  • Actual VF measures to 1.22 V.
  • My 220 Ω measures to 280 Ω. That’s 27% off. If it were truly 280 Ω, 5 V / 1.22 VF / 280 Ω = 13.5 mA.
  • With a 100 Ω that measures 120 Ω: 5-1.22 / 120 = 31.5 mA
  • With a 47 Ω that measures 65 Ω: 5-1.22 / 65 = 58 mA

20%-38% discrepancy in the resistance value? I'm not trusting the resistors (some random 5% thingy) nor the no-name meter and a single data point for each, but still that’s quite a range.

Other solutions to try:

  • 2- Run it in "face to face" instead of bouncing mode. Experimental test show that distance can be around up to 7 cm that way. Sideways, distance was about 2 cm max.
    • Idea is to have a relay box on the side modified with the emitter pointing to the track. Initial tests show that the receiver would have to be mounted slanted towards the emitter, not straight up and proper alignment is going to be tricky.
    • The sensor will work in "reverse", being on when not occupied and off when occupied.

  • 3- Use multiple emitters mounted between ties to get a more powerful illumination.
    • Will ruin the "stealth" mode, may look bulky.
  • 4- Use another IR sensor with a more powerful emitter.
  • 5- Find an IR flood lamp matching the receiver's bandwidth and place it on top of the layout, pointing down.
    • According to the Vishay specs, "Emitter wavelength: 950 nm" with a daylight blocker on the receiver.
  • 6- Make the signal turn on “longer” for the NCE AIU, either by using some kind of RC circuit or a 555 in single shot mode or some Arduino contraption.

[s:2017-04-10] Layout #3 “Test Track”

I tore down my previous layout #2 since it didn’t have a purpose anymore -- originally it was for the kids to play with and for me to play with cameras recognition of trains and automation. I’ve done my part, and the kids didn’t show interest anymore. Being a 4x9”, it was still taking valuable space in my small room. Time to update.

What I cared for is having a workbench and a simple test track on top of it. I came up with a very simple L-shaped workbench design. The workbench is designed to not have any legs in the way and lots of storage space underneath. For the test track, I have a bunch of EZ-Track around so I just used that. It’s suitable for minor switching. I won’t add any scenery, it does not look like a shelf layout since it’s a workbench.

I find EZ-Track really sturdy and easy to work with. The electrical connections are really good so the whole thing can be powered by a single rerailer terminal.

Although I do like the EZ-Track for the ease of snapping and the good contact they make, the turnouts are frankly quite so-so. Using two #4 head-to-head is guaranteed to make an S-curve issue that will derail a lot of rolling stock, for example. On all of them the point isn’t always flush with the rail and lacks a spring to keep it in place once the twin-coil has pushed it in one direction.

A few of my EZ-Track #6 turnouts started creating shorts over time. The frog can be either powered or unpowered. I like it powered but on some of them the frog can make contact with the inside rails -- there’s an insulating gap and it’s not very consistent in size. When installing the turnout, it’s easy to push the inside rails enough to close the gap and create shorts. This is easily fixed by using an Atlas Model Railroad Super Saw to recreate the gap:

[s:2017-04-12] Powering a LED off DCC

Very interesting discussion here:

Summary, TL/DR: We can power a LED directly from DCC, just add a resistor to limit to about 10 mA (or less if too bright).

Suggestion is "nice to have" a reverse parallel diode to limit the reverse voltage on the LED:

However another comment indicates it's enough to compute R to be within the specs of the reverse voltage of the LED (assuming I have the specs).

From [richg1998]: "The NCE Power Cab uses a red led and a 1k resistor to monitor the AC out of the Cab. … No reverse diode…"

That's a good point. SGTM.

This is nice and could apply to Randall on the reversing loops:

[Mark R.] "I have four signals on my DCC layout that give polarity indication going into reverse sections. The green LED is attached to opposite rails on either side of the gap, and the red LED is attached to the same rail on either side of the gap. These LEDs have been running straight off of DCC track power with no inverse protection for over 15 years and have not damaged any of them."

Let's think on how that works electrically by taking an example. Let’s say we’re looking at the “end” of a reversing loop that uses a manual toggle to reverse the polarity.

And if the rails polarity is A/B, we have across the gap:

Since it's a sort-of-AC signal, the 2 LEDs can be on either side:

  • The red can be on either rails, bridging the gap on the same side.
    It will be off when the polarity matches (same voltage), on when mismatched.
  • The green can be across opposite sides of the gap.
    It will be off when the polarity matches (which is improper), on when mismatched (what it should be).
  • It's interesting because we can do it with just 3 wires, one being common to both LEDs.

Now imagine the 2 LEDs are assembled to look like a dwarf signal placed next to the reversing loop turnout. It would make a visual indication on whether the power toggle is in the right direction. Even when using an automatic reverser module, this would be a nice display to have.

We can use the exact same principle to power a green/red mast to indicate alignment of a turnout, e.g. in the case of Sonora at Randall when we have 2 tracks going into one by using the polarity of the frog as a common to both LEDs.

[s:2017-10-31] NCE AIU and short trigger events

This is for Randall but I might just enjoy it myself too… The NCE AIU suffers from an obvious polling refresh rate issue: if an input doesn't trigger long enough, it will be easily missed.

Question is what would be the simplest circuitry possible to make an input trigger longer?

From the NCE AIU pdf:

There's a grounded common and a 5V pull up on each input.

  • When the input is open, the Microchip input is pulled up and the inverter sets the other side of the LED to low.
  • When the input is grounded, the Microchip input is pulled low, protected by the 10k resistor and the inverter sets the other side of the LED to high, thus lighting it.

The obvious way is to use an NE555 to generate e.g. a 1-second pulse. It can be powered by the 5V from the NCE AIU to make sure they share the same ground and power (both 5V need to match to be a closed circuit). This requires at least one RC circuit on the 555, and we need one per input to deal with. Potentially an NCE AIU has 14 inputs, even using a 558 (a quad 555) would still require 4 chips and some wiring or a PCB.

At the other extreme, the “simplest” circuit would be to not have any extra circuitry at all. One option I do not have is reprogram the NCE AIU. I don't think NCE would give me the source, which is too bad because I could just trivially do the 1-second delay in software -- or more exactly, sample and latch any trigger input till the next read from the NCE bus.

A more "modern" solution would be to stick an Arduino in between, e.g. an Arduino Nano is fairly cheap. How many would I need for 14 inputs? 18 pins usable per Nano e.g. 9 inputs and 9 outputs. The Nano can be powered from the 5V from the NCE AIU and would basically simulate the inputs for the AIU. Although at that point, I’d basically add an RS485 shield to the Arduino and consider getting rid of the NCE AIU to begin with.

The cheapest and simpler solution (as in "less wiring") would be to put a capacitor on the input, it should lower it slowing and then raise it slowly. That would introduce a delay into the trigger and the release so it might be good enough. The time constant to reach 63% is τ = R x C. Say the capacitor is fully discharged. We have R=10 kΩ, τ=1s ⇒ C=100 µF and τ=0.5s ⇒ C=50 µF. That's not unreasonable. There should be some resistance in series with the button to not fully short the capacitor say something like 100 Ω or 1 kΩ.

And I tried just this, using R=110 Ω and C=1000 µF because that’s what I had around. A full long button press activates the signal for a good 5-7 seconds after release. Even a very short button press still activates the signal for a couple seconds.

The one consequence is that when powering the DCC, the signal is activated as the capacitor charges for also the same amount of time. This is not a problem since I have a full laptop with JMRI that needs to boot and it takes way longer than the initial charge time.


[Back to main page]