DIY Model Railway Controller

Document Sample
DIY Model Railway Controller Powered By Docstoc
					DIY Model Railway Controller

*** Updated in this document only, 1 March 2001 & 27/3/05 ***
Due to popular request I will present a design for a model railway controller. I've tried to keep it as
simple as practicable consistent with what I consider to be a desirable level of performance and
reasonable level of protection for itself and its surroundings. The design is not quite modular but is a
"building block" to which can be added various options as the user desires.

Why build your own controller?
Well, two good reasons are that it’s great fun if you have some experience of electronics construction,
and it can be a lot cheaper if you want several. However there is another good reason: most
commercially available controllers are not very good, and sorting out the wheat from the chaff is pretty
This ought not to be so, since electronic controllers have been available for at least thirty years with
good pulse-power and smooth control, but I’m afraid anyone who’s ever dabbled in model railway
electronics thinks designing a model railway controller should be really easy. Unfortunately, although it
is pretty easy to make something which works, it’s a lot more difficult to make one which works well,
and damn difficult to make one which works as well as it can work, under all conditions, and safely
too! I know, because I’ve been designing model railway electronics since 1970 or so and am still
finding better ways of doing things!
To make a controller which flatters both the loco and the driver instead of being awkward to use and a
real pain to learn requires considerable understanding of the mechanical and electrical properties of the
motor, controller, and even the operator. For example, the mechanics of many model locos have a
variable amount of friction as the wheels turn; this makes it difficult to achieve a steady slow speed as
the loco tends to stall instead. To minimise the effect of this a controller should have a low output
impedance, which allows the motor current to increase without the speed dropping too much. Negative
feedback (see later) can also help here.
Several older commercial controller designs used various forms of pulse power to give super-slow
crawling performance, but if too much pulse power is used the high peak-to mean current ratio can
cause the motor to overheat. Furthermore, even when the controller is theoretically capable of making
the loco run slowly, some controllers have such an abrupt action on the control knob that it isn’t
practicable to achieve the desired slow running. I’ve lost count of the controllers I’ve tried where you
turn the knob a bit and nothing happens; you gingerly turn the knob a bit more and still nothing
happens, and when you turn the knob a fraction more the loco bounds off at high speed. We are all
supposed to be improving the realism of our models, but how can you possibly control a loco smoothly
when the control is so abrupt?
Another problem is current limiting. With the best will in the world, short-circuits will happen quite
often on model railways for a variety of reasons, and the controller should therefore protect both itself
and the other things it is connected to when this happens. There are quite a lot of ways to do this, but
my least favourite is the thermal cutout which does nothing for several seconds, then cuts out leaving
you with no control for another ten seconds or so until it cools down and resets itself. If you have an
intermittent short-circuit it can be very difficult to work out what is happening, even if there is an
effective warning indicator which some controllers don’t have. Yes, they nearly all have a red led but it
doesn’t always tell you anything useful . . .
Then again, how does the short-circuit affect control response? The overload cut-outs in most
controller won’t operate if a slight shorting occurs between the pickups and chassis, or wheels and
chassis, but some will lose control under these circumstances, either losing speed or (occasionally with
feedback) even increasing it!
19/10/06                               DIYcont3a.doc                                       1
All these things and more must be considered in a well-designed controller, and I consider that the
design presented here has addressed virtually all the problems I know of and is better behaved and
easier to use than any other I’ve used..

Design Philosophy
The first question which arises in the design is the amount of pulse power to be used. Pulse power
works essentially by applying electrical current to the armature not continuously but in a series of kicks
to the armature, to unstick it, move it a few degrees, and then let it stop for a while before the next
kick. With pure dc, anything other than a very good mechanism tends to sit there doing nothing until
the power is sufficient to unstick it, then it runs away at considerable speed.
Some controllers supply lots of pulse energy for this reason, but unfortunately not all motors benefit
from this: Some 3-pole armatures with strong magnets will often either turn through 120-degrees after
a pulse, or not move at all, and this makes the motor reluctant to revolve slowly except at exact
multiples of 1000 rpm. It therefore won’t accelerate smoothly from rest but jumps suddenly from crawl
to slow to medium-fast however slowly you turn the knob. The solutions are (1) to alter the motor, (2)
reduce the pulse content, or (3) make a variable-frequency pulse-power controller (which I’ve done but
it creates other problems!)
The basic controller design here is one which has evolved over many years, and produces a medium
level of pulse power. It produces more 100Hz pulse power at low speeds than a variable-resistance or
simple transistorised controller but a lot less than thyrister-based feedback controllers. The amount has
been chosen to allow most ready-to-run (rtr) motors to turn slowly enough for the loco to crawl
acceptably, without creating excessive noise and roughness or risking damage due to overheating. If
you’re using Portescap-type motors I can’t recommend it for them, but you probably have a variable
dc-controller already. For those with long memories the basic waveform produced is similar to that of
the “Scalespeed” controllers of the 1960s and 1970’s, though the circuitry is quite different.
How slowly will locos crawl? This depends on the loco of course, but well-maintained Triang/Hornby
locos with the old X04 motor will run smoothly down to several seconds per revolution and possibly
down to a speed at which the armature is only just visibly turning. The practical limitation is usually
stiction in the wheels and valve motion which vary with wheel position and stop it unless the speed is
turned up much higher. Maintenance usually remedies this but otherwise only feedback-control will
help disguise it.
A few sophistications have been added that I find so valuable I wouldn’t do without. The first is a
reliable form of current limiting which can protect both the controller, its power supply, the layout
wiring and (to some extent) the loco itself, from the worst effects of short-circuits. The current is
limited to around 1 Amp but can be altered by changing a single resistor for use with either 2mm locos
(lower limit?) or double-headed 4mm locos (higher). A red LED indicates when the current limit is in
operation. Note that the current limit operates instantly and preserves control, rather than waiting for
ten seconds and then shutting down completely, so you get a flashing indication of intermittent shorts
while the loco is running.
A green LED is also provided which lights when the track becomes open-circuit. You’d be surprised
how many locos go momentarily open-circuit while running slowly, due (usually) to lack of
maintenance – the LED shows this quickly. The two LEDs together provide an automatic indication of
the amount of attention needed to loco and track, helping both to be optimised for smooth control. It is
possible to use a single bi-colour LED instead (the two-lead type) if preferred. Note that the green LED
and R6 are optional but the red LED is necessary for current limiting.
I have included a basic inertia simulation circuit, which is both adjustable and switchable. It can be
deleted or improved but is a start for those who like it; if you don’t, miss out C2 and R8 and replace

