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.

Thursday, December 25, 2008

Frohe Weihnachen!



Merry Christmas and a Happy New Year!

Sunday, November 23, 2008

Hier auch!



Winter's here, too, not only here.

Wednesday, November 19, 2008

Morning on Lake Zurich

Sunday, November 02, 2008

MythTV progress

With a nice 32" wide-screen LCD plain analog TV doesn't look very exciting, so I finally took the plunge and got a Silicondust HDhomerun. Setting it up was a breeze. It's supported since MythTV 0.20. Simply connect to cable and Ethernet, scan for channels (use QAM-256/cable-high) and we are in business.

Recording works, but playback ... oh, boy. That poor Celeron D 2.66 has no chance to show HD content. I went through the motions to update the Nvidia driver, update MythTV to 0.21, scoured the Internet for all the tricks to make XvMC work a bit faster, and I got almost to the point where the choppy audio stayed in sync with the choppy HD video. Bah, no fun.

In the end I replaced the Celeron with a Dual Core E2200 processor. A few data points for comparison: With the Celeron we got occasional hiccups when watching a recording while something else is being recorded, or commflag ran. With the E2200 I recorded two analog channels, and two HD channels, and watched another HD recording in parallel with no problem whatsoever. Neat.

Tuesday, October 28, 2008

Arriving back home in the evening



I'm impressed by the quality of the camera in T-Mobile's G1, given how crappy it's optics look from the outside.

Friday, October 24, 2008

Monday, October 20, 2008

Coffeetable - take 2

It turns out the proportions of the first try felt right only when making the table a mere 10 inches high. That didn't quite work. I need the coffee table to be about 18 inches high, and stretching the legs looked really bad. I don't want the table to grow too big, and found a nicely sized glass tabletop at IKEA. The Granas coffee table has just the right size. ... and it's cheaper than buying just a glass tabletop at a local shop.



Here is my second try. I made the box for the layout slightly higher, so that I can fit drawer, landscaping, buildings, and other items under the glass. I think the new foot arrangement makes the table less bulky, and it should work well in our living room.

Friday, October 17, 2008

Proposition 7 a really bad joke

One would think that Proposition 7, which would require to have 50% of all energy produced in California come from renewable sources would be a good thing. Ballotpedia has a good summary.

The Vote Solar blog has a nice analysis of the actual effects of Prop 7. Furthermore, the vast majority of the renewable energy industry opposes it, too. Even the Sierra Club doesn't like it.

I continue to be amazed at how american politics work.

Thursday, October 16, 2008

Train in a coffee table?

Yes, I'm serious with building a train layout in a coffee table. Here are my constraints:

  • It needs to be a glass table (duh)
  • The glass should cover the whole top of the table (i.e. no exposed wood on the top)
  • It needs to be big enough to allow for a continous run N scale train layout
  • There needs to be more to the layout than just a train on a loop



This is my first try for the table, made with Sketchup. The table is about 10 inches high (25cm), 46 inches long, and 30 inches wide (~120x75cm). The glass tabletop is made from tempered safety glass, so if it breaks it will break into small pieces. Right under the glass is a 10cm high box that will hold the layout. The layout sits on a sliding drawer (not pictured), that can slide out all the way, so if I need to work on the layout I can do so with minimum fuss.

Electronics, transformer, and stuff, would be mounted under the table and connected to the layout with a multi-pin connector, so that it is easy to disconnect the drawer from the table. There would probably be some kind of connector on one side to hook up a tethered control. I'm thinking of using a very basic EasyDCC or Digitrax setup. Controlling switches and whether to use uncouplers is still an open question.

I haven't decided yet what kind of landscaping I'd use either. One option clearly is to leave it fairly bare-bones and build something with LEGO bricks. Or let the kids decorate. Or actually model some pretty landscaping. Maybe a desert theme with an old ghost town, or something that more closely resembles California's Sierra Nevada / Gold country.

Sunday, October 05, 2008

Braking in digital and how my expectations have gone up again

Several Web sites deal with approaches to how to make digital trains stop in front of a red signal. It seems a need that was implemented trivially simple in analog times (isolated section before signal; red signal removes power from section; no power, train stops), somehow fell under table when we entered the digital world. While it is now possible to run multiple locomotives independently on the same section of track, stopping them in some automated fashion at the right place as needed is surprisingly hard.

The standard solution (and most similar to the old analog way) is to use a little module that generates a brake signal in an isolated section. The implementation details vary from system to system, but they all share the property that you have no control over the locomotive until the signal is set to green. At list the loco lights stay on, and the loco decelerates in a somewhat controlled fashion before the signal, which is much better than the analog way. The cost of the brake modules, which can run as high as $40 per module and signal, is steep, too.

