Sunday, February 22, 2009

computer control for model railroads: srcpd & spdrs60

Even as a boy I already dreamed of controlling my model railroad with a computer. At the time I had a Schneider/Amstrad CPC 464 with Z80 CPU, 3 inch floppy drive, and a whopping 256kB (yes, KILO-Byte) memory. I thought about using the Centronics printer port to hook up a bank of relais to control switches and semaphor signals. Little did I know...


Fast forward 25 years. Computer-controlled model railroads are pretty common these days. I still love the idea to have a computer control train movements for background traffic, or when I just want to show off my layout. However, it's so much more fun to actually run a train and do stuff with it, while a computer takes care of background traffic tasks.

Over the last two weekends I hooked up the Intellibox via serial port to an old Dell Latitude laptop (which happens to have a fantastic 1600x1200 pixel display), installed the brand-new Debian 5.0, srcpd, and spdrs60.

srcpd is a middle-layer program that hides the mechanics of connecting to the model railroad and provides a generic TCP interface and protocol ("Simple Railroad Control Protocol").

spdrs60 is a graphical UI that is modeled after a Siemens control tower design commonly installed in the 1970's and 80's in Germany ("SPurplan DRucktasten stellwerk bauart Siemens 60").

Taken together, the photos show the result: I have computer control of my layout, including track occupancy feedback. The screen shows the tracks in hidden staging and the ramps leading to it, including the temporary return loop at the top of the ramp. Occupied tracks are illuminated with red indicators.


At the very top of the panel, just pass the bypass switch, spdrs60 shows a train making its way up the ramp, and if you look closely in the upper photo, it's the blue/beige BR151 with a short freight train in the background.
Staging tracks 3 and 4 are currently empty. Track 2 is also illuminated in red, indicating a train. In the upper photo we can barely see it's a BR86 steam locomotive with a gravel train. Finally, track 1 on the computer is still grey. When I took the photo, I didn't configure the feedback sensors for track 1 yet, so the computer doesn't yet show that track 1 is occupied by the red BR216 with a passenger train.

So far, so good. Under ideal circumstances it all works nicely. I control trains from the Intellibox, and the track illuminations on the computer screen change accordingly. I can even "fly blind" and start and stop trains in the right places with only looking at the feedback on the computer screen (not quite the point of this, but a necessary pre-condition for automating control of hidden staging).

However, I ran into multiple problems, particularly with srcpd and how it interacts with the Intellibox:

  • srcpd (at least in version 2.0.12) has a bug that causes it to crash whenever it receives a locomotive status change (INFO GL) for a loco whose id is in the range srcpd is trying to keep track of. Work-around is to set the GL range to 0, so srcpd doesn't try to keep track and report on loco status changes. Very unfortunate since I will need that functionality.
  • The Intellibox serial line control of srcpd tries too hard to be smart. E.g. it attempts to auto-detect line speed, even though there is a speed setting in the configuration. As a result, if srcpd happens to crash and starts up again, its attempts at auto-detection will yield garbage sent to the Intellibox, which can cause the train last controlled by the Intellibox to get a command to run and cause havoc on the layout. The only work-around I know for this, is for srcpd to be started only once after the Intellibox is powered up, or power-cycle the Intellibox after a srcpd crash. Annoying. I might try to change the code so it does all this smartness only when I configure an "auto-detect" line speed, which I won't :-) just open the darn serial port at 19200 bps and be done with it.
  • The Intellibox spontaneously rebooted twice while experimenting with this, and sometimes shows "=0=" instead of the speed or decoder protocol setting for locos. A power-cycle gets rid of the "=0=" display. I'm not quite sure what this stands for and how to get rid of it without power-cycling.
  • spdrs60 has no "intelligence" for train movements. The raw SRCP protocol needs to be either controlled programmatically, or with typed SRCP commands which is not hard by annoying. The syntax is similar to common ASCII based Internet protocols like SMTP or HTTP. In other words, spdrs60 is useful as a control panel for train movements, but it can't implement an automated control system for the staging tracks. However, I do like the openness and flexibility of the srcpd approach.