19/10/06                              DIYcont3a.doc                                         2
SW1 with a wire link. However a small amount of delay is always valuable to smooth the loco’s
response to sudden control knob movements.

Circuit Description – Basic Version
The rectified AC supply to the collector of a 2N3055/TIP3055 transistor TR1 is rectified again to
charge a 220uF capacitor to about 20V, which supplies an LM358 dual op-amp IC1 and a speed
control potentiometer. The voltage from this speed control is delayed by a switchable inertia simulation
network and buffered by IC1a; it is then subtracted from the +20V rail by a differential amplifier IC1b
and the difference used to drive the base of TR1 relative to its collector, giving a pulse output of the
same shape as the rectified supply but with a variable dc level to provide a variable motor speed.
A one-Ohm series resistor in the output and a parallel red LED limit the current output to about 1 Amp
and give visual indication of a short-circuit or overload. A 1k resistor connected across TR1 has no
effect when a motor is connected, but when the output goes open-circuit the current it passes flows
through a green LED, indicating the open circuit state.

Fairly simple. I generally use copper-clad printed-circuit board as front panel with switches and LEDs
protruding through holes but all the other components soldered on to sticky strip or pads on the copper
(back) side. However a pcb may be available at some point . . .
A Heatsink will be needed for TR1, and should be one rated at 10C/W or less, or if you’re making one
yourself it should be aluminium at least three square inches (20
A convenient arrangement of the controls is in the form of a square, with the leds in the top corners,
and the speed control and reverse switch in the lower corners. My preference is the knob and red led on
the right-hand side.

Components for Simple Circuit (fig.1):
IC1:      LM358P
TR1:           2N3055, TIP3055, or other 5A plastic power NPN transistor with heatsink
D1 – D6:       1N4001
LED1,2:        green and red LEDs (40mA max current preferred)
C1:            220uF 35V electrolytic
C2:            10uF 35V electrolytic or tantalum
C3, C4:        22nF poly or ceramic.
R1 – R4:       33kΩ
R5:            1Ω 2.5W wirewound
R6:            1kΩ 0.5W
R7:            10k potentiometer
R8:            small 200k trimmer potentiometer; multi-turn ones are best.

19/10/06                               DIYcont3a.doc                                      3
Circuit fig 1: Simple non-feedback controller

19/10/06                   DIYcont3a.doc        4
DIY Controller - Variations

When the original DIY circuit was described it included a few features which are useful but not strictly
necessary, like the inertia simulation and the LEDs. However a number of other variations are also
possible on the basic controller design including:
•   Regulated supply for speed control;
•   Non-linear speed control
•   Increased output power;
•   Negative Feedback
•   Reduced pulse output
•   Better inertia simulation
•   Remote control from a walk-around handset
•   Automatic control from signals/etc.

A second circuit diagram is provided (fig 2) which for convenience shows some of these additions, but
it isn’t actually necessary to implement them all so they will be described separately.

Regulated Supply
A small improvement in speed control can be obtained by using a regulated supply for the speed
control. This is most useful where several controllers are fed from a single transformer and otherwise
heavy loads on one controller would reduce the supply voltage and slow down the other locomotive.
The regulated supply is particularly desirable if negative feedback is added to prevent the commanded
speed dropping when the loco load and current increase. The extra components needed are R10 and D8
(a 3k3 resistor and a 5V1 zener diode). The zener ensures that a constant voltage is obtained at the
speed control R7 (a 10k potentiometer) irrespective of supply voltage, and at speeds below maximum
the differential amplifier IC1B helps to maintain a constant output voltage too. Since the control
voltage range is now smaller, R11 and R13 are also needed to put it back up again by turning IC1a
from a mere voltage-follower/buffer into an amplifier with a gain of 4 or so.

Non-Linear Speed Control
This very east to implement after the regulated supply - just one more resistor R12 - but why would
anyone want it? Well, it is a fact of life on most layouts that much of the time the locomotive is moving
is spent starting and stopping, yet the portion of the control knob movement which covers this regime is
usually tiny, and the rest is taken up with small variations in high speeds which may be rarely used and
are usually imperceptible. If we can make the control range deliberately non-linear we can expand the
bottom “slow-speed” half of the knob movement and contract the upper “high-speed” half, and thus
improve the controllability at slow speeds.
In technical terms we have altered the control gain across the control range, and in order to cope with
various different locomotives the change must be done smoothly. R12 does exactly that, with a
response which is almost logarithmic like the volume control on a radio. When feedback is used an
additional non-linearity can be added also and this is described later.

19/10/06                              DIYcont3a.doc                                       5
Increased Output Power
Reference has already been made to the output current limit and the possibility of increasing this by
changing R15 to a lower value. If this is done it will be necessary to ensure that TR1 has a good
heatsink; if the effective current limit is then a couple of Amps or more it might also be a good idea to
add a thermal cut-out to limit damage if a continuous short-circuit should occur.
If the available AC supply is rather low or the locomotives are very inefficient or perhaps low-geared, it
is possible they might not run quite fast enough for some users. Although it is inevitable that the
controller “wastes” some of the supply due to its inherent voltage drop, this drop can be reduced at the
cost of a few more components. First is the altered connection to C1, with D5 and a new diode D7
connected to the AC supply instead of the rectified dc. This gains about half a volt on heavy loads, but
a further improvement is possible. Adding R9 (=33k) and altering R4 to 15k reduces the voltage drop
for part of each mains cycle; the two together give about a volt improvement overall at full throttle.

Negative Feedback
This is the big one - the one that separates the men from the boys!
To many people the phrase “feedback controller” implies a certain type of controller using a thyrister
which varies its conduction phase-angle and as a result produces a very high pulse-effect which is
reputed to be harmful to some motors. This type of controller was popularised in a small hand-
controller of one leading manufacturer due to its inherently low dissipation but goes back much further
than that - indeed so far as I know I may even have been the first to make controllers for model
railways using this concept in the early 1970’s. However this particular type of circuit is not essential
for feedback and the circuit proposed produces no more pulse energy than the non-feedback design.
What is feedback? Well as far as model railway controllers are concerned negative feedback means
precisely one thing - instead of setting the voltage applied to the loco and allowing it find its own speed,
a feedback controller selects a speed, compares it with the measured speed of the loco, and uses the
difference to control the voltage applied to the motor. The speed of the loco is “fed back” to the
controller my measuring the back-emf (the “dynamo effect”) produced by the motor when the power is
briefly interrupted every half-cycle of the rectified supply waveform. The consequence is that the
controller tries to keep the motor speed constant despite variations in load or friction caused by, for
example, sticky valve motion or varying gradients.
What are the snags? Well the main one is that feedback systems can oscillate if not well designed, and
in designs such as this one the time-constants have to be chosen very carefully to make the resulting
control smooth and fuss-free rather than aggressive and jerky. For this reason it is a good idea to stick
to the component values I have indicated unless you know exactly what you are doing and are prepared
to spend a lot of time redeveloping the circuit!
The actual feedback components are D9, D10, R11, R14, R15, C5 and C6, but a new switch is also
shown to allow the controller to be switched to non-feedback operation (using R13) for comparison
purposes. The switch isn’t really necessary since the feedback control is so good you probably won’t
ever want to run with it off, but switching it off does show up how bad some locos have become with
lack of maintenance, since a good feedback system tends to disguise variations in speed due to friction.
However to ensure the feedback works correctly it is advisable to keep C3 to 22nF.
Incidentally R15 and D10 form a simple but clever circuit which allows the circuit to have a high loop-
gain at low speeds for effective crawl performance while reducing gain at high speeds where it can lead
to instability. If it is desired to reduce the gain (for example to prevent very small light-weight motors
from “surging”), both R14 and R15 should be increased by a factor of two or so. R14 and D10 also
have another deliberate effect which is to introduce another non-linearity into the control response,

19/10/06                               DIYcont3a.doc                                         6
again to make the first part of the speed control rotation smoother and less abrupt than it otherwise
would be.
Note that for the feedback system to work properly the voltage regulator and inertia components are
necessary. Inertia simulation can be set to a low value, but must not removed completely or surging
may occur if the speed control is altered suddenly and the feedback tries to make the loco change speed

Reduced Pulse Output
Some people running high-precision motors in good-quality chassis may not need pulse energy to run
smoothly at crawl speeds and may prefer not to expose their motors to it. In this case they have a
choice - use a pure dc controller or modify an ordinary one to reduce the pulse output. The basic
controller can be modified for a pure dc output but NOT the version with feedback, since some pulse
effect is needed to leave time for the motor speed to be measured between pulses*; for pure dc, replace
D5 in fig.1 with a short-circuit link and change C1 to 2000uF 35V wkg or higher.
For reduced pulse output with feedback, simply increase C4 to 100nF or more. Some pulse effect will
still be present but less than before.
[* If you do want to run motors on pure dc (no pulse energy) and still want some negative feedback,
this is possible but not with the circuits described here: you need a balanced bridge circuit instead. This
will do what you want, but it does have a snag that for much benefit the bridge needs to be re-balanced
with a trimmer for each different motor type, which is a real pain if you run several different motors.]

Inertia Simulation
This is already present in the basic circuit but can be altered and improved slightly. One thing I hate
about inertia simulation is the long time it takes for the loco to start moving, which usually ends up with
it either not moving at all when I think it will or bounding off at high speed despite frantic attempts to
stop it! I also feel that real locos - particularly those moving light - often start moving very quickly –
it’s actually quite difficult to get a smooth slow start on some full-size locos!
However I think a small amount of inertia delay helps to smooth the loco movements. D11 simulates
this by shorting the inertia simulation resistor R8 when the throttle is opened rapidly (to give fast
response) while allowing it to be effective on coasting and braking. I generally adjust R8 to let the loco
follow the speed control fairly quickly when it is turned gently but still prevent the loco from stopping
on a sixpence. Once you have found a suitable adjustment you can measure the value with a DVM and
replace the potentiometer with a fixed resistor.
Inertia simulation for automatic control is of course another problem, and this is discussed later.

Circuit Diagram
see fig 2.

19/10/06                               DIYcont3a.doc                                         7
Circuit fig 2: Enhanced controller with feedback

Components for Enhanced Circuit (fig 2):
IC1:      LM358P
TR1:        2N3055, TIP3055, or other 5A plastic power NPN transistor with heatsink
D1 – D7:    1N4001 or similar 1Amp power diode. (1N5401 3A diodes will also do)
D8:         5V1 zener, 400mW.
D9 - 11:    1N4148 or similar small silicon diode
LED1, 2:    green and red LEDs (40mA max current preferred)
C1:         220uF 35V electrolytic
C2:         10uF 35V electrolytic or tantalum
C3, C4:     22nF poly or ceramic.
C5:         220nF poly or ceramic.
R1 – R3:    33k
R4:         15k

19/10/06                            DIYcont3a.doc                                 8
R5:            1R 2.5W wirewound
R6:            1k 0.5W
R7:            10k potentiometer
R8:            small 200k trimmer potentiometer; multi-turn ones are best.
R9:            33k
R10    :       3k3
R11:           560k
R12:           3k3
R13:           100k
R14,15:        4k7

Power Supplies & Things
As far as power supplies are concerned the controllers all require 15V or 16VAC at 50Hz from a mains
transformer. This should be rated at 1A minimum for each controller, and if several controllers are used
they can either be run of a single transformer winding suitably rated, or several separate windings on a
single transformer, or separate transformers. If you use more than one controller from a single winding,
then you must ensure that the output feeds from the controller to the track are entirely separate;
conversely if you use a common-return wiring system, then you must use an independent winding for
each controller or you will short-circuit something.
The controllers are current-limited, but a fuse of some kind is still a good idea to prevent damage due
to unintentional short-circuits when something metallic drops into the controller wiring! The best place
for this fuse is close to the transformer, in series with one end of each winding.
Another question often raised is the use of “Relco” type HF so-called track cleaners. Many people
swear by these but I’ve found they just disguise loco problems while creating more dirt. However if you
want, you may use them with these designs provided you fit a 100nF (0.1uF) unpolarised ceramic
capacitor rated at least 30V across the controller output before it gets to the Relco unit.

Other Controller Ideas
As I’ve commented earlier, there are lots of ways to make a model railway controller, and I’ve tried
most of them. I won’t go into details here, but if you do want to try your hand at designing one, then
have a go, but try to think about the problems and issues I’ve raised.
A basic controller that is even simpler than the previous circuits can be constructed using one transistor
and one op-amp (fig 3). If C1 is included this gives pure dc output for use with low-current precision
motors, and if it is missed out it provides a simple low-pulse circuit ideal for automated control
applications such as those needing a controller for each signal block of a long main line. In either case
you can add the current-limit functions and led warning lights or miss them out as you wish. Which
leads us onto . . .

19/10/06                              DIYcont3a.doc                                        9
DIY Controller – Automatic Control Applications

Sooner or later anyone with a large layout starts to think “Wouldn’t it be nice if the trains could run by
themselves some of the time?”. I went through this phase many years ago in the 1970’s and built an
automatic control system which allowed trains to run in a pre-programmed sequence without human
interference. I found this remarkably satisfying, particularly to be able to enjoy trains moving while
painting scenery and doing the thousand other small jobs necessary to make a layout look nice. Of
course a more flexible control strategy is preferable, but the basic concept of making trains run in a
realistic manner by themselves has certain attractions. It is incidentally why the “DCC” form of control
does nothing for me, and why I prefer block-section-based control. So how does one go about this? I
have neither the time nor the space to describe the whole topic of model railway automation (books
have been written about it – believe it or not even as far back as 1939!) but I can add a few comments
and circuits to help those interested in DIY.

Remote / Walkaround Control
This is not really automatic control but is quite a useful idea and can be obtained in two essentially
different ways. One is to have the entire controller in a small box and switch the desired tracks to it
(walkaround controller), the other is to put just a speed and direction control into the box and plug this
into a socket on the front of a controller with an automatic switch to select instead of the normal
controller (remote control).
For a walkaround controller the DIY controller can be quite easily made small enough to fit into a small
case that fits in the hand, but it will need to be an aluminium or die-cast box to allow TR1 some
For remote control operation it is necessary to switch an external potentiometer into the circuit instead
of the normal one and also to provide remote reversing, preferably without taking the entire track
current along the handset wires! If the circuit is to be kept simple a relay is needed for each of these
functions as shown, making two relays per controller (fig 4b) unless a 4-pin or 5-pin socket can be
found with an integral switch in which case a single relay will do (fig 4c).
If you have enough spare wires in your control cable, it is nice to add a couple of isolating or section-
control switches to reduce the need to keep wandering back to the control panel.

Automatic Stop/Start Control
For this application I have in mind the type of automatic control that stops a train when it approaches a
red signal and starts it up again when the signal changes to green. This control is often done at the track
by either switching the track supply on/off (which gives a very sudden stop and start) or by an
electronic circuit which gives a smoother action but is more complex. If possible it is usually better to
do it at the speed control potentiometer, and two ways of doing this are shown in fig 5.
The low-tech solution is to use a relay with an SPDT contact pair (fig 5a), which connects the inertia
capacitor either to ground via the braking control resistor or to the speed control via a variable
acceleration control resistor. Both of these resistors can be adjustable. Notice that in this simple circuit
the manual control has to have the same delay as the automatic control.
A higher-tech solution is available for those using logic or computer control, in which the switch is
replaced by an N-channel mosfet or by an opto-isolator. The latter provides electrical isolation as its
name implies, the mosfet doesn’t and is only suitable for applications where the control logic uses a
common negative supply with the controller. Fig 5b shows this, with the added refinement of an auto-
manual switch which not only allows manual over-ride whatever the auto control is doing, but in
addition allows the manual control to be direct without delay, if so desired.

19/10/06                               DIYcont3a.doc                                        10
An additional diode is fitted to allow quick manual over-ride in emergencies (why do these happen so
often?); the control knob sets the running speed in auto mode, but if it is quickly moved to minimum
the diode discharges C2 quickly without waiting for the normal control delay. An automated
“emergency stop” can also be added with a pair of relay contacts directly across C2, to prevent SPADs
(signal passed at danger), which will over-ride any manual control unless it is fitted instead to the lower
switch contact in which case it will work in auto only. This feature is useful where some locos run
much faster than others at the same speed control setting and therefore cover a much greater distance in

Train Detection
There are an almost infinite number of ways of detecting trains, of which the best but most tricky is
probably optical Infra-Red. Magnets and reed switches are also used, but require every loco to be fitted
which is inconvenient for visitors. However for the purposes of the amateur experimenter a simpler
electrical form of detection is to be preferred which needs no loco modification, and there are several
versions of this. One of the simplest in concept is to put a resistor in series with the controller supply to
each track section and monitor the voltage drop across this with an IC comparator, to detect the arrival
of a loco. Fig 6a shows a circuit to do this, using the controller supplies itself. The resistor is made
deliberately large enough to allow the device to trigger even on a low-current motor or a resistor on a
dummy car where the train is driven at the rear (for example on push-pull multiple units), and a couple
of silicon diodes are added across it to keep the voltage drop within reason at high currents.
The voltage drop across the resistor/diode combination is compared with a small reference voltage by
an op-amp, and when it is greater the op-amp output drops to zero. Note that the detection circuit
needs to be powered from the controller supply, not an independent supply, to ensure it works
A further importantly benefit is to ensure that the section is still shown as occupied when the speed is
set to zero – the detector responds to the current which would otherwise light the green LED. The
circuit is fully compatible with my feedback controllers, by the way – if the resistor is missed out (as it
is on some people’s detector circuits), the voltage drop on the diode affects the speed sensing of nfb
Another important question to ask is whether the train detection will work when in either direction –
usually it doesn’t need to, but the circuit shouldn’t go haywire when the direction is reversed!. If you
do need bidirectional sensing, then use the circuit of fig 6b, which has both independent active-low
outputs for the two directions and a logical-or’d active-low function for train present in either direction.
The circuit simply duplicates the op-amp circuit of fig 6a but with the polarity of the reference voltage
and the op-amp inputs reversed.

Automatic Block-Section Control
Again I need to keep this short, but the principle is as follows. Every block section comprises a piece of
track longer than any train with a signal at the end protecting exit from that section and entry to the
next section. It is operated with its own controller but split electrically into two (or perhaps more)
isolated track sections, a long one at the beginning of the section and a short one at the end covering
the approach to the signal. Note that in the following description the signal controlling an approaching
loco is actually controlled itself by the next (following) section.
When both track sections in one block are empty, the section is able to receive a train from the previous
section and the entry signal is set to green. The train arrives in the section and runs until the loco (or a

19/10/06                               DIYcont3a.doc                                         11
leading track-circuited vehicle if the loco is not at the front) reaches the second track section in the
block, when two things happen: first, the previous block is told the train has arrived and it can reset its
detectors ready for another train, and secondly the train must be stopped if the signal it has just reached
is at red (if it is green, the train can continue without stopping).
Therefore a train arriving in a block section must run until it reaches the second track detector, and
when it reaches it the controller must apply the brake if the signal is at red; when the next block
becomes empty and the signal clears to green, the power must be restored and must be kept until the
train has completely left the block, ie we can’t reset it as soon as it arrives in the next block.

At this point, you need to ask a few awkward questions:
- What happens if one of the vehicles on a train has become detached and is occupying a section?
Answer: If you ensure that the last vehicle in every train is track-circuited, the section will remain
blocked and will prevent another train entering.
- What happens if the train has a loco on the back (either helping another or on its own)? In particular
will the power stay on long enough for it to reach the next section? Answer: It should, which is why we
need to reduce power to the whole track and not just run the loco into an isolated section, and why we
need to keep the power on until the whole train has left the block. This means that if we use a single
relay both to operate the signal and switch the power off to the track, this relay must be left alone until
the train has completely past the signal. It also means that every block bust be longer than the longest
train by the amount of space taken for it to slow down and stop.

1. On long block sections, a third track section can be added to let the previous block be cleared
   before the train reaches the end of the existing one.
2. Three or four aspect signals can be added by using the states of sections in advance as well.
3. Third or fourth aspects can be used to modify the train speed, so it slows under yellows before
   coming to a halt at a red. This is useful to reduce the space taken for the train to slow down
4. The connections between blocks can be modified to cope with junctions.

Figures: (nos updated here on 27/03/05 – paper copies may be wrong)
1,2 as before.
3: Simple controller cct.
4: + remote control relays
5: auto control speed
6: train detector. 4-resistor differential amp, with two ends connected to the res/diode combination and
the other two to +20V and 0V.

19/10/06                               DIYcont3a.doc                                        12
DIY Controller – Amendments 2005/2006

The more complex of the controller designs presented above has been laid out on a pcb for construction
and use in future model railways. Sufficient spare lands have been included to allow a variety of
alterations and additions should these prove necessary. Some of these are listed below.

Background to Circuit
Various previous controller designs have been tried by myself and many others over the years, and it is
practically impossible to appreciate why this controller has been designed this way without an
appreciation of the benefits and liabilities of other designs.
As indicated in the web site description (see above) most traditional model locomotive motors (that is,
early X04-type open frame motors and tender-drive type motors, but excepting the newer central can-
motors with dual-bogie drive) will run happily at high speed but won’t run smoothly at low shunting
speeds. To make them do so requires a measure of pulse power to unstick the armature (without
sending it off at high speed thereafter as the older resistance controllers did). An added improvement is
negative feedback which senses the motor speed and compares it with a set value, so that loco speed
may be set more exactly, with a goof chance the loco will maintain this consistently all the way around
the layout rather than rushing downhill and stalling uphill, or binding on sharp curves.
There have been two traditional waveforms used in electronic speed control. One is exemplified by the
old Scalespeed controller, which used a variable amplitude raised cosine waveform. This has enough
pulse power to give very good results on most controllers but has no feedback capability. Other
controllers produce a somewhat similar overall waveform but usually with less effective implementation
and often less pulse content.
The other style was a negative feedback controller using thyristers, developed by me in the 1970s but
also produced (possibly independently) by Gaugemaster. These have a lot of pulse power and also
have a measure of negative feedback, and can give amazing performance on some poor-running locos.
However the pulse content can also create noise and heat dissipation in the motors of some locos. A
more serious potential fault is that the integrating mechanism in the feedback circuit operates
independently on every half-cycle. Although this allows very fast response to changes in load, it is also
sensitive to motor inertia and some motors with high inertia and low friction prove marginal in stability
– the feedback tends to oscillate and cause the motor to surge visibly under some circumstances. This
detracts from the control finesse and is undesirable.
The solution is to adopt the “Scalespeed” waveform with its slow integration period, and add feedback
to that. The circuit described here (and on the web page) does this with considerable success and is
adjustable in both the amount of feedback and the amount of pulse energy present.

Circuit Design
Speed is set by a potentiometer R7 which is fed from a 5V1 zener to give a reliable constant speed
setting despite load variations on the transformer supply. The voltage on this pot is compared with the
motor’s back-EMF voltage via D9 and R14 and the difference is integrated by IC1a and C6/R11. The
output of this op-amp is a voltage which is proportional to the required controller output power. If
speed is lower than set, this voltage increases and if higher, decreases.
If this voltage were applied directly to the output transistor the output waveform would not b the ideal
raised cosine. Op-amp IC1b therefore acts as a differential summing amplifier which adds a fraction of
the rectified-sine transformer waveform obtained from the bridge rectifier that supplies TR1. Note that
to maintain this waveform it is necessary to provide a separate rectifier (D5, D7) for the storage
capacitor that supplies the op-amp supply and the speed control pot.

19/10/06                              DIYcont3a.doc                                       13
Op-amp IC1b effectively subtracts a variable amount of dc from the rectified transformer sine wave, so
that at full power setting its output matches the sine waveform, and at zero power the output is zero; at
half power the output has the same shape as the sine wave but lowered in voltage, so only the central
peaks “show” above ground. At very low power settings this gives short pulses of power to the motor
– though not very spiky ones – with a long period between.
This is important, as sensing of motor voltage for negative feedback can only be done during the time
the motor is off and effectively free-running. [Note that there is a different kind of circuit that will sense
motor speed while it is running – a balanced bridge – but this needs to be set accurately for the motor
so it is unsuited to applications such as model railway controllers where different motors may be used.]
It is also necessary to compensate for the inductive flyback of the motor inductance. After every pulse,
the energy stored in the motors winding inductance needs to be released before the EMF can be
measured. On a scope this is seen as the short period after the pulse when reverse current is shunted by
the diode D6 (which is essential!) and the motor voltage is briefly negative. This is the purpose of C5,
which provides a delay before the EMF is measured. Without this delay, the inductive flyback will cause
the EMF to be underestimated and the motor will accelerate rapidly when speed is increased or any
extra load is applied.
Resistors R14 and R15 together with D10 provide an attenuator which acts to give deliberate non-
linearity in the control, making the lower-quarter of the speed control more sensitive and the upper half
less sensitive (ie faster), this gives a good compromise but additional favourable non-linearity is added
by R10. R8 and C2 also provide a delay in the speed control response which is necessary for smooth
control, to avoid excessive acceleration demands. D11 over-rides the delay when rapid acceleration is
needed but allows loco speed to run down rather more realistically when speed is cut than the
emergency stop that can otherwise occur. Note that this is not a full inertia simulation which I do not
favour (see web text for more advice on this).
The output of IC1b is fed directly to an NPN power transistor TR1. The built-in current limit of IC1
(approx. 40mA) can be used to limit the maximum output under short-circuit conditions; however this
could reach 4A or so which is unnecessarily high and might damage the loco or layout wiring if
sustained, as well as giving excessive thermal dissipation in the controller. Therefore in the circuit
shown a red led and a series resistor provide a more realistic current limit of around 1A or so.
Under short-circuit conditions the red led will therefore light, even if these shorts are very brief and
only partial, giving some early warning of impending motor and track problems.
A green led is also fitted which light up whenever a loco is present, and thus shows when the loco or
track has gone open-circuit; again this helps to show a variety of loco and track problems and aids in
fault finding. The way it works is that under normal circumstances when a motor is present the base-
emitter junction of TR1 is forward-biased via R5, so that the green led2 is off. However if the output is
open-circuit, then R6 reverse-biases the b-e jctn or TR1 and passes current through R5 and led2 to
ground via IC1b. Of course in this situation there will be no negative feedback (nfb) and IC1b will have
its output low.
Note that the sense of this green led is opposite to some other controllers in that the led glows when an
open-circuit is present only, and both leds remain off when everything is ok.

Recent Modifications & Experiments (2006)
Experiments were carried out using the prototype controller on 20V AC for use with 24V motors of
the Buhler type, and others, in 700 size. The controller performed remarkably well without modification
though obviously the speed zener needed changing for full speed capability. Increasing R7 from 5k6 on
the prototype to 6k9 helped cope with the slightly larger inductance and experiments were also done
19/10/06                               DIYcont3a.doc                                         14
with C6 and R11. With a rather sticky camera driver motor/gearbox, halving C6 and doubling R11
increased the effective attack rate which speeded up the controller response to cope with the sudden
acceleration from near-stall, however this wasn’t really necessary with the Buhler motor.
What did help reduce surging at moderate speed was to add 1uF in series with 200k (pot) across
C6/R11. This reduces the amplitude of the fast response (without slowing it down) to avoid overshoot
on low-inertia motors, but still gives full gain to overcome locomotive friction load/changes when
required. The combination of these two different time-constants and gains seems to improve the general
behaviour of the various motors tried and may in particular help with some low-current low-friction
motors of the modern type. This might be worth including in the design.
Also tried was a resistor/diode from one of the AC inputs to pin 5 of IC1b to give some 50Hz.
Although this seems to help on the original Scalespeed controller it proved of marginal benefit here,
perhaps because of the feedback action. It does make motors more noisy and therefore may not be
worth adding to the design. If it is to be added, a better implementation may be to use a resistive divider
across the AC input to gnd, with a diode to pin 6 (not pin 5). This reduces IC1b output on alternate
half-cycles when the IC1a output is low (slow speeds) but has no effect at high power settings (because
the diode is always reverse biased). Don’t bother with this.
One modification that did improve crawl performance on some motors was to add resistance in series
with D9 – reducing the feedback gain. The circuit as drawn has very high feedback gain (limited mostly
by time-constants) which provides very good control of low speeds. But it was observed that as soon as
the speed control is turned up far enough to give any motor speed at all, negative feedback starts to
work immediately. In particular, the pulses will increase until the motor turns and will then drop in
amplitude. This is usually good for speed control, but in the crawl region (ie where a motor is basically
starting and stopping continually) this can give several large pulses before the feedback turns them
down. The result is a series of low-frequency oscillations (at perhaps 0.5Hz) in which power increases
and decreases. This is not necessarily bad for crawl performance as long as slow speeds actually need
gaps between pulses; however the oscillations are very variable in period which gives uneven
movement, and as the feedback is so high they are very sensitive to control position. The result is a
fairly sudden transition between not moving and moving at the slowest continuous speed.
For the very best crawl performance, it is sometimes better to provide fairly consistent pulses at an
amplitude which doesn’t vary too much with measured speed (because the motor is stopping and
starting). So for example quite a good crawl performance can be obtained on some motors with
feedback switched off. As an experiment, therefore, a pot was added in series with R9 and adjusted
until the controller gave an increased pulse amplitude (enough to make the motor crawl) before the
feedback kicked into effect. On some of the motors tried this definitely gave a more consistent crawl
with the new pot set to 27k and the motor was definitely much smoother at a fast crawl. The feedback
on/off switch on the prototype was set to high/low feedback instead (to switch this resistor in/out) to
aid trials. This resistor should be incorporated into the design (ie independently from R14 which sets
the time constant to lock out the flyback pulse).

19/10/06                              DIYcont3a.doc                                       15
Remote Control
This has been described before, but a simple walk-around control box is desired to allow easier control
of yards and sidings distant from the main controller. Although there are numerous ways of achieving
this the simplest is probably the following.

A) Using a 3-pin plug
The walk-around unit contains a speed-control pot, a reverse switch, and a lead to a 3-pin plug such as
a miniature stereo jack which is easy to plug and unplug and quite robust. The three wires run to the
ends and centre of the jack plug. The reverse switch merely connects a resistor across the pot to
increase the current flow.
The controller is modified with the stereo jack plug’s internal switch to the pot wiper. The socket
terminal that connects to the walk-around pot live end is connected not to the top of the controller pot
but to the emitter of an npn transistor whose base is connected to the pot top end, and the collector
runs via a 12V reversing relay to the +ve supply (+20V). When the reversing switch is operated on the
remote control, the extra current causes the reversing relay to switch in. This gives the required control
with only three wires.

