As far back as I can remember, I've been interested in model railroading. Birthdays and Christmas, I received Lionel O-27 gauge items. I grew up in a railroad town in Arkansas, home of the Cotton Belt Shops (actually the St. Louis & Southwestern, now part of Southern Pacific). They actually build real steam locomotives there, "back in the day."

Both the Cotton Belt and the Missouri Pacific ran trains through the town, and downtown streets were often blocked by passing trains. It was such a common occurrence that our local Episcopal minister developed an uncanny knack for punctuating his sermons with the roar of locomotives. Afterwards, we kids would all go outside and retrieve our flattened pennies from the rails, rewards for patience while sitting through interminable Sunday morning church services.

Dad was a cotton farmer, trained in mechanical engineering. I was practically raised to study engineering, too. I'll never forget a 4th-grade "career day," when we had to write down what we wanted to be and they invited grownups from the community to come in and give group presentations. I wrote down "engineer." Come Career Day, one other kid and I were sent to a classroom where a man came in and talked to us about the Cotton Belt railroad and the jobs that their employees did. The other kid was interested in music, and had written down "conductor." Our presenter emphasized the role of railroad engineers and railroad conductors in rail transportation. So much for Career Day in a railroad town.

Over the years, I went through a series of Lionel O-27 gauge and HO gauge layouts. I had withdrawal symptoms when I went off to study engineering in college. After marrying, a month after college, I build a small N-scale layout which would slide under our bed, to my wife's chagrin. Parts of that layout are still incorporated in my current layout, over 50 years later.

So, what does any of that have to do with computers and model railroading? Well, one of my areas of expertise during my chemical engineering career was application of computers to chemicals production. There were applications galore in production logistics, yield accounting, automatic process control, laboratory automation, chemical process simulation, and optimization. I like to think that I was a leader in applying everything from four-function calculators to scientific calculators to mainframes to minicomputers to PCs to microcomputers. Now that I'm retired, I tinker with 'em still.

...enter my latest fave, the Raspberry Pi, which I guess is a microcomputer. This little guy runs full-blown Linux, something I would have killed for just a few years back. What's even more amazing, though, is that it's very inexpensive and its components and accessories are widely available. The latest rage among the high school and college geek set (of which I am a proud alumnus) is robotics. Model railroading is an old man's hobby, my wife tells me, any maybe she's right, but it's a lifelong hobby and I love it.

But enough about me. I assume that you're here because you have an interest in using small computers to interface to the rest of the world, and I hope what I write will be useful to you. I'll run rough-shod across the field of automating a model railroad. Hopefully you'll find something of use.

- - - -

Early Problems

This first section discusses some of the problems I had while starting out. The AB Electronics folks, Andy in particular, were quite helpful in getting this old self-taught guy started in the world of Raspberry Pi and their expansion boards.

There is enough information for you to hopefully get things right the first time and not make a couple of the bone-headed mistakes that I made, such as hooking up the power backward and frying the expansion boards, and trying to work on the RasPi while it was on, accidentally grounding the 3-volt bus and frying the main board.

Take it from me- - make all your electrical changes with the whole thing powered down, color-code all your wiring (especially the power wiring), and triple-check your wiring before powering up. The traditional "smoke test" technique doesn't work with low-voltage wiring and today's dinky components like it did back in the old high-power days. "Trust me."

Click here to see the details about buying and setting up the RasPi and its expansion boards.

Every model railroad needs an origin story. Click here for ours.

For the next major topic, click here to read about adding Relay Boards.