When I was a kid, I was quite enthusiastic in model railroads and their 1:1 counterparts. I spent my childhood living next to a shunting yard. Huge machines, sounds and smells of large displacement turbo diesels, and occasional visits of huge vintage steam engines made a lasting impression to a small me.
Years pass, priorities in life change, and eventually these things did not play that big role in my life any more. However, that lasting impression of those 72 liter twin turbo engines, and quite a collection of Märklin models from my childhood still kept the spark alive, without me realizing it.
Fuck 2020.
I had many plans for year 2020, and to be frank, model railroading was not among them. However, due to certain circumstances, I found myself with plenty of free time. For a reason still a bit uncertain to me, I decided to take a look at my old model trains. I found my old Märklin Z 1:220 starter kit, which my mother bought me as a present when I was a kid, and decided to give it a try, after many years of sleep. These small precision mechanical things do not like sitting stationary, so a complete cleaning and re-oiling was in order, and as the small steam engine model came back to life, my interest towards these things came was back. What if.. one more time?
But why?
For me, these things involve working with precision mechanics, and give you canvas to let your creative side loose with paintbrushes and airbrush. They also give a nice opportunity to learn new high-tech skills in embedded electronics, software development, and other nerdy things like that, which are in connection with real world physical things. They let you write code, learn and try stuff, and see something physical happening as a result. Beats helloworlds any time. The Serfaus layout runs on Linux, Node RED, custom motor control algorithms and such.
These things are tiny
Model trains require plenty space, which I don’t have. Even if I did, I was not sure, if I want to see the layout open in my house every day, gathering dust. The Z-scale models make it possible to have more realistic-looking setup in smaller footprint, that could be assembled into a box, suitcase, rifle case, guitar case. The downside of the small size is that these “executive toys” are built like high-end mechanical watches, and require similar maintenance. They share also some other things with those time-telling collectible items… Everything must be kept clean and oiled, or these things just won’t work. And if you did your best, those small engines are still very picky. Could that be fixed with software?
70’s electronics with 2020’s software
These things are niche products with very small target audience, mainly in Germany and other central Europe. Their manufacturer, Märklin, has been in financial problems many times in 90’s and 2000’s as modern times has brought people other things to do. Craftsmanship as a whole has been in a decline. As product development is expensive, many of these models still run on small brushed motors from 1970’s, when the Z scale was first introduced. With all the quirks involved.
These motors produce very low torque and run on very high speeds, both traits that are not that desired for slow-running scale models despite of quite creative reduction gear sets. The more voltage you supply, the faster it runs, and usually, the better it runs, which does not look good. The slower you want them to run, the less voltage is supplied and the more quirky they become, stopping in the middle of hidden areas in the layout where you don’t want them to get stuck in.
Quirkiness of these models gave me a nice opportunity to learn about motor control algorithms in practice. Couple evenings of playing with Arduino and H-bridges, got me a crude working prototype that drives these motors with back-EMF feedback loop and a PID controller. The software transmits a short full voltage pulse to the motor that gets it spinning. When the power is cut, the rotor has a bit of inertia, and it still rotates, working as a generator and feeding electricity back for a brief moment. The software waits for this, and measures its strength. This gives the software indication how fast the motor is running, and the PID controller then adjusts the duration of the next pulse energizing the rotor. If the back-EMF strength is less than the desired running speed, indicating a motor running slower than requested, the next pulses are going to be longer. This control loop and transmission of full voltage in pulse width modulated way, makes these picky vintage motors run slow reliably.
Development of this control algorithm gave me practical experience, that benefited me later on in my working life.
Nobody ever gets fired for buying IBM.
The motor controller needed to be interfaced somehow, and I wanted to try modern web development. I started my software development career with PHP and Classic ASP, the later being phased out a long time ago. So I thought that learning how to do front-end things with React with some Node.JS backend would do not harm for my professional career. After couple of evenings playing around with that library or whatever they call that mess, I was confident that my life is too short to be used for React. And now my trains run on the NodeRED, a rapid IoT development platform developed by IBM. And as the old saying goes: no-one has ever been fired for choosing IBM.
The NodeRED sends commands to the Arduino motor control, relays and H-bridges via serial, and user interface is provided by NodeRED UI. A bit quick, a bit dirty, but it works for me. One aspect of the development was, that I had plans to take these creations to shows, events, competitions and so on, so everything needed to be automatic and controlled by software.
Artistic side of things
The layout is based loosely on Noch Serfaus pre-made layout that one can purchase in German online hobby stores. As this was my first model railroad ever, and I had no idea of track geometries and such, I thought it would be a good idea of having a starting point to customize to my taste. Buildings, tracks etc. were bought all over the web, assembled, painted, modified and weathered.
Buildings were essentially plastic model kits, that were modified a little, assembled and painted with an airbrush. Those were initially painted with flat black primer to make all the little details and shadows appear crisply when final, lighter coat of paint was added. Then mildly weathered with paintbrushes. Ready buildings were then added to the layout with internal RGB LED lighting, tuned for very warm white light.
Choo choo.
I needed trains. Who does not need trains?
These things are collectible items, being manufactured in short runs, only for a short period of time, and possibly never again. Trains and locomotives in general, are made in functional things first, and majority of them are not pretty. Most of them are boxy, industrial-looking, ugly and designed with a ruler. Most of them are not things, unlike a classic car or shiny new high-tech gadget, that would make you want them. Only few of such exists. When combined with small production runs make it so, that you can’t buy the items you want new in store. They are also far from being affordable, so I really did not want to buy something that I find ugly. So, it was eBay time.
I ended up wanting two trains for my layout. One with beautiful old-timer cars and a very special blue-colored articulated “Mallet” steam locomotive, the Bavarian GT 2×4/4. This huge steam locomotive existed in blue color with brass highlights for a short time before the war. Like the original locomotive, the scale model of it was a very limited production run not sold for larger audience, and as a rare item, it was difficult to acquire. The model I got, had issues with its very complex internal mechanics and motor, eventually requiring a motor replacement and a full rebuild.
Another train I wanted for the layout was the German Trans Europ Express in its full length, which small scale made possible. Like the steam train, this was also quite difficult to find in a price I wanted to pay for it. My TEE represents the first generation of this model, and is heavily modified. Its internal wirings were modified to provide constant reliable power for both motors and internal lighting. 1970’s coarse running three-pole motors were replaced with smoother-running 1990’s five-pole motors and the control algorithm was tuned to drive the dual-headed long train smoothly.
What next?
The Serfaus was my first take in the hobby of model railroading. And for some reason, I have a feeling that while the corona shitshow that started all this goes away, this hobby does not end here… 😉