B) Using a 6/7/8-pin plug
If a plug with more connections is available, such as an a professional-grade 7-pin din plug or even a
cat-5 lan plug, then the three pot connections and the relay operating switch can be kept separate.
There are also 2 additional wires available that can be connected to the leds to provide remote
power/track/overload indication. The remaining pin can be used to disconnect the internal pot by a
suitable switch if desired; alternatively an op-amp can be fitted in the hand controller and the output of
used to over-ride the normal speed control. A separate +20V supply could be provided for this and
other purposes (such as a power-on led) via one of the remaining pins.

Autostop & Braking.
Decided that best circuit to do this is NOT the previous idea of using the built-in inertia simulation
(since this is basically optional and not liked in shunting) but uses a transistorised Miller circuit
operating across the potentiometer ends. This gives suitable slow-down and speed up when driven from
a 5V logic signal or other source and can easily be added onto the existing controller circuit without
breaking tracks or changing the wiring or component layout. There is space on the planned controller
pcb to add these components or they can be put on a dedicated control panel. It is also easy to interface
this miller circuit to the optosensor discussed above due to its high impedance – indeed the
photodetector can drive the miller circuit directly if necessary.

Miscellaneous Thoughts
If you want inertia, I think the best way to apply it is to use a bipolar npn transistor with its emitter at
ground, its collector to the top terminal of the speed control pot, and a big capacitor (10uF?) from base
to collector. If you connect the base to +5V (or +12V, or whatever) via a suitable resistor (perhaps
19/10/06                               DIYcont3a.doc                                         16
220k or higher?) the transistor will turn on fairly slowly (miller effect) and reduce the speed setting.
Connect the resistor to ground instead and it will turn off even more slowly. This gives fairly realistic
braking and acceleration whatever the speed setting.
The point of doing this before the speed pot rather than after it is that the stop/go can be left connected
for automatic operation yet you can still get direct control for shunting, etc., without having to
remember to switch it off. You can therefore leave an auto stop connected (eg for signals) while you're
still driving the train manually, and if you forget to stop it will do it (realistically) anyway. In principle,
at least! You can also connect a walkaround sub-controller (with just a pot and a switch) easily without
the inertia getting in the way.

