Microcontroller Systems and Model Railroading
Model Railroaders normally work with electricity in a fairly simple manner: constant or variable voltage DC or AC. Turning something on or off requires just a simple switch. DCC complicated that, at least for running trains but sometimes also for accessories, by adding digital communications to the toolkit. Now a switch can send a “message” to a device, or a device can send a message to a central or local control system. This is the basis of DCC and layout control bus systems. And that is only the current stage of a progression that has been going on throughout the history of model railroading. As technology has progressed we have found ways to apply it to our hobby.
Electronics is the science of controlling electricity. As such it could refer to vacuum tubes, or even relays, but is usually applied to mean the control of electricity via semiconductors: the transistor and its kin. The field of microelectronics is formally the study and manufacture of integrated circuit “chips” and similar “small scale” semiconductor devices. Model Railroad hobbyists who were also electronics hobbyists have been applying these to model railroading since the integrated circuit was first introduced back in the 1960’s. And that, in turn, was just another round, before then transistors, vacuum tubes, and even relays had been applied. And, for that matter, relays are still heavily used, for the same reason prototype railroads still use them in places; they’re simple, easy to understand, and relatively reliable and inexpensive. There have been advances since then, but they were largely variations on that theme, more complex “chips” that could do more. Today the latest technology is large, complex, integrated circuits: microcontrollers.
When microprocessors, computers on a chip, were first introduced in the 1970’s they required a boxfull of supporting circuits, and had limited memories of around 4 kilobytes (KB), 4,096 bytes, not quite enough memory to hold this paragraph of text. A decade later they had memories measured in megabytes (MB). A megabyte is 1,048,576 bytes, large enough to hold a short novel. Memory size increased rapidly, and today thousands of books could fit in a computer’s working memory, not even counting external storage (disks).
Computers were still rather expensive though. Few could afford to dedicate one to a model railroad. But as time went on, the microprocessors became more complicated. One of the results of this was the development of specialized microcontrollers for dedicated use in devices. These took the box of supporting circuits found in a typical computer, and shrank it down so it would fit on the chip itself (at the same time, the box-sized computers lived on because they needed to do more complicated things that wouldn’t fit on a chip). Actually the development of these has always paralleled that of small computer microprocessor chips, because the two are similar. The first microprocessor, the Intel 4004, was introduced in 1971, and the first microcontroller, the TI TMS 1000, in 1974.
These started out relatively expensive, and complicated, requiring a great deal of knowledge to apply to a problem. It’s not clear to me when the first microcontroller was applied to model railroading, although I suspect it was in an early command-control system. In the heart of any modern DCC decoder lives a specialized microcontroller that decodes messages from the command station, and uses them to adjust a motor-control circuit, and optionally other things like light-control circuits.
But this was still the domain of companies that could afford the high development cost of creating a new microcontroller-based system. The first simple microcontrollers that had self-contained re-writeable memory and could have programs loaded over a serial interface rather than complex circuitry were introduced in 1993: the PIC series from Microchip Technologies. Atmel supposedly introduced the first microcontroller with flash memory the same year, although I’ve been unable to find any citation of a specific model (just the usual Internet chaff of people repeating the exact same sentence crediting them). In any case, they came out with their first microcontroller based on the ARM architecture in 1994. These two developments really began the era of hobbyist-level programable embedded control systems. As an aside, as of 2016 Microchip Technologies is in the process of buying Atmel.
In 2005 the first Arduino was introduced, based on the Atmel megaAVR microcontroller family. What set this aside from others was that it was intended for use by people who were neither traditional programmers, not electronics hobbyists. The Arduino was a board with a microcontroller and a small amount of power-management and interfacing circuitry, plus a number of “pins”: control and sensing lines extended from the microcontroller that could be used to connect external circuits and devices. This opened the field up even further. For the first time, programmable electronic logic was nearly as simple as using relays. The Arduino was only the first of a wave of such devices. Over the subsequent decade, many model railroaders have applied Arduinos and other programmable microcontrollers to model railroading problems.
I became involved in this in 2011, when I was looking for a way to operate a background light-rail system, with multiple trains and station-stops, my Tram Controller project. As with many of my projects, it was never actually completed, but along the way I produced a simple motor-control library for trains (published on GitHub) and became hooked on playing with these devices, and trying to find ways to use them. Most of those ideas haven’t led anywhere, but it’s been a lot of fun, and a great “learning experience” (that’s code for “I make a lot of mistakes”).
And I wrote a lot about what I was doing, and what I’d learned, both for my own reference (the “online notebook” aspect of this site) and for the use of others who might have the same questions I did. Much of this has been published as the Arduino section of this site, but I’m starting to look at other devices now, and Arduino itself is fracturing into a number of not-quite-identical technologies, which have significant differences for applying them to model railroading and other hobbyist uses. So I’ve decided that I need a larger category (this page), under which I can put both general-info pages such as the use of LEDs or encoder knobs with microprocessor circuits, and sub-sections about specific microcontrollers I’ve worked with.
As usual with pages on my site, I make no pretense that this is a complete review of all of the possible technologies out there, the things you can do with them for model railroading, or even all of the issues and options the models covered may have. This is simply my notebook of what I’ve learned. Use it as a basis for your own discovery if it’s helpful, but don’t expect every answer to be here. I’m still learning, just like you.