Software - Bodgerswood

 

Shortly before deciding to build Bodgerswood I'd bought a Raspberry Pi (basically a single-board computer). I think these are a brilliant piece of kit because you can really play with them in a way you can't with PCs! I'm certainly not the first to hook one up to a railway, but I decided it was the right way to go for the relatively simple software required.

Language

There wasn't much deciding that went into this - Python is the main language provided with the Pi so I'm using it. It gives me a chance to learn something new as well.

Hardware

Inevitably you need more than a computer to run a railway. As mentioned elsewhere I'm using a SPROG 3 for the DCC side of the control. I'd already got a Team Digital SMD82 points controller which unfortunately has a couple of dodgy outputs. As Bodgerswood only has 5 points I can work around this, and it has the advantage of a built in CDU for running Peco solenoid point motors.

For the input from the block detectors (see Detectors and Inputs) I could have built a similar interface board to the one I'm using on Bishopwood and hooked it up directly to the Pi, however for 20 I bought a PiFace board which mounts directly onto the Pi providing 8 inputs and outputs, two of the latter having relays and 4 of the former having test switches. This provides convenient screw terminals for connection and provides a degree of protection for the Pi itself.

Connecting the SPROG to the Pi

In theory this should be fairly simple, the tricky part is actually knowing which device name it's using. The approack I adopted was:

Install the PySerial package using:

sudo apt-get install python-serial

Connect the USB cable between the Pi and the SPROG then restart the Pi

Once restarted go into LX Terminal (assuming you're using the GUI) and type ls /dev/tty* which lists all the TTY devices. Then I unplugged the USB cable and repeated the command - the difference in the two listings is probably the SPROG! In my case that makes it /dev/ttyACM0. It's probably a good idea to always plug it into the same USB port as that minimises the risk of it picking up as a different device another time, I'd also suggest it's better plugged directly into the Pi rather than through a USB hub but that may not be possible, especially if you're using a USB wiireless adapter.

Simple Python Program

The next step was to try and talk to the SPROG from the Pi.

 

 

 

Back | Home | Up | Next