The neatest way to do autostop, by the way, is to sense current through a sense track (isolated from the
main track) just before a signal, and use this to set a latch or relay which applies braking to the
controller. This gives much better results than a simple isolating track and works even if the train is a
dmu powered at the rear, provided only that you have an electrical contact at the front vehicle (eg to
drive a headlamp), so long as the current sense circuit is sufficiently sensitive (10mA or so).

The neatest way to sense the current, by the way, is NOT to sense the current! Instead have one rail
completely isolated, monitor the voltage on it with a relay (high impedance 24V or 48V type, other coil
terminal to +24/48V), and when the loco wheel touches the isolated rail it activates the relay which
shorts the isolated rail to the main track (ie un-isolates it), thus putting the relay on permanently, while
another relay contact applies the brake. It does this via contacts on the signal control relay, of course,
so the train only stops when the signal is at danger - you can use the same technique at distant signals
with a partial brake application. Resetting the relay afterward is done when it reaches the next section.
If this relay is used to drive a signal and lockout the track on a previous section in a similar manner, you
get automatic block control (though you need separate controllers for each section, which means
having lots of simple DIY ones). If you add a track-circuited vehicle to the end of the train (eg a red tail
lamp) then this can give collision avoidance too, though you really need to sense the rest of the section
as well as the signal berth track in case the last vehicle becomes detached somewhere else in the
This is a really old solution (long before I was born!) but a good one, though nowadays you would use
solid-state fets/etc instead of relays. Relays are still good, though, if you like wiring but are suspicious
of semiconductors.

