Motor Control

There are two main systems in use for controlling model railways, DC (Direct Current) and DCC (Digital Command Control). A third system based on wireless control and rechargeable batteries has recently become available but at the moment it’s not viable for small N Gauge locos. With DC power is controlled before it is fed to the track, you need to switch the power to different sections if you want more than one loco running and you need some way of varying the loco speed. By comparison with DCC you feed a constant voltage to the track and a chip installed in the loco varies the speed (and controls other functions) using signals sent from a controller overlaid on the power feed. As each control chip is separately addressable you can have several locos running on the same track without having to switch track power.

Many commercial locos come either ready fitted with DCC or at least come with sockets for the chip to just plug in. With others you need to make more modifications which can be tricky (the last two I needed converting were done by a company called Digitrains). Unfortunately fitting a DCC chip relies on you being able to completely isolate the motor feeds from the wheel pickups, which isn’t possible on the chassis I used for the Peckett saddle tank that’s the basis of this railway. That meant I had to use DC with all the additional wiring complexities.

A big advantage of using DCC  is that you feed the full voltage to the loco at all times which reduces problems with dirty track and dodgy connections. With traditional DC the voltage is varied to alter the speed of the motor, which can make slow running unreliable, but there is an alternative; PWM (Pulse Width Modulation) uses the full supplied voltage but pulses it to vary the motor speed. I was able to source a suitable controller from Adafruit, one of the largest Raspberry Pi peripheral suppliers.  

Connecting the board is very simple, 4 patch leads from the Pi for power and I2C, 2 wires from the power supply and then 2 wires for each output. The board can also be used as a stepper motor controller so there are some connections not needed for my purpose.

There was a spin-of benefit from using this controller, the board has 4 outputs but I only need two for the layout. I’ve utilised a third output to provide dimmable ambient lighting (a series of LED lamps on the underside of the bookshelf above the layout). This allows me to simulate a 24 hour day by dimming the lighting at dusk and bringing it back up at dawn.

I’ve split the layout into 4 sections (see plan). The back two generally use controller output 1 and the front two use output 2, so two locos can run at the same time. When a loco is switching between the two tracks the front right section is switched over to output 1 to ensure smooth running on the crossover.