Tag Archives: Computers

The CH&FR Goes Digital Part 7


Today we present the long-awaited (I hope!) Part 7 of my “The CH&FR Goes Digital” series.

This episode dives into block detection using the Digitrax BDL168 16-input block detector.  We cover track setup, wiring, connecting the BDl168 to your computer with JMRI, and provide a live demo.

Block detection is what we call “knowing where your trains are”, and it works very similarly to how the real railroads do it.  The layout is divided up into electrically separate segments, or “Blocks”.  Each Block is a section of track where you want to be able to tell whether there is a train on that track or not.  It might be a siding, or a length of mainline track, or (less likely) a track in a yard.  The Block is electrically isolated from all the other blocks, and the power feed to one rail is fed through a block detector like the BDL168.

When a locomotive sits on that section of track, even if it is not moving (under DCC) a small current flows through the locomotive’s decoder from one rail to the other, and the BDL168 can detect this current flow.  When it sees the locomotive’s current draw, it reports that section of track as “occupied”.  If there is no current flow, the BDL168 will report “unoccupied” for that track section.

Of course, on the prototype railroad, the trains provide their own power, but the block detectors are able to work very similarly.  By inducing a voltage between the rails, the detector can watch for the metal wheels of the train to short the rails together, indicating that the track is occupied.

On the model, without a little work, we can only detect the presence of locomotives.  Most model railroad cars (in N scale at least) come with plastic wheels which do not conduct.  On the few which come with metal wheels, the axles are insulated to prevent the car from shorting out the track.

By adding a small resistor to one wheelset on each car, the entire train can be detected, not just the locomotive.  One of my favorite videos on how to add resistive wheelsets is by Daryl Kruse who runs the UPRR Geneva Subdivision in N Scale.

For further reference, here are some links…

55″ Dispatcher Panel

55" Dispatcher Panel by BGTwinDad
55″ Dispatcher Panel, a photo by BGTwinDad on Flickr.

This is an early step in the “dream plan” for dispatching my layout(s).  The photo doesn’t really do the scale justice.  This is JMRI displaying my layout panels on our 55″ living room TV.  It’s big enough I can tell track occupancy from my kitchen thirty feet away.

For now, it’s just a novelty, because the current Glover’s Bend layout is small, but the ultimate goal, the “Chestnut Hill Sub” will be an around the room shelf layout big enough for multiple operators, and a panel this big will be easy for everyone to check when they want to see what’s coming.

Ultimately, all of this will also be web-accessible, enabling truly remote dispatching, for my friends who are too far away to visit in person.

Someday, when I win the lottery.

Technicals:  I just installed a Digitrax BDL168 block detector circuit under the layout, and it is monitoring 16 different blocks around the two main lines.  It’s feeding information back over LocoNet to my train room computer, which is generating the displays using the JMRI train control software.  My train room computer happens to have an HDMI display port, which makes it easy to convert my TV into a monitor.  Add a wireless keyboard and trackpad, and I can dispatch trains from my couch!  Easy-Peasey!

I’ll write an article or two about installing the BDL168 and setting up the panel once I get everything debugged and working properly.


Science Night!

Science Night by BGTwinDad
Science Night, a photo by BGTwinDad on Flickr.

Last week I was asked to provide a presentation on a science or engineering topic at my daughter’s school. Since most of the other presenters had the “work” and “research” angles well covered, I decided to show something fun.

To the left is a test loop of track that I built.  The loop is broken into 14 blocks that are wired for train detection through a Digitrax BLD168.    The front, back, and left/right curve halves are connected to Digitrax RX4 for transponding detection.  That may be a lot of technical “jargon” for some of you.  The BDL168 detects which of the 14 track blocks the locomotive is on.  The RX4 allows the locomotive to “check in” and report its road number to the computer.

Speaking of the computer, in front of the layout, left to right you see a Digitrax Zephyr Xtra command station, which actually runs the train.  The small box in the middle is a PR3 which is basically a USB connection for the Zephyr.  And then, of course, is the computer.

On the computer (an Apple MacBook Pro), the JMRI software program is running.  It’s displaying a map of the oval,with the train’s location highlighted.  At the same time, it’s running my Virtual Sound Decoder, playing the sound of the engine through the speakers at back, and of course the sound appears to be coming from the locomotive, which is the whole point!

The poster board to the right has some “slides” showing how various sciences (both “hard” and “soft”) can be applied to Model Railroading or any other hobby.

The whole thing was a big hit with the kids, I think.  Either that or they were very polite.  Of course, they were getting extra credit for it!

LocoIO Completed!

LocoIO Completed! by BGTwinDad
LocoIO Completed!, a photo by BGTwinDad on Flickr.

What is this? This is the LocoIO board. It was designed by John Jabour and updated by Hans DeLoof, and is available from a Belgian company called “Het Spoor” (Dutch for “The Track”) as a kit for about $45 US including shipping, with the current exchange rate.

This little guy plugs into the Digitrax LocoNet, and has 16 independent I/O pins. Each of the 16 I/Os can either act as an input, generating a LocoNet message when the voltage on the pin changes, or as an output, changing its voltage in response to a LocoNet command.