Which reminds me, if you're an old hand with valves: I once built an HF power oscillator from a design
in RM (circa 1970) using a 6L6 valve, which put 12V RF AC on the track to operate coach lighting etc
when the train halted. It also gave lots of smoke on the Triang synchro-smoke units too. Interfered with
the radio a bit, but that didn't bother me!

19/10/06                                DIYcont3a.doc                                         17
Switch-mode high-power NFB Controller for non-railway applications

For non-railway applications a higher power controller may be required. While the previous design of
fig 2 may be used with the current limit altered or removed, there is some merit in an alternative design.
This uses the same approach but a different pulse generator.

Circuit design – Prototype 3
The circuit can use the same circuitry around IC1a as in figure 2 for speed control and feedback, or
could use IC1b in place of the pot to suit alternative speed-control means such as external voltage
control or from a DAC.
However the output transistor is changed to a P-channel power mosfet and this is driven from an
inverting oscillator such as a 555 or an HCMOS inverter. The oscillator is controlled in the same way
as recent R/C drives, by pulling the timing circuit from the voltage control input (the output of
integrator IC1a here) so as to change the mark-space ratio and also the frequency. The maximum
switching frequency (and minimum pulse width) needs to be chosen carefully to suit the motor: too low
and the armature won’t move at all when desired to run slowly, too high and it will bound off at high
The output stage can be arranged to give very low-loss switching if a suitable driver stage is
incorporated, or can add an r-c delay into the mosfet gate to slow the switching deliberately. This
reduces the pulse energy which in turn reduces the vibration induced into the motor and its load by the
pulse energy. In principle a lower supply voltage would do the same job but this would limit maximum
speed. With a suitable driver stage supply voltages can be 24V or greater and currents as high as
needed. A polyswitch can be used as an overload limit.
At very low speeds it is usually desirable to reduce the height of the pulse and to round the edges, to
reduce noise and vibration. The suggested means of doing this here is to use the second half of the
LM358 IC1b to amplify and filter the 15V negative-going pulses output by the 555 and to drive the P-
ch mosfet via a pot which can be adjusted to suit the fet characteristics and to produce the desired pulse
height at low speeds.
In some applications a brake may be useful; some gear trains have significant inertia so that a sharp
motor pulse causes the whole train to oscillate. It has been found that switching a low-valued resistor
across the motor terminals damps this oscillation, particularly at very low speed settings where the
motor effectively stops between pulses. However this is not needed nor wanted at higher speeds. The
suggested solution is to switch the resistor to ground by a second N-ch mosfet which is enabled when
the main P-ch output mosfet is OFF and vice versa, and is also disabled when the speed setting rises
above a low level.
Unfortunately when the N-ch mosfet dive waveform is shaped to give the desired output pulse shape
and size, the driver no longer has the right transition times to activate the P-ch mosfet brake directly.
An alternative and in some ways preferable solution is to drive the N-ch mosfet from the 555 output via
a resistor (which ensures it goes off when a positive output pulse is due), but hold the N-ch fet off with
a bipolar transistor sensing the output voltage. This will hold off the N-ch fet while the pulse remains
high, but as soon as the pulse ends (and the motor inductance sends the output voltage negative) the
transistor turns off and allows the fet to turn on.
However it should be noted that these braking schemes are incompatible with feedback, so feedback
can definitely not be used in this low-speed region where the motor actually stops turning. It would be
possible to de-activate this at higher speeds if desired, but this may not be necessary. The positive
return of the motor to 0V between pulses should give a tighter speed control than the usual free-run
arrangement anyway.