Other solutions that track locos with IR or RFID, are even more expensive.

Making matters worse is how most decoders implement the deceleration part: If the brake signal is detected, the decoder gradually reduces the speed by one speed step every 1/nth of a second. This means a locomotive of an express passenger train going full speed needs a longer distance to stop than a slow local freight train. In order to reliably stop both kinds of trains, one needs to size the brake section long enough for the express train to make a stop in front of the red signal. ... Which means the local freight will stop much farther away from the signal, when in reality I want both to slow down and stop before the signal, or even slow down from the advance signal until the "engineer" can "see" the main signal, then creep to the main signal, and stop only if it's still red once we get really close. This is exactly what real trains do to avoid the hassle of first stopping several hundred tons of steel to a dead stop, just to get it going again a minute later.

Yes, given that digital control should be able to give me this behavior, my expectations have gone up ... again.

The only way this actually can work is with using computer control for the trains not under manual operator control. While it's a lot of fun to really "drive" a train around a larger layout manually and do all the right moves, sounds, etc. at the right time, my layout is neither big enough to provide for long train running, nor do I have the space (or interested people) to actually keep traffic up.

The next best thing is to have a set of trains run on a (pseudo) schedule, and control a few of them manually. E.g. swapping out cars from a freight train, run a passenger local, or even switching work in the yard along with deliveries to local industries. This is fun, but I still want the feeling of a busy railroad with train meets, and background traffic, that I enjoyed with my fathers layout as a boy, and not have only one train operating at any one time.

There is actually software that implements the kind of train behavior and control I'm looking for with minimal amount of detection points. Railware substitutes detection points around signals with precisely measured distances of track, and calibrated locomotives. Since the software knows at any point in time how fast a loco is going, and keeps track of occupancy state of the various sections, it can deduce at what location of track a train is, and make them stop within centimeters from arbitrary points on the layout, ... e.g. just before a red signal.

Now that my expectations have gone up, I want the signals to show red behind a train. I want trains to stop properly at that signal. I want to be able to see traffic happening on my layout without me doing anything ... Well, ok, not so sure about that one. I want switches lined as needed. But at the same time I also want to be able to intervene manually at any point in time, and most importantly, I don't want to sit in front of a screen.

There. I said it. And just created yet another money sink.

Yes, I actually don't want to control my switches and signals from a screen. I stare at a screen long enough during my day job. I want the tactile feedback of buttons, switches and knobs to run my trains, not using a mouse.

Some visual feedback about the state of what the computer thinks what train is where and where it's going will still be needed, so there will need to be a screen somewhere. I'm dreaming of a self-built digital enabled control table.
Alternatively, I control switches and signals the old analog way (still using a control table, but not nearly as slick), but then I can also say Goodbye to most of what I wrote in the previous paragraph.

Time to pull out plans of the layout again, and figure out what I need where, and how much it's going to cost me to do all this... Then take a deep breath put it back in the drawer and concentrate on building the coffee table for the living room first...

Tuesday, September 16, 2008

I'm on the map

A little while ago Streetview did a gimmick to celebrate their one year anniversary. They did a special photo shoot of the Google campus with Googlers lined up along the street. It was quite some festive atmosphere.

I'm on two shots. One on Charleston Rd. I'm to the right of the guy in the black pullover raising both arms.


The other shot is on Amphitheatre Parkway. I'm a little bit to the left of that no parking sign on the street.

How did I manage to be on two shots? The Streetview car with the cameras was driving down Charleston Road to Rengstorff and Amphitheatre Pkwy, then headed towards Shoreline Amphitheatre. Between Charleston Rd and Amphitheatre Parkway is Charleston Park. As soon as the car passed, a whole bunch of us ran to the other side of the park and waited for the car to show up again. It was much slower than expected, so we could have walked leisurely over and still made it...

Sunday, September 14, 2008

Catenary installed

I completed installation of catenary on the underground sections that are permanent. I used the old Maerklin parts, since they are very sturdy and easy to install. Later in the visible areas I'm planning to use Viessmann or maybe even Sommerfeldt. Next up, the ramp to the second level, as well as testing automated, digital braking.

---

Die Oberleitung ist nun auf den permanenten Abschnitten im Schattenbahnhof installiert. Ich habe die alte Maerklinoberleitung wiederverwendet, da sie sehr robust und einfach zu installieren ist. In den sichtbaren Bereichen der oberen Ebenen werde ich wohl Viessmann, oder sogar Sommerfeldt verwenden.
Als naechstes ist die Rampe zur zweiten Ebene dran, sowie Experimente mit digitalen Bremsen.