What’s it for? Well, I’m going to use at least some of the I/Os to turn LED lighting on and off from my JMRI computer. I can use other pins as inputs from block occupancy detectors or control panel switches or whatever. I can even drive the flashers on a crossing gate signal if I like.

With an add-on board it can be used to drive turnout motors or solenoids, and of course the inputs can also provide direct turnout position feedback to the LocoNet.

The kit comes as a bare PC board and a bag of parts, and to build it you have to place and solder all of the parts. This may seem intimidating, but if you’re able to solder track feeders, this should be no harder than a typical model structure kit. The PCB is labeled clearly where each part goes, and aside from figuring out which resistor is which, the placement is pretty obvious. While there are a lot of pins to solder, the small size means it goes quicker and easier than rail soldering.

You may note from the picture that there’s an empty chip socket in the center. This is where the microprocessor “brain” goes. I need to do a final inspection and clean the solder flux off the board before installing this most important chip.

Assembly took about an hour, and went very smoothly. Next up after cleaning and testing, I will install it on the layout and hook it up to a 12V power supply, my LocoNet, and the lights I want to control. After programming it from JMRI, I’ll be ready to use my very expensive light switch!


(Note: Edited 17-Aug-12 to add attribution to John Jabour)

Virtual Sound Decoder for JMRI

Here’s a little software project I’ve been working on, alongside of my more “hard” modeling work.  I made a video demo, as it can be hard to express how this is all supposed to work in words.


This is the result of a confluence of several factors.

I have long wanted to have sound on my layout, but I was balking at the expense and the lack of sound quality from N scale sound decoders (this has more to do with physics and tiny speakers than the quality of the available products).  SoundTraxx had been pre-announcing their SurroundTraxx product for a while, and a couple of online friends of mine have been toying with under-the-table sound systems being driven by hardware sound decoders and larger speakers.  And I had been playing with the JMRI Java Model Railroad Interface project.

It occurred to me that I could write a software program that would emulate (or simulate, if you prefer) the function of a hardware sound decoder, listening to the layout interface for throttle commands and responding to them  just as a hardware decoder installed in a locomotive would.  And most PCs these days come with surround sound audio systems!  JMRI already provided much of the foundation for this, including the layout interface, a nice abstraction of the throttle, and integration with the OpenAL 3D audio system, so it seemed a good match.

I’ve been working on this for a few months.  The basic idea follows very roughly the scheme of an add-on sound decoder.  For each engine you want to have sound, you launch a “Virtual Sound Decoder” (or “VSDecoder”) on the PC, select a “sound profile” from a “VSD File” and assign it a DCC address.  The virtual decoder then sits in the background and generates sounds in response to the throttle inputs.  Thanks to the way JMRI handles throttles, it will respond to any throttle on the system, whether a hardware or software throttle, or a wireless-attached throttle on a PDA or smart phone.  Buttons on the VSDecoder allow the user to directly trigger sounds, bypassing the throttle if desired.

The “VSD File is somewhat like a Digitrax SPJ file, though the two are completely incompatible.  The VSD file is a Zip archive containing all of the source audio files, plus a configuration file (written in XML) that tells the Virtual Sound Decoder when and how to use the sound files.  Each VSD File can contain one or more “Profiles”, each of which describes a specific configuration of a locomotive.  This could be multiple variants of a particular type of locomotive, or several completely different types of locomotives. For example, a VSD FIle might contain profiles for several different EMD engines based on the 567 Diesel prime mover, or an eclectic collection of engines belonging to the Pennsylvania Railroad.  VSD Files can be easily constructed by and shared among folks who are interested in doing so.

Work progresses steadily, and I hope to have a version of this included in the 2.13 development release of JMRI at some point.  In the meantime, if you are interested in developing or providing sound files, let me know!


JMRI at Trackside!!

JMRI at Trackside!!

Originally uploaded by BGTwinDad

You can’t read the screen here, but what you are looking at is my “new” computer, with JMRI talking to WiThrottle on my iPhone. On a desk right next to my layout!!

The computer itself is a hand-me-down from my parents who just upgraded themselves.  I dropped in a new hard disk and picked up a display, and “Shazam!” my kids can stay off the Mac and I can run my trains!

I don’t have a DCC system yet, so I can’t actually DO anything much with it, but I was very surprised how easy it was to set this up. The online instructions were easy to follow, and the system just “came together”.

One interesting side note. I remember buying my first hard disk to install in a 386-SX PC when I was a teenager. IIRC, it cost $200 for 20 MB at the time, and that was considered a good price for a massive disk. Note that the price works out to $10 per megabyte.

The new disk in this recycled computer is a 500GB Seagate, and it set me back $50. That is about 1/100 of a PENNY per megabyte. About 5 orders of magnitude price difference in 25 years.

This was all so much fun that I may have to pause my layout construction (purchasing, at least) while I save up for the Digitrax Zephyr and decoders I was planning to get for Christmas…