Railware is so much cooler than this. sigh.

Yesterday, I came across JMRI which is a different, and apparently quite mature open source software that also supports the Intellibox, at the expense of the generic SRCP middle layer. The UI is substantially more bare bones than spdrs60 and seems to be harder to set up, but JMRI might address some of my problems. It also provides Java libraries I could use for extending functionality, so I'm going to experiment with it next.

Monday, February 16, 2009

Soaked!



It's now raining for more than 24 hours straight. Our backyard is a swamp. There's a lake forming at the edge of the patio. Don't want to leave the house. Brrrr...

Apparently we had a fifth of the season's rainfall this far in the last 24 hours.

Wednesday, February 11, 2009

And there were geese



There's a new soccer field next to Amphitheatre Parkway. Recently, a flock of Canadian Geese decided to make this their resting ground.

Tuesday, February 10, 2009

And there was snow



Snow on the hills around the valley. I always loved seeing this, but this time I had a camera with me and the hills were not shrouded in clouds.

Thursday, February 05, 2009

Maerklin insolvent

Uh oh.

Marklin has filed for bankruptcy protection.

Tuesday, February 03, 2009

Printing a full size track plan in Xtrkcad

Now that construction of hidden staging is almost complete, I'm moving on to building the trackwork of Talheim station and its adjacent industrial areas. There are several challenges for me with this area.

Plan and reality don't quite match. While I'm shocked with how acurate I was able to reproduce the plan of staging, I noticed only very late that the way I laid out the track in the space available is off by about 10cm from plan. That means the upper levels of the layout would need to move by that offset as well. However, Emsingen station has very tight space restrictions due to access hatches in the back of the layout and can't really move in either direction. This means I have to match up plan with reality.

K-Track on cork roadbed. I've never done this before. In staging I used Maerklin's original M-track and just glued corksheets on the ramps. This method is very forgiving and tolerates non-perfect alignment just fine. With K-track, once the cork roadbed is glued to the sub-roadbed, the track actually has to end up in the right place with only a couple millimeters tolerance. Since the track can't really move and I have a tricky switch combination right at the north end of Talheim, I need to be much more careful when installing the cork, so that cork and track end up in perfect alignment in the end. Since the cork forms the base of the track roadbed which will be ballasted later, being careful here will ensure better looks, and better operation later.

Flextrack. I never used flex track before. It's potential uses sound awesome and Maerklin's version is a marvel of engineering (an expensive marvel at that...)
Using flex track I can build the Talheim station in a fairly wide curve and have much more freedom with arranging and connecting the industry trackage.

So, what do I do to get just the right curves in the right position *before* I cut the baseboard from that large 8x4 1/2 plywood board and fit it in the layout?

Print the track plan in 1:1 scale and lay out the track on top of the printout. This way I can bend the flextrack to just the right radius, pin it down, mark it on the board, install the cork, and finally put the track on the cork. I learned this technique from Joe Fugate's video series.

Xtrkcad thankfully supports splitting up the printout into multiple sheets. At first I figured I use the maximum paper size I have available at work and print on that (11x17), but the prints either came out in the wrong orientation or with a Letter size boundary box, or all white with cutting marks in the corners (very annoying...)
I didn't find a way to get around the boundary box problem, so eventually I resorted to just printing on Letter size paper.

Here are the steps to check proper parameters for printing:

  • File -> Print
  • In the Print Dialog, click [Setup]
  • make sure settings are as follows: Printer FILE, Paper Size Letter, Printer None, Format Portrait
  • Click [Ok]
  • In the Print Dialog, verify the settings as follows: Print Scale 1, Page Width/Height 8x11 (21.59x27.94), Page Format Portrait, Print Order Normal, Uncheck Engineering Data
  • Set the remaining check boxes as you like
  • Xtrkcad shows a grid on your track plan, click on the boxes that cover the area you want printed.
  • Since Talheim station is at roughly a 45 angle, I used the Origin X/Y, and Angle textfields to adjust the grid so that two rows of boxes cover the majority of the station area.
  • Hit Print enter a file name. This will produce a Postscript file.
  • Next I used ps2pdf to create a PDF from the Postscript file, which can then be loaded into your favorite viewer for checking.
  • To print to the printer I'm using OS X Preview, or KDE's kpdf and adjust the printer settings to print in grey-scale only. Don't need to waste that expensive color toner...