19/10/06                              DIYcont3a.doc                                       18
Consequently the best driver circuit for the high-voltage pan/tilt motor application could well be a
circuit that more closely resembles the traditional mosfet motor drive circuit with fast-switching
complementary mosfets, but with a comparatively simple slow-down circuit added around the N-ch fet
(eg an R-C delay on gate or between gate-drain), plus the bipolar holdoff circuit described above.
If a micro is available then a different means of pulse shaping can be employed with a normal fast
complementary driver circuit – applying simultaneous pwm at two different frequencies, with a fast
pwm to give pulse shaping of the individual slow pulses needed to turn the armature slowly, and with
the slow giving way to fast at the higher speeds.

Feedback Considerations
The original purpose of feedback in model railway controllers was to improve the smoothness of
running of sticky motors. Essentially the feedback time-constants were made fast enough to respond on
a revolution–by-revolution basis to correct both for variations in motor loading and (in principle) for
cyclic changes in motor response. For this to work properly the time-constants and gains (if more than
one exists) have to be set to match the motors used fairly carefully, or else the feedback can actually
make the motor run rougher than without feedback. In practice feedback gain is usually desensitised to
reduce problems with sensitive motors at the cost of reducing the possible gains to a few.
However with multi-pole motors that already run smoothly at the lowest speed needed, there is little
benefit in having high-gain fast feedback in this manner. On the other hand slow feedback can be used
to regulate the speed of the motor without upsetting the cycle-by-cycle pulse waveform. This kind of
control needs a very high dc feedback but a very large time-constant.
In practice the best compromise may be obtained for a range of motors by using a composite feedback
circuit with two time-constants – a fast low-gain response and a slow high-gain response.
The slowest practicable continuous rpm will also vary with motors. Some motors may run smoothly at
speeds so low that the back EMF is measurable at sub-rev/sec rates (perhaps 100mV or so) while
others may not move easily until a large pulse amplitude is applied which either prevents accurate EMF
assessment or produces rapid variations in speed (and EMF) as the armature and gears rotate and
friction varies.
For the camera-drive application tested, examples of each of these were found. The best motor needed
little or no fast feedback for slow speed movement but slow feedback was necessary to ensure the
motor was moving. In this case, feedback served the purpose of checking the motor is moving and
varying the power applied to ensure that it was moving, and that the speed obtained was roughly
correct. In this case, accurate setting of the speed control voltage and the feedback voltage to the
comparator are needed but control response must be damped to around 1 Hz to avoid mechanical
Another motor tested was incapable of running smoothly at such low speeds and needed a quite
different drive waveform – high energy pulses designed to make the armature move in jerks and at a
very low pulse rate (perhaps 1 Hz). This is not desirable for smooth movement!
A related problem is ensuring that if a particular slow speed is commanded, then the motor moves at
the right speed. With pure analogue control negative feedback via the operator can ensure the right
speed is obtained, but in a remote control application, or where a digital interface is needed, then a
definite speed needs to be ensured for a given digital input. Feedback produces one method of
achieving this if the motor EMF can be read with sufficient resolution (particularly at low speeds) to
make it viable. Experiments suggest this is just about possible at the lowest speed required.
Initial experiments were done with the analogue motor control circuit of fig 2 above. The proposed
digital switching controller should be capable of operating with the required feedback loop behaviour,

