Wimborne Model Railway

By Russell Barnes. Posted

A model town in Wimborne has a separate model railway attraction. When it came time to upgrade parts of it, a Raspberry Pi was the natural choice

In the beautiful town of Wimborne, very close to where The MagPi is made, is a superb model town that has existed for almost 70 years. It’s a lovely tourist spot and a wonderful attraction, of a type that’s fairly rare these days. As part of the model town, there’s also a great little model railway. During the off season just past, the lights that make up part of this miniature railway were upgraded using a Raspberry Pi, by a team led by Terry Coles, an engineering manager who helps out at Wimborne Model Town.

“The fundamental requirement for the lighting is simple,” Terry tells us. “Simulate daylight, dim the lighting to simulate night-time, and then bring on lights in the trackside houses and streets. However, these were not the difficult goals; a bit more work was necessary because the finished system needed to be reliable, easy to use and maintain, and capable of being upgraded readily in the future.”

 The model railway is very detailed

After a lot of discussion, the team settled on a Raspberry Pi Zero for the task: “This allowed for future upgrades and was considered more accessible to the average volunteer than, say, using an Arduino.”

The system isn’t just made up of a Raspberry Pi, though: there’s much more to it. The lights being used weren’t just a few LEDs stuck to a breadboard, as Terry explains:

“The WiringPi2 library was used to allow programming of a pulse width modulation (PWM) signal. This dims and brightens a 48W LED strip on GPIO pin 18 (the hardware PWM pin) to simulate the ‘Day’ lights. A MOSFET driver was used to carry the current needed. The lighting in the houses and elsewhere was switched by four other GPIO pins via a relay board.”

 The lights are controlled in sequence

The system itself was developed on a Raspberry Pi with Raspbian, to make sure it was all working. Originally written in Python with the RPi.GPIO library, it doesn’t quite support hardware PWM so was then changed to the aforementioned WiringPi2. The final code was then moved over to a piCore image for actual deployment. Terry says that as the volunteers will just turn the Pi on/off rather than do a software shutdown - it’s a bit tricky with the way the system is built - piCore was the obvious choice, as the OS is loaded into memory and so there’s no reading or writing going on from/to the SD card.

All the software written for the project is also open-source, with Terry maintaining very thorough documentation and sources that you can find online. If you ever find yourself on the south coast in or near Dorset, go give the model town and railway a look!

 The model town itself is something to behold as well

From The MagPi store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.