Overall, I hope the end-result will be worth all that effort...

Online shops for model railroading

There are quite a lot of sites catering to model railroaders. Most have the problem that their online catalog is substantially larger than their in-stock items. Some don't expose whether they have an item in stock or not.

My favorite for Maerklin related pieces is EuroRailHobbies in Vancouver, B.C. Good selection, but they suffer from the "don't show what we have in stock" syndrome. Good personal service, and so far they were able to organize everything I ordered. Good prices, too. However, they are SLOOOOOOOOW. Only one of my orders got shipped the next day, most took 1-2 months to ship (mainly, because they were waiting for a shipment from Germany...). I'm usually not in a hurry, so I don't mind the wait, since their prices are often 10-15% below their US competition.

In the US, of course there is Walthers in Wisconsin, which recently took over distribution services from Maerklin USA. Their Web site is quite messy, and they tend to charge near full retail. I ordered a few things there if I couldn't find the part I wanted elsewhere.

Euro Model Trains has a wide selection of German and American model railroad related brands, a somewhat funky Web site, but they also sell the items from the full Walthers catalog, usually a few bucks cheaper than from Walthers directly (someone explain that to me...) The one order I placed with them has not arrived yet. We'll see how that works out.
Their prices tend to be a bit higher than EuroRailHobbies, but not outrageous.

Somewhat related sites are MicroMark, which specialized on items for the professional modeller, and AllElectronics which has an electronic parts selection geared towards (railroad) modellers. Both MicroMark and AllElectronics have hard to find items like european style terminal blocks (which are much cheaper and more flexible to use than the american counter-parts), or 3M insulation displacement connectors (IDCs), also known as "suitcase connectors".

Finally, for general electronics parts, I like Mouser Electronics and DigiKey. Mouser's online catalog is a bit better organized and really good for browsing. Especially when searching for that specific part you can't quite name.

Do you know other useful model railroading/electronics sites? Add them in the comments.

Monday, February 02, 2009

Model Railroad shops in the Bay Area

Surprisingly, there are quite a few local shops that claim to carry Maerklin.

The Eisenbahn Clinic is a one-man operation in Hollister. Not really a shop, but Wolfgang repairs and modifies locomotives, and does various fine mechanics work.

Hobbytown USA is a franchise chain with a store nearby in San Jose (on Blossom Hill), which, unfortunately, has a very small railroad section (the only good thing there is the magazine stand). Maybe better that way, I might leave quite some money there otherwise, since they are so close. The store in Fremont is supposed to carry Maerklin. Haven't been there.

D&J Hobby in Campbell used to carry Maerklin, both HO and MiniClub (Z). Last time I was there their model railroad department looked rather sad with lots of empty shelves and the same old stuff I've seen a year ago, that apparently they couldn't sell. Even their selection of US brands in HO or N scale was pathetic.

Tom's Trackside Trains in Burlingame is supposed to have Maerklin. When I was in the vicinity a while ago, they were closed, so no idea if they actually do.

Loco Boose Electric Trains in Redwood City is another store I want to check out some time.

Franciscan Hobbies sounds promising with a large selection of brands and stuff in the store. Worth a shot for getting supplies for the living room table...

A quite impressive store for american brands, as well as basic scenery material and other supplies is The Train Shop in Santa Clara. They are a tad on the expensive side compared to buying online, but are local, and have a huge selection of inventory, what else can you ask for. The store is pretty old fashioned, but functional.

Do you know any other model railroad shops in the South Bay or Peninsula? Add them in the comments.