19/10/06                              DIYcont3a.doc                                      19
but it should be noted that the pulse control mechanism is more non-linear and a fairly high level of dc
feedback is probably essential to obtain reliable speed setting at the extreme ends of the speed range.
Given a digital control word, speed control can be obtained either with a commercial DAC or by using
separate relays/digital outputs to select different resistors in the speed control setting.
To test these ideas a different feedback circuit was constructed using an op-amp (½ LM358) as a unity-
gain follower after the R-C delay in the feedback path, and also a mosfet switch in place of the diode.
The second ½ of LM358 dual op-amp sense the difference between the set speed and the feedback and
turns on an N-ch mosfet when the feedback voltage is lower. This avoids the variable offset voltage
introduced by the standard diode and provides a low-impedance source for feedback.
This circuit was tested and worked extremely well when added to the original controller circuit of fig.2.
However it didn’t seem to work as well on the revised circuit described immediately above, possibly
because the non-constant frequency of oscillation left longer for the feedback sensing to work and for
the armature to slow down. The variable frequency also gave problems producing good drive
waveforms and the mosfet tended to oscillate.
The decision was therefore made to change tack on the design approach and produce a new prototype
that works essentially as per fig 2 at constant 100Hz frequency, but with a separate 555 timer astable to
replace the 100Hz mains-derived waveform.

Circuit design – Prototype 4
This uses the traditional integrator and waveform amplifier of the fig 2 cct, but with three major
changes. Firstly a 555 astable oscillator is added as the 100Hz waveform source, and the live sawtooth
output from this is fed to the –ve input of the second op-amp used as the waveform amplifier. The non-
infinite impedance of this will affect the oscillator by reducing the frequency on low-voltage outputs but
this is desirable.
Secondly a composite output stage is used with a small signal npn bipolar transistor replacing the
TIP3055 and this driving the gate of a P-ch power mosfet attached to the 24V rail, with feedback to the
emitter of the bipolar transistor via a resistive attenuator.
The third change is to use the fet-switch nfb circuit described above. Note also that the op-amps and
555 are supplied from a 78L15 15V reg and thus the peak output voltage is a nominal 24V even if the
supply is greater than this. If the analogue speed reference voltage is 0-15V also, then the integrator
should stop acting as a feedback comparator at speeds around half maximum, and behave as a non-
feedback circuit, which is again satisfactory in principle.

19/10/06                              DIYcont3a.doc                                       20

Shared By:
Description: DIY Model Railway Controller