Thursday, November 2, 2017

Market Street: The Train Departure Board

Short shameful confession time: I built the Market Street layout because it was easier to build than a video game.

A non-trivial bit of my inspiration for the Market Street layout came from the railway switching games made by SIAM Railway Simulations. These mostly-British prototype games provide accurate simulations either of a station or for dispatching a long set of track. The station simulations put you in the role of the tower man and switcher at anything from the end of a country branch to the busy through station at Crewe. The dispatch sections include British settings (Scottish Highland line) as well as realistic versions of Tehachapi Pass, either in the 1920’s or the 1960’s. I’ve played some samples and bought other games.

SIAM's samples page lets you get a taste of the games by downloading demonstration, reduced versions of their simulations. The samples include dispatching the Highland line and Tehachapi Pass, and handling switching in the stations at Crewe and Penzance. The Tehachapi dispatching game gave me a great appreciation for getting trains over Tehachapi Pass in the steam era.

Penzance, 1987 game from SIAM Railway Simulations

Of course, I wanted to try some more American prototypes - handling the traffic coming and going from the Oakland Pier, perhaps. Or why not the San Jose Market Street station? I got a fair way through making an iPad game so I could switch those places, but I found it difficult to control all the switch engines and car movements I wanted to include. After enough tries, I found myself asking "so what would a layout set up like one of these games look like?

So, I’ve built the layout, and I've got an answer to that question.

However, to make the layout operate like the game, I need to know what trains need to come and go. More importantly, if the layout is being exhibited, I want folks to see the names of the trains coming and going so they can understand the sheer number of trains that could be handled in the 1920’s, even if the station was a creaky old Victorian barn.

Suddenly, that way-too-large display on the Raspberry Pi has a use.

Snippet of departure board. Click here to try it out for real.

My inspiration was a European-style flip-card station sign; it’s not quite prototypical for the era, but anyone who’s been in a large train station has seen one of these, so showing a listing of trains should both inform and hint at the sheer number of trains they’re seeing.

And luckily, making such a sign is easy. One of the neat habits of programmers these days is to share programs they’ve written so others can use those programs. A friendly guy named Paul Cuthbertson liked the idea of drawing flip-style departure boards, and based on an inspiring article, went off and wrote a web page to draw one.

Now, I need more than just the departure board graphics for the Market Street layout. I need a sped-up fast clock to show the current simulated time on the railroad, for the compressed track plan means trains won’t take as long to move around as on the real thing. I’ll need a way to control the board when trains arrive and leave. I’ll need a way to manage problems - backing off accidental train departures, or stopping the clock in terms of problems.

I took Paul’s code and created this departure board for San Jose Market Street. (See this Github project for the source code itself.) Pressing a number key (1-9) causes the nth train to move to its next state; a train that’s on its way will go to “arriving” on the first press, then “arrived” on the second, then will be removed from the board on the third.

Paul’s card-flipping web page turns out to require a lot of computing horsepower to flip through all 26 characters for each change. The poor little Raspberry Pi, being the size of a credit card, couldn't keep up. Instead, I changed the program so that the board only performs 6 flips per letter, instead of flipping though the whole alphabet like the real flip board.

So now, when I set up the layout, I just need to set the box containing the DCC electronics somewhere both the audience and operator can see. The stationmaster can use a keyboard to advance the departure board as trains arrive and leave. The operators know what trains they're building; the audience gets an understanding of how easily they could commute from San Jose to San Francisco (or Salinas) in 1928.

And I get a modular layout that's inspired by a video game.

The modern practice of sharing sample code and reusable libraries is a great part of modern programming culture. Great thanks to Paul Cuthbertson for the core of the departure board code!

If the departure board idea might work for your layout, download the sources from GitHub and customize it for your own use. Drop me a note if you find it useful!

Market Street: Electronics and DCC

From the start, I knew I wanted the Market Street layout to have multiple operators working in parallel: switch crews making up and breaking up trains at the station, road engineers coming from the roundhouse, and taking a train out, and freight crews switching the cannery and packing house on the layout. That meant I needed to choose a DCC system for controlling the trains, and I needed to decide what kinds of throttles to use. There were two obvious choices: I could go with Digitrax, the standard for Free-Mo modules, or I could use the same system I had at home - EasyDCC. Neither was attractive. I’m not fond of the Digitrax system; I’ve always had trouble understanding how to use their controls, and have seen too many cases where an errant button press disabled a throttle. EasyDCC would allow me to reuse my existing throttles, but I’d still need to buy a new command station and booster, find an enclosure for both, and then wire all the modules with coax to allow wired throttles to be plugged in around the layout.

Another engineer running a train on the Silicon Valley Freemo-N layout with a phone

Luckily, I was reminded of the local Silicon Valley Freemo-N group. They’d set up their dozen modules (most based on Bay Area scenes) at the 2011 NMRA convention up in Sacramento. When I stopped by to check out the layout, Dave asked if I wanted to run a train. “Sure, but I don’t have a throttle.” “Doesn’t matter,” he replied. “You’ve got a phone - just install WiThrottle.” They were using the iPhone-based WiThrottle, all talking to some random command station connected to a computer. I downloaded the app, and within a few minutes was running a streamliner across their layout.

Fast forward to last year. At the Bakersfield NMRA convention, one of the vendors had the SPROG 3 - a tiny DCC booster and command station that can power smaller layouts. It could be driven by the dirt cheap Raspberry Pi computers and the JMRI software, making for a full DCC system in less space than a cigar box. This seemed like the perfect choice - wireless throttles for the layout meant no wires for a throttle bus. Operators came with their own throttles, so I didn’t need to shell out hundreds for throttles. It could all fit in some tiny box.

Back: Electronics

Front: Monitor

The Sprog / Raspberry Pi plan won. The Raspberry Pi is a full Linux computer; with a keyboard, mouse, and monitor, it could do anything a big computer could (though a bit slower). I wandered over to Fry’s to pick up the Pi ($50). At the same time, I picked up a cheap flat panel monitor with an HDMI plug; the cheapest, at $99, was a 22 inch display - bigger than I expected. It turns out smaller monitors are speciality items now. That monitor set a minimum size for the electronics box.

With the monitor and electronics, I made a plywood box to hold them all in - the monitor set just inside, facing one way, and electronics the other. The box also contains the power strip, extension cables to reach the modules, and power for switch machines - all nice and compact, and easy to transport. Once it’s plugged in, I can use the monitor to start up JMRI and the command station; with some quick clicks on my phone, I’m running a train. All I need to do now is get some additional plywood to make lids for both halves of the box, and I’ll be all set.

Interesting aside: my nephew came over a couple weeks back and wanted to see my trains. The big layout was a mess, so I laid the Market Street modules on the floor, plugged things in, and we ran trains. When we went back inside, he beamed. "Mommy, we ran trains with a phone!"

Now, that 22 inch monitor is too large to use just for starting up JMRI; check out our next episode to hear what else I can do on that screen.