Sei sulla pagina 1di 194

DCC Basics: An Overview

This isn't really the place for a tutorial on DCC. There are plenty of books and
magazine articles for that, not to mention online information. The NMRA has a
number of pages aimed at beginners, for example, and you can no doubt find
many others.

But there is some basic information worth noting as an introduction to the


other pages in this section. For detailed information about DCC decoders, see
the DCC for Model Trains subsection of the Model Trains section. For
information about the DCC systems of my layout, and a few more in-depth
pages about specific topics I’ve had to delve into for it, see the Electrical
Systems pages in The Model Railroad.

DCC Components
A DCC system is composed of at least five parts: the throttle, the command
station, the power supply, the power station and the decoder. Some of these
parts may be combined (in fact, many beginner systems combine the first four
parts in a single device). Additionally, there are optional parts that can be
included, such as additional power stations (called boosters), a control bus,
circuit breakers, and specialized devices such as block occupancy detectors, and
stationary decoders for functions such as turnout and signal control.
DCC System Components

Train Control
The throttle, also sometimes called a “cab”, is the set of controls used by a
human to give commands to a train, such as adjusting the throttle, setting
direction, controlling lights, or (for a train equipped for sound) ringing the bell.
Some throttles are wireless, using radio to connect to the command station,
others are "walk around" throttles that plug into suitable jacks distributed
around the layout. One important aspect of DCC is that once a train has been
told to run at a given speed, or stop, the throttle can be unplugged while the
user walks to the next location, and the train will continue executing the last
instruction it was given. A throttle may be part of the command station (a
knob, pushbuttons or a lever on the box), separate but wired to it in some
fashion, or it may utilize a control bus to communicate with it.

The command station takes commands from one or more throttles and
converts them to DCC form. These are then mixed with the power needed to
run the train's motor (which comes from the power supply) by the Power
Station and sent to the track. The first Power Station is usually incorporated in
the Command Station, but can be separate. If more power is needed than can
be supplied by the first power station (separate or part of the command
station), then additional separate Power Stations can be added and these are
called “boosters”.

Between the Power Station and the Track will be at least one Circuit Breaker.
The first is built into the power station (or the command station if the two are
combined) and protects the total power sent to the entire layout. But it is often
useful to subdivide the track into blocks with their own dedicated circuit
breakers, so that a short circuit (such as is caused by someone running the
wrong way into a turnout set against their train) will only affect a portion of the
layout.

The decoder takes the power and signal from the track, and uses signals
addressed to it, and only those, to control the motor. Because each train has a
unique number, a decoder can tell which commands are being sent to it and
ignore the others, and this allows more than one throttle to control more than
one train. In fact, the command station remembers the last command sent to a
train, and keeps re-sending it, so an operator can unplug their throttle, or
change it’s address to control another train, and the first train will keep
running. This allows one person with one throttle to control multiple trains.

Interoperability
Because of the way DCC was standardized, buying a DCC system from one
manufacturer doesn’t lock you into buying decoders or other parts from
another, but there are limits. Typically the link between the throttle and the
command station is proprietary, meaning that the throttle has to come from
the same manufacturer as the command station. The link from the command
station to booster isn’t necessarily proprietary, although it’s often easier to use
boosters from the same manufacturer anyone with minor wiring skills can use
one from someone else.

There isn’t a standard control bus today, although there is some work to
standardize one, so anything that depends on one is to some extent locked into
use of that system. This doesn’t necessarily mean just the one vendor however:
Digitrax’s LocoNet supports products from a number of vendors, and doesn’t
require a Digitrax command station to be used. But it’s somewhat limited in
choice due to their licensing requirements. What this typically means is that
things like occupancy detectors may require their own communications
method back to a computer, in parallel with an existing control bus if, for some
reason, you don’t want to use models designed for the control bus on your
system (or if your system doesn’t include a control bus; not all do).

Finally, as noted boosters are simply amplifying the DCC signal, and that means
anyone’s booster can be used with anyone’s command station, although you
may need to wire up the correct kind of connector, and figure out what wires
go where. But there are often instructions online, either from the manufacturer
or others. Circuit breakers also don’t depend on the command station, so you
can add ones made by anyone. However, if you want the circuit breaker to
report to the computer when it trips, or if you want to use one that
incorporates other functions (like occupancy detection), then you would need
to take your control bus into account for that aspect.

Decoders, however, are universal. Anyone’s DCC decoder will work with any
DCC command station. Note that there are some digital control systems out
there that aren’t DCC (the term “DCC” is a trademark of the NMRA and can’t
legally be used to describe anything else). There are some limits in practical
terms: trying to run N-scale trains with a DCC system designed for garden
railways is likely to damage the trains due to the higher voltages used. But
technically the decoder for an N-scale train will work with the commands from
a G-scale command station; it’s just that the voltages on the rails are different.

Other Control Feedback Systems


There are two kinds of feedback: that from trains, and that from accessory
devices.

Trains can send feedback back to the Command Station through the rails using
RailComm. Digitrax has a similar, proprietary system called Transponding in its
decoders and command station. Both the command station and the decoder
need to support RailComm or Transponding (and it’s an either/or choice; I’m
not aware of any systems or decoders supporting both). However, you can add
RailCom to a train that lacks it or has a decoder with Transponding (assuming
you turn off transponding). Lenz mades a RailCom-only decoder (the LRC100)
that can be added to a train with an existing decoder to add RailCom support.

A Control Bus is a system separate from the DCC signals that allows devices on
the layout to communicate with each other. This is superior to simply using
stationary decoders, since it will typically support a greater amount of
information being exchanged, and can be interfaced to other communications
systems (like a radio unit for wireless throttles). The NMRA is beginning to
standardize NMRAnet as its control bus, but this is recent. Several existing DCC
manufacturers have developed their own control busses, such as Digitrax’s
LocoNet or Lenz’s XpressNet.

If the system has a control bus (or a “feedback bus” used for feedback only)
devices, such as block occupancy detectors, can send information back to other
devices. This is probably most useful if a computer is also connected to the
control bus. However, it can also be used for other purposes, such as a set of
crossing gates than come down when a train is detected approaching, and go
up when it passes. In that application, two occupancy detectors (one on each
side) communicate with the controller that drives the motor raising and
lowering the gates.

DCC Basics: Power


This page is an overview of how a layout using DCC gets power to run the trains
to the trains. Additionally it covers several useful related topics, including how
to measure voltage in a DCC layout, how much is needed, and how DCC differs
from DC.

For a more in-depth discussion, see my Power for Trains page, and for
information about wiring a layout for DCC see my DCC Layout Wiring page as
well as the excellent Wiring for DCC website, which covers far more topics, and
in more depth, than I ever could.

Voltage, Current and Trains


In a DC-powered model railroad, the motor on a train is directly controlled by a
“power pack”, which puts a variable DC voltage onto the rails. This varies from
0 to about 16 volts typically, and will be “positive” (right rail is higher voltage
than left rail) when the locomotive is to move forwards and “negative” (right
rail is lower voltage) when it is to move backwards.

DCC is, in the end, just a way to get DC power to the motor on a train. It does
this by mixing that power with control information, which the decoder on the
train will sort out, providing variable DC power to the motor depending on
what the control information indicates is desired. But the maximum power the
decoder can provide to the motor is ultimately limited by the power on the
rails, and more specifically, the voltage. And without adequate voltage, a train
won’t run well, if at all. However, too much can be just as bad.

Command and Power


In DCC, commands are processed by a Command Station to put them into the
form used by DCC decoders on trains. These are sent over a Power Station
Interface (which may exist only within a device, or be externally accessible) to a
Power Station that mixes commands with power, and puts the results out as a
pair of “track” outputs (often labeled Rail A and Rail B, although the names
don’t matter except when doing things like reversing sections, see Layout
Wiring for more on this). On systems that also externalize the power station
interface external power stations, called Boosters, can be added to provide
more power. Each power station has to connect to separate parts of the layout,
with both rails insulated between those “power districts”, but trains can move
from one to the other.

It’s the output of the power station that runs trains. Each power station has a
rating in Amps which identifies how many trains it can run. A typical N-scale
loco may use around 1/8th of an Amp (125 mA) so a three-Amp supply could
run as many as 24 trains. Some larger or older trains may use a half-amp or
even more than an amp. And trains with lighting or sound will need more
power than those without.

Power stations also have a rating in volts, with 12 volts being typical for N-
scale, and 14-16 volts being typical for HO (and usually acceptable for N-scale).
Some of that voltage gets lost on the way to the train, in wiring and track, and
some of the power (amps) is similarly lost although rarely enough to impair
operations. The maximum normal voltage in a DCC system is 22 volts, but that
may be too much for small trains, particularly older ones with lighting that have
been converted to DCC.

For more about command stations, see the Control Systems page.

How Much Voltage?


Per the NMRA standards, a decoder must work on 7 volts (measured as
described below, which I’ll call “7 volts DCC” to distinguish it from simple DC
voltage). However, voltage is lost in track, wires, and connections (like rail
joiners), so the command station has to put out more voltage for the system to
work reliably. The minimum voltage a command station should put out is 12
volts DCC. Most common ones will put out 14 to 15 volts DCC. A few put out
more (those designed for G-scale tend to use 20 volts or more). The maximum
a command station is supposed to provide is 22 volts DCC, but that’s enough to
cause problems for some models. Some command stations include a way to
switch the voltage.
If you have a choice of voltages, N-scale is probably best off with 12 volts DCC,
but many common systems used for N-scale provide 14 volts DCC with no
apparent ill effect. Most systems intended for HO provide between 14 and 15
volts DCC (at least one used 18 volts DCC, although it may no longer be made).

Voltage at the track can easily be 2 volts less, and voltage produced by a
command station will vary with the number of trains running. A “12 volt DCC”
command station could easily put out more like 13 volts DCC with no trains at
the output terminals of the command station, and with trains running voltage
on the track could be closer to 10 volts DCC. Don’t sweat the details if you’re a
volt or two either way from what you think is the ideal voltage.

Measuring DCC Voltage


First the fun part: there’s more than one kind of voltage. DC is easy: you have a
positive or negative voltage relative to some reference (often called “ground”
even when it isn’t tied to a real earth ground). Any multimeter with a DC scale
will read DC volts correctly.

The normal measure of a varying voltage (e.g., AC wall current) is the RMS
(Root Mean Square) voltage. This is a measure of voltage such that the power
(current times RMS voltage) would be equivalent to an identical DC voltage
with the same current. But since AC is typically a sine wave, this means that the
peak voltage (which is very short-lived) is actually higher than the RMS voltage.
A good multimeter with an AC scale (called a “true RMS” meter) should read
RMS voltages even for waveforms that aren’t sine waves, within limits, but
cheaper meters (and reportedly this includes some marked “true RMS”) will
only give RMS voltage for sine wave inputs (where RMS voltage is 0.707 x peak
voltage) or things that look similar to sine waves. My experience suggests that
DCC waveforms are far enough from sine waves that even “true RMS” meters
don’t produce a useful measurement.

DCC isn’t a sine wave, it’s a square wave with variable-duration peaks. If you
select address 0 (DC compatibility) and set the throttle to speed zero, you
should get a square wave with symmetric peaks. You can use a purpose-built
DCC voltage meter, such as the RRampMeter to measure this, although there
are other methods. Frankly, I don’t think any serious DCC model railroader
should be without an RRampMeter or equivalent; it’s one of my indispensable
tools; I own two: one built into the power management panel of the layout,
and one in my toolkit.
Because it’s easier to measure DC voltage, Digitrax provides instructions for
calibrating their command stations using a DC voltmeter and measuring peak
voltage. Basically, just measure each rail output in DC relative to the command
station common ground, then add the two numbers. This is a fairly good
method: since DCC is a square wave a DC meter will average the peak voltage
of half the cycle with zero for the other half, yielding one-half peak. Adding the
two gets you peak voltage, and compensates for any difference between the
two. RMS for a pure square wave should equal peak voltage, and for DCC the
two are “close enough” for most purposes. But it only works if your command
station has a ground to measure against; most good ones do (this goes by
several names, including “booster ground”, “common ground” and “home
ground”). I’ll compare how well that works with an RMS meter and an
RRampMeter below.

Note: the “ground” on a command station isn’t necessarily the same as the
“earth ground” aka “safety ground” found in house wiring, although it is
possible to connect booster ground to an earth ground (and useful, as this will
discharge any static charge than might otherwise build up). If you don’t
connect ground to earth, the booster ground will be a “floating ground”, which
is still useful as a reference point between multiple boosters. Just make sure
booster ground isn’t already connected to earth ground through the command
station, as multiple ground paths create “ground loops”, which can be bad for
electronics. And, if you have multiple boosters (or other layout devices using a
ground, such as DCC circuit breakers) make sure they all connect to the same
ground (e.g., wire all of the booster and circuit breaker grounds together).

Assuming you use the “booster common” wiring method (as opposed to
“common rail”, see Layout Wiring for the difference) circuit breakers need to
access the common ground, so this method will also work to measure the
output of circuit breakers. But if those aren’t located close to the track, it won’t
work for measuring track voltage (unless you extend the ground line to
convenient access points).

Rather than measuring peak-to-ground, you can also measure peak to peak and
divide by two. Most meters won’t do this, but an oscilloscope will and some
meters will also.

However, those methods (peak to ground and peak-to-peak) have a problem:


square waves are prone to distortion, which can increase the peak voltage
without altering the power in the signal (i.e., RMS voltage remains unchanged).
So this method works best close to the command station, where distortion
should be minimized. As will be seen below, it also probably works best on an
unloaded power supply (i.e, when no trains are running).

DCC In the real world - not quite square waves (oscilloscope shows output from
a Zephyr command station)

When you look at the diagrams above, it might seem like this “12 Volt” system
really has 24 volts, because the peak-to-peak difference is twice the peak-to-
ground difference. But the important part is that at any given time the peak is
about 12 Volts away from the ground, and this results in the voltage being
averaged to 12 Volts. If you run a 12 volt square wave DCC signal through a
rectifier (which is what a decoder does), you’ll get a constant 12 volts DC
(minus the loss in the rectifier, which is typically around one volt) as the power
supply. The rectifier is, in effect, averaging the voltage to get DC.
In decoders, the output of the rectifier is further varied by the decoder, to
supply the motor with a variable average voltage from 0 to the output of the
rectifier (possibly minus additional loss in the decoder circuitry that varies the
output). Thus the maximum motor voltage will be less than the peak (i.e., RMS)
voltage of the DCC signal.

Note: when I say “variable average voltage”, what I’m talking about is a
technique called pulse-width modulation (PWM), which is a bit beyond the
scope of this page, but it’s how most motor decoders provide a variable output
to the motor using a full-voltage input from the track. See the Train Power
Requirements page in the DC section or the Back-EMF page in the DCC
Decoders section for additional discussion of PWM, as well as the PWM page
for a more in-depth technical discussion.

Distributing Power
To get the power from the command station (or more correctly the power
station typically incorporated in the command station) to the train, typically the
rails are used. Some modelers use live overhead wire, called catenary, in
addition to the rails to more closely replicate real-world electric trains. In a
simple model railroad, connecting the command station to the track in one
location is all that’s needed. As a railroad grows, additional connections and
ultimately a “power bus” will be required.

The basic limitation of rail is that it’s not really a very good conductor. Even
nickel-silver rail is essentially brass: a copper/zinc alloy (nickel-silver adds some
nickel), and that doesn’t conduct electricity as well as pure copper wire. When
the track is about twenty feet from the train to where the power pack
connects, you can be losing a full volt of power with just one locomotive, and
the loss increases with more (or with imperfect track connections, like sectional
track). An excellent site discussing this topic is Allan Gartner’s Wiring for DCC
site, and in particular the page on Track and Wire Resistance. See also my page
on wire Ampacity.

If you want to run multiple trains, or have tens of feet of track, then you need
to run a “power bus”, which is nothing more than a pair of heavy wires (14
gauge is typical) run below the track, with periodic “feeders” (small gauge,
short wires) connecting the “right” bus wire (often red) to the “right” rail and
the “left” bus wire (often black) to the “left” rail. Left and right are somewhat
arbitrary; you just have to be consistent so that you don’t connect a “right” rail
to a “left” rail anywhere (or if you do, as in a return loop, then you need a
reversing circuit between the power bus and the track, which is a special kind
of circuit breaker).

For some more basic information about wiring, see my DCC Layout Wiring
page.

DCC Basics: Decoders


This isn't really the place for a tutorial on DCC. There are plenty of books and
magazine articles for that, not to mention online information. The NMRA has a
number of pages aimed at beginners, for example, and you can no doubt find
many others.

But there is some basic information worth noting as an introduction to the


other pages in this section. This material will focus on the mobile DCC Decoder
(the part of the Digital Command Control system that goes inside a train). For
additional information about DCC decoders, see the DCC for Model Trains
subsection of the Model Trains section.

The Role of the DCC Decoder


In a DCC system, the command station takes the operators commands (via a
throttle), encodes them along with the power and sends both to the rails. The
decoder’s function is to control how the power on the track is delivered to the
motor and accessories on the train by interpreting the commands sent to it.
Because each train has a unique number, a decoder can tell which commands
are being sent to it and ignore the others, and this allows more than one
throttle to control more than one train. In fact, the command station
remembers the last command sent to a train, and keeps re-sending it, so an
operator can unplug their throttle, or change it’s address to control another
train, and the first train will keep running. This allows one person with one
throttle to control multiple trains.

Decoders in trains are called “mobile decoders”, other decoders may be used
to control things like signals, crossing gates, or turnouts, and these are called
“accessory decoders” (or “stationary decoders”). The way the two are
controlled by the user is different, but fundamentally they work very similarly.

The Mobile Decoder


A mobile decoder (often just called a “decoder”) is a small circuit board with at
least four wires (and often more). Two connect to the track, and two connect
to the motor. Most decoders will have additional "function output" wires to
control lights, and a sound-equipped decoder will have two wires for
connecting to a speaker. With function wires, typically one wire is a "common",
and each function has a single wire, with a light, for example, being connected
between the function wire and the common wire. Mobile decoders can also be
“function-only” decoders. These would be used if you wanted to control, for
example, lights in some car other than the locomotive, such as a dining car or a
flashing-rear-end (FRED) device on the tail of a train. They’re also very handy in
multiple-unit passenger trains, where there are two cabs with head- and tail-
lights, one or both of which will be separate from the motor car.

Note: decoders are a sensitive electronic device and easily damaged by


handling. Keep them packaged until use, and follow good ESD safety
precautions when handling them.

Decoders can be wired permanently to a train, or may be connected via a plug


and socket arrangement, so that the decoder may be installed or replaced by a
non-technical train operator. When a train is supplied without a decoder, often
a socket is provided and used to connect to an interim circuit board that is
removed when a decoder is installed. However, both wire-in and socketed
decoders are not commonly found on Japanese prototype trains, so decoders
must be wired in by the purchaser, or in the case of Kato's "DCC Friendly"
trains, special decoders may be installed (see the Kato DCC Decoders page for
more on that).

A decoder typically comes from the factory set to answer to address "3" (the
“default address”), and with a default set of behaviors. These can be modified
by storing numbers into what are known as Configuration Variables
(abbreviated CV). While this isn't particularly hard, most DCC systems seem to
have been designed by and for computer programmers, which can make
actually figuring out what you need to do rather unnecessarily hard for people
who aren't computer programmers.

Decoders pre-installed in a train may have CVs pre-set to reflect characteristic


behavior of the train, or require programming. See the manual that came with
the train.

Motor control in a DCC environment is, technically, quite complex. You don’t
need to understand how a decoder controls a motor, although that can make it
easier to set up things like speed tables and Back-EMF. If you want to know
more, I delve into this on the Back-EMF page in my Decoders section.

The Accessory Decoder


A decoder can also be used independent of a train, such as attached to a
turnout or a signal, so that the operation of these devices can be controlled via
DCC. These decoders are called accessory decoders or stationary decoders, and
behave similarly to mobile decoders in many ways, but are addressed
independently (thus you may have both mobile decoder #3 and accessory
decoder #3 at the same time). The default address for a mobile decoder is “1”.

Control of these is generally done by selecting a “switch” number on the


throttle, and issuing a “close” or “throw” command to it. The switch number is
actually the address of the decoder, although some decoders can have more
than one address because they can control more than one output (accessory
decoders don’t have “functions” the way mobile decoders do).

Static Electricity and DCC Decoders


Any electronic item using silicon chips (and that’s most these days) is
susceptible to damage from Electrostatic Discharge (ESD), more commonly
known as static electricity. It doesn’t take much to totally fry a chip; you won’t
necessarily feel it or see a spark, and there won’t be any visible damage (unless
you have an electron microscope). In fact, even as simple a device as an LED
can be destroyed by static electricity.

Since DCC decoders are fairly sophisticated electronics, they’re more


susceptible than most model railroad items to ESD damage, which can ruin a
decoder, or just make it work oddly. Of course, many other things can make a
new decoder not work properly, and decoders are built assuming they’ll be
handled, so they don’t use the most sensitive components. It would be wrong
to immediately assume ESD damage is the cause when one misbehaves. It
could be, but poor wiring or mis-set CVs may be at fault. Still, taking a few
precautions isn’t too hard, and may save you some cash and frustration.

Here’s my advice on how to work with DCC decoders and other exposed
electronic components. I’ll be honest and admit I don’t always do all of this
myself (but I usually try to). And to some extent it’s probably much more
caution than is called for. But I really don’t want to deal with replacing failed
components, even in those cases where the manufacturer provides a good
warranty.

Kato ships their decoders in a hard plastic case with a small chunk of black
conductive foam, and that’s the safest place to store a decoder. I leave it there
until I need to touch it, and when I do pick it up, it’s by the edges to avoid
touching metal parts. Kato USA unfortunately ships them in a small soft plastic
envelope, similar to the way most other decoder manufacturers package their
products, which isn’t quite as nice. Leave them in the envelope until needed.

First, find a way to get rid of any static charge that builds up. In an ideal world,
both you and the work surface would be grounded through a high-resistance
path, to allow any charge to slowly leak off. The “high resistance” part is
important, as working on something that allows a static charge to move rapidly
from a source through the item being worked on is very bad. A metal table is
not a good surface, unless it’s insulated and only connected to ground through
a mega-ohm resistor.

In a house, there are two main ways to connect to ground. First, grounded
electrical outlets not only have a third “ground” pin (I’m assuming North
American design), but the screw that holds the faceplate on the outlet is
typically connected to ground within the outlet; a wire under the screw,
touching unpainted metal, should be grounded. Second, in a house with metal
water pipes, the cold water pipe is typically connected to ground.

Safety Note: Grounding yourself without a resistor isn’t bad from an ESD
perspective, but it can be dangerous if you’re working around anything
powered by wall current (like a soldering iron or DCC command station), as you
don’t want a short-circuit through you to be the only path to ground. Use a
wrist strap designed for ESD safety, or periodically touch grounded metal when
you aren’t touching anything else, but don’t keep one hand on a cold-water
pipe while working around electricity. That could be fatal.

A wrist strap that can be grounded is a very good idea (Google for “anti-static
wrist strap”, without the quotes, to find dealers, or go to Radio Shack, which
sells these for about $6, part 276-2397). Just clip it to a wire connected to a
known good ground. These straps use resistors, so they don’t provide a ready
path for a short circuit. If you don’t have a wrist strap, touching grounded
metal immediately before working (after you sit down) should dissipate any
static (note: touching metal that isn’t grounded, like the arm of a chair, won’t
do anything useful). As noted above, grounding yourself with a bare wire for
the duration isn’t a good idea for personal safety reasons.

An ESD mat that can be grounded is helpful if you’re going to do a lot of installs,
but they aren’t cheap (Google for “static dissipative work surface”, without the
quotes, and you should find a number of specialist dealers who sell them).
These, too, use high-resistance grounds.

Next, set up your work area to avoid generating static electricity in the first
place. Wood furniture on a wood floor is good. Avoid plastic tables and
furniture, and rugs, if you can. Otherwise, consider working on a small piece of
wood placed on the table, to insulate the things you’re working on from
discharge through the table. You can put rubber feet on the piece of wood to
protect the table top, or just rest it on a towel. Working in a very dry room is
also bad (but very common in the winter, when most of us work on trains).

Clothing is important. Avoid wool, silk and polyester or other synthetics (cotton
is good, as long as you don’t combine it with other fabrics). Avoid walking on
carpet wearing socks. Don’t wear a sweater while working on electronics. Avoid
petting your cat, too.

Lightweight plastic bags are a great source of static electricity (as are styrofoam
packing peanuts), because they can rub together and generate a charge.
Neither is a problem for shipping parts in good packaging (e.g., the Kato boxes
or envelopes used by most decoder manufacturers), but you’re going to pick up
a charge when you open the bag/box. Unpack any shipping boxes away from
your work area if you can, and ground yourself and the plastic boxes containing
the parts before opening any of those (for example, touch a metal faucet while
holding the Kato box in your hand). Setting the Kato boxes down on a grounded
ESD mat or holding them while putting on a wrist strap also works to dissipate
any charge you and they picked up from the unpacking. Note: a heavier plastic
bag, like the kind some decoders are sold in, could generate a charge if rubbed
on something else, but is less of a risk than a lightweight bag that can fold in
and rub against itself in multiple places.

Finally, avoid unnecessary handling of decoders or other exposed circuit


boards. Even the ones wrapped in insulated tape should only be handled as
much as is necessary, although the tape is good protection against ESD. Leave
them in the box until you’re ready to work on them, then move them straight
to where they’re going. If you’re going to solder directly to the circuit board,
you can place it on some wood, otherwise leave it in the box and solder to
wires separately until you need to pick it up. When you do handle a decoder,
try to avoid touching metal components or even the black plastic “chips” on the
board. Handle the board by the edges if you can.

All of the above may leave you afraid to touch anything. Keep in mind that a
good wrist strap will eliminate most static electricity (as will periodic touching
of grounded metal if you don’t have a strap). You can work on electronics in a
bone-dry room, wearing a wool sweater over a silk shirt, as long as you and the
work surface are properly grounded, although I wouldn’t recommend it. And
with cotton clothing, wood tables, and sufficient humidity in the air, you’re
likely safe even without grounding yourself. Take whatever precautions you
can, and you’ll eliminate almost all risk of ESD damage.

The other common method of destroying decoders, typically caused by hooking


up the wires wrong, isn’t ESD, it’s a short-circuit. That’s usually accompanied by
smoke and a burning smell, and is rather obvious. Make sure the wiring is
correct before applying power, and make sure bare metal isn’t touching the
decoder board (unless it’s supposed to), before you put the train on a
programming track or the railroad.

DCC Basics: Motor Control


DC motors are controlled by varying the voltage and polarity of the DC power
connected to them. In a simple DC power-pack a rheostat is used to provide a
voltage to the track that varies from zero volts to the power pack’s maximum,
which is often around 16 Volts. A simple switch is used to swap the positive and
negative outputs to change the polarity (and thus the direction the motor
turns). This tends to waste a lot of power as heat because a rheostat is a
resistor and resistors convert power to heat, but since that’s happening inside
the power pack, and “a lot” isn’t really all that much at these voltages, that’s
acceptable.

DCC decoders need to take a constant-voltage AC input from the rails, and
control a DC motor somehow. Even if they could use a rheostat or transistor
the way a power pack does, wasting power as heat inside a plastic model is
more problematic. The technique normally used instead is called Pulse-Width
Modulation, and it’s a fairly simple and commonplace, and efficient, method of
controlling DC motors from a digital controller. The same technique is used in
many other applications outside of model railroading, and most motors today
are designed to work well with PWM (this may not be strictly true of motors
made prior to the 1980s, although often those will work without undue wear
on the brushes, which is the main risk).

PWM is very straightforward: the digital signal on the rails, which is a form of
AC, is first converted to DC in a rectifier, providing a constant DC voltage, and
the DC is then sent to the motor through a controller. The controller doesn’t
just send the voltage constantly though, instead it can be turned on and off
very quickly. If it’s mostly on, the motor is getting near full voltage, if the
interruptions are more frequent or longer, and it’s mostly off, the motor is
getting very little average voltage, even though the peak voltage is still the full
DC voltage (perhaps 16V). The polarity can also be reversed in a manner similar
to the power pack, and this too is a function of the motor controller. And
because it works by turning off the power with a switch, rather than throwing it
away in a resistor, it’s not wasting power or producing excessive heat.

DCC motor control is fundamentally a “digital” form of motor control. Digital


motor control could be used in other control systems (like a conventional
“power pack”), but commonly those use analog (i.e., DC) motor control.

The rest of this pages gets into the technical details of this, none of which you
need to know to run trains with DCC. But I’m curious, and like to know what’s
going on inside things.

DC Motor Design
Model trains typically use “brushed permanent-magnet DC motors”, meaning
motors that uses brushes to energize windings (via a “commutator” contact) on
the moving part of the motor (the armature) and create a magnetic field that
acts against that of a permanent magnet mounted to the stationary frame of
the motor. In this kind of motor, the current in the winding has to reverse as
the winding moves from when it is approaching the magnet’s “north” pole to
when it is approaching the magnet’s “south” pole. This is achieved by putting a
brush on each side of the motor, and arranging this so that the “commutator”
for one end of the winding will contact one brush for roughly half the cycle, and
the other brush for the other half of the time (and vice versa for the
commutator on the other end of the winding). To avoid short circuits there
needs to be a gap where it contacts neither. For more details on such motors,
see my DC Train Motors page.

In a typical motor, power to an individual armature winding will be positive for


half of a rotation of the armature, and negative for the other half. The actual
“on” percentage will be less than half, but probably not much less, due to gaps
between the commutator pads. During the half-rotation that the winding is in
one polarity there will be a constant magnetic field generated by the winding.
When it switches polarity at the end, there’s a period where the old magnetic
field dies down and the new one (in the opposite direction) establishes itself.
This happens very quickly, with the complete changeover taking roughly a
quarter a millisecond for typical N-scale motors, and perhaps three-quarters of
a millisecond for an HO motor.

The length the field remains on depends on the speed of the motor. At full
speed, a motor may be turning at 14,000 RPM, or roughly 4.2 milliseconds per
rotation. At low speed a rotation could last close to 100 milliseconds. Which
means that at the fastest speed the armature is changing polarities roughly
every 2.1 milliseconds.

The above is true of a motor on simple DC power, and is based on the physical
structure of the motor. With DCC it doesn’t change. What does change is that
during part of the interval where the brush is touching the commutator and
electricity could flow (and would flow with normal DC), there may be no
electricity flowing because the motor controller has turned it off. But simply
turning the voltage off doesn’t turn the magnetic field off; as noted it takes
time to die down. If the pulses come close enough together, the field will
remain at mostly the same level, varying only slightly as pulses come and go.
We’ll come back to this important point below.
Motor Controller and PWM
With DCC, the motor’s speed and direction must be controlled by a digital
processor, working with the constant-voltage power supplied by the track (the
DCC on the track is alternating current, but in a roughly square wave, so when
rectified to DC it produces a constant DC voltage). The most efficient way to do
this is through pulse-wave modulation, where power is switched on and off
quickly to create “pulses” of full-voltage power (the “pulse amplitude” is equal
to the rectified DCC voltage). These pulses repeat on a regular basis (the “pulse
cycle”) and the longer the pulse, the higher the average voltage provided. And
it’s the average voltage that defines the speed with which the motor turns.

For more about PWM, see the PWM page.


PWM

The way the decoder creates these pulses is to use a set of four transistors acting as switches. In the
diagram below, the track voltage is rectified and fed to the left (positive) and right (negative) sides of
a structure known as an “H bridge” (look at it sideways to see the “H” shape). When switch 3 and 2
are on (as shown), the motor will rotate in one direction, when switches 1 and 4 are on, the motor
will rotate in the other direction, and when all four switches are off, no voltage is being delivered
(the gap between pulses).
But there is a bit more going on. What the voltage pulses really do is create a
current through the motor. While voltage produces speed, current produces
torque, which is the energy needed to move the train. And because the motor’s
wiring is an electromagnet (which is a form of inductor), once the current starts
flowing it doesn’t stop immediately when the voltage goes away. To permit the
current to continue flowing when the switch (which is a transistor) is off, the
circuit will have “Flyback Diodes” that permit the current to bypass the open
switches (without this, the energy stored in the inductor would build up a
damaging level of voltage between pulses).
Typical Current (blue) due to voltage pulses (green)

If the pulses come close enough together, the current never quite stops, and
the end result is more even production of torque and smoother operation of
the train. Of course as the armature turns, eventually the current changes
direction, the pulses now operating in the other polarity, and the current slows
and reverses direction. This happens fairly quickly, so the energy wasted when
the current is being reversed is minimized. At typical operating speeds, a
“supersonic” decoder is going to produce at least ten and possibly thousands of
pulses before the armature can reverse polarity.

Motor Operation
The motor in the train operating on DCC is thus part of a more complex system,
the operation of which can be modified to an extent by how the DCC decoder is
configured. This has a number of different effects, and often more than one
way to emphasize one attribute over another, or to chose how the motor will
behave under different conditions.

Motor Torque
Torque is the rotational force produced by a motor, a measure of the power
available to move the train, overcoming friction and pulling loads up grades.
More torque means longer trains can be pulled, or steeper grades climbed for
the same size train, or higher speeds can be reached. Torque is highest when
the motor is stalled (“stall torque”) and declines linearly with rotation speed
until it reaches zero at the unloaded maximum rotational speed (when all
power is being used to overcome internal friction and back-EMF). In practice,
the load on the motor will define the maximum speed; more load, and the
motor runs out of power to move the train against it’s own drag at a lower
speed. If torque is reduced, then the train will have a lower maximum speed,
and in fact a lower speed for a given voltage compared to the same motor with
less load.

Fundamentally torque depends on the design of the motor and drivetrain, in


particular on the electrical power supplied to the motor (voltage times current)
and the gear ratio of the drive train (a higher ratio means a lower top speed but
more torque for pulling loads).

With PWM another factor comes into play. Fundamentally, a DC motor works
by creating magnetic fields in the windings of the motors armature (the moving
part in the middle) that react against the fixed magnet on the outside of the
motor. Electric current produces a magnetic field, but magnetic fields have a
tendency to persist for a short time once created. Ideally a continuous current
would be used, which requires a continuous voltage. In a DC train, that’s
exactly what is done.

But with DCC, PWM is used, meaning that instead of continuous power, there
are pulses of power (pulses of voltage, which create pulses of current). Because
magnetic fields tend to persist, this works. But because magnetic fields also
tend to build up slowly rather than instantaneously, longer pulses are better
than short ones. As PWM frequency gets higher, pulses get shorter but more
frequent. The same amount of power in the PWM pulses is less effective at
building a magnetic field with short pulses as it would be with long ones. The
effect is that higher frequency PWM produces less torque for the same
available track voltage than lower frequency PWM, and this effect is magnified
at lower speeds.

Note: strictly speaking, “power” in a motor is the product of torque and angular
speed, and is maximized at the halfway point between full-load/no-speed and
no-load/full-speed (at both of which points one factor is zero and hence power
is zero). Meaning that a motor produces its maximum power when it’s turning
at half its maximum unloaded speed. An interesting corollary of that is that
since current is proportional to torque, not power, the motor will be drawing
exactly half its stall current at the point of maximum power.

Train Speed Control


In a DCC system, the connection from the throttle controlled by the operator of
a model train to the decoder is digital, and DCC defines the speed of a train as a
“speed step” from zero (stopped) to 126 (100% speed). When the operator
turns a throttle knob, the throttle converts this into a speed step and sends
that to the decoder.

Although the motor controller chip on the DCC decoder deals with the motor in
terms of a PWM pulse duration and the delay, the decoder deals entirely with a
percentage of track voltage, typically expressed as a number from 0 to 255
(where 255 = 100%). This exactly fits in an 8-bit Configuration Variable (CV).
Normally a decoder will have a speed table made of 28 CVs (it estimates the
ones in between to create a table of 126 steps), although the table can be just
three CVs (stop, middle, and full) from which it will calculate a full speed table.

The decoder looks up the received speed step in whatever it’s using for a speed
table (set by the user or calculated), which contains the appropriate voltage
level. So half throttle might be sent as speed step 63 (of 126, meaning 50%),
and looking that up in a speed table might produce 50% motor voltage, which
would be represented as 128 (out of 255) in the table. Of course the user could
have decided that half throttle should produce 1/4 speed (or anything else) to
allow for smaller changes at low throttle (and larger changes at high throttle),
and programmed a number like 64 (out of 255, meaning 25%) in that cell of the
table, but we’ll ignore that for this example.

Motor controller chips typically also represent the output voltage as a fraction
using 256 steps, so the decoder could simply take the value from the table (128
in this example) and put it in the controllers voltage-control register to set the
motor voltage. More often, manipulations will need to be done on the number
(for improved slow-speed running or load compensation), and sometimes
motor controllers use a larger number of steps in their control register (so
voltage could be defined on a 0 - 511 or 0 - 1023 scale). Thus the usual result is
that the decoder takes the value from the speed table (128), scales it to fit the
controller (e.g., to 256 for a 0 - 511 scale) and then applies any modifications to
it (such as changes due to BEMF and “dither”, or scaling from one of the Trim
CVs), and ends up with a motor speed percentage (such as 76/128 or 152/256
or 608/1024, all of which mean 59% voltage).

It may also apply changes such as momentum (which are based on the
Acceleration and Deceleration CVs). This would cause it to save the target
speed (128 in this example), but set the motor to some speed between the
current speed and the target speed for a time, then set it a bit higher (or lower
depending on whether the throttle had been turned up or down) and repeat
until it had gradually adjusted the motor to the desired speed step using the
selected acceleration (or deceleration) rate.

One important consequence of this is that the speed of a train depends on the
track voltage. If you set up a train to run at 100 scale mph at 100% throttle on a
13.8V Zephyr like mine using a speed table, and then take it to someone else’s
layout that uses a 16V “HO” DCC command station, it’s going to run something
closer to 116 scale mph (the actual speed will vary due to other issues like
friction in the drive train, so that’s only approximate). On a 12V “N” DCC
system, it will run at something closer to 87 scale mph. There’s no such thing as
“absolute” speed with DCC, only fractions of track power.

PWM Frequency and Audibility


The frequency of the PWM cycle (what I’ll call the base frequency for reasons
that will become clear in a bit) is controlled by how the decoder’s motor
control circuitry is built, and to a limited extent can be altered by making
changes to how it is set up by the CPU (this is why some decoders can let you
turn off “supersonic” PWM). The choice of what this frequency should be is not
a simple matter (I go into some of the issues on the PWM page).

But one important aspect is that each pulse makes the motor vibrate slightly,
so the pulse frequency produces faint sound waves of the same frequency.
Higher frequencies are harder to hear, making the motor less noisy. Lower
frequencies are also bad for the motor: below a threshold they cause more
heating of the motor, and too much of that can damage it.

Hearing loss happens progressively with age, making it harder to hear all
sounds. But the effect is magnified at higher frequencies. It’s not so much that
older people can’t hear higher frequencies, but that their (our) sensitivity to
them drops, making it harder to hear quiet higher frequencies. A loud motor
close up at 16 kHz is likely still audible to 50-year-old who couldn’t hear it ten
feet away. Whereas an 18-year-old probably hears both equally well. So a
decoder that’s “supersonic” at 16 kHz is likely still audible if you listen close
(unless you have other hearing-loss problems), but put it in a body shell that
damps the vibration (not all will do so) or stand back from it, and you may not
hear it unless you are younger than the average model railroader.

Also, PWM isn’t necessarily just one frequency. In some throttles it is, and the
“base frequency” is the only frequency. But in others, because the pulses are
bunched into groups, the sound you hear will depend on the cycle over which
those groups occur. This will be lower than the base frequency, and thus more
audible. So “supersonic” is something of a misnomer, although the high-
frequency PWM called “supersonic” does reduce the amount of nose that’s
audible.

Low-Speed Compensation
When there’s no magnetic field in the armature a motor isn’t turning, and the
friction of the motor and drive train is “static” friction, which is higher than the
“dynamic” friction that comes into play once the motor and gears are turning.
For these reasons, getting a stopped train started requires a little extra
“oomph” that won’t be needed to keep it moving.

One common method to get a motor started is to briefly apply extra voltage
when the decoder moves from speed step 0 (stopped) to speed step 1. This
extra voltage comes in the form of holding the first pulse on longer. For
example, a typical PWM pulse might be a multiple of 0.24 microseconds
(corresponding to a decoder frequency of 16 kHz). This is extremely short. A
motor at its slowest speed is probably turning at about 55 RPM. This means
that each rotation lasts over 900 milliseconds, and there would be about 7,200
of those short pulses occurring in a single half-rotation to energize a winding.
But because each is short, with a long gap between them, the magnetic field in
the motor could be slow to build up. At its fastest (14,000 RPM) a half-rotation
lasts just 72 microseconds, but at that speed the pulse would fill the interval
(62.5 microseconds), even at 90% throttle it would be effectively continuous.

Note: at a decoder frequency of 1,000 Hz, each pulse would still be only 4
microseconds long, and there would be about 450 of them per half-cycle.

So by holding the pulse on longer, often several milliseconds, more energy is


pumped into the motor to create the magnetic field. Once established, this
controller can use ordinary pulses to keep the motor turning. The optional Kick
Start CV (CV65) can define the “amount” of this kick, but since the NMRA didn’t
define how it was used, a value of “2” on one manufacturer’s decoder may not
work the same as a value of “2” on another’s.

TCS has replaced Kick Start on their decoders with “dither”, which is discussed
in the Torque Compensation section below.

For a given motor and drive mechanism, a voltage of 1/255 of track voltage
may not be enough to keep the motor turning, so it may be necessary to also
set the Start Voltage (CV2) or Speed Step number 1 (CV67) to a value higher
than 1. Which to use depends on the decoder, and whether you are using the
basic speed table or the “28 Step” speed table (enabled by adding 16 to CV29,
which sets bit 4). On most decoders, CV2 only applies with the basic table, but
some decoders apparently also enable it with the 28-step table. CV67 only
applies when the 28-step table is selected.

One more problem is torque (power). It takes more power to move a


locomotive pulling a train, than to move just one locomotive. And it takes more
power to pull a train up hill than to pull it on level track. For this reason the
step 1 voltage may need to be higher than what it takes to keep just a
locomotive moving. If you set up the loco alone on a test track, then put it on
the layout with a train, you may be disappointed.

Torque Compensation
But there are decoder features that can help solve this problem. These go
under different names from different vendors, and may reflect slightly different
methods, but all of them share the same goal: to compensate for low torque,
particularly at low speeds. There are two major types of this: the non-adaptive
ones (often called “dither”, although Digitrax simply calls theirs “torque
compensation”) and the adaptive method usually called “BEMF”. I’ll cover
BEMF separately, so for now lets focus on the non-adaptive ones.

As the term implies, these are simple methods that don’t change what they’re
doing based on how the motor behaves. You turn them on, and maybe set a
configuration variable to tune it to work better with your motor, and it “just
works”. What it’s basically doing is adjusting the way the pulses are provided to
the motor at low speeds, to ensure that the magnetic field in the armature is
stronger, at least some of the time, increasing the average force the motor is
using without necessarily increasing the speed that it is turning.

I don’t actually know what “dither” does. This is an area I need to investigate.

Back Electromotive Force-Based Compensation


Electromotive Force (EMF) is another name for voltage, it’s basically the force
that pushes electrons through a conductor. One characteristic of a motor is
that it creates a voltage in the windings that opposes the voltage causing the
motor to turn. This reverse voltage is known as back electromotive force (or
BEMF). It basically subtracts from the driving voltage, reducing the current
through the motor, and lowering the effective torque of the motor. The
amount varies with the rotational speed of the motor, so a faster motor
produces more BEMF and has less torque.

A neat trick with this is to briefly turn the voltage driving the motor off, and
measure the current produced by the back EMF. Because the current isn’t
produced immediately, it takes time (likely over a millisecond) to measure this
current, so there is a fairly long measurement period required in comparison to
the PWM frequency (which would normally be issuing tens of pulses per
millisecond for a typical “supersonic” PWM frequency. But if this isn’t done
often, the occasional lost power won’t be significant.

Once the current is measured, the speed of the motor can be estimated. And
since speed is based on the applied voltage and the load on the motor, the load
can be estimated (since the controller knows what voltage it is sending). Doing
this dozens of times a second allows the motor controller to raise and lower
voltage to compensate for changing load (e.g., going up and down grades,
around curves, or across switches or crossings where the wheels encounter
increased resistance.

All of this makes for a highly-responsive control mechanism (a “closed loop”


control method) that can adapt to changing conditions to maintain the motor,
and thus the train, at roughly the same speed. For more on this, see my BEMF
page.

Pulse-Width Modulation
Pulse-Width Modulation (PWM) is a common technique for controlling the
speed of a DC motor with a digital controller. It is so common that PWM
controllers are built into some microprocessor chips used as integrated
controllers. A Digital Command Control (DCC) decoder uses PWM to control the
speed of the motor in a model railroad locomotive or other motorized vehicle.
PWM is just one aspect of controlling a motor, and others are discussed on the
parent DCC Motor Control page. This page gets into the details of just how
PWM is used, and what options you might have for adjusting it (and why you’d
want to).

Reminder: in a DC motor, the basic principle of operation is that applied


voltage creates an electric current through the motor’s windings, these are
wrapped around a ferrous core called the armature that connects to the shaft
of the motor so the current creates a magnetic field in the core, and the
armature is mounted in a frame containing a fixed permanent magnet, so the
interaction of the two magnetic fields creates a torque (force) on the armature,
causing it to turn. The torque is proportional to the current, and the current is
limited by the voltage (and a bunch of other factors we’ll get into below). Thus
voltage essentially determines the unloaded speed of a motor, and how much
torque is available from the shaft of the motor. Turn up the voltage, and the
motor spins faster if the load is constant. Add more load, and the motor slows
down if voltage remains constant.

Decoder Design
In a modern decoder, most of the functions are handled in a microprocessor.
Because microprocessors continue to get smaller and faster, newer designs can
do more processing in the same space, leading to features like Back Electro-
Motive Force feedback control (commonly called BEMF) and high-frequency
PWM (marketed as “supersonic” output, although it really isn’t). This also
results in more miniaturized decoders with the same capability as larger ones
of the previous generation. The microprocessor will set the motor controller to
output a specific average voltage (called a “duty cycle”) when it receives a
throttle change from the user, and then go off and do other things. The motor
controller is a tiny bit of hardware that will output PWM with the requested
duty cycle until told to change it.

The motor controller itself is typically a very simple device, often part of the
microprocessor “chip” on the decoder, that has a couple of “registers” allowing
its operation to be controlled by the software running on the decoder’s
microprocessor. The user doesn’t program the speed in the controller directly,
but rather can set variables (CV’s) that the software uses to decide how to
program the controller. And the software may alter the controller’s settings
hundreds or even thousands of times a second. But if not, the controller will
keep on doing the last thing it was told to do: run the motor at voltage “X” in
one direction or the other.

Why PWM Is Used


PWM is desirable as a method to control a DC motor digitally because it is
efficient (no power is wasted as heat as in a resistive control) and simple to
implement in a digital circuit, requiring only fast-switching power transistors
and a counter to time their operation. These translate directly to lower costs
and smaller and cooler-running, and thus more reliable, circuits. They also use
less power, which is beneficial with running a lot of trains off one supply.

What PWM Means

In PWM, a “pulse” of power is provided where the voltage is changed from zero
volts to the maximum available (the Pulse Amplitude). The pulse lasts for a
time (Pulse Length) and then is off. The controller repeats this cycle on a
regular interval (the Pulse Cycle). The reciprocal of the length of this cycle is the
frequency of the pulses, which can range anywhere from a few tens of pulses
per second to more than 20,000. The amplitude of the pulse will always be the
same, and in a DCC decoder’s output it is the rectified track voltage, so it will
typically be about 1 volt less than the peak voltage on the track (around 11 - 15
volts for a typical N or HO decoder pulse).

WIth simple PWM, the pulse cycle remains constant, as does the amplitude,
and only the pulse length is varied to control the average power in the motor.
However, because the PWM controller can be reprogrammed on the fly by the
microprocessor, it is possible that the pulse cycle length could also change
dynamically (this would no longer be PWM but rather a mix of PWM and PPM,
or Pulse-Period Modulation). I haven’t (yet) seen a decoder do that.

Decoders will, however, turn PWM off entirely for a time so that they can
measure the voltage generated as Back-EMF by the spinning armature, which is
how they estimate the speed of the motor and adjust it (the whole process is
typically called “Back-EMF” or “BEMF”). The exact length of the gap required
depends on electrical characteristics of the motor, and thus will vary a bit
between individual models with different motors.

Controlling Speed With PWM


As mentioned above, in a PWM motor controller, power to the motor is
regulated by varying the duration of PWM pulses. These can be as simple as
turning the power on for X% of some period and then off, and simply repeating
the cycle to create a chain of identical “pulses” of power, or can be much more
complex and arrange these pulses into groups of varying duration. But in the
end they’re all doing the same thing: turning full power on for some fraction of
the time, and off for the rest. By doing this, the controller is varying the
average voltage supplied to the motor. And in a DC motor, speed is
proportional to voltage. Thus it is varying the speed.

But a DCC decoder has no way to know what the track voltage is, or how fast
(in RPM) its motor is turning. All it knows is that at throttle speed step N it
should provide X% of power to the motor. What “X” is, can be defined in a
number of ways (such as a speed table) and modified in others (such as
applying BEMF-based adjustments) before the value is given to the motor
control circuit itself. What the PWM controller then does is issue pulses of the
necessary length at the requested frequency.

And the requested length of the pulses will be based on some integer
subdivision of the interval that corresponds to the requested frequency. A
common subdivision (for reasons we’ll get to later) is 256. So if the interval
were 1 millisecond, then each pulse would be an integer multiple of 1/256
milliseconds, or roughly 3.9 microseconds. A throttle setting of 10 (out of 256)
would equate to 39 microseconds per pulse, and full throttle would equate to
3.9x256 microseconds, or 1 millisecond (at full throttle each pulse runs into the
next one and power is on continuously, at least until we complicate things with
BEMF). These integer multiples of some base pulse length are called “speed
levels” and are an attribute of the hardware of the decoder (e.g., in this
example “level 1” is a pulse of 3.9 microseconds, “level 2” is 7.8 microseconds,
and so on up to “level 255” which is essentially continuous power).

Although the motor controller deals with the motor in terms of pulse duration
and the delay until it repeats the cycle, the decoder deals entirely with a
percentage of track voltage, typically expressed as a number from 0 to 255
(where 255 = 100%). This exactly fits in an 8-bit Configuration Variable (CV). So
the end-user programming the CVs in a decoder to run a train is really working
in percentages of track voltage expressed as a 0-255 number.

For example, in the photo below, a TCS M1 decoder’s motor output (orange
and gray wires) is measured with the throttle set at step 64 (out of 126), or
roughly half power. Each pulse lasts about 25 microseconds (the Pulse Length)
at maximum amplitude (15.03V DC). The power is being pulsed roughly every
62.5 microseconds (the Pulse Cycle time), or at a frequency of around 16,000
Hz. Looked at another way, with a frequency of 16 kHz, the the Pulse Interval is
62.5 microseconds, and if this is subdivided into 256 speed levels, then each
pulse is an integer multiple of 62.5 / 256 = 0.244 microseconds, so half power is
about 128 x 0.244 = 31.2 microseconds (while I said 25 microseconds above,
the oscilloscope I used here isn’t accurate enough to tell 25 from 31).
M1 Step 64: 16 kHz PWM (at 50 µseconds/division), 15.03 volts peak-to-peak

The person who set up (“programmed”) the decoder can define the voltage
percentages set by the decoder at various speed steps, using either a simple
min/max basic speed table for a more detailed 28-step speed table. And in
doing that, they can make assumptions about the track voltage, and work with
knowledge of the train’s motor and geartrain design. Thus the decoder
programmer could know that the train will, for example, go 183 scale kph at
full speed on a 14V DCC layout, and scale the maximum speed step to be 2/3 of
track power to provide for 120 scale kph (meaning set the top speed CV to 2/3
of 255, or 170. Unfortunately if someone then takes the train to a 12V DCC
layout, it’s going to run about 14% slower (and things get more complex with
BEMF).

We’ll get into programming and the choices that can be made later on. But the
decoder isn’t aware of any of that, it’s just doing what it was told to do, and
providing 170/255 of whatever voltage it’s supplied with when it receives a “go
speed step 126” command.

PWM Frequency and Torque


As the voltage varies from zero to peak and back in a square wave, the current
passing through the armature windings actually increases and decreases in a
sawtooth pattern. This is because the armature and windings form an inductor,
and in an inductor current doesn’t immediately rise to the level allowed by the
resistance. Instead it climbs asymptotically towards it. For a typical small DC
motor, it will rise to 99% of the maximum in as little as half a millisecond, and
at most tens of milliseconds, although just how rapidly depends on the specific
motor design.

Note: for the mathematically-inclined, current rise occurs based on the time
constant, τ, which is computed from the inductance (L, in Henrys) and
resistance (R, in Ohms) as τ = L/R. At half throttle when the PWM looks like a
square wave, after time τ from the start of voltage, current will be at 63% (1/e)
of the nominal value, meaning 63% of 50% or 31.5%. At time 3τ it will be at
95% (of half-throttle) and at 4.6τ at 99% (see motor tutorial in references). For
a typical N-scale motor, τ is measured in hundreds of microseconds or more, so
near-full current will be reached in no more than tens of milliseconds if power
is applied continuously for that long.

And current is important, because torque, the force used by the motor to
overcome friction and other sources of drag, is based on the current, not the
voltage. Voltage makes the motor spin, but current makes it propel the train.

What this means is that for a PWM controller with a frequency of even 1 kHz
and a 256-level motor controller, the current may not ever reach 99% of that
possible, because the longest pulse (other than 100%) lasts barely a
millisecond. And the higher the frequency gets, the further from optimal the
current will be. This is the fundamental reason “supersonic” PWM has less
torque than even normal (kHz) PWM, and normal PWM has less torque than
real DC (which will reach 100% of current, or fairly close to it, after even a
fraction of a second).

There’s a formula for the current in an inductor as a function of elapsed time:

where:
I = current (Amps)
V = voltage (volts)
R = resistance (of motor windings) (ohms)
L = Inductance (Henrys)
t = time (seconds) since application or removal of voltage

The inductance of a motor is the hardest part to know. Multimeters that


measure inductance are uncommon, and typically only measure it at one
frequency (unless they’re very expensive meters), and motors are “non-linear”
inductors because of their use of a soft-iron core, meaning that their
inductance changes with frequency. Note that the stall current is the maximum
current, so you can calculate the resistance if you know the voltage and stall
current (from R=V/I) or the stall current if you know the resistance (I=V/R). But
at best you can only approximately know the inductance unless you have much
better equipment than I can afford.

Note: I had problems measuring resistance of the motors, and ended up


calculating it from the observed stall current (R=V/I is valid if you let the current
run long enough to stabilize). I did measure inductance (L) with a meter that’s
probably using a 1kHz frequency, so extrapolating that to 16 kHz is likely to
introduce some error, but that’s the best I can get with the instruments I have.

The following diagram illustrates the behavior of current in a typical N-scale


motor. This was one of my Kato E231 motors, a 3-pole skewed-winding motors,
but I actually saw nearly identical numbers from a five-pole motor (see my
Typical Motors page for specific numbers for each). The current shown here is,
of course, theoretical, derived from motor R/L constants rather than measured.
It’s also not showing BEMF, so this is the maximum current that can be
produced to pull a load; actual current in normal operation would be lower.

The graph shows current with the motor driven at 16 kHz. Current (blue line)
rises exponentially once voltage (green line) is applied, and declines
exponentially when it is removed.

Note that the current isn’t climbing anywhere near peak current, despite the
voltage during the pulse being at peak. That’s because the peak is too short
even starting from 250 mA for it to climb very far in the time the pulse is on.
What really matters though is average current, not the peak.

Here the current is oscillating around 300 mA (about 60% of the 500 mA stall
current). The oscillations amount to 20% of the range, so this is relatively
inefficient, but not terribly so. This is a consequence of this particular motor
having a time constant equating to a 12 kHz frequency, so we’re just a little
above that, allowing for a significant drop.

Note: I’m still not sure these diagrams are right, although they’re closer to
correct than the old ones. More work is needed on this.
PWM Current (blue curves) and driving voltage (green square waves, scaled to
show 100% at 0.060) for 50% throttle, 16 kHz PWM

At 25% throttle, the current is much lower, averaging around 150 mA. The
amount of oscillation, at about 75 mA, is lower than at 50% in absolute terms
although larger relative to the actual current. This is about as expected: the
exponential decay keeps the motor from loosing too much field strength, even
over a relatively large gap.

PWM Current for 25% throttle, 16 kHz PWM

In contrast, here is the same motor at 25% throttle with 1 kHz PWM. Now the
pulse is long enough that the current can climb nearly to 100% strength, but
then the gap is correspondingly longer, so it can fall all the way to zero and
remain there. The average probably works out the same, but the large swings
correspond to more energy lost as heat in the armature.
PWM Current for 25% throttle, 1 kHz PWM

Let’s look at one more example, how the motor would react at 32 kHz. The
oscillations are much smaller than at 16 kHz, although average current is
roughly the same.

PWM Current for 25% throttle, 32 kHz PWM

PWM Frequency and Noise


When the pulse goes through the windings, the magnetic field increases,
causing an increase in speed. It also causes an increase in the tugging force
between the armature and the frame of the motor due to the increased
magnetic field. When the pulse ends, the tug relaxes. The effect is to cause the
motor to vibrate slightly, at the same frequency as the pulses. That means that
the vibrations created in the motor by turning the power on and off with a
16kHz PWM signal will have a sound frequency of 16 kHz also. That’s not quite
“supersonic”, but it’s going to be hard to hear for the average older modeler.

There’s another kind of noise to be concerned with, Electromagnetic


Interference, or EMI. As the decoder’s PWM frequency becomes higher there is
an increased quantity of EMI produced by the switching transistors in the
motor controller, as well as by the brushes in the motor. This can be filtered in
a variety of ways by the designer of the decoder, but doing that adds to the
complexity (and cost). And failing to do it could run afoul of regulations on
acceptable radio interference.

So while higher frequencies are good for acoustic noise, they have a cost for
the decoder manufacturer (and thus for the person paying for the decoder).

Most modern DCC decoders use high-frequency PWM to control the motor, as
will be described in the technical section below there are limits to how high this
can be, and some advantages to lower frequencies, but most decoders will use
a frequency around 16 kHz by default.

PWM and the Motor Time Constant


A motor is an inductor, and thus is can be characterized by a “time constant”,
which is simply the inductance divided by the resistance (L/R) and gives a
number in seconds. Taking my typical N-scale motor, this gives me 2.3 mH /
26.7 ohms, or a time constant of 86 microseconds, which equates to a
frequency of 11.6 kHz. The other N-scale motors I measured had frequencies
between 8 kHz and 12 kHz (HO motors were slightly lower, but I didn’t measure
many of those). A good rule of thumb is that to avoid excessive heating in a
motor from PWM, the frequency must be “significantly above” the time
constant, as illustrated in the graphs of motor current above. This is another
argument in favor of using supersonic PWM.

The issue here is that it takes a time related to the time constant for current in
the motor to rise (and decay). That time is based on the creation (and
relaxation) of the magnetic field in the motor, and uses up energy. When the
field decays, the energy spent creating it goes somewhere, and that’s into the
motor’s armature as heat. In technical terms, this is called “hysteresis loss” by
motor designers. A short pulse with a long gap implies the maximum loss as
heat, where a long pulse with a short gap or a very short pulse repeated before
the field can decay will minimize such loss.
There’s a second issues as well: whenever a magnetic field is changed,
electrical currents are induced in conductors. Because the armature is a
conductor currents, called “eddy currents” are induced within it, wasting some
energy as heat each time. More pulses per rotation means more changes, and
more lost energy, as well as more heat, which could damage the windings at
higher loads on the motor, since current through the windings would also be
producing heat. The only way to avoid that is to limit the current, so at higher
PWM frequencies the motor must not be run at full voltage with a full load.
Exactly what amount is safe is not well defined, but the basic point is that the
higher the PWM frequency, the more heat is produced from eddy currents and
the less margin there is for heat produced by current in the windings, and
hence a lower limit on motor pulling power.

Motors are designed to somewhat limit eddy current loss though the use of
layers of stamped metal for the armature, rather than a solid casting. While use
of layered armatures reduces manufacturing costs, the smaller portions of
metal also reduce the amount of energy lost in eddy currents by keeping the
individual looped paths of that current small.

Thus the ideal frequency depends on the duty cycle of the PWM, and
specifically on the length of the interval between pulses for the lowest speed
(shortest pulse) we want to use, in order to reduce hysteresis loss. And this
places a minimum bound on the frequency. But the maximum frequency is
effectively limited by the loss in allowable current (i.e., the loss in effective
torque) as more heat is produced by eddy currents.

So the ideal is to be enough above the minimum frequency set by the time
constant to avoid hysteresis loss at low speeds, while not being so high as to
create undue loss due to eddy currents. While we can calculate the former
fairly easily, it is harder to determine the latter. But this is probably why
“supersonic” decoders are just barely above the limits set by the time
constants of typical motors.

Let’s Get Technical


So that’s the high-level view (really, it was). Let’s lift the curtain and see what
goes on behind the scenes.

Motor Speed Levels


Because the interface from the microprocessor to the motor controller is
digital, a speed is expressed as a level from zero to some hardware-based limit.
And that means that the motor controller’s output isn’t a continuous range of
speed, but a number of discrete speeds, often called “levels”. A typical motor
controller may use up to 10 bits (1024 levels), but many use as few as 8 bits
(256 levels). Since DCC only has 126 steps, that’s twice as many as necessary. A
decoder could just choose to use only half of them (128 levels), but when
adjustments to the selected voltage are made (such as with BEMF) it can be
useful to have finer-grained control on the voltage being supplied to the motor.

And that’s the reason 256 is typically used as the number of steps (as noted
further up the page). It’s enough to add one extra level in between the
required ones, without requiring more complex (and thus more expensive)
motor controllers. Exactly why more steps are more costly is an interesting
topic in its own right, and I’ll come to that later, but first let’s take a look at
how the PWM frequency relates to the motor speed.

PWM Frequency and Motor Speed


We’ll start with an example of how PWM pulses feed power into the windings
of a motor. This example uses a three-pole motor, but the behavior of a five-
pole motor is essentially the same. In the diagrams below, the output of the
motor controller (PWM pulses) is shown at the top of each diagram, with an
arbitrary time scale, and below this is a diagram showing the armature of the
motor with the commutators (gray patches) as they move past one of the
brushes (semicircle to the left). For simplicity the other half of the circuit and
the other brush are not shown.

The following discussion is not entirely correct - rewrite needed.

At time T0, the positive brush is contacting one winding (lower left), the
negative brush is contacting another (lower right), and the third winding (top)
is not being energized (the gap is exaggerated here). At time T1, the “top”
winding has moved to the left to contact the brush and is now energized, but
the original “lower left” winding is still energized as well. At time T2 the first
winding has rotated to the bottom and is no longer energized, but the former
“top” winding (now “upper left”) remains energized. In fact, the winding that
was at the top at T0 will be making contact with the brush from T1 to T5, but will
no longer be touching it at time T6. A complete rotation of the motor here
would require twelve time intervals, during two of which the winding’s
commutator is not contacting the brushes (from time T7 to T11 the winding that
started out at the top at T0 is now energized with the opposite polarity).
An important thing to observe here is that with three brushes, during a given
motor cycle each will encounter the positive brush once (three “contact
events”) and at the same time as each “event” one or more windings will be in
contact with the negative brush. If power is fed in pulses as in PWM rather than
continuously (as in DC) then there needs to be a minimum of three pulses per
motor shaft rotation to energize each winding. Why not six? Because the
windings are arranged back-to-back, energizing one “positive” is also energizing
one or more “negative” on the other side of the motor. Note that with five
windings (a “5 pole” motor) you need five pulses per cycle, not three, to ensure
every winding is energized to each polarity in each cycle.

And if the “dead zone” between commutator sections (designed to keep


windings from energizing at the wrong part of the cycle) is long enough, more
than three evenly-spaced pulses could be required to bridge the gap and still
energize all three windings at least once.

In this example there are more than three pulses per cycle. But note that this
doesn’t mean that the windings are continuously energized. Between the
pulses at time T0 and T1 there is no power to the brushes, and thus during this
period while the winding could be energized, it is not. This is because the
pulses are relatively short (shown here at about a 17% duty cycle), reflecting a
low throttle. To an extent that’s desired, as we don’t want full speed in the
motor at low throttle. There are problems however. We’ll come back to this in
other sections below.

But the important part here is that there’s a fundamental minimum PWM
frequency based on the rotational speed of the motor. And if the PWM “Pulse
Cycle” is a fixed length (and it is), then this frequency has to be based on the
top speed the motor will go in practice. That’s not the manufacturer’s rated
speed with no load, but it is the speed the motor will be turning at for an
unloaded train on level track. I measured one of my Kato motors, and at a
rough approximation top speed is 16,000 RPM under those circumstances.
That’s 267 revolutions per second (or 3.75 milliseconds per revolution). To get
three pulses in that time, the interval must be less than 1.25 milliseconds
(meaning a PWM frequency of more than 800 Hz), and to get 5 (for a five-pole
motor) it much be less than 0.75 milliseconds (meaning more than 1,333 Hz).
Thus, efficient use of a motor argues for a minimum PWM frequency greater
than one kHz for a typical N-scale Kato motor (and for other similar motors).

Now if you know you’ll never run your motors at full speed, you can adjust
that. A freight engine is going to have a much lower top speed than a passenger
train, and they typically use exactly the same motor (although they could use
different gear ratios). So a motor that needs 1,333 Hz in a passenger train, but
is run at no more than half that speed in a freight engine could get away with a
decoder PWM frequency of 667 Hz.

Rather than lots of short pulses, what if you used a pulse longer than the time
the winding remained in contact with the brush? That would seem to be more
efficient, and in some ways it is.

Let’s look at a pulse for 17% throttle where the winding remains energized
from when it first touches the brush at time T1 until it breaks contact at time T5,
as shown below. You would then need a gap five times as long as the pulse,
meaning about 2.5 rotations of the armature, for the same average current
(not counting inductance effects). The benefit of this long pulse is that the
magnetic field strength in the winding would be maximized during that one
cycle, providing the most amount of torque possible for a given amount of
voltage and duration (i.e., for a given duty cycle at a set track voltage).

The problem is that 2.5 rotations with no power is a long time; at 17% of top
speed a typical train will probably have moved close to 40mm (1.5”). That’s
long enough for friction to slow it significantly. If the motor is turning fast
enough, the fact that it’s only being given a “kick” of power once every ~3
rotations doesn’t really matter. And this is at 17% throttle where there’s only a
1/6 ratio of on to off. What about speed step1, where there’s a 1/255 ratio? To
keep the pulse on for a full rotation, it much be off for 255 of them. That’s
obviously not going to work, so at best you won’t really get a full-duration
pulse at all speeds, you’d have to pick a speed above which you wanted full-
duration pulses, and still live with shorter pulses at low speeds.

There’s also an inefficiency here. If the pulse is just long enough for one
winding, even assuming you could somehow synchronize it, this means that the
other two windings would be energized for only part of two cycles (one
positive, one negative). A longer pulse to ensure all three are energized (one
full rotation) would then require a longer gap (several rotations at this power
level, hundreds if you tried to do it at speed step 1). The takeaway is that this
“long pulse” approach isn’t very good at providing continuous power, and while
it might be a bit more efficient at providing average power without a significant
amount of friction, it’s probably not going to work well in a real-world
environment.

Switching and Clocking Limitations of “Supersonic” PWM

High-frequency PWM has limits. Because this is creating a high-frequency wave


by turning the power on and off, the transistors that do that must operate at a
fairly high speed. To create a 16 kHz wave, they must turn from off to on, and
then back to off within that 62.5 microseconds, meaning that they’re switching
once every 31.25 microseconds. That’s fast. Not incredibly fast by modern chip
standards, but still fast. And to do that, a bit of hardware is counting clock
pulses to time the length of the PWM pulse. That means the clock needs to be
running fairly quickly. In fact, it takes a clock measured in megahertz to
produce a kilohertz-level PWM signal with the 256 levels typical of BEMF-
equipped decoders. Doubling the frequency requires doubling the clock speed,
and that has a cost (more expensive components, more careful design, etc)
that will be reflected in the cost of the decoder.

That “twice every 62.5 microseconds” is just for an output that is on exactly
half the time (the “base frequency”). If you want it to be on shorter or longer,
one part of the wave will have its “on” and “off” decisions made more closely
together, requiring a higher switching speed (more expensive power
transistors) and thus a faster clock speed (more expensive chip and circuit
design). Ultimately there’s a cost to faster PWM.

There’s a formula for this (see below for more detail). What it works out to is
that for a PWM signal to have 128 steps (the minimum in modern DCC) in a 16
kHz signal it needs a clock running at about 2.05 MHz. Many BEMF control
designs create additional “virtual” speed steps in between the real ones, to
allow finer control. This has a direct effect on the clock speed required. To
create one virtual step between each real one (meaning to use 256 motor-
speed steps and to make the on/off decisions twice as fast), raises the
requirement to 4.1 MHz. Changing the base motor frequency also affects the
needed clock speed: going to 32 kHz with 256 steps doubles the needed clock
to 8.2 MHz. There’s a very real cost to this, although it comes down every
couple of years as chips get faster and cheaper. And with BEMF in the picture,
it may be preferable to spend that extra capability on more speed steps for it,
rather than on reducing the noise further with a higher PWM base frequency.
The decisions involved in design of a motor decoder are not necessarily
straightforward.

There’s also an inefficiency in turning those power transistors on and off too
rapidly. Power is lost each time a transistor switches, and the faster they switch
the more power is lost. Pushing PWM too high can have a significant
performance impact due to switching loss, although I don’t have specific
numbers for how high “too high” would be. I expect this is negligible in
comparison with the general inefficiency of the motor itself.
Motor Controller Clock Speed
As noted above, the clock used to drive the motor controller must be much
faster than the frequency of the PWM, and this increases as the number of
levels of control of the motor speed (steps) increases. A PWM motor controller
doesn’t set a motor to any possible speed, but to one of a number of levels
from 0% to 100% of the speed possible with the available power.

For example, the PIC16F88 chip used on Kato’s EM13 motor decoder can
produce up to ten bits (1024 steps) of PWM. If the chip is driven by a 3.6 MHz
oscillator (and I think it is in the EM13), to get 8 bits (256 steps) of resolution
the PWM frequency must be limited to about 14 kHz (per a formula in the
datasheet for the PIC, which may be generally applicable to other controllers),
and to get 7 bits (which is really the lowest you’d want) it must be limited to
just under 29kHz. With an 8 MHz clock, 32kHz PWM is still slightly below 8 bits
of resolution. Thus “ultrasonic” decoders with higher frequencies either have
fewer bits of resolution, or require higher clock rates (which make the circuit
design and testing a bit more complex and likely add to the cost). Digitrax notes
that their FX3 decoders use 255 motor speeds in normal use, although the
BEMF function claims to use all 1024 on the DZ125 at least.

I suspect the reality is that all current DCC motor control systems are at
frequencies that yield around 8 bits of effective resolution, and that’s “good
enough” to support 128 speed steps plus one interpolated BEMF setting in
between each step with current clock speeds. Initial work with a scope suggests
that these decoders are using a frequency of around 16 kHz for the PWM, but
in some cases the signal is more complex than a simple string of pulses, and
other frequencies (both audible and supersonic) may be included in the mix.

PWM Output from a decoder to a motor (Digitrax DZ125)

Motor Controller Steps and Clock Speed


I’m going to get a bit technical here about why PWM has “steps” and how
those relate to decoder cost and PWM frequency. If you don’t care about
knowing the “why”, simply understand that PWM needs at least 128 steps for
DCC, and 256 is fairly common when BEMF is used, and there’s a cost reason
why this tends to imply that “supersonic” decoders aren’t quite supersonic.
And if that’s all you need, skip down to the next section heading.

In theory, PWM pulses could be sent with any duration, and continuously vary
motor speed from zero to whatever maximum the available voltage made
possible. In practice, PWM is produced by a digital motor controller chip that
works by counting pulses from an oscillator and using an integer number of
oscillator pulses to determine the length of each PWM pulse. A decoder
doesn’t “known” what the available voltage is, it merely works with
percentages of whatever is available. This means that there are discrete speeds
the motor can turn at that are evenly “stepped” from 0 to “full” speed
(whatever full means for that motor with a given supply voltage). For a typical
model train motor and DCC controller, these are likely to be 256 steps, each
about 40 RPM faster than the previous one (10,000 RPM motor divided by 256
steps). Since a typical train with typical voltage can run around 250 scale kph
(I’m rounding a lot here), that means that each step represents about a scale 1
kph increase in the speed of the train. And since there’s no way to a human to
tell 32 scale kph from 33 or even 34 scale kph, the result looks like a smooth
and continuous increase in speed as the throttle is turned up.

This counter will have a size in bits, and 8 is common. If the oscillator is running
at 1 MHz, and the counter has 8 bits, then the PWM pulse it generates can be
anywhere from 1 microsecond to 256 microseconds long, but it can only be an
integer multiple of 1 microsecond, it can’t be 1.5 microseconds long. The clock
can also be scaled. If you wanted times up to 512 microseconds, every other
clock pulse could be counted, and then the PWM pulses could be 2, 4, 6, etc.
microseconds in duration, but never 1 or 3.

What this means is that the PWM pulse pattern has to repeat. Let’s assume
that the clock is ticking once every 250 nanoseconds, meaning at 4 MHz. This
means the shortest pulse is 250 nanoseconds long, and the longest is 250 x 256
= 64,000 nanoseconds, or 64 microseconds long. Assuming we want that
longest pulse to mean 100% power, that means that the pattern repeats every
64 microseconds (making that the wavelength) since at full power the end of
one pulse has to bump into the start of the next. And thus the frequency
(1/wavelength) is 15,625 Hz. Which is very close to what DCC decoders called
“supersonic” often use.
But that’s for 256 steps. If we used the same clock with 7 bits (128 steps), then
the wavelength would be half as long (250 x 128) and the frequency twice as
high (31,250 Hz, or really supersonic). If instead we wanted 1024 steps, the
wavelength would be four times longer (250 x 1024) and the frequency a very
audible 3,906 Hz.

And the clock is the same, make it run at half speed (500 nanosecond ticks) and
the wavelength is doubled and the frequency halved for the same number of
steps.

Put mathematically, the formula is: Base Frequency = Clock Frequency x


2^(Counter Bits).

I ran across a variation of this formula in a microchip datasheet that computed


the usable bits of the counter (the steps) from the PWM frequency (the length
of the cycle) and the speed of the oscillator (the ticking clock). If you have more
bits in your counter, you won’t be able to use them, because you’ll get to the
point where to stay at the desired frequency you have to repeat the pattern (so
you might have 10 bits, but have to repeat after counting to 256, or 8 bits
worth). That formula is:

Resolution = Log ( Fosc / Fpwm ) / Log(2)

where Resolution is the number of usable bits, Fosc is the frequency of the
oscillator, and Fpwm is the frequency of the PWM.

When computing resolution from the PWM frequency and the clock frequency,
you can end up with fractional bits. That’s okay, as it simply means that the
ability to create the necessary number of steps is not quite exact. If you have
7.9 bits, you’ll miss an occasional step if you try to create 256 steps (8 bits), but
you’ll mostly get it right, and that’s good enough for a motor controller. On the
other hand, if you have 7.1 bits, trying to create 256 steps isn’t going to work
very well, and you’ll end up doing about the same as if you’d tried for 128 steps
(7 bits) in the first place.

These formulas are a useful guide to understanding approximately what is


required to make a DCC motor controller work. DCC uses 127 steps (126 speed
steps plus zero), meaning 7 bits of “levels” are required. Based on this
relationship, for a PWM signal to have 128 steps in a 16 kHz signal it needs a
clock running at about 2.05 MHz.
Many BEMF control designs create additional “virtual” steps in between the
real ones, to allow finer control, so you’ll see decoders that talk about having
“256 level resolution” . This has a direct effect on the required oscillator (which
in turn affects the cost of the decoder in several ways: faster clocks cost more).
To create one virtual step between each real one (meaning to use 256 motor-
speed steps), raises the requirement to 4.1 MHz at 16kHz. Changing the base
motor frequency also affects the needed CPU speed: going to 32 kHz with 256
steps doubles the needed processor to 8.2 MHz. There’s a very real cost to this,
although it comes down every couple of years as chips get faster.

Magnetic Field Strength and Current


The torque of a motor comes from the strength of the magnetic field in that
motor’s armature tugging and pushing against the permanent magnet of the
frame. The strength of the magnetic field in an electromagnet depends on a
number of things, but fundamentally it is proportional to the strength of the
current flowing through the magnet’s windings. Thus, the motor’s torque is
proportional to the current flowing.

The current in turn depends on the voltage and the resistance of the windings.
But because an electromagnet is an inductor, the current does not go from
zero to full instantaneously as the voltage is applied. Rather there is an
exponential rise from zero to an asymptotic approach to the maximum
(meaning that it gets most of the way there fairly quickly, but never quite gets
all of the way there) as shown in the diagram in the PWM Frequency section
above.

Electromagnets (and DC motors using an electromagnetic effect) are “non-


linear” inductors. What this means is that there’s a relationship between the
time it takes to raise the current up and the strength of the magnetic field in
the armature that’s related to the frequency at which you’re trying to do it. I
believe the next effect is to make it even less effective as the frequency is
raised (above and beyond the basic problems this causes), but I haven’t found
numbers to quantify this aspect yet.

The longer the motor voltage is on, the more the magnetic field can build up in
the armature, and the more efficient the motor will be at converting electrical
power to torque. But there is actually a limit to this in a typical brushed DC
model train motor, since the armature winding is not energized throughout the
full cycle of the shaft’s rotation.
Because the field in the winding (and the flow of current) reverses every half-
cycle, this process has to start over twice per cycle in any case. With PWM, it
has to start over with each pulse. So to maximize the current, it would be
desirable to have all of the power being supplied in a half-cycle provided as one
pulse.

If there’s only one pulse per cycle, or if the pulses are so far apart the field has
collapsed, it will be harder to increase the current (take more time, or provide a
lower strength for a given time of applied voltage). As it turns out, for typical
motors the field will collapse far faster than the next pulse can arrive, until the
duty cycle is well above 50%.

With short pulses, it’s better to put them close enough together to get multiple
in one half-cycle of the motor rotation, so all of the windings are energized at
least once. For a 12,000 RPM motor (200 Hz), a PWM frequency greater than
400 Hz is beneficial. On the other hand, this doesn’t rule out the advantage of a
pulse that exceeds the half-cycle time when the winding is making contact, as
shown in the PWM Example section up above. For the same motor, and
assuming 256 speed steps, this means that the pulse must last longer than
1/256 of 1/6,000th of a second. Since that’s less than a microsecond, it’s not a
hard requirement to meet at top speed, but at low speed it’s essentially
impossible to have a pulse long enough, so you will always get multiple per
half-cycle.

Optimizing PWM Frequency


You can’t really optimize the frequency, although there are some choices that
can be made. Fundamentally the decoder has no way to know when the
commutator is in the dead portion of its cycle and when it isn’t (I suppose
current draw could be measured and a model built from that that was used to
arrange PWM pulses). Assuming the dead zone is relatively short, and the pulse
frequency high relative to the rotational frequency, this can probably be
ignored anyway.

The other problem is that motor rotation speed is variable, and thus the
frequency of the commutator reversals is variable. PWM by definition has a
fixed frequency.

One thing you could potentially do is have the microprocessor reprogram the
motor controller at each speed step, to “tune” the frequency to the speed of
the motor. This would allow pulses to be longer at low speed steps and shorter
at higher speeds. At least on paper, this should allow the “pulse” to be kept at a
similar length (by shortening the cycle length in tune with the motor speed).
When the motor is rotating a few turns per second at most, pulses would last
8-16 milliseconds at speed step 1, while at half throttle the motor is rotating
about 100 times a second, and a half-period pulse would last around 5
milliseconds. Pulses in the millisecond range are guaranteed to always have full
current for most of their duration (it probably takes about 0.4 milliseconds to
get close to full current), and thus be very efficient. I’m not aware of anyone
who’s actually done that though.

DCC Basics: Power for Trains


As noted on the DCC Basics: Power Systems page, the function of a DCC system
is to put voltage onto the rails in a way that enables it to be used (along with
the control information also provided) by a DCC Decoder to operate the motors
and accessories of model trains.

Note: for information about the power systems on my layout, see the Electrical
Systems subsection under The Model Railroad.

Also see the DCC Basics: Power page for information on measuring voltage on a
DCC layout.

Voltage and Trains


Why is voltage important? Because voltage is what controls the speed of a DC
motor. At zero volts it’s not turning. At 6 volts DC a “12 volt” motor should be
turning at something roughly half its nominal maximum speed. And at twelve
volts DC, it should be at maximum. And that’s true for any (normal) model
train, sort of. In the real world, nothing is that clean, and different scales have
different conventions. Most HO systems are based around 16 volts (the normal
maximum specified by the NMRA), most N-scale around 12 volts (the normal
minimum), and some trains don’t follow these conventions at all. And then
there are the power supply manufacturers, who seem to operate on a “more is
better” philosophy, probably to avoid voltage getting too low due to losses in
poor track wiring. A typical Kato N-scale pack puts out about 14 volts
maximum, not 12, and power packs for the HO modeler often put out 18 or
more (some popular MRC models put out 22 volts at max throttle). However,
that’s not the full story.

The maximum voltage for a DC motor in a model train is codified in the NMRA’s
Standard S-9 Electrical, which has been unchanged since 1984, before DCC was
introduced. Actually, what the NMRA says is that the maximum voltage shall be
“not less than” 12 volts DC at the rail. NMRA Recommended Practice RP-9
Electrical further recommends that DC power packs should produce a
maximum between “12 and 16 volts [DC] while delivering rated current”.

While motor control in DCC is more complex than simply varying the voltage,
the maximum available voltage is still the limit for the maximum available
speed. In practice most trains don’t need even the “typical” maximum voltage
to run at their highest prototypical speeds (high-speed passenger trains, aka
bullet trains, are an exception).

All that makes perfect sense, but there’s one last bit: S-9.1, Electrical Standards
for Digital Command Control, All Scales (PDF), says that “The RMS value of
NMRA digital signal, measured at the track, shall not exceed by more than 2
volts the voltage specified in standard S9 for the applicable scale” and “The
minimum peak value of the NMRA digital signal needed to provide power to
the decoder shall be +/-7 volts measured at the track” (which implies an RMS
voltage of 7 volts, not 12).

Note: when I describe voltage as “N volts DCC” I’m referring to the DCC RMS
voltage, which is what a device like the RRampMeter will measure. The
RRampMeter is an essential tool, and no operator of a DCC layout more
complex than a dozen feet of track should be without one. I own two: one
portable, one built into the layout’s power panel.

Now what’s interesting here is the reference to “for the applicable scale”,
because NOWHERE does the NMRA actually require or recommend that there
should be different voltages for different scales. The closest they come is in S-
9.1 where the diagrams showing min/max acceptable voltages for power
supplies and decoders have lines showing “typical” N, HO and O/G voltages
(which appear to be 12, 14.5, and 18 volts respectively). But that’s clearly a
reference to existing practice, not a recommendation. I’ve seen numerous
online references to NMRA “requirements” that voltages be 12, 14.25 (that
precise number from multiple sources, not 14.5), and 18 volts for those scales,
from people who ought to know, and yet the standards don’t actually say that.
The NMRA Conformance Testing requirements (PDF) will pass any command
station or booster with an output between 7 and 22 volts RMS.

This suggests that S-9 (and the RP that goes with it), is a bit dated, and that the
NMRA has subsequently been thinking about a wider range of acceptable
voltages. This makes a bit of sense, as in 1984, when S-9 was last updated, HO
and O dominated, and N was a niche scale. Today, there is substantially more
N-scale use, and there is also Z scale which is even smaller. Electrical standards
appropriate for HO aren’t necessarily correct for N or Z.

My reading of the NMRA standards is that a DCC signal having a minimum peak
voltage of 7 volts is required “at the track”. That’s in conflict with the
requirement that the DCC RMS voltage of that signal should not be less than 12
volts. That’s probably just sloppy writing, and what S-9.1 should have said was
“at the track outputs of the power station”, with the difference between 12
volts and 7 volts being down to losses in bus wires, track, and locomotive pick
ups.

A sensible interpretation would be that a command station for N-scale use


should put out 14 volts DCC (12+2), while a command station for HO use should
put out 18 volts (16+2) DCC. However, most actually put out between 14 and
15 volts DCC and systems that did put out 18 volts actually caused problems for
some sound decoders.

So, How Many Volts?


Which doesn’t tell me what the voltage should be for an N-scale train. The
NMRA only says that 12 volts DC is “typical”. My questions are: what is the
“best” amount, and what are the safe limits (maximum and minimum)? The
only real guidance is that most equipment was probably made to expect the
older range (12-16 volts DC) from DC power packs, and so it should be safe to
operate in that range. And track loss can be several volts, so voltage at the
track as low as 10 is probably reasonable. But what’s the “right” voltage? That’s
a harder question.

More isn’t necessarily better. The most common problem is having too much
voltage, which causes engines to run too fast, and may damage lights and
sensitive electronics. While the Digitrax Zephyr puts out 13.8 Volts DCC
(measured with my RRampMeter), some entry-level systems are designed
primarily for HO use, and put out substantially more, some 18 volts or more,
which have caused Soundtraxx sound-decoders to malfunction. The NMRA
maximum limit on “power station” output is 22 volts, but that’s really a safety
limit, not something that’s desirable for a command station or booster to put
out. The normal maximum output for a command station or booster intended
for large-scale (O or G) use is 18 volts DCC RMS, which fits the NMRA
recommended (RP-9) maximum of 16 volts DC plus the 2 volt allowance of S-
9.1.

With passenger trains, lighting is also a potential issue. Lights (bulbs in


particular) produce waste heat, which in an enclosed space can build up and
melt plastic. If the lights are controlled by a decoder (like headlights usually
are), they might be given a clean 12 volt DC signal by the decoder (that’s a big
“might” though, and more likely they’ll get track voltage less about one volt
lost in the decoder). And in any case, car lighting is often not controlled, and
simply takes the voltage from the track. This means that extra track voltage
goes straight to the lighting, potentially overdriving it.

Overdriving a bulb can shorten its lifespan, or even melt a model. Overdriving
modern LED lighting is worse. It WILL shorten the life, often significantly, and
could cause heat-related problems, although LEDs produce significantly less
waste heat than bulbs. But the real problem is that LEDs have a limit, and going
beyond this simply causes the LED to fail immediately (and possibly melt, which
could damage the car it is in). LED lighting designed for DC use should be safe
to at least 16 volts DC, since many DC power packs are rated for that voltage,
and possibly to the NMRA 18 volt limit. But that may not be as true of Japanese
trains, as the market there is largely N-scale. Also, what’s going to matter here
is probably the “peak” voltage, which in practice will be a bit higher than the
“DCC RMS” measure of track voltage due to overshoot.

There are other components involved as well. LEDs use resistors, and some
LED-based lighting uses a rectifier (or diodes) to keep it constantly lit whether
the train is in forward or reverse. Often these are made with tiny surface-
mount components that can be overloaded themselves at voltages above those
expected. Yet another reason to be sensitive to maximum voltage.

It is pretty clear that N-scale trains built for DC are generally intended to
operate at maximum voltages of 12 volts DC (in fact that’s the rating of Kato’s
power pack), although they may be safe to operate at higher voltages. I believe
that derives from the original multi-vendor de-facto standards for N-scale
trains, rather than from any NMRA standard. And since a DCC decoder can put
out up to nearly the track voltage to the motor, that’s clearly a good limit to
honor. Many DCC command stations and boosters have selectable output
voltages by scale, with “N-scale” meaning 12 volts (DCC). So, despite the fact
that there isn’t an NMRA standard (or any formal standard as far as I can tell)
that spells out per-scale voltage requirements, I clearly want a command
station and/or booster with a nominal track voltage of approximately 12 Volts
RMS (i.e., “12 Volts DCC”) for my N-scale trains.

Kato markets the Digitrax Zephyr (which puts out a 13.8 volt DCC RMS signal),
and they’ve told people that operating their car lighting on DCC without adding
the DCC controller is okay (“okay” doesn’t mean it won’t shorten the LED life
though). So a 14 Volt DCC RMS track voltage should be a safe maximum even
for Kato’s trains, and perhaps for other Japanese manufacturers (although I
have reason to suspect others are more sensitive). More might be safe, or
might not.

One caution: light rail models (i.e., “trolleys” or “trams”) from Japan are often
intended for use with lower voltages, because the models run slower than
normal trains. This means that even 12 volts is high for such a model (9 would
be more typical) and thus if these are converted to DCC, using a system with
more than 12 Volts is probably a bad idea.

The other question is minimum voltage. That’s harder, as there are no specs.
Various DCC systems I’ve seen are rated to work properly at the NMRA
minimum voltage of 7 volts DCC RMS, but not all, and that’s clearly lower than
you want to be. I’ve seen reports that Kato locomotives will work okay with just
10 volts, and that makes sense to me, since they’re intended for track with lots
of Unijoiners, which is going to experience loss, and Kato’s power pack puts out
12 volts maximum. I don’t know that that’s true of all N-scale trains I’d run, but
it seems reasonable. So that’s my target range: 10-14 volts DCC RMS at the rail,
with a desire to try to stick close to the center of that range at 12 Volts DCC
RMS to keep peak voltage as low as reasonably possible while still allowing for
dirty track and Unijoiners.

Current and Trains


If voltage controls the speed, it’s current that provides the power to maintain
that speed under load. The more work a motor is doing, the more current it will
draw. An individual N-scale train may use 0.5 - 1.0 Amps (500 - 1000 mA),
particularly if equipped with older bulb lighting, and one with a sound system
could use even more. However, a modern motor draws less than 100mA except
when stalled, and likely under 250mA at stall current (decoders need to be
sized based on stall current). In typical use, even a long passenger train with
LED lighting isn’t likely to draw more than 200mA under normal use, and it can
easily be half that.
The size of a power supply depends on the number of trains and their typical
power needs, plus a margin. You need to have at least an Amp between the
setting of the circuit breaker(s), which is the most your trains can draw, and the
rated limit of the command station. Thus a 3 Amp command station can
probably power ten typical trains ( (3,000 mA - 1,000 mA)/ 200 mA), and a five
Amp station 20 trains. This can vary a lot in practice however.

With circuit breakers used to divide the layout into electrically isolated
sections, each section will contain at most a few trains. In addition, Unitrack
(which I’m using) is rated for a maximum current of 3 Amps. So that’s a good
setting for the circuit-breaker trip point, meaning the zone protected by a
single circuit breaker shouldn’t contain more than 20 modern N-scale trains at
any time, and you probably want to ensure it’s always fewer to avoid any
spurious circuit-breaker trips.

But that doesn’t say how much current the command station (really the power
station contained in it, or any booster) should supply. One of the rules of
thumb is that for N-scale, 5 Amp supplies are a good maximum. But that’s
mainly to reduce the risk of damage in a short, and with circuit breakers that
isn’t really a requirement since they’ll provide the protection at a lower value,
regardless of what the command station can do. I chose to use a 5 Amp
command station, but I could probably have safely used a larger one.

Of course, in the worst case, the power that can be unleashed in a short is
limited by the size of the power station. More power, means more chance of
damage. That’s a good argument for using multiple smaller power systems
(e.g., several 3 Amp boosters instead of a couple of 5 Amp boosters or a 10
Amp command station). However that can cost more, and 3 Amp boosters
aren’t exactly common, so most people have settled on using 5 Amp systems.

Note that older trains, and larger-scale trains like HO, have larger requirements
than what I’ve described above, which is more specific to my N-scale modeling.

DCC Power Supply


The Digitrax command station I settled on using, the DCS 100, includes a built-
in DCC “power station” to provide up to 5 Amps of track power. With six tracks
(not counting the helix or storage tracks), and the likelihood of having at least
two trains on each of the commuter tracks (three if I want to get clever), it’s
possible that even a 5 Amp command station could be inadequate. However,
the more I look at it, the more it seems that a typical train is going to use less
than 200 mA (0.2 Amps), so one 5 Amp supply should cover my needs. But just
in case, even though I’m starting with just the command station, I’m planning
for subdividing things and adding a booster later if I want.

My command station, and any future booster stations (add-on power stations),
needs a 5 Amp 12 Volt DC power supply. Digitrax makes the PS2012 supply,
which can drive up to four such stations. A “scale” switch on it controls the
output voltage: set for N-scale, it outputs 13.8 volts DC (which is “close
enough” to 12 volts, per Digitrax’s manuals) at up to 20 Amps total. A special
cable, part YC52, splits one of the supply’s two outputs into two, with inline 5
Amp circuit breakers. Without these, some separate fusing would be required
to protect the command station input line. With a pair of these cables, and the
supply set for N-scale, I have four 5-Amp, 13.8 volt DC power supplies. I only
need two, so the other two will be used for DCC accessories.

But honestly, from what I know now this is seriously overkill. I could probably
have run the entire layout just fine using my old Zephyr command station. It’s
only likely limit was the “10 simultaneous trains” limit, and I could have
replaced it with the current Zephyr Xtra and added a small booster like the
Railstars RailBooster to address that if I’d wanted. It might be a bit more
expensive than what I did, but my current thinking is that more, smaller,
systems are the best approach for N-scale. For my “next” layout, whenever I
get to that, I’m strongly considering use of multiple 3 Amp boosters instead of
one big central 5 Amp supply.

DCC Basics: Wiring a Layout for DCC Power


Layout wiring is fairly well documented, and pretty simple when you come right
down to it. But I think it’s worth restating some of the basic concepts as part of
this section, as this is what I used as the basis of my own layout wiring
described in the Electrical Systems subsection of my Model Railroad section.
For a discussion of many of the issues in depth, see Allen Gartner’s site on
Wiring for DCC.

One word of warning: DCC uses low voltage, so it’s not typically subject to the
same regulations as household wiring. But it is high-current AC power, and in a
short circuit this will produce a lot of each (enough to melt rails or weld things
to them if the circuit breaker doesn’t work!). Working with DCC power systems,
particularly the larger ones with 5 Amp supplies, isn’t something to approach
carelessly, nor is it something younger children should do unsupervised (a
simple plug-and-play all-in-one DCC system isn’t really the same thing, as it
uses much lower maximum current).

Additionally, I am not an electrician or an electrical engineer. What I have


written here is what I believe, and what has worked for me. But make your own
choices and use at your own risk.

Two Essential Tools


There are many important or useful tools when building and wiring a model
railroad, and I’ll note a few below, but let me remind you of two I consider
essential to anyone building a DCC model railroad of any size or complexity.

A Good Multimeter - In general the digital ones are better, but an analog meter
can work. Buy a good one if you can; you’ll only end up replacing a cheap one
later. At a minimum for track wiring this needs to measure DC on a 0 - 20 volt
scale (having a larger range is better), and resistance on a 0 - 50 Ohm scale
(most meters will have a much wider set of resistance ranges). Other ranges
aren’t really useful for track wiring, but can be for other things. I have a meter
than can measure current in milliamps, and I use that for a lot of things.

A DCC Specialties RRampMeter - This measures both voltage in current in DCC


wiring, which a multimeter can’t do very well. You can certainly get by without
one of these. You can get by without your left hand too, but would you do so
voluntarily? If you want to know what’s really getting to any given spot on the
track, or the track bus, this is a very handy tool for understanding that. And it
will help a lot in tracking down power problems. The model that comes with an
enclosure and test leads (model II) is the one I prefer. The version with battery
backup (model III) can be useful if you also work on DC layouts, as the normal
kind won’t work if track voltage drops below 7 volts.

Electrical Supply
First off, you need electricity. You can just plug your DCC command station into
a wall outlet when in use. That’s all you need for a simple layout. But for
something larger you’re going to have a bunch of things to wire up. If you can,
connect these all to one wall outlet (unless you hit the limits of that outlet’s
circuit breaker) as this avoids any potential issues with ground loops. If you
can’t do that, at least make sure all the devices sharing a ground line (DCC
command stations, boosters and things like DCC circuit breakers) all connect to
a power strip, or strips, connected to one outlet. That’s not critical for things
without a grounded plug, but it’s still probably a good idea.
Second, if you don’t unplug things when not in use (and you may not want to,
as some devices, like wireless throttles, need continuous power to keep from
running batteries down) then split your devices into two groups: those that
have to stay on, and those you can turn off, and plug the latter into a power
strip with a switch, so you can turn off the whole layout. This avoids running up
your electrical bill (those wall-wart transformers use electricity even when the
devices connected to them are turned off, and the same can also be true of
individual devices with power cords). It may also help protect them against
power surges due to lightning, although as long as something’s plugged in,
even if it’s turned off, there is often a path for a nearby lightning strike to affect
equipment; power switches can’t cut the ground wire, and typically only cut
one of the two power wires.

Finally, buy a good surge protector and connect all the power strips to it (or, if
you want to spend more money, buy surge-protected power strips instead, but
get good ones with a high rating for the number of Joules absorbed and with all
three lines (hot, neutral and ground) protected. This way you’ll at least be
protected from some power problems. But if you live in an area subject to lots
of lightning, don’t count on the surge protector to save you; unplug the things
that cost a lot when not in use, and unplug everything if you can (a nearby
lightning strike can find its way through any conductor, so if some devices are
plugged in, it could get to others through the track).

I’m a particular fan of Tripp-Lite’s premium Isobar line of surge protectors. The
IBAR4 isn’t cheap at around US$50, but it handles surges of up to 3330 Joules in
its current version, and has a metal case to contain any flames from a really
serious surge that melts the protector circuitry, plus a heavy power cord that
will be safe up to the full 15 Amp rating. It also has a lighted switch, so you can
be sure if it’s on or off in dark under-the-layout installations, and mounting
holes on the back so you can attach it to the layout structure with a few screws.
I have a couple of these on my layout, but in a hard-to-photograph location.
There are other good brands out there, and what really matters is having a
good surge protector, not the specific kind.

My layout uses a larger Isobar for the computer and several “always on” things
(mainly the supply used by the throttles to keep from running their internal
batteries down), into which is also plugged a smaller Isobar with a switch,
positioned where I can easily reach it. A long power strip (a four-foot strip with
a dozen outlets) is connected to that, and all of the rest of my systems plug into
the long strip. Thus, when I throw the switch on the small Isobar, the whole
layout other than the computer and the keep-alive power for my throttles
shuts down.

Tripp-Lite Isobar IBAR4 surge protector


Image likely Copyright by Tripp-Lite, but it didn’t say.

Wire and Connectors


Always use stranded wire, it’s more flexible and easier to work with than solid
wire, and will last longer in places where it does have to flex. The only
exception might be in track feeders, where it can be easier to solder thin solid
wire to rail, but even there stranded probably wins. The size of the wire will
vary (see below). And since we’re handling low voltages, nearly any kind of
insulation will do (house wiring wire for AC power has very heavy and rigid
insulation to handle high voltage, and can be problematic to work with; it may
still be a good choice for long runs like track power bus wiring if you can get it
cheap).

As a general rule for DCC: don’t use wire smaller than 22 gauge unless you
know it will be carrying less than the full output of the power supply, and keep
in mind that in a short-circuit, like a tool dropped across the rails, any wire
without its own circuit breaker could be carrying the full load. If you have a
smaller DCC system rated for 3A (like a Zephyr), the magic number is 24 gauge.
In both cases, for runs of more than a few feet, using heavier wire is a good
idea.

Kinds of Wire
You’d think wire was wire, but it isn’t. I cover this in more detail in my Wire
section, but here’s a quick overview.

Wire sold for household wiring comes in solid and stranded forms, and this is
also true of some other kinds. Stranded wire is more flexible and will survive
more flexing without breaking than solid wire. It’s almost always preferable.

Household wiring also has thick insulation, for handling high-voltage power for
decades safely. That makes the wire harder to bend, and physically larger, than
some other kinds.

Finally, house wiring is often made from aluminum rather than copper, to save
money. Aluminum doesn’t conduct electricity as well, and you can get in big
trouble if you connect aluminum wire directly to brass or copper fittings. It can
be used, but it needs to be used with care (and how is a more in-depth topic
than I’ll cover; consult a home-improvement book that covers electrical wiring,
as that’s something they need to describe).

Wire designed for lower voltages comes in several forms, known as primary
wire, hookup wire and speaker wire (aka zip cord). Avoid using zip-cord: it’s
often cheaply made and hard to work with if you use things like crimp
connectors.

Hookup and primary wire both use thinner insulation than house wiring, but
still plenty for the voltages used in DCC. This makes it easier to work with and
easier to run in cramped locations under a model railroad. Most of this wire
will be copper, but some cheaper wire is aluminum. And some high-quality
hookup wire is pre-tinned, so it looks like aluminum but isn’t. Primary wire
tends to be available in the same large gauges as house wiring, making it a
good choice for a power bus or other wire carrying the full output of a
command station or booster any distance. You can get it from home supply and
marine supply stores. Hookup wire is smaller, and useful for track feeders. You
can get a limited selection of it in Radio Shack, although much more (and better
prices for bulk) will be had from online specialty dealers.

I use stranded copper primary wire for most of my track power bus now (some
parts were done with house wire), and good-quality copper hookup wire for
track feeders and wiring from my circuit breakers to the track feeders.

Wire Size, Safety and Voltage Loss


There are two reasons wire size matters. The first is safety: wire has a
maximum current it can carry before melting, which is based on its size and
composition. In general, wire of 22 ga or larger (smaller gauge numbers) is safe
for 5 amp currents between a booster and circuit-breaker, and wire of 24 ga or
larger is safe for 3 amp currents, the most you’d normally have in one circuit-
breaker section (it’s also the limit for Unitrack). A lot depends on what you
consider “normal” room temperature and how well (or how badly) wires can be
cooled by air circulation. For this reason, almost every table listing the relevant
numbers is different, because a different set of assumptions went into it. I’m
using a fairly conservative table (see below) as my source for the above, to
provide a safety margin.

The second issue is voltage loss, which is based on Ohm’s law Volts = Current x
Resistance. On a DC layout, current is limited to one (or perhaps two) motors,
and is well under an Amp. But with DCC, a dozen trains could be pulling power
over one pair of wires, and the curent limit of the command station (or
booster) is what matters. Here are some typical loss numbers for a typical 5
Amp command station:

12 ga: R = 1.932 Ω / 1000 ft, Loss @ 5 Amp = 0.0097 volts/ft.


14 ga: R = 3.072 Ω / 1000 ft, Loss @ 5 Amp = 0.0154 volts/ft, or 1.5 volts in
100ft
16 ga: R = 4.884 Ω / 1000 ft, Loss @ 5 Amp = 0.0244 volts/ft.
18 ga: R = 7.767 Ω / 1000 ft, Loss @ 5 Amp = 0.0388 volts/ft.
20 ga: R = 12.349 Ω / 1000 ft, Loss @ 5 Amp = 0.0617 volts/ft.
22 ga: R = 19.636 Ω / 1000 ft, Loss @ 5 Amp = 0.0982 volts/ft.
24 ga: R = 31.223 Ω / 1000 ft, Loss @ 5 Amp = 0.1561 volts/ft, or 1.5 volts every
10 feet.

If you only started with 12 volts, and you need 7 to run the train (and you’ll lose
some in the track), it doesn’t take many feet of thin wire to cause a problem.
This is why it’s a good idea to use wire of heavier gauge for the DCC power bus.

Resistance and other basic figures from a table derated for high-temperatures
(i.e., normal loss won’t be as bad, but may approach this due to wire heating
from extended use) from this page. Also, resistance is doubled to reflect the
“out and back” nature of the wiring, so a “foot” here is a foot of distance from
the source, not a foot of copper. I’ve used other ampacity tables at times (like
this one).

In general, ampacity tables give two sizes: the size allowed where the wire is in
open air (called “chassis” wiring in the linked table) and the size used where it’s
in a closed environment like a conduit (called “transmission” wiring in the
linked table). So, for open air wiring carrying 5 Amps, 22 gauge is the minimum.
Likewise 24 gauge can carry 3 Amps. Unless you bury all your wire inside the
layout material, you can use the open air number.

Online tables are really designed for high-voltage power wiring, and DCC is a
somewhat different environment. I have been working on my own ampacity
table, although at present it’s still based on other tables. Over time I expect to
refine it for conditions more specific to model railroading.

Crimp Lugs
Some people like to solder all connectors. That’s a good idea for things that are
hard to reach and won’t ever need to be changed, like feeder wires where they
connect to the track. I’m less convinced it’s a good idea elsewhere. Two useful
ways of connecting wire to other wire are terminal strips with spade lugs, and
insulation displacement “suitcase” connectors. You can get both terminal strips
and crimp-on lugs at Radio Shack or a home supply store. Use #6 lugs with
Radio Shack strips, and typically #8 lugs with the larger home-supply strips. You
need to get lugs sized for the size (gauge) of wire used as well. It seems that
these are color-coded, with blue being for 14-16 gauge wire and red being for
16-22 gauge, but that may be the particular suppliers I use (two of them have
the same convention though).

Spade lugs will work well with wire with a variety of different insulation
thicknesses, since they crimp onto the bare copper. Thus these can work with
typical house wiring type wire, with “primary wire” and with “hook-up wire”.
And I use them will all three kinds. The one thing they aren’t very good with is
solid wire; they’re much more reliable when used with stranded wire. When I
have to use solid wire, I generally just loop it around a screw on a terminal
strip, or solder it to something, and don’t use crimp-on lugs with it at all.

Crimp-on lugs work without soldering to the wire because the pressure of their
crimping creates an oxygen-free metal-to-metal bond that can’t corrode
(corrosion of the exposed wire can still happen, but it won’t work its way into
the bond unless you’re operating in exceptionally corrosion-prone
environments, like on a ship. That’s also why lugs on a properly screwed down
terminal strip work: a oxygen-free joint between metal created by pressure.

You can put two wires into one lug’s crimp connector if they aren’t the heaviest
gauge allowed, and this is handy when you want to connect a bunch of feeders
to one distribution wire (you can see a couple of those in the image below).
It’s a really good idea to use spade lugs and terminal strips that are a shiny
silver in color, rather than the golden-color of brass. This is because the shiny
ones are made with tin or some other material plated with tin, and won’t
corrode as easily or as seriously as brass will. In a damp basement, brass gets
covered with an insulating layer of corrosion in a couple of years, and that’s not
good.

BTW, if you are going to use lugs, you’ll use hundreds of them, so buy bulk
packs of 100 to get the lowest cost. Invest in a high-quality crimping tool (for
insulated and non-insulated wire) like this one. I have essentially that model
bought from a local home-supply store, and it was worth every penny. Your
hands will thank you.

Kato Track Feeders (top) wiring to a terminal strip with bus wire taps using
spade lugs.

Terminal Strips

Terminal strips and crimp lugs come in two sizes useful for the size of wire
typically used in a model railroad. The #8 connector is larger, and more suitable
to the heavy-gauge wire used in a track power bus. The #6 connector is smaller,
and preferable for the wire typically used in lighting or track feeders. Radio
Shack is a good source for the #6 size, while the #8 is typically found in home
supply stores or from specialty electronics suppliers.
Two sizes of 8-position terminal strip, #8 (top) and #6 (bottom)

Jumper Strips
One thing that’s really useful with the Radio Shack strips (I haven’t found a
good equivalent for the larger ones) are something they call Jumper Strips.
These are simple strips of metal that slip under the screw on one side, and are
connected to bridge several adjacent screws together. This is useful for splitting
one output into several. You need a good set of “diagonal cutting pliers” to
separate these (and safety glasses; the cut bits are heavy, sharp, and tend to go
flying) although flexing them with ordinary pliers may work eventually. You can
do the same with loops of wire (with or without spade lugs) or one wire that
has several spade lugs on it (actually several short wires crimped into the lugs
to act as one longer one). In the diagram further down the page, the
“distribution wiring” terminal strip next to the circuit breaker assumes this kind
of interconnection.
Radio Shack jumper strip and #6 terminal strip

Suitcase Connectors
Suitcase connectors are designed to tap into a wire. They have one slot that
slips over the wire, and a second slot with a cap on one end where you feed in
a second wire, then you crimp a steel pin down (using a pair of pliers or similar)
and snap the connector closed. The 3M company made the originals of these
under the brand Scotchlok (although there are now a number of different types
of connectors under that brand) and you can find copies by others now.
Typically these are color-coded based on the wire gauge, with yellow used for
10 or 12 gauge, brown used for a 18-14 gauge tap off a 12 gauge through wire,
blue for a 16-18 gauge tap off a 14 gauge through wire, and red for 16-22
gauge wire (but individual manufacturers or models may vary, be sure before
you buy). There are specialty tools for crimping these, but a good pair of pliers
will do the job if used with care (I still destroy the occasional connector).
Sometimes I regret not buying a better tool, but I use a lot fewer suitcase
connectors than lugs, and the tool was expensive.

One important note: suitcase connectors assume the wire is a certain size, and
almost all of these are sized for wire with the heavy insulation typical of house
wiring or “primary wire”. If you use low-voltage “hook-up wire” this is often
much smaller, because which the copper is the same thickness, the insulation is
much thinner. This may not work as well (or at all) with suitcase connectors. I
only use high-voltage house wire and primary wire with suitcase connectors,
and I use terminal strips and spade lugs for all my hook-up wire.

Suitcase connectors tapping the track bus (14 ga wire)

Electronics
In DCC, there are several kinds of electronics. The most important one is the
Command Station, also sometimes called the DCC supply. This is the box that
either incorporates a throttle or to which throttles are connected (or both).
Additionally it usually incorporates a DCC Booster (aka Power Station) to
amplify the DCC signal from the minimum 1 Volt (used to communicate with
other boosters) to the 7 - 23 Volt signal required on the rails (typically around
12-18V). And it will always incorporate one circuit breaker, to protect trains on
the track from a short-circuit.

But in addition to the command station, there can be one or more additional
boosters (to provide power for more trains without using very high amperage
out of one power supply). Boosters will normally incorporate a circuit breaker
as well. Each booster needs to be connected to the command station to receive
the DCC signal and to a ground line shared with the command station and any
other boosters. Some other devices may connect to this ground as well, as
noted below.

Finally, there are related devices that have a role in getting power to the track.
These include Circuit Breakers, Automatic Reversers (related to the circuit
breaker and sometimes the same device can act as either) and Occupancy
Detectors. There are many other DCC devices (e.g. stationary controllers for
turnouts) that aren’t part of the power system, but which may connect to it
either directly or via the track. I won’t discuss those non-power devices here.

Wiring
Wiring between the Command Station and the track can be as simple as a
single pair of wires connected directly to the track, appropriate for a simple
layout. In a more complex layout, more complex wiring is often needed or
provides an advantage even if not strictly needed.

The diagram above shows a command station and booster used to power four
sections of track. A section can be any length, although 6’ (2m) is a reasonable
upper limit if you divide a layout up like this. That doesn’t mean that you need
to do this the minute you have six feet of track. But you’ll see a clear benefit if
you have even twenty feet of track or if you want to run multiple trains with
shorter amounts of track.

Preferably the command station and any boosters will connect to their own
“track bus”: a pair of heavy-gauge wires that follow the tracks, and track
feeders will either connect directly to them (via suitcase connectors, soldered
joints, or terminal strips) or connect to intermediate devices that connect to
the track bus. Note in particular that the bus for each power supply is separate,
but that the ground line is continuous, but only needed normally by the Circuit
Breaker and Command Station & Booster, although some Occupancy Detectors
also need a ground connection. Also, as things like Occupancy Detectors
normally only sense one wire, the rail with the other wire doesn’t always
require a gap (more on this below). The rail connected to the red wire in this
example needs a gap between all four track sections.

Note: the words “section”, “block” and similar may have specific meaning to an
individual DCC systems manufacturer (and vary between them), and often have
other meanings in model railroading or real railroading (e.g., a track detection
block or a signaling block). I’m not going to go into all those here, but be aware
of whose document you are reading and what they mean by the term, and
don’t confuse it with what someone else may mean. Here I’m going to use
“track section” to mean a length of rail with a gap at each end in at least one
rail, and “electrical section” to mean a set of devices and associated rails. In the
diagram above, B and C form one electrical section because they share a circuit
breaker and distribution wiring.

In some cases one section of track may benefit from having more than one
feeder to a rail. This can be necessary with switches, for example, where a rail
may be isolated by the frog of the switch. In some cases the switch will bridge
the gap internally. But in others the rail will need to be fed power separately on
both sides. Both feeders could wire together to the bus as shown above for
“D”, but they could also both wire to one occupancy detector, if you wanted to
treat both sides of the switch as one “occupancy block” for some reason. Or
you could wire them to two separate detectors, as shown for A and B
(assuming that the gap between them is at the switch).

Track Power Bus


There will be one or more DCC power supplies, usually a command station with
an integrated booster, and optionally separate boosters. Each supply will
connect to a separate set of track sections. As mentioned previously, a simple
approach is fine for smaller layouts, but as things get bigger, a power bus (also
called a track bus or track power bus) will make things easier to wire up and to
fix. Note that if you have more than one supply, by definition you have more
than one power bus and in general it is a good idea to keep them totally
separate. The two supplies should be connected via a ground wire as large as
the bus wire (that’s called “booster common” wiring, Digitrax uses the name
“home ground” to mean the same thing; the alternative is “common rail”
wiring, used on some DC layouts, but not recommended between boosters for
DCC).

Note that you can use “common rail” wiring between one command station
and the feeders, the recommendation above just applies to multiple power
supplies. Since you still need the heavy-gauge track bus wire for each rail, and
you’ll typically have just the pair of them, unlike a DC layout where each
electrical block had a separate wire back to a control panel, there’s less
advantage to common-rail wiring for DCC. There may be other reasons to avoid
common-rail wiring; see the feeder discussion below for more on this. The
main reason to use common rail wiring is when converting a pre-DCC layout,
most of which used common-rail wiring, to DCC. Using common-rail wiring for
DCC avoids having to add gaps in the common rail and extra wires.

If you have a power bus, the thickness of the wire (wire gauge) depends on
several factors. Thicker wires (smaller gauge numbers) are better, up to a point.
But you need to take into account how you wire to them. For example, things
like “suitcase connectors” can dictate wire gauge: I use a 14-gauge bus tapped
with blue suitcase connectors and 16-gauge distribution wiring, in part because
that made it easy to find the connectors. The other factor that controls gauge is
power loss (and for really small wires, maximum current).

In a power bus, distances are long, so the most important factor is power loss.
At the 5 Amp maximum typical of most indoor DCC layouts, 14 gauge is fine,
and 16 gauge will work for smaller layouts. If you’re doing very long runs, or
using higher-amperage supplies, heavier wiring (like 12 gauge) may be a good
idea. The Wiring for DCC site has a discussion of this, as well as more info about
power (voltage) loss in wire. I now have some further discussion on this on my
Ampacity page.

While two independent wires are easiest to work with, over a long distance
they can help distort a DCC signal, due to inductance created by the wire. Some
sites recommend twisting the wires together (or using pre-twisted wire,
although that’s harder to tap for feeders). The standard doesn’t require this,
and rules-of-thumb seem to vary. I’ve seen numbers ranging from two to four
twists per foot (meaning six to twelve per meter). When run separately,
keeping them well apart (more than 4” or 10cm) can help avoid distortion to
some extent. Twisting also helps make the wires less subject to acting as an
antenna to pick up other noise. Note that untwisted zip cord (speaker wire) is
probably the worst of both worlds; the wires aren’t quite together, but they’re
very close, and the wire isn’t twisted.

Ground Wire
There are two kinds of ground wires, a “safety ground” is the kind found in
typical home wiring, where it is designed to provide electricity a safe path to
earth ground in the event of a short circuit, to prevent it from trying to get to
ground through you. Electrical systems can also have a “floating ground” that’s
really just a way for all components to share the same idea of what “0 volts”
means. Depending on the system, it may or may not be a good idea to connect
a floating ground to a safety ground.

In DCC systems, a floating ground is used to connect DCC circuit breakers to


each other and to the power supply, and to link multiple power supplies. This
ground should use wire as heavy as the current-carrying wire (e.g. if wire to a
circuit breaker is 16 gauge, use a 16 gauge ground wire there, if wire from a
power supply is 14 gauge, use 14 gauge ground wire there). Digitrax says that
their ground wire can be connected to your building’s safety ground (and this
will actually have some benefit, by allowing static electricity to drain from the
system). Other manufacturers are likely similar, but you should consult their
manual and reference pages to be sure. If you are connecting a device with an
AC input to a safety ground, the wire used should be large enough for the
maximum possible current permitted by the wall outlet (typically 15-20 Amps).
That means 16 gauge or larger. I used 14 gauge wire for all of my ground
wiring, except for short bits of 18-20 gauge used for the inputs to DCC circuit
breakers that needed smaller wires.

It’s a common convention to use green insulation (or green with yellow stripes)
for ground wires, to make them obvious, and I did this when wiring my layout.
But it’s not required by law for layout wiring the way it is for high-power house
wiring.

If you do want to connect to the building ground, you need to decide how to do
that. Some electronics may have a grounded chassis (e.g., the Digitrax PS2012
does, and provides a screw location you can use to ground the command
station; you do need to exercise some caution doing that). Alternatively, if you
have copper water pipes, the cold water pipe is usually connected to ground
and you can find straps for connecting wire to those in an electrical supply
store. On a grounded outlet, the screw holding the faceplate on is typically
grounded, so a wire with a lug on the end can be used there.
Note: wiring components to a safety ground isn’t something to take lightly, as
you could end up using that path for significant current in the event of a short
circuit in the AC power supply. It’s a good idea to use heavy (e.g., 14 ga or
similar) wire. Also, there are potential safety issues, so if you aren’t familiar
with house wiring, it’s a good idea to have an electrician do the work (if you can
find one who will). In any case, that’s something to do at your own risk.

Other Distribution Wiring


If you have devices (like occupancy detectors) between the power supply and
the track, you’ll need some wire between them and the power bus, and
possibly between them and the feeders. Although you may be able to wire the
feeders directly to them, I find it easier to wire the feeders to terminal strips
and run distribution wiring. This wire, which I’ll call distribution wiring, should
be kept as short as possible. What I do is tap the 14ga feeder (with a suitcase
connector) and wire that to a terminal strip near the electronics, then I run
lighter wire (typically 16 gauge) from the strip to the electronics and from the
electronics to the terminal strips with the track feeders.

The 16ga wire from the suitcase-connector tap typically ends on a spade lug on
a #8 terminal strip. The photo below shows my set of bus wires (I have more
than one pair) tapped and connected to one terminal strip (mostly hidden
under the wire), and short jumpers from this to a second strip at bottom right,
to which the track feeders connect. This is an older photo, and the short
distribution wires have been replaced by my circuit breakers and DCC
occupancy detector systems on the current layout, which is why I kept these
two terminal strips separate.

Note: the reason I have more than one pair is basically due to a
misunderstanding as to how much power my trains would use when I designed
the layout, coupled with extra pairs used for things like accessory power and
my DC test track. You really only need one DCC power bus in any given section
of the layout, and I’d do things differently if I were rewiring the layout today.
Typical bus taps (colored wires) and on-table distribution (blue/gray wires) to
track feeders (bottom right)

Distribution wiring may still need to carry the full 5-Amp supply. This means it
needs to be 22 gauge or larger, and I typically use 16 gauge as it minimizes
power loss while still being easy to work with. I’ve used 18, 20 or even 22 gauge
in some places due to limitations on device connectors. As long as the wire is
short, there is only a small amount of extra loss when using the smaller sizes.
Just don’t use wires smaller than 22 gauge (24 gauge for smaller 3 Amp DCC
systems) unless you’ve got a circuit breaker set to limit current.

Feeders and Rail Gaps


A track feeder is a wire connected directly to the rail, and commonly a pair of
these connected to the two rails will be placed together. This needs to be done
fairly often, as rail is actually a pretty poor conductor, and long lengths of it will
lose a lot of power. Sectional track also loses power at each rail joiner. You’ll
see a notable loss of train speed in even 20’ of track without additional feeders.
Purists will say that a permanent layout with sectional track needs a feeder on
each section, and to an extent that’s good advice, as the connection at each
joiner will get worse over time as dirt works its way into any gaps. You could
also bridge those points with a short bit of wire soldered to the rail (which still
allows the tracks to expand and contract due to temperature changes, unlike
soldering the rail joiner itself). In any case, you probably need a new feeder
every 3 - 6 feet to minimize voltage loss due to the rail itself.

Note: prototype rail often has wires connecting one length of rail to the next,
as electrical continuity is important for signaling (and in electrical railroads for
power grounding), so soldering a short length between rails and painting it the
same rust color can be thought of as a modeling detail, as well as part of the
electrical system.

You can add feeders without adding insulated rail gaps. For example if you
want to provide power to multiple lengths of sectional track. You will need to
add insulated gaps if you need to keep the two feeders separate. For example,
if they have individual occupancy detectors or circuit breakers. You’ll also need
to have insulated gaps for things like reverse loops.

Feeders carry less current than most other wiring since they are located fairly
often, meaning typically one train can be drawing power through them. They
can potentially carry up to whatever your DCC circuit breaker is rated for during
a short (the one on the command station could be rated up to 5 Amps or more,
but a more likely size is around 2-3 Amps). Kato’s feeders, like their Unitrack
itself, are designed for a 3 Amp maximum current, and that’s a reasonable size.
If you’re using one big 5 Amp command station, having DCC circuit breakers
between it and the feeders set to trip at 3 Amps or less is a good idea. A feeder
wire should be as short as possible, to minimize loss, and as small as possible,
to make it easier to attach to the track and less obvious. As noted above, for 3
Amps the minimum size is 24 gauge, and that’s usually a good choice.

When it comes to designing feeders, you don’t even need to have insulated
gaps in both rails most places you have gaps in one, although it is
recommended. You can gap only one rail and have the other continuous (called
“common rail” wiring), but this can be problematic for DCC and is mainly a
technique for DC wiring (or converting a DC layout to DCC without lots of extra
work), to reduce the amount of wire. Even with common rail, some things like
reversing sections and separate DCC booster sections need both rails gapped.

When gapping a rail, be sure to plug the gap, otherwise rail may expand in
warmer weather until the two bits touch. When I wired up flex track on my old
HO layout, I’d superglue a bit of 0.010” strip plastic into a gap (using thick “gap
filling” glue), and then cut away excess after the glue fully set using a pair of
modeler’s flush-cutting pliers (sprue cutters). I did this before painting the
track, so the insulator would be indistinguishable from the rail after painting.
You can also use insulating rail joiners between sections of track. With
Unitrack, I just use the insulating Unijoiners.

Common Rail
In DC, Common Rail Wiring was a useful technique for blocks. Every power
supply had one side connected to the “common” line and one rail was
connected to this (and not gapped). The second rail was connected to
individual wires back to a control panel, and gapped between feeders. This
allowed for independent control of each electrical block, while minimizing
wiring. With DCC you don’t need that wire back to a control panel, which
eliminates much of the benefit of common rail wiring. You can still do it, and
it’s handy when converting a DC layout to DCC not to have to re-do all the track
feeders. But it can cause problems with more complex DCC layouts, so it’s
something to avoid if you can.

The main issue with common rail wiring to be aware of is that with multiple
power supplies (boosters) you need to separate the “common” wiring for the
tracks connected to supply #1 from the common wiring for the tracks
connected to supply #2, and gap the common rail between rails fed from
supply #1 and rails fed from supply #2. That’s a big difference from how
supplies shared the common line in DC environments. Trains will still
momentarily bridge that gap, but that’s handled by a heavy ground wire
between the supplies as described earlier.

A second issue exists if you use circuit breakers. Unless both rails are gapped
between a section of rail protected by a circuit breaker and other rail, a short
may find a path that doesn’t trip the breaker. In the diagram at the top of the
page I showed the gap between track sections A and B as “optional”, and that’s
really not true if you have a circuit breaker protecting sections B & C as shown
there.

With common rail wiring, you only need to gap one rail (let’s call it the “red”
rail) and leave the other continuous (except where you have phase reversals,
see below). Occupancy detectors will connect only to the gapped rail. But you
still need periodic feeders to the ungapped rail from the black track bus wire
due to power loss issues, so all this is really saving you is the effort of making
insulated gaps. I just gap both rails everywhere; it’s simpler.

Polarity and Phase


In DC wiring, you have “polarity”, one wire is “+” and one is “-“, and in a model
railroad you switch them to control direction, but at any given time, one rail
and the wire feeding it will be “+” and one will be “-“. In DCC, the polarity is
changing thousands of times a second, but at any instant one will still be “+”
and the other “-“, it just happens too quickly to measure with a typical
multimeter. Just like in DC, where rails that touch (or that can be momentarily
bridged across an insulating gap by the wheel on a train) always need to be the
same polarity to avoid a short-circuit, in DCC rails that touch or can be bridged
need to both be “+” at the same time. This is called being “in phase”.

If you look at the output of a DCC command station or booster, the two
outputs will be labeled “RAIL A” and “RAIL B” or similar. Think of these as the
“A” phase and the “B” phase. It’s a good idea to have some conventions for
these, like “the Red bus wire always connects to the ‘A’ phase and the Black to
the ‘B’ phase” so you can keep other wiring consistent. Also, except where you
have to deal with track that forms a loop or curves back on itself, a convention
like “the rail to the front of the layout connects to the ‘A’ phase” can be very
useful. With a loop, you can do the same thing with “the rail to the outside of
the loop connects to the ‘A’ phase”. It doesn’t matter which phases you pick,
just pick one and be consistent. With Kato track feeders that have a blue and
white wire, I use “Front rail to the Blue feeder wire to the Black bus wire to
RAIL B” as my convention (my “three B’s”; I probably should have used “back
rail” and had “four B’s”, but I didn’t think of it at the time) . Sometimes this
means I need to rearrange my Kato feeder track sections to keep blue to the
front.

Reversing and Phase Changes


In DCC, you have what’s called a “Reversing Section” when one length of rail
has to meet rails at its two ends that can’t be in the same phase. This means
that this bit of rail in the middle needs to have its phase match one end at one
time, and the other end at other times. This can happen where track loops back
on itself, or where two tracks meet a third in a “wye”, or with turntables, or
with some more complex track arrangements. Follow your rails around your
track plan, keeping track of “phase”, and if one rail suddenly goes from phase
“A” to phase “B” or vice versa, you need a reversing section.

A reversing section needs to be as long as the longest train that can cross it.
This is because it’s going to need to swap phases any time a wheel bridges a
gap at either end, and if wheels at both ends are crossing the gaps at the same
time, problems can result. You don’t need lighted cars or wheels with resistors
to cause a problem, all you need are metal wheels. And most newer model
trains use metal wheels, at least the good ones.

The device that does this phase swap is called an Automatic Reverser (or Auto
Reverse Circuit, or Reverser, or Reversing Circuit Breaker). What happens is
that the Reverser is connected in the middle of the feeder, meaning that one
side connects to the track power bus (or something connected to that, like an
occupancy detector) and the other connects to the two rails of the reversing
section of track. The reversing section has to have both rails gapped at both
ends no matter how you do other wiring. And you can’t have two reversing
sections adjacent to each other (otherwise both reversers will try to reverse
their section when a train crosses, which isn’t going to turn out well).

Many diagrams for Reversers show them connected to rails outside the
reversing section instead of to the track bus. This works, because those rails are
connected to the track bus. However it can cause problems if the rails
somehow get reversed or de-powered (due to a turnout switch or other
causes) or if you want to use occupancy detectors (a train in the reversing
section will be drawing power from the adjacent track, and appear to be in that
section). It’s best just to wire them to the track bus (or a device connected
directly to it).

Reversers work by detecting short circuits, the same way a DCC circuit breaker
does (and some perform both functions). If a Reverser is connected
downstream from a circuit breaker (meaning, if there is a DCC circuit breaker
between the reverser and the command station) then the reverser needs to be
set to detect the short at a lower current than the circuit breaker is set to trip
at, otherwise the circuit breaker will just shut off all the track power to the
reversing section.
Here is a somewhat complicated reversing section. On the top right, the main
track is fed from the track bus. The bus uses Red and Black wires, and at a
simple feeder (A) these connect directly to the blue and gray (I’m using gray
here, because white doesn’t show up against a white background) feeder
wires.

But if you follow the outer rail around it will eventually need to switch from
gray to blue, which makes this loop a reversing section (even without the siding
in the middle of it). To make this a functional reversing section, a reverser
needs to connect to the rails within the loop (at either B or C). If the siding
didn’t exist, just one connection (at either B or C or anywhere else) would be
needed. With the siding, and assuming power-routing turnouts are used (such
as Kato’s #6) and that you want it to work even if only one turnout is switched,
both turnouts need a feeder on the point side, and since there are rail gaps at B
& C, the mainline feeder isn’t reaching them so this is where the reverser’s
output will connect.
There are usually multiple ways to achieve the same goal. In this case, you
could gap the two tracks on the left (outer loop and inner loop) where they
meet the frog side of the switches, feed both loop tracks from the output of
the reverser, and count on the mainline feed to get power all the way to and
through the two turnouts. That will work fine if your longest train will always fit
in the siding of the loop, but if you want a longer train to pass one in the siding,
then the diagram as shown provides a longer reversing section for longer
trains. In fact, the B & C rail gaps can be located immediately to the left of the
switch at A, which will provide the longest reversing section possible.

The way this works is that when a train crosses a gap between the inside of the
loop and the outside (going in either direction), it briefly shorts the track inside
the loop to the track outside the loop. If the two are in phase (as shown at B
above) then nothing happens and the train moves on. But if the are not in
phase (as shown at C), then a short circuit through the train is created. The
Reverser detects this, and reacts before enough current can flow to do
damage, by switching its output phase. Thus, in the example above while the
blue wires at B & C started out connected to the black bus wire, just like the
blue wire at A, when a train crosses C the blue wire is switched to connect to
the red wire inside the reverser. With the wire switched, the rails on both side
of the gap are now in phase, and the train moves on. This all happens so quickly
that the train doesn’t slow down.

There are many ways to hook up a reverser, and many instructions will show
them connecting the track outside the loop to the track inside the loop. That’s
a perfectly fine design in a small layout, but if you have a power bus, they really
ought to connect to it.

DCC Basics: Control Systems


In a DCC layout, something has to send commands to the decoders mounted in
the locomotives, and that or some other system optionally also has to manage
stationary decoders (such as those controlling turnout switches) and receive
information back from trains or other devices. In many layouts, these functions
are separated with more advanced features being performed on a computer.
That same system can do other things as well.

Command Station
In DCC, the command station is the functional element that converts
information about what the train is to do into DCC data that can be sent over
the rails to the decoder. The command station function is usually integrated
with a Power Station in a single box. A Power Station mixes the DCC data
control signal with power to actually run the trains. Separate Power Stations
(called Boosters) are also sold. And there are some solutions which separate
the command and power functions. A command station must include either a
throttle or a way to connect one or more throttle to it. Many use a Control Bus
to connect multiple throttles.

Example 1: a simple DCC command station, Digitrax’s Zephyr, integrates a


throttle, command station and 3 Amp power station in one case, while
including a “power station interface” and control bus via a pair of loconet
connections. On it’s own, it’s a complete solution. If more power is needed,
additional power stations can be added (and those don’t even need to come
from Digitrax since part of the NMRA standard allows for interoperability,
although a minor amount of wiring skill is needed.

Example 2: a computer equipped with the USB “Sprog II” and appropriate
software, such as JMRI, allows the computer, and some smartphones, to act as
the throttle and the computer/Sprog combination as both command and a
small 1 Amp power station. Although intended for benchtop programming of
DCC decoders, this will work as a simple system for one train (possibly a couple
in N-scale). If more power is needed later external power stations can be
connected to the Sprog (documentation is thin on this topic, but it’s very likely
they’re using the same standard approach as both Digitrax and Lenz do, and
any booster could be connected).

A command station doesn’t just run trains. Most also support throttles that
have some degree of control for stationary decoders, typically designed to
allow someone running a train to throw a turnout switch from their throttle by
entering its number and pushing a button. Command stations may also
incorporate more or less sophisticated decoder programming capabilities or
other features.

Monitoring
Sending commands isn’t the only control activity. With stationary decoders,
keeping track of their state may be desirable: for example, to create a
dispatcher’s panel showing which turnouts are thrown. There are also more
complex feedback systems, such as block occupancy detectors and decoder
status reporting systems.
For most of these things, a simple command station is of limited utility
(although some European systems like the ESU ECoS pack a lot of functionality
into the command station). What is really needed is a computer and a way to
connect the computer to the control bus being used to interface to the devices.
For most modern computers a USB interface is used, although some older ones
used serial ports.

The control bus depends on the equipment used, and doesn’t have to be the
same as the bus used with the command station for hand-held throttles. For
example, Digitrax’s Loconet can be used with their occupancy detectors and
other systems even if the command station doesn’t support LocoNet. Similarly,
Lenz’s XpressNet can be used to communicate with RailComm detectors even if
the command station does not support XpressNet (there’s a small “gotcha”
with RailComm, noted below).

I’ll cover both Control Bus options and Detection systems in more detail, but
the following provides a brief overview of their capabilities.

Cab, Feedback and Control Busses


A system used to tied multiple devices together with one set of wires is called a
bus. Originally these were used simply to connect hand-held throttles to DC
power packs, and were called Cab Bus systems. These worked in one direction
(from throttle to power pack). These were eventually elaborated to allow
control of other devices, like turnouts. Then similar systems were developed
that could be used to report back things like the occupancy of a section of
track. These were called Feedback Bus systems. Finally, as electronics became
cheaper, more complex systems were developed that did both, known as
Control Bus systems.

Which of these you use most often depends on the DCC command station (or
other train-running system) you chose. But often you can mix multiple systems,
particularly if you have a computer. Of course, having multiple of them defeats
the purpose of simplifying everything to one set of wires. Ideally there’s be just
one, and that’s the future promise of what the NMRA is doing with NMRAnet
(recently renamed Layout Command Control, or LCC), but it’s not quite there
yet.

Occupancy Detection
The simplest form of feedback is occupancy detection. You connect the
detector between one of the DCC bus wires and the rail it would normally
connect to (meaning it’s in the middle of the feeder) and isolate that rail from
adjacent ones. When a train is on the connected section of track, the power it
uses flows through the detector, which reports “I’m occupied”. If there’s no
train, there’s no power use, and the detector reports “I’m not occupied”.
Occupancy detectors can be quite simple, although unless all you want is a red
light on a physical panel some more complex system to report their status back
to the computer or command station is required (i.e., either a feedback bus or
a control bus).

Decoder Transmission
A more sophisticated approach to detecting trains is called Decoder
Transmission, and it allows the decoder to send information back over the rails,
either to the command station or to a detector through which is routed power
for a section of the layout (so you can know where the decoder is, as well as
what it’s doing). Decoder transmission can be used by decoders that provide
tracking of fuel or water levels (some decoders will stop the train if a
fuel/water level is set and goes to zero). Or it can be used in conjunction with
occupancy detection to say “I am train 2137” to the detector, which can then
report “I’m occupied by train 2137”.

Train Detection
Detecting the presence or absence of a train, or its identity, is an important
capability. It can be used to trigger crossing gates, to manage lineside signals,
to create a dispatchers panel showing where trains are, as part of an
automation system, or for all of these purposes.

Train detection is also intimately connected to the concept of a layout Control


Bus, as detecting something isn’t much use if you don’t tell anyone. Actually,
that’s not quite true, as a detector could simply be wired to a crossing gate to
turn it on (dropping the gates) while a train was nearby, or to a signal, to make
it red when a train was on the facing track. But that’s a bit simplistic, so in most
cases, if you’re going to bother with detection, you probably want something a
bit more sophisticated in terms of communications.

There are a number of methods for detecting trains (for a more detailed
overview of the types, see this page). The most sophisticated is to have the
train announce its presence. DCC decoders that support RailComm can do this,
but it requires devices along the line that receive and recognize this
information. A more basic approach is simply to detect the fact that the train
makes an electrical connection between the rails, allowing a current to flow.
To do this, the track must be divided into electrical blocks, and a sensor
attached to each block. This sensor will then report the presence (and if
RailComm is in use the identity) of the train in its block. A simpler method is to
place a detector beside the track that will report when a train passes. These
can be simple photocells, or tiny switches touched by the wheels of a passing
train. But one problem is that these can only detect a moving train at one
point, whereas a current-based detector will detect even a parked train (on
DCC layouts) anywhere in the block.

This page will focus on block-based electrical detection of trains. You can also
detect trains with other methods, like photocells or IR photodiodes. I’ve done
the latter using an Arduino for one of my layouts, and it’s written up on my
Arduino IR Sensors page. But while that method works, it’s not going to be as
good as current detection at detecting a parked train. For things like hidden
storage tracks, I’d want current detection.

Electrical Block Detection


In a model railroad that uses the track to deliver power to the trains the rails
will have a voltage difference, and when something that conducts electricity is
placed across them, a current will flow. That something may be a motor pulling
hundreds of milliamperes (mA), or a resistor drawing less than 10 mA, many
detectors work for currents as low as 1 mA.

Current in a conductor (wire) can be detected by measuring the voltage drop it


creates across a resistance, or by measuring it indirectly by the current it
induces in another wire. The latter is usually more expensive, but somewhat
safer (since the measuring wire isn’t connected to the track, there’s no way
track power can get into the sensitive electronics). Systems that use voltage
drops are often described as “diode-based” since they use diodes to divert a
portion of the current (and going through the diode to get to the track causes
the drop in track voltage). There are two common methods of indirect
measurement: the simple induction coil (also called a Current Transformer) and
the more sensitive Hall Effect sensor.

Most inexpensive detectors are of the voltage-drop form, often but not always
using an optoisolator to separate the track wiring from the rest of the detector,
for a degree of protection. The big problem with voltage-drop systems is that
they have to discard a significant amount of the track power in a resistor to
make a measurement. Some can consume as much power as a small N-Scale
locomotive. Typically they’ll also typically reduce track voltage by 0.7 volts.
Current-sense transformers are more efficient, as the amount of power lost in
an active detector is much lower, and there’s no voltage drop.

Block Occupancy Detection and Reporting


To use a current-based detector, the track feeder for one rail (not both) in a
block of track that’s insulated at both ends is fed through the hole in the
decoder. If the block is fed at multiple locations, the sensor should be applied
to the feeder before it splits, so that power drawn anywhere in the block will
go through the detector, otherwise operation may be erratic.

Note: the diagram below shows both rails insulated, but this will work with
common-rail DCC systems also. Only the red rail needs to be cut and insulated
for the detectors to work.

The track feeder may have to be taken to the detector, or the detector may use
a coil that can be located on the feeder a moderate distance from the detector.
The detector itself just provides a simple yes/no output, which could be used to
directly control something like a crossing gate. A typical single detector costs
around US$10 - US$20, but they’re often sold as boards containing several
detectors. These do not include the circuitry needed to interface directly with a
computer.

While standalone detectors can be useful, a more preferable method today is


to pass this information to a computer, which can display the location of trains
on a track diagram, and control things based on which detectors are in use. To
do this, the detector will need to connect to something that can report the
status back to the computer over some kind of control bus (often just a serial
link). Examples of such a devices are: motherboards for C/MRI, Digitrax DS64
accessory decoders for Loconet, the Railstars Io for NMRAnet, the Train Brain
for CTI systems and the Lenz LR-101 for XpressNet.

Often the detector and reporting device are on the same circuit board, but not
always. And while there might be one detector with one reporting device, it’s
more efficient (and quite common) to have a single reporting device report the
status of several detectors (on the same circuit board, or on separate boards
wired to the reporting device.

Using Detectors
To use a current-sensing detector, there must be current. A locomotive motor
is going to draw at least 30 mA even with a very efficient modern N-scale loco
running “light” (pulling no cars) on level track. That’s quite a lot and easy to
detect. Car lighting can also be detected, although as tiny surface-mount LEDs
have come into use, current for these may be 7 - 10 mA, and much harder to
detect, but still reasonable.

To sense single cars that aren’t lighted (e.g., freight cars in hidden storage), you
would need to put tiny surface-mount resistors on wheelsets. There are a
number of ways to do this, but the simplest is probably to use conductive
epoxy (as described here and on Wiring for DCC). A 10KOhm surface-mount
resistor will create a current as low as 1 mA depending on track voltage, so
either you need more than one in a block, or a very sensitive detector. You
could use smaller resistors, but then you’ll lose more power in every axle,
which will add up quickly (a 1 KOhm resistor will use 10 - 15 mA of current, so
ten cars would use as much power as the small loco pulling them, and they’d
use it even if you parked them on a siding). Most people seem to use 10KOhm
resistors, with some using 15K or even 22K and counting on multiple cars to be
in a block for detection, but other use resistors as small as 4.7K.

Note: on a 15V DCC system, 10KOhms produces 1.5mA. Most layouts have
track voltages a couple of volts lower than the supply, and N-scale supplies may
be 12V DCC. I’m assuming 10V DCC track current as the lower limit (officially
DCC works down to 7 V DCC), which produces 1 mA of current through a
10KOhm resistor.

Another problem is that a simple detector may only work on current flowing in
one direction. That’s no problem for a locomotive or resistor, as they draw
power from the DCC source in both directions. A simple LED circuit, however,
could draw power from only one direction, and if it’s the opposite to that used
in the detector, the LED circuit can’t be detected. LED lighting with a “full wave
rectifier” will draw power from both directions, but this is an area where some
lighting circuits economize.

Very sensitive detectors used with DCC can have a problem with falsely
detecting empty tracks as occupied. This is caused by capacitance between the
rails drawing a very small amount of current on each DCC cycle (two
conductors, the rails, separated by an insulator, the air, make a capacitor and
can store charge, although only a tiny amount). The normal solution is to
desentitize the detector (not all allow for this), which does mean that it can’t
detect very small currents, like a single resistor-equipped wheelset. Another
approach is to keep the length of track blocks used as detection sections fairly
short, since that reduces the amount of capacitance, and hence the current on
empty rails.

Another potential problem lies in accessory decoders that draw power from
the track, like turnout controllers. These draw power continuously, so any block
containing one will always be detected as occupied. Accessory decoders that
use track power either need to connect directly to the track bus, or draw power
from a section of track that isn’t sensed (often you’d isolate a switch from the
sensed blocks on either side anyway, so a switch with a built-in accessory
decoder would be easy to isolate).

Feeders can pick up “induced” current from adjacent feeders or track bus
wiring. It’s best to “twist” a “left rail”/“right rail” pair of feeder wires around
each other if they run for any distance, and to avoid running them parallel to
other feeders or to bus wires. If you have to cross other DCC wires, try to do it
at right angles. Also, if feeders are long, it’s best to sense them as close to the
track as is practical, as this minimizes false current cause by capacitance in the
wiring (you can’t entirely eliminate this, and the detector has to compensate
for it, but designing to minimize it is good practice). The more sensitive a
detector is, the more likely it is to detect false currents, since these will be
small.

Typical Block Detection Sensors


Here is a list of the commercially available current-based sensors I’ve found.
Some of these only work with the manufacturers specific system, although I’ve
omitted ones that include additional circuitry for such systems, so there’s the
possibility that these could be adapted for other systems without being too
expensive. For some helpful comments on the use of these sensors, see Alan
Gartner’s Wiring for DCC site’s Block Detection page.

Circuitron BD-2 (US$25 list)


This is a simple voltage-drop sensor, which can work with DC or simple DCC
use. The normal version is limited to 3A systems, but there is also a BD-2HD for
use with up to 6 Amp systems (such as most larger DCC command stations and
boosters). Because it is a voltage-drop sensor, it reduces track voltage by about
0.7 volts. When a train is detected, the output is connected to ground,
otherwise it is an open circuit. This can be used with most types of logic boards
with the addition of a pull-up resistor connected to the logic board’s internal
positive voltage (on an Arduino, use INPUT_PULLUP mode). The BD-2 requires a
10-18 Volt AC or DC power supply. The BD-2 has a rather unique approach to
installation, placing it in line with feeders to an isolated section of the common
rail. This allows detection sections (on layouts wired as common rail) to be
independent of electrical blocks). Sensitivity is adjustable, and reportedly as
low as 0.3 mA (50K ohms on a normal layout).

Circuitron BD-3 (US$20 on one site, but does not appear to be available)
The BD-3 is fully isolated and designed only for DCC use. It includes a position
to add a connector compatible with the C/MRI detector motherboard. It
requires a 10-18 Volt power supply. This appears to be new, and as of October
2013 not yet available. Although listed in their catalog (edition 301) there is no
specification sheet for it on their website, and no hobby stores appeared to
have them in stock. From the catalog description, it appears to have similar
specifications to the BD-2 except for being fully isolated, only working with
DCC, and having a place to solder on a C/MRI-compatible connector.

CTI TB002-DCC (US$20)


The TB002-DCC is a coil-based pair of detectors on a single board. It’s designed
for use with their Train Brain control bus system (power supply comes from the
Train Brain, and that’s also where the sensitivity control is located), and it’s
unclear what it’s detection specifications are, or if it can be used
independently. However their manual suggests that these are designed for a
+5V pullup resistor supply and this implies that one could be read with an
analog pin on a microcontroller. They also make a conventional diode-based
detector pair for DC layouts, for the same price.

Dallee TRAK-RT (US$30)


This is a coil-based sensor for one block that controls a relay. It can be used
with DC or DCC. The relay could be used to directly control a device, or
connected to a on/off sensor on a control bus module of some kind. It requires
a regulated 12V power supply.

Digitrax BD-4 (US$30)


This is a coil-based sensor for four blocks. Although they don’t actually say so,
this would appear to be for DCC use only. No detection level is listed, but it
claims to detect wheel resistors (of unspecified size; an older version of the
documentation apparently recommended 10 KOhm resistors). They warn
against using this with “supersonic” decoders. Apparently there is some
problem with noise sensitivity that can cause false detection, but it only occurs
with some command stations and works fine with supersonic decoders on
others (see this Yahoo thread); they reportedly fixed it in the BDL-168 (which
includes the Loconet circuitry, so it’s not listed here), but not in later editions of
the BD-4. This is the least-expensive sensor, if you need four of them per
location.

Lenz LB-101 (US$24)


The LB-101 contains two independent current-sensing detectors for use with
DCC only. Each of these will close an “electronic switch” when a train is
detected, and the detector can sense currents down to 1 mA. The LB-101
apparently uses track power to power itself.

NCE BD-20 (US$15 list, but often available for less, particularly in bulk)
This is a coil-based sensor for one block, designed for DCC use. The output is
designed for logic boards, and pulled “high” to +5V when no train is detected,
and “low” to ground when one is. It is sensitive enough to detect a current of 8
mA or less (a newer document suggests 3 mA, see note), suitable for SMD LED
car lighting and larger or multiple on-wheel resistors. It can be used with a
variety of reporting systems (including with NMRAnet). There were apparently
two versions of this, although the current version replaced the previous one c.
2002. The original, designated “BD-20” (“Rev. B” on a schematic from NCE) can
be recognized by the use of a two-position screw-terminal connector. The
present “BD-20A” (“Rev. C” on a schematic from NCE) has a four-position
screw-terminal connector. It’s usually just referred to as a “BD-20” (or “BD20”)
without the “A”.

Note: detection sensitivity on the BD-20 is apparently around 10-12 mA with


the wire fed through the coil. Looping the wire multiple times can increase the
sensitivity (see the schematics in the linked page above describing the two
versions). With four loops (the maximum safe number on a 5A command
station), sensitivity is around 2.5 to 3 mA.

RR-CitKits BOD-1 (US$13 list)


This is a coil-based sensor with screw-terminal connectors. It is diode based but
can be used with either DC or DCC. It uses a current-loop approach, or one pair
of pins is connected when the sensor is occupied (a second pair connected only
when the sensor is empty is used). It is intended for use with some kind of
input device (such as a DS-54) or some circuit (like a crossing gate).

RR-CitKits BOD-8 (US$38 list, plus US$15 for a set of 8 detection coils; also
requires use of a Tower-series controller)
Despite the name similarity, this is very different from the BOD-1. It uses coil
sensors (8 of them), and is designed to be used in conjunction with their
“Tower” series of input devices, including both the TC-64 (original and Mark II
versions), TowerMan and Tower-LCC. The original serial TowerMan controller
(which is LocoNet compatible) has been joined (as of early 2016) by the LCC-
based Tower-LCC, making this the first block detector available for LCC. Note
that this uses all 8 sensors on a Tower ribbon cable, so a maximum of two (16
detectors) can be used with a TowerMan or Tower-LCC. Still, that works out to
US$11 per detector (including Tower-LCC and coils).

Do-it-Yourself Block Detection


Block detection of trains actually isn’t that hard, electrically. As noted above,
there are two main techniques used: voltage-drop sensing, and induced-
current sensing. The former is what most systems used in the past, and many
still do today. Done right, it works quite well, but there are a lot of ways to do it
wrong. Current sensing is how some of the more sophisticated solutions work,
particularly for DCC.

Voltage-drop systems are required for DC layouts (and will work with DCC if
designed for it). But problematically, these put the track voltage on the same
circuitry as is connected to some more sensitive electronics, like a computer.
The best of these use optical isolators (“optoisolators”) to protect the
computer. Many cheaper designs omit this, which I think is a really foolish bit of
cost-savings. Model Railroading with DCC has a circuit diagram for a good
detector with isolation, which costs under $7 each if you’re building more than
10 of them.

Current sensors only work with DCC (or AC-powered layouts), since DC doesn’t
have the same effect of inducing a current (although the Dallee detector above
seems to be similar and works with DC; at least in theory you could detect the
change in current when a train enters or leaves a block and there are complex
circuits that will detect DC current). The current controls what is effectively an
amplifier circuit, so the small induced current acts as a switch to control other
circuits, usually switching them between “on” and “off” states. This circuit
could be a high-current circuit to control a light or relay, or a logic circuit to
switch between “one” (+5V) and “zero” (ground) states, depending on the
circuit design.

There’s a nice description of how this works along with a sample circuit on this
site. These are simpler circuits than voltage-drop designs, but the coils aren’t
cheap (US$4 - 7) so the end cost is probably about the same, but could be less.
One nice touch of these is that the coil isolates the track power from the
computer, and the coil can be mounted remotely from the circuitry (with some
care: use twisted-pair wires run away from DCC lines and of limited length), so
one circuit board could easily support multiple block detectors spread over a
section of layout.

Another circuit for this is available from this site, and the author also sells
circuit boards.
Another page describing examples of both kinds of detectors is this one.

Inductive Detection Circuit


Detecting trains via current sensing is not new. In fact real railroads were using
this method in the 1800’s (it was invented in England in 1864). Model railroads
have been doing the same since at least the early 1970’s. But for model
railroads using DC, most detectors used simple diode-based voltage-drop
sensors, despite their flaws.

The largest problem with that approach is that there is no isolation of delicate
electronics from high-power, high-current electricity in the track and track
power supply. Some diode-based detectors use opto-isolators to address this
problem. That may be “good enough” but it still has high-power circuits wired
to circuit boards connected to sensitive electronics. There is significant room
for an error if a bared bit of wire touches the wrong thing. And if that happens,
the consequences can be expensive.

A secondary problem is that diodes always drop about 0.6 volts, so this reduces
the track voltage. And with high currents in a short the feeder may be carrying
5 Amps for an extended period; the diodes will get hot. Which adds cost and
space for power diodes and heat sinks if you don’t want to be replacing diodes
every time someone wrong-ends a switch frog. Actual power loss isn’t too bad,
however, so if you can live with the voltage reduction, which affects top speed,
these detectors will work with DCC even when locos are drawing an Amp or
more of power (e.g., multiple sound-equipped locos in one block).

But there’s another way to sense current: induction. The basic idea is to use a
coil, which acts as a transformer to tap off a small portion of track power.
While a small amount of power is still lost (much less than in the diode-drop
method), the actual voltage in the track feeder isn’t changed.

Additionally detectors based on inductive circuits are naturally isolated: the


feeder has to pass through the coil, but it remains insulated (and the coil is
typically encased in plastic) so there’s no risk of a short circuit. In fact, these
coils are designed for applications where high voltages and/or currents need to
be safely measured, so isolation is a key feature.

The actual circuit at the center of these inductive designs is a well-known one
called a current-sense transformer circuit. Use of coils for AC current
measurement is a technique that goes back at least to 1912 and the
development of an open-air coil known as the Rogowski Coil. The modern
version uses a magnetic-core coil, typically a toroid (donut) shape made of
ferrite or a similar material, with the transformer secondary wrapped around it.
This in encased in an insulating plastic box with a hole in the middle, and a wire
fed through the hole forms the primary/ The ratio of the number of times the
primary goes through the hole (usually only one or two times) to the number of
secondary wrappings (usually 50 or more) provides the transformer’s reduction
ratio. A 1:100:1 (1 primary to 100 secondary) coil will produce a 1 mA current in
the secondary when a 100 mA current goes through the track feeder wire. This
current in the secondary can be used directly, or as a control for other circuitry.
Note: These sensors only work with AC, since constant current does not
produce an induced magnetic field to drive the secondary. But DCC is a form of
AC, so they’re an ideal choice for DCC occupancy sensing. It’s possible to make
coil sensors that work with DC, but those are much more complex circuits.
Anyone building DC/DCC-compatible occupancy detectors is probably using the
diode method rather than inductive sensors.

There are three well-documented circuits for this kind of detector. This page
will summarize them and describe their differences (see the linked web pages
for the complete design with more discussion by the authors of the designs), as
well as going into the two most interesting ones (at least to me) in more depth.

History
A number of people have worked on inductive detector circuits for model
railroads and published their results over the years. This doesn’t pretend to be
a complete history. I’m just reporting what I’ve found so far.

The earliest I’m aware of is a design published in a 1972 article by Wayne


Roderick, “Signalling on the TSL”, describing a system he used on his Teton
Short Line layout. He’s updated his design over the years, and the latest
detector is described online. His 2004 detector was a return to use of induction
(after using a diode-drop system for his early DCC detectors), motivated by a
desire to keep the DCC signal away from the logic circuits due to potential noise
issues. This detector works in part by using a capacitor tuned to the coil to
produce a resonance near the DCC frequency of 8 kHz, which produces a
substantial amplification, eliminating the need for a pre-amplifier. His circuit
does still require Op-Amps (LM339/LM3302) to amplify the coil current to a
level that can be used in logic circuits (i.e., 5 volts).

Note: Roderick’s page also has a good description of a couple of methods for
attaching 10 KOhm resistors to wheelsets so that freight and unlit passenger
cars can be detected.

Another detector is Rob Paisley’s VT-5 detector, which is one of several designs
he’s documented. These designs are all copyright by him, with the earliest
dated 2005. These were apparently originally developed for, and used on, the
London (Ontario) Model Railroad Group’s layout. Paisley makes his printed
circuit boards (without components) available for sale (see his website linked
above).
Similar designs have been done commercially (e.g., NCE’s BD-20, which dates
from some time prior to 2001 and uses a similar current-sense transformer
circuit, although reportedly with a coil having more turns).

Paisley’s circuit is different from Roderick’s approach, using a transistor


connected to a LM556 timer. The transistor serves to amplify the signal from
the coil to a level that can be used with logic circuits. The 556 is basically there
to limit the output to a HIGH/LOW state of +5/0 volts, rather than the arbitrary
voltages in between coming from the transistor. It’s important if the circuit will
connect to other logic circuits, but not necessarily required for a connection to
a device such as an Arduino, which is going to use its own circuitry to convert
the voltage to a HIGH/LOW state. Additionally, his circuit does not appear to
make use of resonance, with the capacitor sized much too large for that.
Although the design predates the Arduino, it will clearly work with it.

The most recent design I’m aware of, described by its author as “inspired by”
that of Paisley, was created by Reinhard Müller (with contributions from
Helmut Schäfer), for use by the German FREMO club (website no longer exists).
This was designed to work with an Atmel microprocessor. Although Arduino’s
use an Atmel processor, this likely predates the availability of Arduinos, so it
was for some other Atmel-based system, but functionally an Arduino should
work the same. This was tested in 2006, and the design refined by the addition
of a capacitor to handle transients from track capacitance (C2 in the diagram
below) plus a change from use of the internal pull-up resistors (which can be as
low as 20K ohms) to a 100K Ohm pullup to improve sensitivity. Müller notes
that the resistor in his circuit (R1) is required to dampen oscillations. This
design was tested in 2006, and over 1,000 copies “distributed” within the
organization (I’m not sure if “distributed” means someone sold them, or just
that the design was distributed to 1,000 people).

Note: Müller describes several versions of his circuit, including one suitable for
directly controlling other devices. For the remainder of this page, I’m going to
focus on his final design, as specified for use with a microprocessor (such as the
Arduino).

The Circuits
Thus there are two similar but not identical circuits based on a simple
transformer-as-switch approach if you want to build your own detectors (as
opposed to using commercial ones). Both have been proven in real-world use,
and both can be built with parts available today, although these aren’t
necessarily going to behave exactly like the originals did. The third circuit could
also be used, but it seems needlessly complex so I’m not going to address it
further, at least for now.

One problem with this kind of sensor is that due to its sensitivity it can render
false positives due to capacitance in wiring or track. Tracks normally have very
tiny amounts of this, although long lengths of track and wiring may be more
prone to it than others. Müller’s design addresses that with C2, which
effectively filters these pulses. Less sensitive detectors wouldn’t need to deal
with this issue unless the track was particularly problematic. The longer the
section of track (the block) being detected, the more capacitance there will be.
Feeder wiring can also contribute to capacitance. Some layouts, particularly
ones with short blocks and separated wires, may have less of an issue with
capacitance than others. Before building any detector in bulk, it’s worth
experimenting a bit to see how a design works for your specific environment.

While circuits can be modified to make them less sensitive, an alternative


method of dealing with capacitance in the track, credited to John M. Smith, is
documented on Allan Gartner’s Wiring for DCC site.

Here’s a version of Paisley’s VT-5 circuit stripped down to basics:


Paisley’s Inductive Detector circuit for use with microprocessor

Parts and ratings:


- coil: originally 300 turn, ~200mH coil, no longer available (see note)
- Q1: 2N3904, NPN, Ic=200 mA, hfe = gain = <100 (typical)
- D1: 1N4148; If = 200 mA max, Vf = 1V @ 100 mA, 0.72V @ 5 mA

Paisley’s circuit originally used a Coilcraft J9119-A (specifications unknown) for


the current-sensing coil, now long discontinued. This was replaced by the Vitec
57P1822 (1:350, 73 mH) or alternatively the 57P1820 (1:300, 180mH). He also
mentions use of the AS-103 (1:300, 250 mH) as being available in Europe.
Coilcraft no longer makes a 300-turn sensor, but its specifications for smaller
ones are in line with other manufacturers, so assuming the original was 300
turns, it’s likely to have had inductance around 180 - 250 mH (the 1822 above is
rather low in inductance, but there are current equivalents, such as the Triad
CST206-3A, Digikey 237-1100-ND, or Pulse PE-51719, Digikey 553-2019-ND,
with 300 turns and inductances of 130 and 80 mH respectively).

Note: the two Vitec coils are still available from Surplus Sales of Nebraska (as of
October 2013), but both appear to have been discontinued by the
manufacturer (I can’t even find a data sheet that lists the 1822 anymore, and
the last datasheet describing the 1820 is dated 2007). Neither is available from
any of the usual big electronics retailers, which suggests that remaining
inventory is low and these aren’t good parts to plan on using (although they’re
still available if you only need a few).

For simulation purposes, I’ll assume a 350-turn coil with 73 mH inductance, but
I’ll also take a look at the Pulse coil (1:300, 80 mH), as that seems like the best
current replacement and compare with a 200 mH coil just in case that was
what the original used.

Sensitivity of this detector is claimed to be ~1 mA with 1.5 loops of the feeder


through the coil (a 1:233 ratio with the 1822 coil). He also notes that sensitivity
is improved with a tight winding of the feeder around the coil, as opposed to
just passing the wire through the hole as shown on the datasheets.

And here’s an example of Müller’s circuit, stripped of all non-essentials and


showing what would be needed for use with an Arduino digital pin in INPUT
mode:

Müller’s Inductive Detector circuit for use with microprocessor


Parts and ratings:
- coil: Nuvotem Talema AS-100 (Digikey TE2301-ND, $3.08 each in qty. 10+); 50
turns, 6 mH @ 10 kHz, 50 ohm resistance
- Q1: BC547C; NPN, Ic = 100 mA, hfe = gain = 270+ (600 typ.)
- D1: 1N4148; If = 200 mA max, Vf = 1V @ 100 mA, 0.72V @ 5 mA

Both the AS-100 coil used by Müller, and an alternate (PE-51686NL, 50 turns, 5
mH) he listed are available from Digikey in updated lead-free designs
compatible with the European ROHS regulations, which means they’re
relatively new and not likely to be obsoleted any time soon, or the
manufacturers wouldn’t have invested in updating to meet ROHS specs; they
just would have discontinued them. The other components are commonplace.
Müller’s circuit is still a viable one to build as of 2013.

Sensitivity of this circuit is said to be ~1.5 mA of track current.

Sensitivity and Real-world Use


How sensitive does a detector need to be? It depends on what you want to do
with the information, and in part on what kind of trains you’re running.

On a DCC layout with track voltage of 10 V DCC (a “worst case” scenario), an


axle with a 10 KOhm resistor will draw a current of 1 mA. If you want to detect
one car, and only put resistors on one axle per car, that’s your limit. Unless
you’re using this with hidden storage tracks, detecting a single car probably
isn’t the best criteria. And if it is, you could add resistors that are smaller (a 5
KOhm resistor will draw two milliamps @ 10 V DCC) or put more axles of them
on cars that are likely to be left parked alone.

With freight trains, assuming they’re moving forwards, the locomotive will hit
the detector first, and it’s drawing tens of mA. Just about anything will detect
that. However if you’re switching and back into a grade crossing, you might
want to detect that first car (or you could just load up a caboose with more
resistors, or smaller ones). Two axles equipped that way will draw 4 mA. In that
case, extreme sensitivity probably isn’t needed.

My case is passenger EMUs. These will be lit, but the motor car will be in the
middle of the train. I’ve seen lighting draw as little as 3 mA (5 mA+ is more
likely), but my cab cars will actually have both interior lighting and a cab
decoder with a head/tail-light LED. I need to measure this, but I expect my
power draw for cab cars will be close to 10 mA. So I’m not concerned with
extreme sensitivity either.

If you really need to, you can make these detectors more sensitive by winding
the feeder around the coil more times (although too much of that is likely a bad
idea, at least with some of them). You can also make them less sensitive (see
the websites for the two authors for discussion of that topic).

Detection time is also a factor here. As currents go down, the circuits take
longer to detect a block going occupied (a block going clear is not dependent
on current levels). How much the delay matters will depend on the layout. A 40
mph (64 kph) freight is moving a lot slower than a 200 mph (320 kph) bullet
train. In 10 milliseconds, an N-scale freight will move 1 mm, while the bullet
train will move 6 mm (1/4”). At 100 msec, the freight will have gone 12 mm
(1/2”), while the bullet train will have moved 60 mm (2 1/3”). Extend this out to
a half-second, and the freight has moved 60 mm (2 1/3”) while the bullet train
has moved 296 mm (11 2/3”).

There are certainly situations where waiting a second or more to detect a train
is reasonable. But I’ll draw an arbitrary line at a half-second for determining the
limit of a detector’s sensitivity.

Comparing the Circuits


It’s instructive to look at the two circuits, and compare how they work. Both
use a coil to sense current in a track feeder, and both produce an output that’s
either HIGH (close to +5V) or LOW (close to Ground). And both use a capacitor
to keep the output stable when there’s nothing to detect, and a transistor as a
switch to drain that capacitor when there is. There are significant differences
between them in how they go about doing this, and what the end result looks
like.

Note: at present my comments on the performance of these circuits is all based


on circuit simulations. At some point I’ll probably build a couple of the more
interesting solutions, and see what they look like in the real world, but that’s
likely some time in the future.

Paisley’s circuit is using R1 to keep the emitter side of the transistor floating
above ground. Any voltage released from C1 through Q1 will build up at the
input of the 556 integrated circuit, and very, very, slowly drain away through
R1. As long as there’s a continuous supply of current into C1, and hence Q1, the
input to the IC will remain close to +5V while there is current in the track. Once
it goes away, C1 quickly recharges, but the input to the IC slowly drains. The IC
very simply takes the input voltage, and above a certain level sets its bipolar
input HIGH, indicating that a current flow has been detected (there’s a second
output, but it’s less useful for this kind of microprocessor-based sensing). A
microprocessor, such as an Arduino, can connect to either of those outputs (or
you could just wire up one and ignore the other). C2 in this diagram is simply
acting as a filter on the power supply, so that an poorer source of voltage can
be used. In fact, per Paisley, this circuit is very tolerant of input voltage, and
anything from +5 to +12V can be used.

The circuit is admirably simple: ignoring the filter capacitor, it requires only
seven components: coil, diode, transistor, capacitor, two resistors and a
LM556. And both R1 and the LM556 can be shared with two detectors, making
the component count per detector six.

Müller’s circuit is even more streamlined. In its most basic form: coil, diode,
transistor, capacitor and two resistors; the integrated circuit is eliminated. As
Müller noted, the improved sensitivity will likely require the addition of C2, but
it’s still a simpler circuit. The differences in cost, however, are negligible.

Müller’s circuit operates slightly differently. In it, the state of C1 is sensed


directly, and it will be HIGH when no current is flowing in the block. When
current flows, Q1 activates and drains C1, but in this case it’s drained straight
to ground. Once the voltage in C1 drops below about 2.6V, an Arduino (or
similar device) will treat that as a LOW reading. When current stops flowing, C1
recharges and the Arduino will see HIGH once voltage goes above about 4
Volts.

Circuit Simulation
To understand how these circuits work, I needed to simulate them. As I’ve
mentioned before, I’m not an electrical engineer, so any of the following could
be wrong. My track record on getting these things right is mixed at best, and I
don’t have much experience with transistor-based circuits. Use at your own
risk. That said, I think I understand what’s going on here.

To simulate these circuits, I needed to build models that would work with a
simulator. This is a bit harder than it sounds, because the simulators available
to me don’t have a built-in model for a current-sensing coil (I also had problems
finding transistor models for the BC547 series, but eventually located those). I
made one using a normal transformer with the appropriate turn ratio, but I’m
not sure it’s 100% correct (it does seem to produce approximately correct
behavior, so I think it’s close). Any errors likely affect each model equally.

To define the transformer, you have to use the inductance of the coil. The
SPICE model requires this for both the primary (track feeder) and secondary
(coil), but the data sheet only gives the number for the coil. The number for the
primary is calculated from the secondary, based on the number of turns of the
track feeder, using an inverse-square rule. Here’s the formula, where Ls comes
from the datasheet (in millihenrys) and Np/Ns is the ratio of the number of
turns of feeder to the number of turns in the coil:

Lp = Ls x (Np / Ns)^2

So, for 1.5 turns of primary into a 300-turn 80 mH coil, you get:

Lp = 80 x (1.5 / 300)^2 = 80 x 0.005^2 = 80 x 0.000025 = 0.002

And thus you set up the transformer with 80 mH in the secondary, and 0.002
mH in the primary.

Note: by definition, simulations are not exact. Models of semiconductors aren’t


the same as real ones, and real-world variations between components that are
rated identically can be significant at the limits of circuit behavior. While most
of what the models are telling me is likely correct, trying to gauge minimum-
current sensitivity is quite risky. The fact that my “minimum current” numbers
are higher than those of the original authors likely reflects limitations of the
model. However, if my model says detector A is 10% more sensitive than
detector B, that’s likely true, even if 10% of what may be subject to dispute.

All circuit simulations mentioned here were done in NGSpice 25, using Volta
(for OSX) as a graphical front-end to draw the circuits and plot the results.
SPICE models were collected from online sources for the specific diode and
transistors, but generic models for capacitors, resistors, and coils were used
(the coil model was a generic transformer that had parameters set to match
the coil’s inductance characteristics; this is probably the weakest portion of the
model at present).

Note: all of the simulations of Paisley’s circuit use his recommended 1.5 turns
of the track feeder (looping it twice through the hole and then back the way it
came, so it can be made snug against the coil). Müller’s description, and a
photograph on his site suggest that normal use is to pass the wire through the
coil, so I’ve used 1 turn (which is what “go through the hole” is) as the standard
configuration for his sensors. He does note that accuracy can be improved with
multiple loops, but do did Paisley.

Worst-case Current Performance


Assuming these detectors are used with a 5 Amp DCC supply, the worst case for
component tolerances comes when a short happens, sending the full 5 Amps
through the track feeder. Obviously, systems can be designed with block-level
circuit breakers to limit peak current more (and, alternatively, some people use
8 Amp boosters). But for a reasonably-flexible design, 5 Amps is a good target.
It’s also what I’m using today on my layout, although I’m likely moving to a
3A/block approach based on block-level circuit breakers.

Paisley, 1:233 ratio (1.5 turns into 350-turn, 73 mH coil):


This is the Vitec 1822 coil specified as the replacement for the long-unavailable
original coil. Unsurprisingly, the detector catches this level of current very
quickly, within the first DCC pulse (about 22 microseconds from the start).
Voltage applied to the base of Q1 is 1.2V at most, well within safe bounds.
Current at the base of Q1 peaks at about 42 mA, and current through the
collector-emitter junction (Ice) peaks at 428 mA. This is above the 200 mA limit
of the transistor, but only for about 25 microseconds. Once C1 has drained, It
won’t recur.

Note: this is for C1 with 2.2 uF. Raising this value will extend the duration of
this value, but doesn’t raise the actual current. That’s in line with the transistor
characteristics, which have reduced gain as current rises. A 10x gain at currents
exceeding 100mA is not unreasonable.

Ice (collector-emitter) current in Amps over first 100 usec after pulse starts (5A
feeder current)

Paisley, 1:200 ratio (1.5 turns into 300-turn, 80 mH coil):


Using the best available replacement for the original coil, the Pulse PE-51719,
doesn’t noticeably change the detection time for a maximum current pulse.
Current into the base rises slightly, to about 50 mA, and Ice climbs slightly to
462 mA, but that’s essentially identical to the original coil for all intents and
purposes. The pulse is slightly shorter as well, falling under 200 mA in 23
microseconds.

Paisley, 1:200 ratio (1.5 turns into 300-turn, 130 mH coil):


Because the inductance seemed to play a role in the sensitivity, I decided to
look at the behavior of the Triad coil as well. If this has problems, the Vitec
1820 is going to be even worse, making that a poor choice as well. Peak current
into the base is now 50 mA and Ice peaks at 463 mA, essentially identical to the
Pulse coil. Pulse duration is 25 microseconds.

Müller, 1:50 ratio (1 turn into 50-turn, 5 mH coil):


In the worst case, current into the base spikes to 190 mA, but only remains
above 100 mA for about 12 microseconds. Ice peaks at 117 mA, but only for 13
microseconds. This completely drains C1, so it doesn’t happen again on later
DCC cycles. I’m not aware of a current limit at the base (Müller states that it’s
500 mA, but that’s not on any data sheet). As with Paisley’s circuit, Ice is
exceeding the transistors nominal limit, but similarly only for a very brief time.

Detection time is remarkably fast: just 5 microseconds.

One of the things that concerns me about Müller’s circuit is that the use of a
1:50 coil is producing higher currents in the transistor base, and he’s used a
transistor with a lower rating for collector-emitter current and higher gain. I
don’t know if that’s a problem, and it doesn’t appear to cause too-high of an
Ice current. But it seems like an undesirable feature.

The effect of the much smaller C1 is easily seen in the graph below: the
capacitor drains very quickly, so the high current is not sustained (the +/- axis is
reversed from the one above because I was sloppy inserting the measurement
point in the circuit).
Ice (collector-emitter) current in Amps over first 100 usec after pulse starts (5A
feeder current)

Sensitivity
The other extreme is how low a current in the feeder the detector will detect.
This is limited by the reduction provided by the coil and the characteristics of
the transformer. There’s an interrelated question of how quickly it will detect
the current, since detection depends on draining C1, and that takes time. As
sensed current drops, the transistor is turned on for shorter intervals each
pulse, and the rate of drain goes down quickly. At some point it will be
balanced by the recharge rate through the pullup resistor, and that likely sets ti
extreme limit of detection. But for practical purposes, I’m going to draw the
line a 1/2 second, mostly because longer takes too long to simulate, but also
because I think that’s long enough to wait to know that a block has gone
occupied.

Note: the time for a block to go clear is different, as it mainly depends on R1


(pulldown) and C2 size in the Paisley circuit and R2 (pullup) and C2 size in the
Müller circuit, and doesn’t depend at all on the current being sensed.

Paisley, 1:233 ratio (1.5 turns into 350-turn, 73mH coil):


This circuit has a very predictable behavior: as currents get lower, detection
time increases. If there’s limit, it likely lies beyond any reasonable detection
time. At 10mA, detection takes about 23 milliseconds. At 5 mA it takes 85
milliseconds. At 3 mA detection time is up to 250 microseconds (a full quarter-
second). At 1.5 mA, detection time is 480 microseconds, or essentially a half a
second. I’ll draw the line there. It’s not quite the 1 mA of the author’s definition
(that likely comes around 3/4 of a second). But it’s still quite good. And, as
noted, simulations aren’t going to be exact, particularly at the limits of circuit
behavior like this.

Incidentally, this is what the currents look like from the coil into the base of the
transistor, and from collector to emitter (draining C1) during the first four DCC
pulses after the block goes occupied (i.e., the first half millisecond). Each of the
Ice spikes lasts only about 1 microsecond.

Base current (peak 11 microamps) (1.5 mA feeder current)

Note: the downward spikes are the ones triggering the transistor, a quirk of
how I set up the simulation.

Collector-emitter current (peak 1 mA) (1.5 mA feeder current)

Paisley, 1:200 ratio (1.5 turns into 300-turn, 80 mH coil):


Sensitivity is reduced slightly with the new coil, translating into longer
detection times. A 1.5mA track current now takes longer than a half-second to
detect (perhaps 2/3), and a 2mA current takes about 425 milliseconds. That’s
interesting, as the lower ratio should make the coil more sensitive, not less. The
higher inductance is probably playing a role here, as it will choke off the base
current pulses faster, lowering the rate at which C1 drains.

Paisley, 1:200 ratio (1.5 turns into 300-turn, 130 mH coil):


Detection time for a 2 mA current does indeed rise slightly, but only to 247
milliseconds. So increasing the mH does have a sensitivity effect, but not a
major one.
Paisley, 1:200 ratio (1.5 turns into 300-turn, 250 mH coil):
Just to be complete, I re-ran this analysis for the A-103 coil, to see how a
significantly larger mH rating would affect operation. Surprisingly, this
improved detection time for 2 mA track current to about 80 milliseconds.

What’s happening here, as you can see below, is that the base pulses are being
extended, causing the Ice current to flow for a longer period, and thus draining
C1 faster.

Note: the upward spike is the current in the reverse direction before the diode
acts to bypass the transistor. It remains short because the diode’s response
time doesn’t change, or perhaps because it’s drained the limited charge in the
transistor’s base and there’s no more current to flow.

Base current (peak 25 microamps) (1.5 mA feeder current)

Collector-emitter current (peak 1 mA) (2 mA feeder current)

Müller, 1:50 ratio (1 turn into 50-turn, 5 mH coil):


At 10 mA this circuit takes just 250 microseconds to detect current in the
feeder. But as the current drops, this becomes significantly longer. Detection
time for 5 mA is 16 milliseconds.
One interesting thing about this circuit is that is has a very solid cut-off of the
detection. Once current drops below a threshold, C1 recharges faster than it
can drain, and the circuit never falls to a point allowing reliable detection. In
my simulation, this happens immediately below 5 mA (4.95 mA fails to work).

Lower the track current below that, and Müller’s circuit stops detecting the
change (C1 never gets pulled below 4V, because it’s recharging too fast even
with just a 100K pullup; put another way, it’s not draining fast enough.
Surprisingly, Paisely’s circuit works at lower currents; it just takes longer and
longer to detect things. At 4.3 mA, detection time is 95 milliseconds. At 4 mA
it’s about 110 milliseconds. At 3 mA it’s around 180 milliseconds. At 2 mA it’s
approaching half a second, and that’s probably a good place to call “done”.

Base current (peak 25 microamps) (5 mA feeder current)

Collector-emitter current (peak 7.8 mA) (5 mA feeder current)

Reset Time
The time it takes the detector to go clear depends on the time it takes the
circuit to return to its original state one current is no longer flowing in the
feeder and the transistor has turned off. In Paisley’s circuit, this is the time it
takes the charge (from C1) at the input of the 556 to drain away through the
pulldown resistor (R1). In Müller’s circuit, this is the time it takes C1 to recharge
from the pullup resistor (R2).

Both of these are simply defined by the time constant of the RC circuit. C1
needs to recharge to about 80% of full, and the time constant defines how long
it will take to recharge to 72% (from zero). But the capacitor may not quite get
to zero anyway, so the time constant is a fairly good approximation of the
actual time. In practice, it might be slightly longer.

The time constant for Paisley’s circuit is 2.2 seconds (with C1 set to 2.2uF). This
can be reduced by reducing the size of C1 (he suggests a lower limit of 1uF) or
reducing the size of R1 (but too low may affect sensitivity).

The time constant for Müller’s circuit is much smaller, just 10 milliseconds. This
is because of the much smaller value of C1 (and the smaller value of R2 relative
to Paisely’s R1). This would be even faster if the internal pullup resistor were
used (which varies from ~20 to ~40 kOhm, so times would be about 2 - 4 msec).

Summary
What this all says is that as specified, Paisley’s circuit is more sensitive than
Müller’s, although that may in part be due to his addition of the capacitor to
prevent false detection of track capacitance-induced currents. Paisley’s circuit
is more efficient, tapping off just 0.5% of feeder power compared to Müller’s
2%, but realistically the difference doesn’t matter. Aside from that, Müller’s
circuit reacts faster to blocks going both occupied and clear, and has slightly
fewer solder joints if you have to hand-build a lot of them.

In a dead short, both of them exceed their transistor’s “safe” level of collector-
emitter current, but only briefly. It’s likely that this can be addressed with a
simple current-limiting resistor between C1 and Q1, although that may have
implications for the circuit’s sensitivity.

I’m not done with my investigation, but I’m probably ready to put it on the back
burner and think about what I’ve seen so far. And maybe order some parts to
try building a couple and seeing how they actually work. I’ve also played
around with simulating some variations on both circuits, to see if their
weaknesses can be addressed. This led to some unexpected behavior that I’m
still working to understand. I’ll likely add to this page, or add a new page, in the
future to discuss that work. But for the moment I’m going to stop here with this
analysis of the original circuits.

Decoder Transmission
There have been a couple of vendor-specific technologies that allow a train’s
DCC decoder to report information back to the command station (or to a
computer). The NMRA is now working on a standard for this, and refers to this
technology generally as “Decoder Transmission”. This is distinct from what
decoders do on a programming track to report the value stored in CVs,
although technologically there are similarities.

What the NMRA is working on standardizing is a system for decoder


transmission developed by Lenz, under the name RailComm, although the
standard has been in a draft state for years (it does seem to be making some
progress). The current draft standard is RP-9.3.2 (PDF), dated May 2012,
replacing a 2003 draft that apparently was never implemented.

With Railcom, in addition to the detector (and decoders that support it) you
also need something called a “cut out” device on the power station’s output.
This is built into Lenz’s power stations, and likely other new ones. But it needs
to be added via an external device to older systems. And that’s the “gotcha”,
despite being a monitoring system, RailCom does need to alter the command
station output, and products that do that aren’t easily come by (and aren’t
cheap). After surveying the existing products in 2012, I don’t think RailComm is
quite ready for prime time yet. But it’s something I plan to keep an eye on.

Transponding
Digitrax has a proprietary form of decoder transmission called Transponding,
which works with their occupancy detectors and those of a few other
companies. Few if any decoders other than theirs support it, however.

Digitrax’s transponding is something I spent a fair amount of time on, and


there’s a description of that on my Occupancy Detection page and my BDL168
Testing page. Frankly I could never get it to work consistently or reliably, and
eventually stopped trying. It’s not a bad system (assuming you can get it to
work, and many apparently do), and if you’re already invested in it not likely to
be worth abandoning. But the train has left the station on Decoder
Transmission, and Transponding was left on the platform. RailComm is clearly
the NMRA’s future direction, and as an open standard it’s likely to be everyone
else’s direction, just the way DCC displaced a bunch of proprietary competitors.

RailComm
Like Transponding, RailComm depends on decoders and detectors that support
it. Further, as noted above, command stations and/or power stations
(boosters) need to provide for the “RailComm Cutout” in their DCC signal, to
allow trains an opportunity to transmit their information. If you have a
RailComm-compatible command station, such as those made be ESU (ECoS) or
Lenz, adding it isn’t too hard (but may be expensive).

Lenz makes a distinction between RailComm and RailComm Plus, the latter
apparently allowing unsolicited transmissions from a decoder. I’m pretty sure
the latter is what the NMRA is calling Decoder Transmission in their latest RP,
and what most people are calling simply RailComm, which just adds some
terminology confusion (should you shop for RailComm or RailComm Plus?).

RailComm Decoders
A number of DCC decoders, unfortunately not including Digitrax, support
RailComm. Lenz also makes a simple decoder that can be added to a train with
an existing decoder that does not support RailComm, the LRC100, which retails
for US$16-20 each in packs of 5.

Note: apparently back around 2003 Digitrax decoders wouldn’t work at all on a
Lenz system with RailComm enabled. It’s unclear if that’s still an issue today but
it seems unlikely that it would be.

RailComm Detectors

For each block/zone where you want to be able to detect RailComm-equipped


decoders, you need a detector. This splices into one of the feeder wires, and
has some kind of bus connection to allow it to report back to a computer. Each
manufacturer does their own bus.

DCC4PC
UK firm DCC4PC sells a Local RailComm Reader that supports 16 zones for
about US$209 list (£160 in their native U.K. due to VAT). It uses their Omnibus
network, and a US$79 Computer Interface Device (UK£60 with VAT) is required.
See their site for a list of suppliers. Note: I have no experience with these, and
this is not a recommendation.
ESU
It’s not strictly a detector, but the ESU ECoS 50200 command station
incorporates a “global” RailComm detector, so it can read back variables like
fuel level from decoders that support this, and tell you what addresses are in
use on the locomotives on the layout. They don’t apparently sell a standalone
detector, not even for expanding their own system, which makes this of rather
limited benefit.

Lenz LRC120
The granddaddy of RailComm detectors, the LRC120 retails for around US$70
and detects trains in one block. It includes a simple four-digit display to show
the address of the currently-detected decoder. As far as I can tell, all this can
do is display the loco address on its display. There’s apparently no computer
interface. This is one of their older “non-Plus” units.

Lenz LRC130
Both a simple power-use occupancy detector and a RailComm detector, the
LRC130 will support up to four blocks. And it communicates with a computer
via their new RailCommbus (a USB interface is still required to the bus).
Assuming it ever ships. It was apparently announced in 2010. I’m currently
seeing it priced as “TBA” on a number of sites in January of 2013, and not
offered for sale by anyone. At least at launch, this may be limited to Windows
XP systems, although I’d expect JMRI support to happen fairly quickly. For Lenz,
the LRC135 is a USB interface to their Railcommbus. It’s also not yet available
or priced.

TAMS
TAMS is a German company (German website). Their RCD-1 (US$40 built, also
in kit form) is a one-block detector and their RCD-2 (US$62 built, also available
in kit form) is a two-block detector. The RCD-2 can also control up to 8 switched
outputs (for things like crossing-gate control, presumably). Both use their RC-
Link USB computer interface (US$92) and their own bus (which may be limited
to 24 detector modules, if I’m reading the translated German correctly).

Uhlenbrock
Uhlenbrock is a German company, which can make finding and using their
equipment a bit harder. But they do publish manuals in English and there are
some sources accessible to English-speakers (see the Suppliers page). Their
US$54 (list price in Euros converted to U.S.) MARco (product 68500), which I
learned about from a review on this site, seems to be fairly new (it’s not listed
as new by the manufacturer, but I can’t find it in any English-language store).
But for U.S. modelers it’s very significant, as it is a RailComm detector that
works with LocoNet as its communications method. Note that this does not
remove the need for the command station to provide a cutout (see below); this
device is only a detector.

RailComm Cutout
If you don’t have a RailComm-compatible command station or booster, you’ll
need to add something called a “cutout device”. This connects to the track
output of the command station (you’ll need one for each booster if you have
those) and briefly interrupts the signal at the allowed times to give decoders a
time to send their information. Non-RailComm decoders should work fine with
this as RailComm was designed to be backwards-compatible with older
equipment (there’s some chance some older ones might not, and I saw one
very old report about problems with Digitrax decoders and an earlier version of
RailComm, but it seems to be fairly unlikely that this is a problem with the
current RailComm and recent decoders). The problem lies in finding a cutout
device: at present there’s only one supplier (in the U.K.) who wasn’t shipping
when I first looked for these, and I was unwilling to buy a whole new command
station just to experiment with RailComm. That derailed my initial plans to see
how it works. It’s now available, so I may revisit this in a bit.

DCC4PC
In addition to their detectors this UK company also makes a Cutout Device
(which started shipping in January 2013, see links above) that can condition the
output of a non-RailComm DCC command station. List price is US$79 (£ 60 in
their native U.K. due to VAT).

TAMS
TAMS makes a cutout-module, but it’s only for use with their own booster.

And that’s it. It’s clearly still early days for RailComm. I could probably run a
RailComm-compatible Lenz booster off my Digitrax command station (Digitrax
has instructions for doing just that on their website and these should apply to
the current LV102 RailComm-compatible booster). But that requires buying a
US$180 booster to replace the perfectly good power station built into my
DCS100. And it assumes that the LV102 will condition a DCC signal from the
DCS100 to add the cutout, which isn’t guaranteed (it depends on who creates
the preamble bits, and how smart the LV102 is about processing them if it
doesn’t create them). An $80 cut-out device is much more interesting.

An Arduino DC Train Controller


I had a very simple problem: I needed a back-and-forth DC controller to run a
tram line (aka, light rail line, in Japanese: 路面電車 or romen densha, literally
“road surface train”, often translated simply as streetcar, even though the
remaining two lines in Tōkyō have very little in-street track). But most of the
devices on the market assume a simple single-tram, single-line arrangement,
and none of the ones that don’t assume shared tracks, at least not in the form I
need. What I want to model is a line with two running tracks with double-track
mid-line stations and a single-track station at each end. Both of the surviving
light rail lines in Tōkyō are built this way: the Toden Arakawa line and the Tōkyū
Setagaya Line.

After I started, I realized that I could use essentially the same circuit to model a
single-track line that used a double-track station in the middle for two trains to
pass. This would be appropriate for a number of smaller rural lines operated by
one or two-car DMU (diesel multiple unit) vehicles. So this is actually a fairly
flexible design, and not limited simply to light rail vehicles. I started building a
simile diorama layout (my One Point Five Meter Line) using this approach.

While these pages are the most up-to-date material on the project, as well as
holding the most detail, the blog posts (Musings) I made regarding the project
as it unfolded may also be of interest. Those are collected under the Tram
Controller categroy. I also have some pages covering the basics of using an
Arduino for model railroad projects that might be useful to read.

A number of the diagrams from these pages are available in larger 800 pixel
versions in the Arduino Diagrams album.

Note: at present this project is once again stalled, partially because I’m not
working on either layout that required it and I’m not sure if of when I will. The
motor control library was completed and published, see the bottom of this
page for location. This won’t run a train on its own, but provides the needed
capabilities to manage a motor shield as a throttle with direction and
momentum.
Minowabashi Station, Toden Arakawa Line (2009)
From Flickr, Photographer: haribote

Eventually I hit on the idea of using an Arduino equipped with a “Motor Shield”
(DC motor controller for Arduino) to run two vehicles back and forth on such a
track. I could have used a fancy computer-controlled DCC system, but then I’d
have to convert all my trams to DCC. And for this application, DCC is a bit
excessive and costly; most of the capabilities I’d gain I don’t really need.

Credit where it’s due: I took the idea of using IR emitter/detector sets (i.e., a
LED/phototransistor pair) from a comment on the Modelrail Otenko blog about
the author’s experience using these for distance sensing. He also has a post
with basic information about using Arduino for train control which probably
planted the seed that became this project. His goals are more lofty than mine
though: I just want a simple out-and-back controller customized to a particular
type of vehicle and speed range.

Warning: The Arduino uses Pulse-Width Modulation (PWM), a type of pulsed


power, to control DC motors. This is fine for most motors, but “coreless”
motors run at low speeds on pulsed power can overheat to the point of self-
destruction. Most DC train motors aren’t coreless, but I’ve heard rumors that
Kato’s Unitram motors are coreless. These are ultra-small motors developed to
make cellphones vibrate by spinning a weight at high speed for a short time.
I’m setting my program up to use “ultrasonic” PWM (which is not the default
on an Arduino), and that should avoid problems with coreless motors. But if
you’re using Unitrams or other coreless-motor designs, you’ll want to be
careful.

Overview
To do this I need some way to use DC that provides for two independently-
controlled low-amperage voltage-controlled power supplies of roughly 0 - 9 V
DC (I don’t need these things to run too fast), and some way to selectively
switch the two end stations between them, as well as independently
controlling the voltage on each. I also need to have some position-detection
capability, so I can stop trains in the station, and know when a train is
approaching the end of the line.

What I’m using for track is Tomix’s FineTrack MiniRail PR140-30 switches and
C140 and C177 curved track (more info and photos). The radius (140mm is
about 5.5 inches) is wide enough that an articulated tram can negotiate it, but
sharp enough to look “realistic” as a tram line next to other train tracks with
gentler curves. There’s a wealth of information about using this for light rail
modeling at the EasyTrolley website.

One of the nice things about this is that these switches are “slip switches”. This
means that a train can run through them the wrong way without derailing. For
example, in the picture below, the switch adjacent to Station A will be set to
send outgoing trains to the red track, and never changed. But a train
approaching on the blue track can run into Station A with no problems. It’s not
all gravy though, these switches are built with power routing circuitry that only
works if the switch is thrown, and if you’re entering from one track and the slip
switch is thrown the other way, there’s a short dead zone on the track. A
vehicle with pickup on both wheelsets will bridge it, but one with single-truck
pickup is likely to stall, particularly at low speed.

The trams I’ll use, at least initially, will be my Modemo Tōkyū Setagaya line
two-car articulated Series 300 cars. I have several of these, so I can vary the
ones running at any given time to add yet more variety (I don’t have room for a
mid-line depot, otherwise I could do even more). I also have some Arakawa line
trams, and one Kato Unitram, just to add some variety.

If I just wanted to run one tram at a time, a simple out-and-back controller


would work (you can buy these relatively cheaply, such as this one or this one,
or I could even build my own). But what’s the point of double track if you don’t
have at least two trams? I want this line to look realistically busy. I could
eliminate the single-track stations and just run two parallel lines, but not only
would I double the electronics cost, I’d lose the “left hand running” of the
prototype system, and that’s part of the character I want to capture. Ideally,
what I want are two trams running back and forth and stopping at all three
stations, pausing, and then continuing, without ever hitting each other.

The tram line is actually part of the Urban Station scene. It runs along the back
behind the buildings (almost totally out of sight, unfortunately) and then curves
across the road and under the viaduct station, so that station C is near the front
of the layout, adjacent to the subway tracks.

Urban Station Scene Tram Line Diagram

Tram at station C
Now to make this work, the yellow and green tracks in the diagram above need
to switch to match the polarity and voltage of the track that the train is running
to/from, and some ability to detect train location is needed. For example, a
train approaching Station A on the blue line must not enter the yellow station
track if there is another train on the yellow track, and the yellow track must
change to the “blue” supply before it can enter. Similarly for the train to
depart, there must not be another train on the red track and the yellow track
must switch to the “red” supply.

The Station A (and Station C) power supply selection is done via a relay, where
a signal causes “Red” to be selected, and the absence of a signal causes “Blue”
to be selected (and the opposite for Station C). Stops will just be done by
gradually adjusting the voltage to zero, for realistic “slow down then stop”
behavior, when the detector registers the train’s presence in the station. The
detectors just short of the station will allow a train to be held while another is
in the station, or to be slowed from “track speed” to “entering station speed”
before negotiating the switch. Similarly a departing train can be kept at a lower
speed until it clears the switch, then that detector can allow it to be set to
“track speed”.

Train detection is needed at the following eight locations: Station A, Red track
at Station A switch, Blue track at Station A switch, Station B Red Track, Station
B Blue Track, Red Track at Station C switch, Blue track at Station C switch, and
Station C. With that, trains can be stopped in stations and approaching the
switches, and we’ll know when a departing train has cleared the switch.
Detection could be done with block occupancy detectors, but those are
relatively complex. A simple photocell (using ambient light) could be used, but
a better method is to use an LED/phototransistor emitter/detector pair, which
allows it to work regardless of ambient light, for night running and operation
below the viaduct station.

Further, I’m going to set up four station-exit signals (one at each station) and
two station-entry signals (one on the blue line just before the switch to Station
A, and on on the red line, just before the switch to Station C). These will be
simple red/green signals with two separate LEDs on a mast (likely NJ
International #2004 signals).

I’ll also add some kind of manual override to allow using the power to position
trains before starting automatic operation, although initially I’ll depend on
putting things on the track in the right place by hand. And I’ll include a pair of
potentiometers to allow “track speed” to be adjusted individually for each tram
(not all of my models will work the same).

Enter Arduino
After thinking about this for a long time, during which I’d read several articles
and websites about using the Arduino microcontroller to operate DC motors in
robots or to act as a DCC command station, and even as a DC throttle for a
train, it finally hit me that it could also be used to automatically control DC
trains (yeah, I’m a bit slow on the uptake). The Arduino is designed to be used
by “artists, designers [and] hobbyists” according to its website. And that’s
reassuring, as while I used to do a fair bit of programming, I find the
semiconductor electronics side a bit daunting. But fresh off designing my car
lighting system, and assembling a DCC booster kit this didn’t seem
overwhelming.

There are a number of different Arduino models to choose from. But there is an
important software difference between the ones I’m looking at and older
designs: the newer ones don’t require driver installs on the computer used to
program them. So I limited my choices to the newer ones.

Due to some issues around which Motor Shield I was going to use (see the
Shields page for information about compatibility) I decided to use an Arduino
Uno, as this was relatively inexpensive (US$30) and easy to find (Radio Shack
sells them). This, however, turned out not to have enough control lines (pins) if
I wanted to add signals, so I switched to use of an Arduino Mega 2560 (US$59).
I actually ended up buying both (and several others besides) along the way, so
I’ll need to eventually find something interesting to do with the smaller ones.

Assuming this all works out (and so far it seems to), I can see wanting to do
other things with Arduino in the future. It’s a very flexible little controller.
Arduino Mega 2560 (original version)

You can do some limited DC motor control straight off the Arduino board, or
build your own motor controller if you need lots of power, but I also discovered
that there is a “shield” (an add-on board) called the Ardumoto ($25), which can
operate two DC motors at “up two 2 Amps each” (we’ll come back to that claim
later). One thing to be aware of: this board comes without the screw terminal
connectors or headers to attach it to the Arduino. That’s fine if you want to
place one remotely from the Arduino and solder wires to it (as many do), but
for my purposes I wanted to attach it directly and piggy-back off the Arduino
power supply. What I should have bought was the Retail version ($30), which
comes with the needed parts (some soldering is still required, but if you’re
afraid of a small amount of soldering, this isn’t the project for you).

Actually, there are now (2013) a number of shields available, and you can find
some of them at the local Radio Shack. My Survey of Shields page has more
information. I still ended up back with the Ardumoto shield.
Ardumoto Shield with headers and screw terminals

Well, that’s not everything, as I also need a pair of DPDT relays (or four DPST
relays), and eight IR emitter/detector pairs. I’ll come to those later. Total cost
for the installed system should be about $100 with all parts included (see
below).

Parts mostly acquired (Feb 2011), I started in on detailed planning, after


discovering I had bought the wrong relays. I also didn’t like the first detectors I
bought (which were oriented to receive light from above, and I found some
that faced sideways instead. Then I stalled out, and didn’t return to the project
for two years.

Power
The Arduino can run on a variety of voltages, but less than 7 or more than 12
can cause problems. I’m going to use a regulated 12V supply, since I can get
one from Sparkfun cheap. If it wasn’t regulated, I’d use a 9V supply to be safe. I
may also wire the motor shield to the layout’s 12 volt electronics bus. The 8 IR
LEDs don’t have to connect to the Arduino at all, just a supply voltage, and I’ll
likely use one of the layouts lighting or accessory supply lines for that.

Stalling Out
At that point, the project stalled for about two years while I worked on other
parts of the layout. I did however connect my Arduino up to a computer and
download my first example program (the “Blink” program), and play around
with modifying it to learn the programming/downloading interface. Except for
the fact you program it in a language very much like C, this is really easy to use
(programming in C isn’t that hard, but there are easier languages for hobbyist
use and I’m surprised they aren’t using one).

Note: it is C actually, or rather C++ an object-oriented dialect of C. Still, they


make it quite easy to use, and there are reference pages and lots of
information for beginners on the Arduino site. Don’t be turned off by the
programming aspect. While complex programs are just that, complex, there is a
lot that can be done fairly easily, especially if you can start with a program or
example that someone else wrote and customize it for your needs. And lots of
people post Arduino programs on line (Google for the word “Arduino” along
with other phrases). I’m putting my programs up for others to use, see the links
at the bottom of this page.

Returning to the Project


After a long delay, I resumed work in April of 2013. I had some new ideas (not
all of which worked) and since then I’ve been working on this fairly regularly,
one part at a time (I spent most of April and early May getting the motor
controller working, then I spent the rest of May and all of June getting the
sensors to work, early July went to some work on controls, before I took a short
break, and in late August resumed working, starting on multiplexed LED signals.
September went mostly to the signals, and to beginning to put everything
together into the actual Tram Controller program. With each phase, I did short
little test programs (some of them I’ve made available online since I think
they’d be useful examples, see the software section at the bottom of this
page). The important code from those test programs will eventually find its way
into my Tram Controller program or the libraries used by it.

Radio Shack stocks Arduinos these days, and along with them are a couple of
motor shields. One is an Arduino design similar to the Ardumoto (part 276-131,
apparently now discontinued), and the other is from “seeed studio” (part 276-
242). This is seeed’s version 1 shield, which is nice in that it has a very large
heat sink, and uses a better selection of pins than the Ardumoto (avoiding the
Timer0 conflict that shield has on the Leonardo). I’d planned to use the V2
version of the seeed shield, but unfortunately it has some kind of design flaw
when used with an external power supply (exactly why I’d wanted to use it)
and I managed to fry mine. Back to the Ardumoto shield for me.

One downside to the seeed was that while their V1 shield is available in the
U.S. at Radio Shack, the V2 needs to be ordered from their website, and so
there will be a shipping charge from China (which is quite high unless you want
to wait several weeks for delivery, and I’m always impatient). So I had to wait,
and pay extra, only to have the darn thing go up in smoke. Some days are like
that.

Updated Parts List


This is my current (likely not final) parts list, excluding track and wiring:

Arduino Mega 2560 (Sparkfun DEV-11061) @ $58.95


Ardumoto Shield (Sparkfun DEV-09815) @ $24.95
Stackable Header Kit for Ardumoto (Sparkfun PRT-10007) @ $1.50
Two-pin, 3.5mm pitch, screw terminals (Sparkfun PRT-08084) (2) @ $1.25
Power Supply (12V, 600mA) (Sparkfun TOL-09442) $5.95
5V DPDT relay (Tycho IM23TS, Digikey PB1169-ND) (2) @ $3.19
Detectors (Sparkfun SEN-00241 the Digikey 160-1065-ND & 160-1063-ND). (8)
@ $1.95 or $1.05

Total: US$108.63

Note: you can get the Detectors from other suppliers like Digikey for about half
of what Sparkfun charges. You’d need to buy a lot for the extra shipping to be
worth it, or be buying other parts though. I also managed to find the Mega
2560 R3 locally (in a “Made in Italy” official Arduino box) for US$35, barely
more than the cost of an Uno. I bought two.

Design
My design for this is relatively straightforward. The Arduino controls the two
throttles, stepping speed up and lowering it down for a reasonable departure
and arrival performance, and a fixed top speed appropriate to the trams. It will
also select which power supply is in use by a section of track, Eastbound or
Westbound (which I’ll abbreviate to “E” or “W” from here on). And all of this
will be coordinated based on inputs from the train detection sensors so the
trains stop at the station platforms and don’t hit each other at the ends. When
trams are moving in one direction, they will be connected to the E power
supply, when they reverse and head in the other direction the same tram will
be connected to the W power supply. Thus the two power supplies never
actually need to change polarity, and I could have wired things to save myself
the need to use the two direction-control pins if I’d wanted to.

As noted, I’m using a shield (circuit board) to provide the two power supplies
rather than building my own power amplifier circuit. The Ardumoto shield uses
two of the Arduino’s digital output pins per motor output: pins 3, 11, 12 and
13, while the seed shield uses a slightly different approach with three pins per
motor. Each motor has a speed pin and one or two direction pins. Maximum
amperage is relatively low (although the seed could probably drive a pair of
small HO motors). My needs are well within even the Ardumoto’s safe bounds,
which are around 600 mA total current without some kind of added heat sink.

I’ll use some relays to switch the track in the two stations between the “East”
and “West” motor supplies. The east and west motor outputs never change
direction, and are always connected to the east-running and west-running
tracks respectively. This design could actually allow me to run three trams: one
in an end station, and one running on each of the running lines. When a tram
enters the empty end station, the tram at the other end can start down the
line, and the tram on the other running line will be able to enter the now-free
station, clearing its line for the tram at the far-end station, and so on.

But to make it work, I need to know where the trams are, and that means I
need sensors. And because I want the tiny plastic people driving the trains to
know when it’s safe to leave a station or enter then end stations, I’ll need some
signals. In the schematic diagram below, O1 to O8 are the optical detectors
that let me know when a train is passing a certain location, and S1 to S6 are the
signals (all are two-color red/greed except for S2 and S5, which will be three
color signals but will only ever display yellow or green.

Simplified Track Diagram showing sensors (On) and signals (Sn) as well as two
trams (T1, T2)

Sensors

Sensors are actually fairly simple in concept, but to use them efficiently, I’m
going to complicate the design a bit.

First the basic idea: to know where a tram is, an infrared LED (emitter) is placed
on one side of the track, level with the body of the tram. On the other side of
the track a phototransistor sensitive to infrared light is placed. Using infrared
makes it less likely that sensors will be confused by room lighting (well, not
really, that turns out to still be an issue), and using an emitter/detector pair
makes calibrating the sensitivity of the sensors simpler, and also allows them to
work in dark areas such as underneath the viaduct station.

But because I need 8 sensors and the Arduino is limited in the number of
analog pins, I need to multiplex them. I can share the outputs and inputs
between multiple sensors in a way that will allow me to read one at a time,
while using as many as the product of the pins. My original plan was to use four
outputs and two inputs to control eight sensors. If you need to multiplex a lot
of inputs (or outputs) there are specialized chips that reduce the number of
required pins even more, but I don’t need that and I want to avoid unnecessary
electronics (just one more thing to get wrong). For simplicity, and because I had
enough pins, I’m actually going to simplify this further.

There are some power limits to this I need to watch out for, which I’ll say more
about later. Time is also a factor: although I’m working with relatively slow-
moving trams, each sensor has to be on long enough to stabilize, and can’t be
off longer than it takes the tram to pass it at top speed. That puts a bound on
how quickly I can cycle through the sensors and how many there can be before
the cycle time becomes long enough that I could miss one, which I’d need to
determine by experiment if I were going to do a lot of these. Thankfully with
only 8, I’ll be reading these far more often than I need to, particularly for slow-
moving light rail vehicles.

Control Buttons
The controls are simple, and consist of two switches and two potentiometers.
These are:
- Switch 1: Auto/Manual: In Auto model the controller is active, in Manual the
auto-stop is disabled (see Throttle section below).
- Switch 2: Clear/Emergency Stop: immediately sets both throttles to zero
without momentum when set to “stop”.
- Potentiometer 1: Set train A maximum or manual throttle (see Throttle
section below).
- Potentiometer 2: Set train B maximum or manual throttle.

This doesn’t allow for manual operation. These controls only affect how the
automatic operation is

Note that the Arduino will continue to run its program regardless of the button
settings, it just won’t do very much when it’s in “park” or “emergency stop”
mode.

Both of these have some implementation complexities. The potentiometer is


an analog control, that need to be scaled to produce a 0-255 value, and it likely
needs some smoothing as well. The switches need to be de-bounced. That
topic is covered in the Arduino Buttons and Switches page in the Arduino sub-
section of my Electricity for Modelers section.
One important comment about the way the motor shield outputs are used, and
how this is affected by the potentiometers. Only the two end tracks switch
between motor shield outputs, the middle tracks are fixed (that part of the
Original Design diagram up above is unchanged). But each potentiometer
affects the top speed of one vehicle. This means that the setting read from pot
#1 will affect motor output A when that output is driving vehicle #1 (basically,
when the tram is moving “east”) and motor output B when that output is
driving vehicle #1 (when it is moving “west”).

Relays
A relay is a simple electromagnet connected to a spring-loaded switch. Off, it’s
thrown one way by its spring, when power is applied the switch is thrown the
other way by the electromagnet. A Double-Pole (DP) switch can switch two
lines simultaneously, which I’d prefer for switching both tracks . It is also
possible to use a single-pole relay and common rail wiring or even two single-
pole relays. A Double-Throw (DT) switch has two “on” settings, allowing it to be
used to switch between two inputs. So the relays I’d prefer to be using are
Double-Pole, Double-Throw (or DPDT) relays to connect one pair of output pins
(the track) to two different pairs of input pins (the East and West power
supplies from the Ardumoto shield).

However, you can get relays preassembled on a shield. The downside is that
instead of two DPDT relays you get four SPDT relays, so you have to throw each
rail separately. That isn’t really a problem, since there should not be a train on
the track when you switch the power supply to that track. The upside is that
the shield handles driving the relay using power from the Arduino’s power
supply rather than through the Arduino pin. That’s important because a relay
uses a magnetic coil and is a power hungry device. The model I’m likely to use
(seeed studios version 2) has four relays that each use 72 mA when they’re in
“closed” state, much more than the 40 mA limit of a pin. So if I were driving
these directly, I’d need to rig up a transistor and use it to power the relay
(which is what I expect the shield is doing).

This does take up to 250 mA of my power supply, which makes it, aside from
the trains, the most power-hungry part of this system.

One downside to the seeed shield is that is does use the Arduino power supply,
and the sudden change of two relays being thrown and adding 144 mA of load
might affect other circuits.

Throttle
The original concept had a “one size fits all” approach to the speed the trams
would run at. Along the way, I realized that this was a bad idea (due to gear-
ratio and motor design differences) and that I needed a way to adjust the
maximum voltage used for individual trains separately so I could speed-match
them. This led to adding two potentiometers.

The potentiometer, or “pot” for short, is a device with three electrical contacts
(a rheostat is similar, but has only two contacts; don’t use one of those by
mistake). These are available in several types, and for this application the
“linear taper” version is preferable because the numbers read by the Arduino
are proportional to the distance the control is turned. For an actual throttle
used to run a train directly, it might be preferable to use a “log taper” (aka
“audio taper”) model, as these produce less change in the returned value for
degree of rotation at lower throttles, and more at higher (see this excellent
explanation of how they work), allowing for finer control at low settings.
However, since my experience is that even slow speeds need a high setting
(unless I want to do some additional mapping of the control) I’m going to use
the linear version, at least initially.

At first I’d planned to use one pot (and thus one analog pin), with two buttons
used to “learn” a top speed for each throttle from it. When button A was
pressed, the pot would have been read to set the maximum speed for throttle
A. When button B was pressed, it would have been read to set the maximum
speed for throttle B. This, however, needs two digital pins, which were in short
supply when I was designing for the Uno, plus one analog pin. I went to two
always-active potentiometers (two analog pins, zero digital pins) as a result.
Even with more pins, I think this is a simpler design in several ways, so I’m
going to stick with it.

One reason for that was that I realized that this allowed a relatively crude
manual control mode to be added as well since the pots would be always live
and could be associated to one tram. Although I don’t have the extra pins
needed for a pair of direction switches (well, I do now; but I’m not sure that I
need them), I came up with a way to do without these. This idea behind this is
that in “manual” the each pot will control the voltage for one tram. The auto-
stop function will be disabled except at the end of line stations, but the sensors
will still be live, and when a tram is in an end station, once the pot is set to
zero, the direction is reversed. A “hold down” will be needed to keep power
from being applied even if the throttle is turned up, until any tram on the track
leading away from the station has reached the far-end station.

What this does is allow me to stop, or not, at intermediate stations. So, for
example, I could add other “flag stop” stations that don’t have sensors along
the line, and stop at them manually. Additionally, because the end-of-line auto-
stop is still engaged, if I’m busy with one tram and the other reaches the end of
the line it will stop rather than crashing.

A potentiometer is one of the simplest Arduino controls to use. The outer two
of its contacts are connected to the Arduino’s +5 and Ground pins to create a
voltage across a resistor, and the middle pin, which is internally connected to a
“slider” that moves along the resistor when the shaft is turned, is connected to
an analog pin (I’ll use A0 as my example). When the analog pin is read, it will
sense a voltage between zero (if the slider is at the ground end) and +5V (if the
slider is at the far end). These voltages are reported as an integer from 0 to
1023. This will need to be scaled to the throttle range (0-255) and this value
stored to serve as the maximum value for the train’s speed.

Here’s the essential Arduino code to read one:

const int MAX_POT = 1023;


const int MIN_POT = 0;
const int potPin = A0;

int readThrottle()
{
int th = constrain ( analogRead(potPin), MIN_POT, MAX_POT );
return( map( th, MIN_POT, MAX_POT, 0, 255) );
}

This defines a function which when read returns a number from 0 to 255
corresponding to how far the knob on the potentiometer has been turned. The
MIN and MAX values can be changed if the pot you are using does not go all
the way to 0 or 1023 (e.g., if you test it and it only goes to 1012, set MAX to
that value and readThrottle will output 255 when the pot returns 1012).

While there are many different maximum resistance ratings for


potentiometers, a 10 K ohm one is a good choice for use on an Arduino (the
data sheet for the Arduino supposedly says “10K or less”, although I can’t find
that statement, and higher ones may work acceptably; it’s likely the intent is to
keep the pot resistance well below the 20K ohm internal resistance of the
analog pin, to limit current). Values above 1K ohm will be more efficient of the
Arduino’s limited power supply than lower values. If you use one rated 100
ohms, 50 mA will go through the pot, which isn’t a huge problem as the +5V pin
is limited to the board’s limit of 500 mA (in some cases it can handle more). But
it’s never a good idea to waste power if you don’t need to; you may need it for
something else. I’m using a 10K ohm pot; they’re easy to find (Radio Shack 271-
1715 or equivalent) and the best match for the Arduino’s requirements.

Note: some potentiometers come with a switch, which is thrown when the
shaft is pushed in rather than turned. You could use this on a single digital pin
as an A/B switch (for example as a direction control). If you do that, the
circuitry may get a bit complicated, since you’ll need a pull-up or pull-down
resistor to keep the input pin from “floating” when the switch isn’t thrown, and
also a LED so you’ll know if it’s in the A or B states. That’s all feasible (and could
even be fun to figure out), but I don’t have the pins to spare and I don’t need
additional switches, so I won’t be doing that.

Signals
And then I decided to add signals. These will be multiplexed, with six two-LED
signal masts driven by five digital pins. For more about how I’m doing this, see
my Using LEDs with Arduino page. Unfortunately in doing this, I ran out of pins,
and had to step up from an Arduino Uno to the Mega 2560, which has more
pins available (at twice the cost, normally, although I found one on sale).

The LEDs will be be pulsed, but quickly enough that they appear to be always
on. But at any given instant at most two LEDs will really be activated. The
signals I’m probably using (NJ International #2004) use 10 mA LEDs, and I’ll light
two at a time with the way I’m driving them, so this uses up (2 x 10 mA) = 20
mA of my power budget. The power dissipated in the resistors is tiny, so 1/8 W
(125 mW) resistors could be used, but it will probably be easier to find 1/4W or
1/2W resistors, and those can be used equally well. Also, 100 Ohm resistors can
be substituted for the 91 Ohm ones (91 is a standard 5% size, but may be hard
to locate; I have a local store that sells them).

The actual wiring for this is “charlieplexed” rather than simply multiplexed, and
rather complex. See my Arduino LED page for a full diagram. I’ll only be using
the first six (or four for the One Point Five Meter Line) of the ten LED pairs
possible with five pins. The software for charlieplexed LEDs is also more
complex, but it lets me drive 12 LEDs with 5 pins, rather than the 7 pins a
simple multiplexing scheme would require (or the 12 I’d need if I just wired
them directly to ground). Since I don’t have to fit this in the Uno any more, I
could have reverted to one of the simpler methods, but I expect I’ll use this
technique again, so I decided to get it working now, so I’d know how it worked
next time.

After some thought, I realized that the two signals allowing trains into the end
stations ought to be three-light signals. They’d only ever display yellow
(caution) or red (stop), and wouldn’t use the green, so electrically they’re the
same as a two-LED signal. Ideally I’d make these four-light signals so they could
display yellow-over-yellow on a single head (that’s a “speed restriction”
indication, typically meaning a 25 kph limit), but unless I want to scratchbuild
or hack a Tomix signal that’s not an option, so for now I’ll plan to use the NJI
#2005, 3 color, silver, signal mast.

Summary of Controls and Pin Assignments

My current, and hopefully final, plan is to use an Arduino Uno as my controller,


an Arduino Motor Shield, and a Seed Studios Relay shield (all presently
available from Radio Shack, although the motor shields are on clearance and
seem to be being discontinued).

The following pin assignments will be required:

Motor Shield: 3, 11, 12, 13 (Ardumoto shield)


Relay Shield: 4, 5, 6, 7 (seeed version 2 relay shield)
Sensors: 2, 10, A2 (16), A3 (17), A4 (18), A5 (19)
Throttle Pots: A0 (14), A1 (15)
Switches: 8, 9
Signals: (22, 23, 24, 25, 26 - on the Mega)

This design, before I added signals, used every pin on the Uno except 0 and 1,
and those do double-duty for the Arduino’s serial driver, so using them can be
problematic. When I decided to add signals, I had to switch to use of a Mega
2560 Arduino, at twice the cost. But now I’m not short of pins. I’ll still multiplex
things; someday I may have a use for the other pins, so I might as well be
efficient.

This is not by any means the only way to arrange things, it’s just what I ended
up with.
Train Operating Logic

The Arduino has to follow some basic rules to make the trains run, which will
be encoded in a program. The program logic really only needs to know about
three speeds: stop (throttle at 0), “run slow” (throttle at a relatively low speed)
and “run fast” (throttle at a scale 40 kph). However, the actual throttle output
set by the program will ramp up or down between these values with some
delay for realistic acceleration and braking using the momentum function of my
library. As trains move down the line, they’ll pass or be stopped at occupancy
detectors made up with simple infra-red LED emitter/detector pairs as
described above. The program will react to these events (sensor becomes
blocked, sensor becomes clear) by changing the throttle or power supply of
one of the motor shield outputs, and possibly by switching one or both end-of-
line stations to use the other motor shield output (which effectively reverses
direction, since each motor shield ends up always being set for one direction).

As trains move about, they’ll be held at stations for a reasonable boarding


period (tens of seconds). Because one train can’t be released from an end
station until after the other train has arrived at the far end single track (two
trains can’t share the same line) this will tend to synchronize the two trains to
keep them as far apart as possible, although I’m planning to randomize the
timers somewhat, so they don’t look artificially in sync.

Also, while I’m building this as a two-track line with stub end stations, nearly
the same program will work for a single-track line with a mid-point double-
track station. In this layout, a train can be moving over half of the track while
the other one moves over the other half, going down to the end station,
stopping and waiting, then returning to the middle. This is a reasonably typical
design for a single-track branch line with a passing station in the middle, or the
kind served by small one or two-car DMUs. That’s not what I want to model on
the main layout, but I’m using that variant for my One Point Five Meter Line
display layout.

The following diagram elaborates the plan some, compared to the original
diagram at the top of the page. The sensors now have logical names,
corresponding to the Sensor Design circuit diagram up above, and the middle
station has been split into two stations since the two halves operate
independently.

I’ve removed the high-level overview of the operating program that used to be
listed here, as I’ve realized that it has some errors. I’m working on a revised
design, but that will probably go straight to code (which will eventually be
available), rather than being listed on this page.
Line with Sensors

Note that this way these tracks are arranged, a departing tram always uses the
straight line out of the station. That isn’t required by the program or the switch
itself, and I could have done it otherwise, but I thought this way looked more
realistic.

PWM Frequency
PWM, as I’ve described before, has a frequency. When used in DCC decoders,
there is a preference for “supersonic” frequencies, meaning 16 kHz in most
decoders. That’s partly limited by the decoder clock speed, as putting a fast
clock in a decoder raises the cost, and there are limited to the ability of slower
chips to generate fast PWM signals.

But faster-clocked (higher-frequency) PWM has advantages. First, it keeps the


motor’s armature saturated with current, which is both more efficient and
produces less waste heat in the motor. For the typical motors I’ll use,
frequencies “significantly above” 12 kHz are a good idea (12 kHz is the
frequency derived from the time constant of the motor). Second, PWM will
cause the motor to vibrate, and higher frequencies are harder to hear, and thus
less distracting. That first point is particularly important for coreless motors,
used in some model trains, as heating with low-frequency PWM can destroy
the motor. Motor manufacturers often suggest that 20 kHz is a good frequency
(significantly higher and you start to get into inefficiency from switching losses
in the circuitry producing the PWM signal).

An Arduino, by default, produces PWM at 489 Hz. That’s very low, and a very
poor choice for driving a model train engine. One thing I am doing is adjusting
the timers of my Arduino to produce higher-frequency PWM (it’s a fairly simple
software change, if you have the right model Arduino). It turns out the choices
come down to 8 kHz, which I think is too low, 62 kHz, which is probably high
enough to start seeing switching-loss problems, and 31 kHz, which seems like a
really good frequency to me. This is covered in more depth on the testing page.

Because I’m changing the frequency, the pins used to output the PWM signals
(Motor A PWM and Motor B PWM) to the motor shield can’t share the timer
used for internal system clocks (Timer0). What this means in practice is that
Arduino’s based on the AT MEGA 126, 328, and 2560 need to be used if you’re
using the Arduino or Sparkfun Ardumoto shields, and that Arduino’s based on
the 32U4 chip (Leonardo among others) can’t be used. This is discussed in more
detail in the README file for the TrainMotor library linked below.

Stalling Out II
After a burst of activity that ended with the completion of the TrainMotor
library, I set the project aside again. Actually, I’d completed a substantial
portion of the control program, but not to the point where it actually did
anything. And I’d run into some issues with my sensors I wanted to work on
before I continued, but never actually did. Someday I’ll go back and finish those
up, and then probably work on the controller again, but as of mid-2015 it’s
been on hold for over a year and a half. What’s described below is the current
state of things.

Software
For the moment, all I have is a test program that moves a small loco back and
forth a few inches on one track using 31 kHz PWM. It’s a proof-of-concept for
the PWM throttle at this point. I’ve started work on the actually controller
program, which borrows heavily from various test programs I’ve written
already, as well as using the TrainMotor library I wrote. When I have that
working, I’ll update this page and post at least one Musing to describe what I’ve
done.

Proof of Concept Test Program


Both motor shields (Arduino/Ardumoto) work on my Mega. The Seed shield
worked until it fried itself. I’ve put the source for my original test program up
on my site, just unzip and save it to a place where you can open it from the
Arduino application. It’s defaulting to the Ardumoto shield, and you’ll need to
change a constant to make it work with the seeed shield. It’s also only tested
with the Mega 2560 (which should work for older Megas as well).

It starts with a delay of several seconds, to let you start the serial monitor,
before activating the throttles. The throttle values are fixed (edit the main loop
to change them). All it does is move the loco back and forth about 8” (20 cm). It
will output messages to the serial monitor explaining what it is doing. If you try
to run it on an Arduino it doesn’t support, it will blink the pin 13 LED in an SOS
pattern.

I will warn that this is really, really, alpha code. I’ve only tested it with my
sacrificial B23. If you run it with something valuable, and it bursts into flames,
don’t blame me. That said, you can download it here. But you’re probably
better off getting the Train Motor library and its example problems discussed
below.

Note: the original program as written only compiles on the Mega. I should have
tested that, even if I didn’t have a working model of anything else to load it
into. There’s code in there to build it properly to run on older 168/328
Arduinos as well as the new Leonardo, but that turned out not to be quite
right.

Sensor Demo Program


I also have a demo program for the sensors now (download it here). This has
been tested on both my Uno and Leonardo, but all it does is scan up to four
sensors and report when they transition up or down. See the Sensor Testing
page for further info. I’ve made a number of improvements to the sensor code
since that was published.

Signals Demo Program

I created a short program to test (and illustrate) the “Charlieplexing” method I


will be using to multiplex the signal LEDs. That’s available (download it here) if
you want to see it. This is described on my Arduinos and LEDs page.

I elaborated this into (and even published) a complete library for Charliplexed
signals, which is described in a Musing.

Simple Throttle Test Program


I wrote a simple one-train manual throttle using one of the two motor
controllers on a shield. This is a very basic wrapper, with most of the
functionality other than the controls written as a separate library (based on the
proof-of-concept program noted above). Because I think this might actually be
useful to other people, even if it really is still “alpha” code at this point, I’ve put
it online via a source-code sharing site that allows others to copy it and set up
their own versions. The code is all released to the public domain so anyone can
do anything with it.

I’ve posted the source code for the library, including the original oscillate proof-
of-concept and simple_throttle example programs, on github in
KensCode/TrainMotor.

TramController
This is currently under construction (and that project is on hold as noted
above). When completed it will be the program described on this page that
runs two DC model trains back and forth on a line with shared end stations.
Code will be posted to the KensCode github site once it’s functional, but that’s
years away.

JMRI
JMRI is the Java Model Railroad Interface. This is a collection of software tools
for controlling a model railroad. Originally DCC-specific, it has since been
extended to support other types of control environments. JMRI consists of
several tools that operate independently, the two most commonly used are
DecoderPro, which programs DCC decoders through a simple form-based
interface and keeps a database of your locomotives and their decoder settings,
and PanelPro, which allows control panels to be created for accessory decoders
and similar systems. JMRI is available for Windows, OS X (Mac) and Linux
computers, and it is free.

JMRI also provides support for using Internet-connected devices as throttles


(“cabs”) for a DCC layout. This is mainly applicable to Smart Phone use, and
requires an app for the specific smartphone. See the page linked above for
additional details.

This page is about using JMRI for layout control, and this is specific to PanelPro,
although it does touch on some other aspects.

Installing JMRI
This is pretty straightforward, usually: download the program and put the
programs where you usually put applications (on Windows, run an installer, on
the Mac just open the .dmg you downloaded and drag the JMRI folder to
Applications). It’s a good idea to read the release notes for the specific version,
particularly if you are upgrading to a new version, as changes could be
incompatible with older versions and require some work. And backup your old
version first, just in case.

For OS X users, as of OS X 10.11 (known as “El Capitan”) signed drivers are


required by the operating system (and older drivers were not “signed”), so you
need to get a new driver for your USB interface from the company that made
that hardware.

One of the recent trends has been the use of JMRI on Raspberry Pi computers,
particularly as a Wi-Fi interface for smartphones. Older versions of the
Raspbian operating system had some issues with this, although this seems to
have been improved in later versions: the “rxtx” serial library for using the Pi’s
GPIO pins was a problem in older versions, and there was some requirement
around updating JAVA, but both seem to have been fixed as of the “Jessie”
release in late 2015, if not earlier.

There’s a script for installing JMRI on a Pi, although I think it’s specific to an
older release at present. It’s also designed to operate the “screen” of the JMRI
system on another computer, so it installs a version of VNC for remote access.
If you want the Pi to use an attached screen, this is unnecessary and may
require you to undo some things to use a local screen. I haven’t used this script
myself, although I have read it and used the information there to figure out my
own approach to installing JMRI on a Pi.

This is complex enough that I’ve created my own page on installing JMRI on a
Pi. That’s just my way of doing things, and not the only way, but is does
describe the basic things needed under the current version of Raspbian (Jessie).

Once installed, JMRI keeps files it creates in an assigned per-user directory. On


the Mac, this is ~/Library/Preferences/JMRI (the Library folder is the one in
your home directory, but it’s invisible by default on recent versions of OS X; to
reveal it, open a window and go to your home directory, select menu View /
Show View Options, and then click the Show Library Folder checkbox at the
bottom of the list). With Windows a JMRI folder in your home directory is used.
On Linux systems, ~/.jmri is used (that’s a normally-invisible file with a name
starting with a period in your home directory). This is where you can find the
XML files it creates to record panel definitions, among other things.

XML files are human-readable text files with a very specific structure that is
easy for computers to process. However to edit them, you need to use an
editor that won’t try to reformat the file (and it’s really a good idea to make a
copy and save it before trying anything). You can find a number of free editors
designed to work on XML if you look around, or just use a simple text editor.
On the Mac, TextEdit in “simple text” mode will work, except that it always
sticks .txt on the end of the file name, so you’ll need to fix that filename after
editing (XML files end with .xml). I use the freeware TextWrangler myself.

PanelPro
The PanelPro application is for creating control panels to manage a model
railroad. It uses the same control bus (or busses) also used by DecoderPro, so if
you’ve already set up a connection for DecoderPro, you won’t need to do that
again.

JMRI stores everything under a Profile, and you can have more than one. That’s
mostly needed if you use a computer to manage more than one layout, so I’ll
assume you have one and otherwise ignore it.

Within a profile, PanelPro can do two things: create a Layout Control Panel
(using New Panel / Layout Editor) or create any number of local control Panels
(using either New Panel / Panel Editor) or New Panel / Control Panel Editor).
You don’t need an overall Layout Panel to create smaller control Panels. And
the same object (turnout or similar) can be controlled from more than one
Panel, although the actual object only exists once and has the same name and
definition for all panels. The two types of local control panels exist to support
slightly different needs, and I’ll cover that aspect in more detail shortly.

One of my great frustrations with PanelPro is that it doesn’t automatically save


changes to things, or even prompt you to save them reliably (sometimes it
reminds you, but not always). That’s probably good once a panel is defined and
being used by operators, who might change something by accident. But it
means you can spend a whole evening creating a control panel, only to forget
to save it and lose all that work. And this also extends to supporting objects. If
you add an object (like a turnout) and then forget to save that table of objects,
the next time you start JMRI the panel will be referencing an undefined object
and won’t work. I’ve done this too many times. So, figure out how to save
things and save often.

The interface is also a bit “quirky” on the Mac. It really wants to have per-
window menu bars like Windows, but it doesn’t actually do this. Instead the
main menu bar at the top of the screen changes depending on which window is
selected. If you are working on a panel, and need to open the turnouts table to
add one, you need to select the main PanelPro window to get the “Tools”
menu so you can use it to open the Turnout Table. DecoderPro works the same
way, so I’m used to this, but it was really hard to figure out the first time I used
JMRI.

JMRI Objects
JMRI is based on an internal model that uses “sensors” and “turnouts”. A
sensor is anything that reports information to JMRI, while a turnout is anything
that can be controlled from JMRI. Tha’s not limited to just turnouts. Both of
these are simple on/off devices (sensors can’t report anything more complex
than “on” or “off”). With a turnout, “off” is assumed to mean “lined for the
through route” and “on” to mean “lined for the diverging route”. More
complex objects (like blocks) can be built from the simple ones.

Signals aren’t a basic object, but something built atop that underlying
functionality, although they appear as a different class of object. Actually, they
appear as two kinds of objects, simpler “Signal Head” objects and more
complex “signal mast” objects that are composed of multiple heads and follow
a specific set of rules affecting what they can display. This is very useful if you
want to model a kind of signal supported by JMRI. Unfortunately this doesn’t
include standard Japanese MLIT signaling, so I had to define my own set of
rules for this.

In JMRI, objects have a hardware type that relates to the control bus. This
doesn’t appear to be something that can be changed once an object is defined,
so you have to know before creating an object how you will manage it. And you
can’t change the control system without deleting the object and creating a new
one.

That’s particularly bad since it means that if you build a complex layout, and
then decide to change from say LocoNet to LCC as your control system, you will
have to delete every object from every control panel that references it, and
then manually add the new version. In essence, you have to re-create things
from scratch. If you want to get your hands dirty with a text editor, you can
probably fix this with a bunch of batch changes to the XML files that define the
layout profile, but that’s not something most people would want to do.

Each object has an internal name based on the communications system and the
object type followed by type-specific information about how to communicated
with it. So a LocoNet turnout will be “LT” followed by a number, and an LCC
turnout will be “MT” followed by a pair of Event IDs. Sensors are similarly
named LS or MS and signal heads LH or MH (although I don’t think JMRI
supports LCC signals yet).

Each object also has a human-friendly name that’s just a text string. This could
be the label used on a control panel, such as “T11”, or it could be something
more readable like “East Lead”.

Objects also have a “state”, which starts off as “unknown” when the program is
first started (and any past state is forgotten). These can be controlled directly
from the table of objects (there’s a “Cmd” button for each that cycles through
the allowed states) or from a panel linked to the object (where clicking on the
object’s icon does the same thing as clicking the “Cmd” button).

Control Panels
A Control Panel in JMRI is really just a window containing some icons that
correspond to objects in JMRI. These icons can change when the object
changes state (i.e., a signal icon can have different appearances for red or
green signals). But they don’t have to. Also, the icon will very depending on the
kind of control panel. If you want a traditional CTC panel, the track diagram is
just a static graphic, and the icon that controls a turnout is the switch below
the diagram. If you want a more modern look, the icon of the turnout is what
you click, and its appearance will change depending on whether it is lined for a
through route or a diverging one.

Electricity for Modelers


This section (formerly the Layout Electricity section) collects a variety of general
reference information related to use of electricity for model railroading. It’s
where I stick any reference info that doesn’t fit in the other two sections, but
I’ve also included a couple of “Basics” pages to provide background for new
readers.

However, there is additional information elsewhere. See the Electrical Systems


sub-section of The Model Railroad section for topics about the layout power
supply and DCC systems, and see the DCC for Model Trains sub-section in the
Model Trains section for information about installing DCC decoders and similar
systems in model trains.
The “all layout” panel is designed to be used for a more schematic kind of
overview, not attempting to replicate anything prototypical that I’m aware of.
It’s useful if you have a moderate sized layout (or a really big monitor) and
want a birds-eye view of the whole thing at once. The two local control panel
types are better suited for more prototypical kinds of controls.

What’s a Watt?
Basic Electrical Concepts for Model Railroading (DC edition)

This page is an introduction to the basic terminology and concepts needed to


understand electricity as it applies to model railroading. It also includes an
example of how to wire up LEDs (used for building lighting or similar) to a
power supply. It’s not a primer for doing anything complex; there are
undoubtedly better people than I to explain such things. This page is just here
for complete novices.

Model railroads use Direct Current, or DC. This is electricity that always flows in
one direction, as opposed to Alternating Current, or AC, which reverses
direction 120 times a second. That’s not quite a true statement, as model
railroads use AC from the wall to power the DC systems, and they also make
use of Digital Command Control (DCC), which is like AC except that it reverses
direction thousands of times a second.

But DC is the important stuff. It’s what makes the motor in the train run, and
DCC is just a fancy (and optional) way to get DC to the motor. In N-scale, the
standard DC voltage is 12 volts. HO uses 16 volts, and many power-packs for
HO/N scale will put out 16 volts or more, but some models are sensitive and a
12-volt N-scale power supply is recommended.

Note: DCC systems will sometimes have a switch to set voltage, but not always.
Digitrax’s popular Zephyr puts out 14 volts, but as Kato re-sells this for their n-
scale trains, apparently 14 is “close enough” to 12.

Electrical Circuits
In any discussion of electricity, you need to think in terms of an electrical
circuit: a closed loop including the source of power (a battery, or wall outlet, or
whatever) and the “load” (device being powered). Electricity can only flow in a
circuit, and when it does that flow is called the “current” in the circuit.
However, it always picks the path of least resistance to make that circuit, so if
you give it more than one option, it’s usually going to use just one. That’s
another of those not-quite-true statements, as if the two circuits are close in
resistance, the electricity will flow through both, but not evenly. If they’re far
apart (like in a “short circuit” where one path has essentially zero resistance)
one of them will get nearly all of it.

Most people writing about electricity like to use a plumbing analogy, where
voltage equates to water pressure, resistance to pipe diameter (it’s harder to
move water through small pipes, so small pipes are like high resistance wires),
and current to, well, current (rate of water flow). I’m not sure how helpful this
is, unless you’re a plumber to begin with, but perhaps it helps to visualize
things. So, if it helps to think of electricity this way, by all means do so; it’s a
good analogy.

There are three important aspects to electricity: the intensity of the source
(measured in Volts), the rate of flow through the circuit (Amperes of current)
and the difficulty in pushing current through the circuit (Ohms of resistance).
There’s a fourth measure, related to the others, of how much energy is being
used, called “power” (measured in Watts).

A very basic circuit

Volts, Amps, Ohms, and Watts


A volt is a unit of “pressure”, for lack of a better word, abbreviated as “V”. The
higher the resistance in a circuit, the more volts it takes to move the same
amount of power through it. And the corollary is that for a given resistance,
increasing the voltage increases the current flowing in the circuit. But voltage
isn’t the whole story, as a power supply has a limit on how much current it can
provide (its “power”). As resistance goes down, a power supply can provide
more current, but it can’t provide more power than it has, and that will
ultimately limit the current.

Twelve volts DC isn’t all that much; it could give you a mild shock, but that’s
about it at the power levels used for model railroading. However, DCC systems
use more power, and 12 volts of DCC could do some damage with sufficient
power behind it. I’ll come to that in a bit. But basic model railroading uses DC
on the track, and at power levels that are safe even for small children to play
with.

When electricity flows through a DC circuit, it creates a “current” that moves


from “positive” to “negative”. Actually that’s another not-quite-true statement.
Electricity has two polarities, and the actual direction of current between them
is really irrelevant. It helps to think of it as moving in a specific direction, so
long ago one was picked. They had a 50/50 chance of picking the correct one
(this was long before anyone figured out what an electron was), and they got it
wrong. We can thank Benjamin Franklin (yes, that Benjamin Franklin) for that.
But the idea stuck, so even though the actual electrons that make up electricity
move from negative to positive, the current is still said to flow from positive to
negative. Confusing to novices, but it really doesn’t matter.

Current is measured in units called Amperes, or Amps (A) for short. For many
model railroad situations, a more useful measurement is milliAmperes
(milliamps or mA), or thousandths of an Amp. So a model locomotive may
require 500 milliamps to run, and an LED light may need just 30 to 50 milliamps
to light it. Current is abbreviated as “I” rather than “C”, because André-Marie
Ampère was French and he used the word “intensité”, or so I’ve read.

Resistance is what gets in the way of current flowing. Conductors, like copper
and other metals, have relatively low resistance. Wood, plastic, glass and other
insulators have very high resistance. Some conductors are better than others.
The nickel-silver used for rail is a pretty poor conductor actually, which is one
reason it’s a good idea to connect the power supply to the tracks every six feet
or so; it will certainly work if you don’t, but about 20 feet of track is enough to
visibly slow a locomotive due to the loss of power in the rails. Resistance is
measured in Ohms (or sometimes milliOhms) and usually designated with an
“R” in formulas, although the greek letter Omega (“Ω”) is used to label numeric
values (i.e., “R=50Ω” can be read as “Resistance is 50 Ohms”).

Typical 24 gauge copper wire such as Kato uses in their Unitrack feeders has a
resistance of 19 mΩ (nineteen milliOhms) per foot, while code 80 nickel-silver
track has a resistance of 76 mΩ per foot when powering one train, and this
rises to over 300 mΩ per foot when powering several (resistance rises with
increased current). And larger wire has much less: the 14 gauge wire
recommended for a power bus on a DCC model railroad has a resistance of just
3 mΩ per foot in typical use.

Note: it’s easy to get confused when working with volts and milliamps and it’s
generally best to convert everything to the non-”milli” version (i.e., divide by
1,000 and think of “20 milliamps” as being “0.020 amps” instead). If, when
you’re done, the number is less than 1, multiply by 1,000 to get “milli”-
whatevers.

Finally, “power” is a measure of how much electricity is needed to do


something. Power is measured in Watts, which you’re probably familiar with
from the “100 watt light bulb” in a lamp. That’s a bulb that uses 100 watts to
produce a little light and a lot of heat (incandescent bulbs are not very efficient
light sources; most of the power is wasted as heat).

You get watts with DC by simply multiplying voltage (in volts) times current (in
amps), so a watt is sometimes written as VA. AC is a bit more complicated, but
it’s roughly the same. Watts are designated “W”, or “mW” for milliwatts (a
milliwatt is volts times milliamps, or millivolts times amps but that’s not
commonly used). Another way to put this is that P = VI (power in Watts equals
Volts times current in Amps). This is one form of what’s known as Joule’s Law.

Those are the basics: volts, amps, ohms and watts. But there’s one more
relationship to know: remember when I said that voltage is what is needed to
move power through resistance? That’s summed up in “Ohm’s Law”: Voltage
divided by Resistance equals Current (V/R=I). This is more useful when
expressed as V=IR or R=V/I, although all three mean the same thing.

Resistors
Anything that uses power has resistance, but sometimes you need to
deliberately add more resistance to a circuit. That’s where the resistor comes
in. This is a device that converts power to heat (i.e., throws it away), in a very
precise manner.

Resistors come in standard values, and have accuracy ratings. A 100 ohm 5%
resistor could be between 95 and 105 ohms, but would be marked as “100
ohms, 5%” (there’s a color code for the markings). Typical resistors are 5% or
10% types, although you can get more precise ones. However, the cost quickly
goes up for higher precision, and for most model railroad applications precision
isn’t really needed.

Standard sizes for 10% resistors are:


10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68, 82, 100, 120, 150, 180, 220, 270, 330,
390, 470, 560, 680, 820, and so on (e.g., 1000, 1200...).

Standard sizes for 5% resistors are all of the above, plus:


11, 13, 16, 20, 24, 30, 36, 43, 51, 62, 75, 91, 110, 130, 160, 200, 240, 300, 360,
430, 510, 620, 750, 910,...

Resistors also have a power rating (e.g., 1/4 Watt). You calculate the rating
needed based on the voltage dropped by the resistor times the current used by
the connected load (such as a train motor or LED). And it’s a good idea to have
a large safety margin, so if you’re using more than 60-75% (e.g., more than 150
mW to 188mw on a 1/4 Watt resistor), you should step up to the next higher
rating.

Resistance in series is additive. If you need a 30 ohm resistor but don’t have
one, you could connect a 10 ohm and a 20 ohm resistor end to end, and the
result is the same as if you had a 30 ohm resistor.

DC Track Examples

So, to make a concrete example, a train that uses 500 milliamps of current at
12 volts is using 12V x 0.5A, or 6 Watts of power. Not much, compared to a a
light bulb.

For another concrete example, if you have a current of 500 mA (one train’s
worth) flowing through ten feet of track with resistance of 76 mΩ (milliohms)
per foot, then there will be a voltage drop of V=IR = 0.5A x 10 x 2 x 0.076Ω =
0.76 volts due to power lost in the rails, which isn’t very much (the “x 2” is
because you have to count each of the two rails). That lost power goes to heat
the rails, but the amount is so slight you’d never notice it.

DCC Example

But if it were a DCC layout with enough current for six trains (6 x 0.5A = 3
Amps), and a resistance of 300 mΩ per foot (3Ω total) , then you’d have a
voltage drop of V=IR = 3A x 10 x 2 x 0.3Ω = 18 volts, and since you started with
just 12 volts, that means it isn’t going to work at all. This is why DCC layouts
don’t use a single track feeder, but instead use heavy-gauge bus wires
connected to the track in multiple places.

Note: I used 300 mΩ per foot in this example because resistance actually goes
up for larger currents.

A DCC Cautionary Note


Because DCC layouts can power multiple trains, they need power supplies that
put out several Amps of power (typically between 2 and 8), rather than the
small supplies used in typical DC power packs (which put out 1 -2 Amps at
most, and often under one Amp). This means that the current can punch
through fairly heavy resistance (and in doing so produce a lot of heat), and
what that means is that two pieces of metal that are close together but not
quite touching (like the wheel of a derailed train and the rail) can actually have
current jump through the air between them (air has quite a bit of resistance,
but if the gap is small, you’ll get an electrical arc across it). And that produces
enough heat to melt metal, and weld the wheel to the rail, or start a fire on any
flammable scenery nearby.

DCC power supplies have circuit breakers to protect against this kind of
problem, but there can be situations where those aren’t quite good enough.
And that’s why I said DCC wasn’t quite as safe as DC. It’s safe enough for an
adult or teen who knows to pull the plug if there’s a problem, but it’s not
something I’d let a child use unsupervised, particularly not with the larger (5A
or more) power supplies.

Power Supplies
There are three important characteristics in a power supply: AC or DC output,
voltage, and maximum current (or power). If you want to power a few simple
accessories or lightbulbs, a typical model train powerpack will usually have an
accessory output that provides a limited amount of AC current. If you are
looking to power LED lighting or other more sophisticated circuitry, you’ll
probably want a DC power supply, rated for 5 to 16 volts (12 volt supplies are
fairly common, and useful), and probably under one amp of current. Larger
supplies are needed for some things, but handling larger currents can be more
dangerous and one large supply is often more expensive than several small
ones.

Note: since the voltage is fixed, you can get power from maximum current
ratings, and maximum current from power ratings. Remember P=VI (which is
the same as I=P/V).

The simplest power supply is a transformer that can be plugged into a wall
outlet. These come in both AC and DC versions (the DC models include a
rectifier to convert the AC output of the transformer to DC). The cheapest
produce “unregulated” power, meaning that the voltage is only approximate,
and may vary. A more sophisticated, and expensive, supply will be regulated to
produce a constant voltage regardless of variations in the input power or load.

Digitrax makes the PS14, a 14-volt, DC power supply with a maximum current
of 300 milliAmps. This has a “stabilized” output (what that means isn’t clear,
except that it probably has some form of regulation). This lists for about US$13.
One advantage of the PS14 is that it has a built-in circuit breaker in case of
overload, so you don’t need to add a fuse.

However, Sparkfun sells a 12-volt, 600 mA regulated supply for US$5.95 that’s a
nice size for lighting or small accessories. And if you buy 10 or more, there’s a
discount. It doesn’t include a circuit breaker, so you should add a fuse (see
below). If you look around you can probably find others around 1 Amp for
reasonable prices.

Such power supplies typically come in the form of a block that plugs into the
wall outlet (this contains the transformer and regulator), with a cord having a
2.1mm jack as the output, but this can be cut off and the supply connected to
layout wiring (preferably via a screw-down “terminal strip” connector, so the
supply can be removed for testing or replacement). Or you can buy a matching
2.1mm socket, and connect that to the layout, allowing for quick removal of
the power supply.

Another option is to re-use the power supply from an old desktop computer, as
these provide both 5V and 12V DC outputs of several Amps. The only
disadvantage of these is that they put out far more power than you’re going to
need (often tens of amps) and are internally fused accordingly. With the
lightweight wire you’re likely to use on the layout, this could pose a fire hazard,
and using a smaller external fuse is probably a good idea. Pick one sized to your
actual needs (1 or 2 amps, most likely).

When connecting any power supply to the layout, it is a good idea to include a
fuse. This will protect the power supply against any short-circuits in the layout
wiring, and conversely protect the layout wiring against an overload caused by
a short-circuit, which could otherwise start a fire or damage the wiring. A
simple way to do this is to use an inline fuse holder of the kind used in
automobile electronics (which also run on 12 V DC). Simply connect one end of
a fuse-holder (Radio Shack 270-1281 for US$3 or similar) to the jack (or other
connection on the positive output of the power supply), and the other to the
layout wiring (perhaps via a screw terminal). The other side of the jack
connects directly to the layout. It is usually preferable to connect the fuse to
the positive side of the power supply (typically the center pin on the plug or
jack) although that’s just a convention in this case. Then insert the fuse
appropriate to the power supply rating (i.e., equal or less than the rating) and
to your needs (at least 20% larger than what you need, but not a huge amount
larger, and in any case less than or equal to the maximum output of the power
supply).

Adding an inline fuse holder to a wall-wart power supply

LED Example
Here’s another example: suppose you wanted to use the Digitrax PS14 DC
power supply to power some LEDs used for lighting buildings and other
scenery. The PS14 puts out up to 300 mA of current at 14 volts DC (so it is
limited to 14 * 0.3 = 4.2 Watts of power). A typical “super bright” white LED is
rated for 120 mW of power dissipation, and 30 mA of current at a “forward
voltage” of 3.6 volts (you’ll note that 0.03A x 3.6V = 0.108 W, not 0.120 W, so
the ratings are obviously a bit approximate). So, just off the cuff, you might
assume that you could power ten of these LEDs off that supply (300 mA / 30
mA = 10). It’s not quite that simple.
First, the PS14 puts out 14 volts, not 3.6. Simply hooking up the LED to it would
overload the LED, causing a “pop” and letting some smoke out, and that would
be the end of the LED. You need to drop the voltage to 3.6 volts. One way to do
this is to use a resistor. Recall Ohm’s Law: R=V/I. You want to take away 10.4
volts (14-3.6) when the current through the LED is 30 mA, so R = 10.4 / 0.03 =
346.6 Ohms.

Resistors come in standard sizes, so you probably can’t find a 347 Ohm resistor.
Also, most resistors are accurate to +/- 10% (some are 5%, some 2%), so you
need to pick a larger resistor (to ensure your voltage is lower than desired, not
higher). The next standard value above 382 (347 + 10%) is 390 ohms, so lets
assume you can get one of those (your actual choices might depend on what
you had at hand or in the local Radio Shack’s inventory). Since it’s a 10%
resistor, that means it’s really between 351 Ohms (390 * 0.9) and 429 Ohms
(390 * 1.1), so it will actually drop the voltage by 10.53 to 12.87 volts, leaving
the LED with 3.47 to 1.13 volts.

Both voltages are below 3.6 volts (the “forward voltage” or Vf rating of the LED)
so that’s safe (it won’t harm the LED). At the lower voltage, the LED might be
rather dim, although this tends to be self-correcting due to the way LEDs and
resistors work (at lower voltage, the LED draws less current, so the resistor
drops less voltage; the end result is that not as much reduction occurs as the
math might suggest). Still, testing the LED and resistor combination to see if it
provides adequate light is a good idea. That combination of LED and resistor by
the way is using 420mW of power (30mA x 14V): 108mW in the LED and the
rest in the resistor. We’ll come back to that.

Note: a LED is a “Light Emitting Diode”. A diode is a semiconductor that will


only pass current in one direction, almost always from “anode” (positive side)
to “cathode” (negative side). If you hook up a LED backwards it won’t light.
Since LEDs normally have a maximum allowed reverse voltage (Vr) that is larger
than their forward voltage it may not be harmed, and this effect is used in
some types of circuit. Still, it’s a good idea to make sure your LED is in the right
orientation, and has the right size resistor, before applying power. Buy spare
LEDs too; you’ll undoubtedly fry a few of them (I do).

In any case, for lighting to work, you need to get the direction right. The
cathode is typically marked in some way: with ordinary LEDs having leads, one
is usually shorter than the other, and this is the cathode. Sometimes other
marks are used (e.g., a “tab” or “band”), or one side of the LED case will have a
flat spot, but these are all normally on the cathode. Unfortunately, surface-
mount LEDs (a.k.a., SMDs) don’t always adhere to this convention, and these
are the really small LEDs most likely to be needed in n-scale applications. LEDs
have specification sheets (usually PDF files downloadable from online sales
sites, or the manufacturer; you can google for the LED part number and the
word “datasheet” if all else fails), and it’s a good idea to read these for any LED,
but almost essential when working with SMDs.

Or, you can just test it. If you have a multimeter with a “diode” mode, that can
be used, otherwise hook up a wire with the appropriate size resistor to a power
supply (either the layout one, or on a workbench) and just touch the two
contacts briefly to see which direction causes it to light. There’s some risk of
blowing the LED when you do this if you’re using a supply greater than 5 volts if
you touch it longer than “briefly”; testing with a small battery would be
preferable.

A Simple LED circuit

Now that’s one LED. You might think you can string a bunch in a row, but each
needs 3.6 volts, and that’s additive so ten would need 36 volts, and you only
have 14 volts to work with. Obviously, one long string isn’t the right approach.

Back to that power supply: it puts out 300 mA at 12 volts, the LED needs 30
mA, so you could hook up ten of them (each with their own resistor) in parallel,
meaning that each LED+resistor chain has one end connected to the positive
output of the supply, and one end to the negative. This does indeed use
300mA, and power ten LEDs, but it’s throwing away most of that power in
resistors.

The answer is to string LEDs together in series, so each string makes the most
possible use of the power supply. This works best if all the LEDs in a string have
the same current (milliAmp) rating, but each string can be different. It is also
important that each string has a resistor, as this helps the LEDs draw the proper
amount of current. Thus the total voltage requirements of each string of LEDs
(before adding a resistor) must be less than the power supply voltage and a
resistor must be added to use the rest.

With this example (Vf=3.6V), you can use at most three in a row, as that needs
10.8 volts, leaving just 3.2, which is less than the amount required for a fourth
LED. You need a resistor to get rid of the remaining 3.2 volts (107 ohms by the
formula above, +5% is 112, and the next standard size is 120 ohms). If you want
to maximize the light output, it is best to get as close to Vf as you can get, by
using a more accurate (5% or even 2%) resistor, and picking one as close as
possible to the needed value (but stay on the high side to avoid over-driving
the LED, which could damage it). On the other hand, lowering the voltage
slightly (using a larger resistor) will lower the current draw, and while this
reduces the output, it also extends the life of the LED. You only need to reduce
the voltage a small amount (perhaps 5%), and the approach described above
essentially does this since the resistor is always slightly larger than needed, but
you could probably use a 150 Ohm resistor and still get a fairly bright LED, using
much less power and extending the LEDs life.

Now, each string of LEDs still uses 30 mA (the current doesn’t change just
because there are three LEDs in a row; more power is used, but that’s because
each LED has 3.6 volts of its own, and uses the same amount as a single LED
(3.6 x 30 mA = 108 mW), there’s just less power wasted in the resistor (3.2V x
30 mA = 96 mW to be precise). And that means you could connect 10 strings
(300 mA) to the power supply, with thirty LEDs total, instead of ten.

Another way to look at this is that when the manufacturer said “300 mA”, they
really meant “300 mA x 14 Volts = 4.2 Watts”. If each LED draws 108 mW, then
a string draws 420 mw (3 LEDs at 108 mW each plus the resistor at 96 mW),
and again you can power 4.2 / 0.42 = 10 strings. Note that the number of
strings (10) is the same in both examples, because it is the string that consumes
420mW in both cases.

A general rule-of-thumb is to load an electrical circuit (i.e., a fuse or circuit


breaker) no more than 80% of its rated load. In other words, not loading the
PS14 beyond 240mA, or in this example eight of the ten strings. And thus,
instead of the ten LEDs you might think could be powered, you can actually
power twenty-four and still have a safety margin. Digitrax actually says that you
can operate three of their DCC units that need 100 mA off of the PS14, so its
300 mA rating may already be the 80% number (or they may be overestimating
the requirements of their DCC equipment). You may well be okay with ten
strings on the PS14. But when working with other supplies, I’d attach a fuse
equivalent to the rated value or less, and load them to 80% of the value of the
fuse.

Note: an earlier version of this page had the capacity of the PS14 computed
incorrectly.

A more sophisticated method for powering LED lighting

For more information about LEDs for model railroad use, see my LED Lighting
page.

The “Panel” type is probably better for replicating older physical control panels
with switches and indicator lights, such as CTC machines (and some really nice
ones have been made that way). The “Control Panel” type can be used for that,
but has additional capabilities that make it better at replicating modern CRT-
based controls (where track color changes when occupied, or locked out for
maintenance).

Unfortunately JMRI isn’t a graphics editor, and you will need to create at least
part of your panel in an external editor, unless you want to use one of the pre-
defined ones. Objects displayed on panels are normally represented as GIFs. It
may be possible to use JPEG graphics also, but all of the predefined ones use
the GIF format. A program like Photoshop Elements can be used to create GIF
graphics, although it’s not very good for editing existing ones. I use it to make
new ones using its internal PSD format, then export to GIF for use.

JMRI can do basic scaling and rotation, so if you need an object to be


larger/smaller, or angled at 45 degrees, it can do that using the basic icon. At a
minimum you’ll probably need to create a background graphic for your control
panel, although there are some pre-defined, and possibly some control icons if
none of the pre-defined ones are suitable. The “Control Panel” version does
have some simply object editing capabilities, for creating circles and rectangles
or setting the background color.

Soldering for Model Railroaders


This page is an introduction to electrical soldering for Model Railroaders,
focused on such basic things as wires and small electronic components.
Soldering brass models is a rather different skill, and one I know nothing about,
and while many of the same basics apply, you should look for a good tutorial on
that elsewhere.

Note: the following is advice based on my own experience and what I’ve read.
I’m not an expert at this and don’t pretend to be, but I’ve managed with only a
few minor burns over the years, so I’m probably doing something right.
Ultimately how you use this advice is up to you; don’t blame me if you manage
to hurt yourself.

The Basics
Soldering isn’t any harder than other craft skills practiced by model railroaders,
such a gluing together plastic kits. There is some basic knowledge, a few skills
to learn with practice, and the need to choose the right tool for the job. Just as
you wouldn’t use super-glue for a part under mechanical stress, you don’t use
acid-core solder for electronics. Learn the basics, and then you can work
confidently, and gradually work your way up to more complex tasks.

Safety tips:

- Just as with power tools, don’t work around pets or children.


- Solder is very, very, hot, and can spatter. Wear safety goggles/glasses at all
times.
- Solder can drip. Don’t hold the work or the iron above anything easily
damaged, like your lap.
- Soldering irons are hot. Pay attention to where the iron is, and put it on a
stand when you can’t.
- Lead is very harmful if ingested. Don’t eat/drink/smoke when soldering and
wash your hands afterwards.
- Smoke from burning rosin can damage your lungs, ventilate your work area
and don’t lean over the work.

I’ll say it again: lead is dangerous, particularly to children. If you use lead-based
solder, be sure to keep it out of reach of children and wash your hands after
handling it, and never do anything (like eating, smoking or chewing on a pencil)
that might convey lead from your hands to your mouth while working with it.

Beyond that, keep the work area clean so the iron’s cord won’t snag on
anything. Use a comfortable seating position that lets you hold the iron to the
work without undue stress. And good lighting is essential. I use a shop bench
with a pair of 40W fluorescent tubes above it, or a halogen desk lamp when I’m
working on a desk or table.

Essential tools:

- Soldering iron (see below).


- Rosin-core solder (see below).
- Clips to hold wires together (see below).
- De-soldering braid for the inevitable mistakes.
- A damp sponge (never re-use this with food utensils or pots/plates; see the
safety tips).

Non-essential but useful tools:

- A stand to hold the hot iron, preferably with a place for your sponge.
- A modeler’s vice and/or a stand with alligator clips to hold the work.
- A tip-tinning tray (you can just use solder for this)
- RMA rosin flux (or equivalent) with a brush or pen applicator (see below)

Work Area
A clean, well-lit area with a chair and work surface at the right height is very
important, as you’re likely going to spend hours sitting there. You also need to
be concerned about keeping the work in place and not dripping blobs of hot
solder on fine furniture. Setting the tablecloth on fire is also likely to be
frowned upon by domestic authorities (and your insurance agency).

My work area is either a table or workbench, with an anti-static mat on it to


protect fine components from static charges. Atop that I place a small board
(my preferred size is about 8” x 8”, but I’ll use whatever scrap lumber is handy)
which protects the mat (and whatever table is under it) from burning solder.
Items not being worked on sit on the mat (or in storage drawers or boxes), and
the “work” (whatever I’m working on) sits on the board, or in a vice or other
clamp that holds it above the board.

Soldering Irons
This first question anyone asks after looking at a selection of soldering irons is
“which do I need?” The answer is “it depends”. If you’ll always just work on
small wires and ordinary-sized electronic components (e.g., putting decoders
into trains), a small, light, pencil iron of 20 to 30 Watts is all you need. If you’re
soldering feeders to rail, a heavier iron (40 Watts or more) may be more useful,
although I used a small pencil iron for this for years with careful use of clamps
(and a few melted ties). And if you want to solder to surface mount
components (like really small LEDs), then a temperature-controlled iron is very
nice to have.

If you’re getting into more complex electronics, there’s value to stepping up to


something fancier. I use a Weller WESD51 today for the temperature control,
but for years I used a simple 20W/40W switchable Radio Shack iron. Although
that one has a number of bad reviews online, it worked fine for me. But for
most people, you’re best off starting with a basic iron and deciding later what
you need, rather than spending a hundred dollars or more on a fancy model
with features you don’t need.

I haven’t tried any of the portable or “instant heat” irons that have come on
the market in recent years. I’m a bit dubious about them, in particular the ones
that use an electric arc at the tip (flowing electricity and small electronic
components is almost certainly a recipe for fried electronics). But for
applications like feeder soldering, where you may need to work on a finished
section of the layout in a tight space, and you can disconnect any electronics
from the track, these might be very useful indeed.

Ultimately, the iron is a tool for applying heat to a point where heat is needed,
and not applying it elsewhere. A low-wattage iron can only apply a small
amount of heat, then it cools down to the point where it’s not melting the
solder (or worse, melting the solder but not heating the object being soldered
enough to avoid a “cold solder joint”). A high-wattage iron can apply too much
heat if you hold it in place longer than needed. In general, a lower wattage iron
is safer for a beginner still learning technique. But higher wattage can be useful
if you’re soldering solid-core wire to flex-track rails (you need a lot of heat in a
hurry to avoid melting the ties). Some irons have selectable wattage.

Really fancy ones have settable temperatures, which is different from just
selecting the wattage. With these, a sensor near the tip reports back to the
controller, and more power is fed when needed to keep the iron at a pre-set
temperature (or close to it anyway). Unless you’re going to be doing a lot of
work with individual circuit components, this is significantly more than you
need for typical “wire and decoder” kinds of soldering, and there’s a high cost
to such models.

Equally important is the tip. Tips wear out and can be damaged, so an iron with
a replaceable tip (make sure you know where to get replacement tips) is a good
investment. The tip puts heat onto the work, so a conical point is most
commonly used, although for fine work with surface-mount components a
“screwdriver tip” or small wedge (really small, about 1-2 mm across) is useful.
Cheap irons will use all-copper tips, which wear quickly and aren’t
recommended for use with lead-free solder. Better models use copper
electroplated with iron.

A grounded iron (one with a three-prong wall plug and a description that it is
“ESD safe”) is a good idea if you’re working on sensitive electronics, but not
needed for track feeder or simple decoder wiring.

These days, everyone has online reviews. Check out the usual stores (Amazon,
Radio Shack) or specialty electronics sites (Digikey under Product Index /
Soldering, or Jameco) to find a good price, and read reviews of a few models on
several sites that have reviews.
And clean and “tin” the tip frequently to make it last (more on that below).
Also, turn off the iron when not in use. Not only is a hot iron dangerous, but if
you forget about it for several hours, it could damage itself. I killed a $40 iron
that way once.

Solder: How Big, What Kind, and Lead or Lead-free?

After the iron, the solder itself is the most important item. It comes in different
sizes, and with and without a rosin core, and now you have the choice of
traditional compounds that include lead (Pb) or Lead-free versions. Let’s get
the last out of the way first. Solder was originally a lead/tin (Pb and Sn)
mixture, now there are more complex formulations available that eliminate the
lead. In some places lead-based solder is now illegal to use on consumer items,
and becoming harder to find in general.

Lead is a neurotoxin. It can cause harm to brains and other nerves, and affects
both adults and children, but children are more at risk as their brains are still
developing. If you have kids, particularly kids who want to learn to solder, lead-
free is the way to go.

But that comes at a cost. Lead-free solder is a bit harder to work with, as it has
a higher melting point. This makes damage to fine components a bit more
likely, and requires a bit more skill to use. Many people still like to use lead-
based solder and claim the safety issues are manageable. That said, safety
regulations may eventually make this a moot point, so learning to use lead-free
solder may be inevitable.

If you do use lead, the risk is reportedly limited to ingestion (eating it). At any
normal temperature used for soldering lead doesn’t vaporize, so you can’t
inhale it. But lead gets on anything that touches it, like your hands, workbench,
and tools. So don’t eat, drink or smoke while working, don’t work on the
kitchen table, don’t re-use a knife used to push your work around for cutting
anything edible, and do wash your hands immediately after soldering.

Frankly, I think washing up after working with chemicals is good advice for any
modeling work; just because you don’t know something’s harmful yet, doesn’t
mean it isn’t. Over the years many supposedly “safe” substances have turned
out to be very harmful indeed. Why take chances you don’t need to?
There are several compounds used for solder, generally described by the
percentage of the different elements in them. Traditional lead solder, also
called 60/40 solder, is a mix of 60% tin (Sn) and 40% lead (Pb), the amount of
rosin isn’t included in the list, but is around 1%. Per wikipedia, 63/37 is
preferred for electronics work. Lead-free solders are typically based on a tin-
silver-copper compound (Sn-Ag-Cu), often with a fourth element added, which
can vary.

The vapor produced by soldering is harmful, but that’s the fumes from the
burning rosin (which is basically sap from a tree), which includes the kinds of
chemicals you’d get off a cigarette, and worse. Repeated exposure can
supposedly cause irreversible asthma, so don’t breathe the fumes.

Solder is sold as a wire on a spool, and comes in three basic forms: Rosin Core,
Acid Core, and Plain. Acid-core solder is only used for plumbing and similar
things, and it can damage fine details (and needs to be cleaned off after use).
Don’t use it. Plain solder is used in some kinds of work where you want to
exactly control where the solder goes by applying rosin separately. For all
normal uses, you want your solder with a rosin core.

Solder is sold in different diameters. The really thick stuff (1/8” or several mm)
is for structural work, not electronics. A heavy-gauge wire (1 mm or a bit larger)
is probably the right size for soldering track feeders and large-gauge bus wires.
Smaller diameters are useful with electronics. But if you get too small, there
won’t be enough rosin in the solder to work properly, and you’ll need to add it
up front (using a bottle with a brush or something similar). That’s mostly
needed with you get down to surface-mount components and solder that’s a
fraction of a millimeter in diameter.

Flux: Rosin and Other Kinds

Up to this point, I’ve used the word “rosin”, because I wanted to be specific.
Rosin is one form of what’s more generally called “flux”. Flux has two purposes,
to remove oxidation and other impurities from the surfaces being soldered
(and to keep it off while working), and as a “wetting” agent, to allow solder to
flow more freely. There are many kinds of fluxes, see this Wikipedia page for
more detail.

All fluxes are corrosive to some extent, as they’re based on some form of acid.
Rosin fluxes are based on pine sap, and come in different grades of activity. The
more active ones require the work (area being soldered) to be cleaned after
use. Grades R (also known as WW) and RMA are the ones to use without
cleaning afterwards, and this is what’s preferred for hobbyist electronics work.
RA-grade solder requires cleaning, although the wikipedia page says that some
compositions do not. Cleaning, however, could be with a damp lint-free cloth
or alcohol wipe or swab dipped in alcohol, whereas more active fluxes would
need more careful cleanup.

Cleaning of the soldered joint is needed if an “activated” flux that might have
left acid behind was used. This prevents long-term degradation of the joint. The
alternative is to use a “no-clean” flux (which typically means “R” grade rosin
flux, although as noted above cleaning isn’t strictly necessary for RMA and
some forms of RA rosin flux). However, these don’t do as good a job of cleaning
or wetting.

In general, RMA flux will give you the best mix of features for hobbyist work:
sufficient activity and “wetting” for ease of use, without the need for cleanup.

However, rosin itself is falling out of favor due to its own toxicity issues (more
related to groundwater pollution from discarded electronics), and being
replaced with other kinds of “flux”. These new fluxes are known generically as
“water-soluble” fluxes. Often these are “no-clean” fluxes (equivalent to R-grade
rosin flux).

In addition to flux-core solder of various kinds, flux is also available in liquid or


paste form, and in pens that can be used to apply it in small quantities to
specific locations.

Cleaning and Tinning the Tip

The tip of the soldering iron is the part that conveys heat from the heating
element in the iron to the item being soldered. For maximum efficiency, it’s
important that this tip have a layer of solder on it, and be free from burnt rosin
or other debris. You also don’t want excess solder clumped on it.

A damp (not soaked, just damp to touch) kitchen sponge is the easiest way of
cleaning the tip. Just buy a bunch of these in a light color, and throw them
away when damaged too much. You can also buy special iron-stands with a
space to keep the sponge, and these are handy (you can always cut a normal
sponge to fit rather than buying expensive replacement sponges). While
working, use brief passes across the sponge to clean debris and excess solder
off the tip (let the iron heat back up for a few seconds after this). When debris
builds up on the sponge, you can usually wipe it off with a finger when holding
the sponge above a trash can. Toss the sponge and get a new one when you
can’t clean it (or if the surface has gotten burned because you let it day out
while using it).

In industrial applications, use of specialty sulfur-free sponges and de-ionized


water are recommended, but both are unnecessary for hobbyist soldering. It’s
all about tip wear and how often you need to replace it, and contamination of
solder joints with foreign substances and the effect that has on reliability. None
of that is likely to matter much in small-scale model railroad applications; I use
tap water, although I do buy the special sponges, but that’s mostly a matter of
convenience, as I can get them at the local electronics supply store.

Note: as mentioned previously, keep solder away from food. Don’t wet the
sponge in the kitchen sink. Fill a small cup with water and pour on the sponge
outdoors or over a bucket if you don’t have somewhere else to wet it.

To “tin” the tip, get the iron hot, touch the end of the solder to the tip to melt a
small blob onto the tip, roll the iron around and re-touch the solder as
necessary to coat the whole tip, then wipe off any excess on the sponge. Expect
hot solder to drip while you’re working. A correctly tinned tip should be shiny
silver all over the point. Re-tin whenever simple cleaning on the sponge isn’t
enough, which means often.

Surface Preparation: Cleaning the Object to be Soldered

Solder works by bonding to metal. And to do that, the metal (both pieces)
needs to be clean of dirt and even oxidation. The “flux” in the solder (typically
rosin) does part of this, but it can’t do it all. You need to start with a clean
surface, and in some cases you may need to add flux directly to the surface.

With insulated wire, when you strip the insulation you expose wire that hasn’t
had much opportunity to oxidize. That’s generally sufficient. To make things go
quickly you can “tin” the wire, in much the same way as you tinned the iron’s
tip, but you need to have clean wire first. If the wire was previously stripped
and you can’t cut off the exposed end and strip more, fine emery cloth or a file
could be used to clean it, or a commercial “contact cleaner”, although many of
those leave a residue behind that could interfere with solder.
For track, not only do you need to remove oxidation, but if the rail has been
painted or treated with a “weathering” compound, you need to remove that
from the part where you’re working. Soldering to the flat underside of the rail,
which you can clean with a file and emery cloth until it’s shiny, is easiest.
Soldering to the outside of the rail is harder to do in this regard, because it’s
harder to clean it. A glass-fiber pen, which can be found in auto-supply stores
where paint for repairing chips is sold, can be used to clean small, hard-to-
reach areas. But be careful, as these shed small glass fibers, which can irritate
your skin (wear gloves, and if possible wipe the part with an alcohol wipe or
swab or similar afterwards, to remove any fibers and loose dust).

When you solder with rosin-core solder, a small amount of rosin is released as
the solder melts, and cleans the area where you are applying solder of
remaining oxidation and other impurities. But rosin boils quickly at soldering
temperatures, and if it boils off it can’t do its job. This is one reason you apply
solder to the metal surfaces being soldered, and not to the iron (the other is
that the metal needs to be hot too, to form a good joint).

Flux can be applied in advance, using a brush or other applicator. This can be
useful as a way to clean hard-to-reach places. Because flux also serves as a
wetting agent, which allows solder to flow easily, this can be used to more
precisely control where the solder goes (in this case, solid solder could be used
rather than rosin-core solder). As noted above, the kind of flux used matters, as
you don’t want to have a corrosive one on an electronic circuit or wire joint
(unless you clean it afterwards, and that’s hard to do well for the more active
fluxes). Even with RMA flux, you want to use the minimum necessary, not
slather it on the parts.

Holding the Work: Clamps and other Tools


Since solder is molten metal, you can’t hold the part being worked on with your
hand (this should be obvious, but you’ll likely learn this the hard way a time or
two before it sinks in). Further, since it takes time to cool, the two objects
being soldered can’t be allowed to move until it has cooled sufficiently to form
a bond, which takes several seconds. Finally, since the points being soldered
are often surrounded by other parts that could be damaged by heat, you need
some way to keep the heat from spreading. In general, a few small clamps will
do all of this.

Oddly, one of the best tools for the job is a surgical hemostat. This is a small
clamp made entirely of metal that locks in the closed position. These are
chrome-plated, which keeps solder from sticking to them. They come with
smooth or serrated jaws, and with straight or angled tips. I prefer the angled-
jaw version with serrated tips for track feeder wiring, using two of these (one
at each end of the length of wire touching the rail). This both holds the two
securely together, and also serves as a heat sink, so adjacent plastic ties are
much less likely to melt. You used to be able to get these at Radio Shack, but
you’ll probably need to order online from an electronics specialty store now, as
they seem to have dropped off the Shack’s online catalog.

Hemostats are, unfortunately, a bit large and clunky for fine work. You can get
special soldering clips made of aluminum (which has the benefit that solder
doesn’t stick to it very well), and these work fairly well, although the springs
are too strong for really fine items, and can bend them. Chrome-plated clips
used by hairdressers also work as heat sinks, and have gentler springs. You can
often pick up a bag of several dozen for only a few dollars (they work well for
other model-clamping tasks also).

With surface-mount components (or similarly small items), you need to clamp
the objects rather than the point being soldered, which isn’t ideal. I’m still
working on the right way to do this when you have something like a surface-
mount LED and a wire, but no “surface”. I’m pretty sure the answer involves
growing a third arm (alligator clips can also work).

Tip Temperature
If you have an iron with an adjustable-temperature tip, your first question, like
mine, will likely be “what’s the right temperature?”. Again, the answer is “it
depends”. Solder melts at different temperatures depending on its
composition, but you want the tip temperature to be sufficiently above that so
that even as it cools in use, it’s still making the objects being soldered hot
enough to melt solder.

Lead solder melts at 183°C (361°F) or below. Lead-free solder has different
melting points depending on the compound, from 187°C (369°F) for “Sn77.2
In20 Ag2.8”, a common form used in electronics, to temperatures of 230°C
(446°F) for more specialized forms, and even as high as 250°C (482°F). But you
want to be hotter than that, as the tip will cool quickly as heat flows into the
item being heated, and the two need to equalize at a temperature above the
melting point.
The recommended temperature depends on what you’re using for solder, and
on other constraints. I’ve seen a recommended range of 316°C to 371°C (600°F
- 700°F) for lead solder, and 371°C to 426°C (700°F - 800°F) for silver-solder or
lead-free solder. However, I’ve also seen 400°C given as an upper limit.

And several recommendations have been to start low (around 260°C/500°F)


and raise the temperature until you get “the desired result”, which isn’t the
most helpful tip I’ve ever seen.

One very specific tip (which I can’t find now) said to use 288°C (550°F) for lead
solder, and to raise it about 28°C (50°F) for lead-free. The latter seems
excessive to me, since the difference for typical electronics solders between
lead and lead-free is around 4°C.

I initially tried using 288°C (550°F) when I purchased an adjustable-temperature


iron, using lead-based solder. This didn’t work as well as I hoped, and I
switched to a temperature of 343°C (650°F), which has worked better, for both
through-hole semiconductor components and wires up to 16 gauge.

More Info
Tutorials:
Aaron Cake’s How to Solder - An excellent overview, with a fair number of
photos
Circuitrework.com’s Soldering Basics - Fairly terse
Instructables How to Solder guide - an ad-heavy guide, but with lots of photo’s
and detail
Sparkfun Electronics’ SMD How To - a guide for how to solder surface-mount
components, excellent!
Tips and other References:
Cooper’s Better Soldering - a short manual focused on tip care and forming a
proper joint on through-hole PCB components.

Wire for Model Railroads


Model Railroaders are a thrifty bunch, and will often recycle wire from previous
layouts, junked hardware, excess wire from other projects, and other sources.
This can lead to a variety of different kinds of wires being used. Wires will
typically be either copper, tinned copper (typical of some data cables and
“hook up wire”) or in some cases aluminum although that’s less likely. Wire is
typically stranded and insulated with inexpensive but bulky PVC insulation.
Solid wire may be used for DCC bus wiring (although it’s hard to work with; I
prefer stranded myself). And wire with specialty insulation, such as “magnet
wire” with thin enamel insulation, may also be used.

Note: in almost all cases electrical wire will be made of soft annealed copper,
however aluminum is sometimes used to reduce cost. Aluminum has a higher
resistance, and thus a larger gauge wire will be required to carry the same
current as copper.

Wire
If I were starting from scratch, knowing what I know now, I’d use tinned marine
primary wire for DCC bus and control panel wiring, and tinned hook-up wire for
track feeders, electronics wiring, and DCC decoders. I expect to use magnet
wire for some specialty lighting and decoder applications, but not otherwise.

I cover the application of wire to model railroads on my DCC Layout Power


page, but for additional information including some real-world resistance
measurements of wire, see Allan Gartner’s Wiring for DCC site, in particular the
Track Wiring page. Note that his resistance numbers are typically for a pair of
wires of a given length, while mine are for a single wire, so mine need to be
multiplied by two, or his divided by two, for comparison.

Wire Gauge and Size

The size of wire is measured in a number of different ways. In the U.S., the
American Wire Gauge (AWG) system is still used. Other similar systems in the
rest of the world (like British Standard Gauge) have largely been replaced with
metric systems. In “gauge” systems, a number refers to a typical cross-section
in an indirect manner (it can be calculated, but it’s usually easier to look it up in
a table). In metric systems what is usually given is the number of strands (which
can be 1 for solid wire) and the diameter of the strands, which can be used to
directly calculate a cross-section. For example, 14 AWG wire has a cross-section
of 1.94mm2 when made from 19 strands (typical) and 2.08 mm2 when solid.
Although the solid wire can carry slightly more current because of the larger
cross-sectional area, for all intents and purposes the two are identical. Identical
metric wire would be specified as 19x0.36mm or 1x1.65mm wire. Metric
40x0.25mm also has a 2.0mm2 cross-section, and thus is roughly equivalent.

The following table lists two typical strandings plus sold wire, with the diameter
(in millimeters) of each strand. If you have a digitial micrometer, you can
measure an individual strand and count the number to determine what gauge
the wire is. The cross-section in square millimeters is also listed. This is for for
solid single-strand wire, but stranded wire will have a similar aggregate cross-
section.

Some typical wire types

Wire Types
Wire used for a model railroad likely falls into one of the following categories:

House Wiring:
Wire intended for in-conduit commercial AC use (identified on packaging as
type THHN, TFFN or TFN) can be either stranded or solid, and typically uses
bulky high-voltage PVC insulation with a slick nylon coating, making it much
larger than other forms of wire. The advantage is that it can be relatively
inexpensive (not that copper is ever cheap) and when used for bus wiring, bulk
is rarely a problem. THHN is available with insulation in standard colors based
on the electric code in effect in your area.

This wire can also be extracted from two-conductor “romex” used inside house
walls, although in that case wire insulation colors will typically be limited to
black and white.
Bus wires are the main application for this, particularly for long distances or
when large-amperage command stations are used. The stiffness of the solid
form of this type of wire makes it a poor fit for wiring inside control panels, and
even stranded can be a bit stiff for such use due to the thick insulation. This
wire is typically sold in 500’ spools, but some stores will sell it by the foot (at a
higher price, of course).

I’ve read some misinformation online about thicker wire somehow being
unsuitable for DCC frequencies. While there’s some minor skin effect reduction
in effective capacity for larger wire, this never overrides the gain in capacity
from having larger wire in the first place. And it’s generally a trivial reduction. If
you need heavy wire to push high-current track bus lines over a longer
distance, there’s no problem (other than how hard it is to work with) in using
12-gauge (2mm dia.) or even 10-gauge (2.5mm dia.) wire. That’s probably
mainly an issue for garden railroads though.

Zip-Cord:
Zip-cord (aka lamp cord, aka speaker cord), two stranded wires sharing a single
jacket, although made for household AC use, is closer in structure to Primary
Wire. Zip-cord is typically good-quality annealed copper wire. It comes in a
variety of gauges, although typical lamp cord is 16ga or 18ga. Insulation is
typically bulky PVC and not color-coded although often available in black, white
or brown insulation. Speaker wire will have one of the two wires marked so
that positive and negative aren’t reversed, but standard lamp cord may not.

While this could be used for bus wires, at least for shorter ones, it’s a fairly
poor choice due to the bulky insulation and typical wire gauge. It’s also not
really suitable for insulation-displacement taps, or for stripping mid-wire, to
connect feeders. Finally, placing the two wires really close to each other
without twisting them around each other can actually cause some signal
degradation for DCC, which makes zip-cord even less desirable.

It can still be used for smaller layouts where you aren’t approaching the limits
of length or power handling.

Primary Wire:
Primary wire (also known as Marine Wire) is low-voltage wire in larger gauges,
typically of stranded copper. Insulation is typically PVC. Because of this, and
because the insulation doesn’t need to be as thick as in wire for commercial AC
use, it is more flexible than THHN. This may be available in relatively short
lengths (I get it in 25’ packs from the local home supply store; it’s also available
in 100’ spools). This is suitable for DCC bus wiring and wire inside larger control
panels. Primary wire is available with insulation in a variety of colors.

This wire may be found in automotive-supply and marine-supply stores, among


other sources. The marine form is often tinned to resist corrosion, which likely
has some long-term benefit in model railroad applications.

Hook-Up Wire:
Hook-Up wire is a specialty wire available in a wide range of sizes. This is
typically stranded wire of either copper or tinned copper, using PVC or more
specialized insulation. Tinned wire is coated with tin (or in some cases silver or
gold, but those materials provide little real benefit for the cost) and has a
slightly higher initial resistance, but will increase in resistance less over time, as
tin does not oxidize the way copper does (an oxide coating increases wire
resistance). Tinned wire can be distinguished from aluminum wire by scraping a
bare piece of wire with a razor blade, which will reveal the reddish color of the
copper if present. This is typically sold in 100’ spools, although it is sometimes
available in shorter sizes. Hook-up wire is available with insulation in a variety
of colors.

Wire recycled from computer cables is likely to be similar if not identical to


hook-up wire.

Some (rather expensive) forms of hook-up wire use specialty insulations that
are thinner than typical PVC insulation, which may be useful for decoder
installations, but these really don’t reduce the size a lot (maybe by about 10%).
If the size of the wire is an overriding concern, consider using magnet wire
instead.

Hook-Up wire is available in a range of gauges suitable for track feeders,


control-panel wiring, and decoder wiring.
Note: Digitrax sells 30ga “decoder wire” which appears to be tinned 7-strand
(0.1mm diameter strands) hook-up wire with a cross-sectional area of about
0.057mm2.

Magnet Wire:
Magnet wire, also called winding wire or enameled copper wire, is a solid wire,
typically of annealed copper. Insulation is a thin layer of any of a number of
compounds, which typically requires scraping with a knife blade or burning in a
flame to remove (wire-strippers won’t work because it’s too thin and tightly
bound to the wire). Some versions can be directly soldered, because the hot
solder melts off the insulation, but that’s not true of all.

One big advantage of magnet wire is that the thin insulation makes the wire
easily concealed when adding lighting to structures. While aluminum is
sometimes used, the larger size required for a given current negates one of the
largest advantages of magnet wire: the small diameter. In 30ga, typical magnet
wire has an outside diameter (including insulation) of just 0.29mm, while
ordinary stranded hook-up wire is 0.81mm in diameter, nearly three times the
diameter.

The downsides to magnet wire are that it isn’t color-coded, and it’s not
normally sold in smaller lengths. The smallest I could find online for 30ga wire
was a 1/2 lb spool (it’s sold by weight), which contains about 1,600 feet (500m)
of wire, for US$60. Priced per foot, that’s not a bad price, but how much of it
will you ever use? It’s also solid wire, so using it where it could flex (e.g.,
connecting a decoder to truck-mounted pickups) might be prone to failure over
time, but in most decoder applications flexing probably wouldn’t be an issue.

Note: I found 100’ spools of magnet wire at a local electronics hobby store, so
you may be able to find it in reasonable lengths if you look.

Why Stranded Wire?


Stranded wire carries the same current as solid wire of the same cross-section
(or gauge), so what’s the difference? Stranded wire is much more flexible. In
larger wire (like a DCC bus) this makes solid wire harder to work with. Solid
wire also doesn’t work well with insulation displacement connectors (suitcase
connectors) or crimp-on terminals (although you can apparently buy versions
of the latter designed for such use). If wire is going to be subject to flexing,
solid wire is also more likely to break over time, although in most model
railroad applications this isn’t likely to be a problem. The exception would be a
modular layout with a DCC bus that’s repeatedly connected to other modules
and disconnected; those linkages get a lot of flexing.

Why Copper Wire?


Most wire is copper, some is aluminum. Copper costs more, so why use it?
Copper conducts more current with less voltage loss than aluminum of the
same gauge. You also need to be careful when connecting aluminum wire: if
connected to copper wire or brass terminals, the joint will corrode. Terminals
need to be tin-plated to avoid this. You can certainly use aluminum wire if you
exercise care, but I’d avoid it.

If you use aluminum wire, the general rule of thumb is to step up two wire
gauges to get the same ampacity. Thus, if you need to use a 14 gauge copper
wire, you should 12 gauge in aluminum.

Why Tinned Wire?


Why is tinned wire important, and just what does “tinned” mean, anyway? In
soldering, to “tin” a wire is to flow molten solder onto it, which makes later
soldering it to some other object much easier as the solder already has a good
bond to oxide-free copper. Solder itself is made of tin mixed with other
elements (usually 60% tin and 40% lead plus a few trace elements, but there
are now lead-free solders that contain other materials). The purpose of those
other elements is to make it easier to apply the solder; it’s the tin that’s
important. And “tinned” wire is wire that has been coated over its entire length
with tin, through either electoplating or dipping in molten tin. So this saves you
a little work, but is that it?

Note: you can buy “tinned” wire that is coated with silver, or gold, but these
are for exotic uses and have a matching cost. Any normal “tinned” wire will be
tin-coated.

The benefit of tin, in either form, is that it doesn’t corrode the way copper does
(this is also why terminal strips are typically tin-plated). Bare copper wire
exposed to air with any moisture will soon form a less-conductive outer layer,
and for AC applications (like DCC) this can have a significant effect. It’s also a
problem with DC, but typically only with very excessive corrosion, such as is
found on copper wire used in salt-water boats. And even if the wire is
insulated, moisture will work its way under the insulation over time, and
gradually coat the whole surface this way.

For wire in a damp basement (and most basements are damp at least some of
the time), and which is likely to remain in a model railroad layout for decades,
it is going to be subject to corrosion. Unless you live on the coast, the effect is
likely to be marginal and I can’t quantify it in either case. But it would seem to
me that using “tinned” wire for model railroad wiring is a good long-term
investment, though not a requirement.
Choosing Wire
The most common “decoder wire” seems to be 30ga. While many people
(including me) have used 30ga wire for decoders with no problems, it is
somewhat on the borderline. It can carry 120mA using the most conservative
numbers (and 400 or more by some tables), and that’s sufficient for normal
conditions in an N-scale train, and it may well be safe even under stalled
conditions given the safety margins factored in. There are likely plenty of
models and usages which could get away with even thinner wire. There are also
situations where it would be inadequate.

You can get “hook up wire” in a variety of gauges from electronics suppliers.
This is typically sold in these gauges in 100’ (30m) spools, and for stranded
copper runs about US$18 per spool with PVC insulation. However, to minimize
size thinner, but more expensive, insulations are available at a bit over $30 per
spool. And, of course, you could use magnet wire for the smallest outer
diameter.

For my EMUs, if I want to be absolutely safe, I should use 26ga (0.4mm) wire
for the pick-ups and motor, and 31 ga (0.23mm) for the lighting. That’s
extremely conservative however, and 28ga is likely fine, while 30ga is probably
adequate. Note that with bulb lighting or larger (or older) motors that draw
more current, large wires will be required.

I’m considering ordering 100’ spools of 28ga wire with Polyphenylene Ether
(PPE) insulation, with the following Digikey part numbers for my installs:

6710 RD005-ND, Red


6710 BK005-ND, Black
6710 OR005-ND, Orange
6710 SL005-ND, Gray

I could, however, end up going with 30ga versions of this or using magnet wire
in either gauge, as it’s even smaller. I need to do more work on my ampacity
tables before I convince myself which is best.

If I do use this, it is tinned-copper stranded wire, which I like for this


application. There’s a cost to this, and I have to get it in sufficient bulk that I’ll
probably never have to buy any more (I think I can do about 200 installs with a
100’ spool of each color). I’m also not likely to use the same wire for the lights,
and may stick with the Digitrax 30ga wire for those, or even use something
smaller.

One of the nice things about this wire, from a purely non-technical standpoint,
is that it uses a more environmentally-friendly type of insulation rather than
typical PVC. It contains no halogens or hazardous substances that would
prevent recycling. See the manufacturer’s page for further information.

Model Railroad Wire Ampacity


The ability of a wire to carry current without failure, known as its Ampere
Capacity or Ampacity, depends on a number of factors including the diameter,
voltage, frequency, composition, insulation and environment. Ultimately this is
related to the heat produced by current flowing through the wire, and the
wire’s ability to dissipate that heat. More heat than can be dissipated will raise
the temperature, until the wire or the insulation melts, or until objects adjacent
to the wire reach their ignition point and catch fire. Wire in open air dissipates
heat more efficiently than wire in a closed space. The type of electrical
insulation used also is a significant factor.

One note of caution: I’m not an electrical engineer, or any kind of electrical
expert. I’m a hobbyist with some technical knowledge (just enough to hurt
myself). What I’m presenting here is my current “best guess”, and what I’ll use
for my own model railroad layout. That doesn’t mean that it’s right, and it’s
quite possible even with my numbers that a wire could get hot enough to
damage a model. Follow your local electrical codes for anything those codes
cover if they are more restrictive than what’s presented here, and even if low-
voltage wire is exempt use them as a guide to maximum “safe” current levels.
And if in doubt, use a larger wire.

See the Derivation page for further information about these tables, and where
their data came from. If you believe any of this material is in error, please send
me an email at the address on the About the Site page.

Application
A model railroad uses wire to provide electricity to trains and to scenic
elements (building lighting, for example). This is typically low-voltage DC, but
may also be Digital Command Control (DCC), which is a form of AC using
variable frequency signals ranging from about 100 Hz to about 10,204 Hz (the
normal maximum is around 8kHz). Motor decoders used with DCC will also use
Pulse-Width Modulation (PWM) to control the motor, another form of variable-
frequency AC using maximum frequencies around 15,000 - 30,000 Hz.

Wire size here is given in American Wire Gauge (AWG), but this measure isn’t
used in the rest of the world. In Europe cross-sectional area (or in some cases
number of strands and diameter of each) is used. I haven’t been able to find a
metric ampacity table (they’re likely out there, but in some language other
than English so Google doesn’t find them when I search). However, there are
conversion tables (like this one), and I’ve used that to get the mm2 numbers
listed below. Wikipedia’s AWG entry also includes an ampacity table with the
metric equivalences, but it doesn’t include the ampacity measure for smaller
gauges.

Model Railroad Ampacity Tables


Electrical standards and safety organizations publish ratings for wires based on
their size (gauge, or cross-section area), such as those in the National Electrical
Code (NEC) published by the National Fire Prevention Agency (NFPA) in the U.S.
Ampacity tables (like this one) describe the allowed minimum size of wire for a
given current under two conditions: in open air, and in a confined space, given
a number of assumptions, one of which is that wire can be allowed to heat to
90°C (194°F), close to the melting point of typical PVC insulation (sometimes
75°C is used instead). These tables are designed for household or high-current
AC at standard frequencies, and are rated to avoid fires due to overloaded
wiring as well as to limit voltage drop under typical conditions to an acceptable
amount. They are the right thing to use for power wiring, and reasonable to use
for layout power bus wires and similar.

But they aren’t necessarily a good description of how wire works in DCC
applications due to the much higher frequencies in use there, and some of their
assumptions may not be desirable. For instance, styrene melts at about 100°C,
but it can deform at lower temperatures. Allowing a wire embedded in a plastic
model to reach 90°C is probably not a good idea. Also, these tables typically
assume an environment of 20°C, or 68°F (sometimes 25°C, or 77°F), and wire in
very warm environments can’t carry as much current as wire in a cooler
environment would before it reaches the same temperature.

I’m going to define my own tables, specific to the usages of model railroading,
and those will go here. At present the tables below are somewhat incomplete,
being based on existing tables or other information which has not been fully
adapted to this purpose.
Normal Wire
You can find a number of Ampacity tables googling around the web. They’re a
good starting point. Based on a number of things I’ve read, it would appear that
derating allowed current by 20% will limit wire temperatures to 75°C (167°F),
which would provide for a good safety margin within a plastic model and I’ve
illustrated that below.

In the table below, the NEC safety rating for AC power wiring is listed to show
how it differs from the simple ampacity numbers found in some tables.
Ampacity is listed for three additional situations: “Cu Open Amps” is open-air
wiring (e.g., a power bus hung beneath a layout), “Cu Encl A” is an enclosed
rating for the standard 90°C value (applicable to wires inside a control panel or
similar) and “Cu 75°C A” is a derated number reflecting the approximate limits
for a wire not to exceed 75°C in a 20°C environment, reflective of wire used
inside an enclosed styrene model or structure.

The “Cu 75°C A” number falls in the middle between the baseline numbers
from the original table (which I suspect are overly optimistic) and the magnet
wire table below (which I suspect is overly conservative). For the time being,
I’m going to use that column as my guide for use. And that tells me I could use
30ga wire with no problems on my decoders, and might even be able to use
32ga. To be sure, I’ll stick with 30ga.

Normal (stranded) Wire Ampacity

For another perspective, a chart from a manufacturer of hook-up wire (I’ve


seen similar tables from other cable manufacturers) shows that 28ga wire in
open air at 25°C can carry about 2.2 Amps with a 35°C temperature rise above
ambient (60°C or 140°F), but only about 0.2 Amps with a 10°C rise (35°C or
95°F). That’s so completely different from the above that it makes me wonder
just what assumptions are being used by both of them.

Magnet Wire Ampacity


Magnet wire is available in larger sizes, but as this is solid core wire with
expensive, high-performance, insulation, it is really only applicable to model
railroading in smaller sizes, where it can be used for LED signal heads, structural
lighting, or perhaps decoder installs where space is very constrained. In the
table below, OD is the diameter of the wire plus insulation, “mA (in air)” is
applicable where the wire is not constrained, and “mA (interior)” is a worst-
case number for wire that is unable to exchange heat with surrounding air (and
the number here is probably further derated for use in a magnet, so the real
“interior” number may not be this low).

This table appears to be very conservative, and I’m not sure exactly why. It was
derived from some amps/square-meter numbers found online for “typical”
magnet wire, and I suspect it assumes use in an actual magnet, where wires are
tightly packed and heating each other. That makes it much more conservative
than the general table up above.

This suggests that for a single colored LED (30mA), wire down to 36ga is safe in
any application, and wire down to 40ga may be safe if the wire is exposed. For
decoder use, however, even 30ga is likely to be problematic in a tightly
constrained space if a motor is stalled, although it may otherwise be adequate.
Again, the table up above may provide a better guide, although it may be
overly optimistic. Note than an SMD LED draws about 5-7mA of power, so even
40ga should be safe for an application using one of those even if the wire is
enclosed, such as in a signal mast. However a signal using conventional 1.5mm
LEDs (20mA to 30mA) should probably use 36ga, although 38ga may well be
adequate.
Magnet Wire Ampacity and Specifications

Voltage Drop
For large-scale wiring, loss of power in long runs of small wire leads to a drop in
the effective voltage delivered to the load. For short track feeders this doesn’t
matter much, and for the low currents of smaller-scale models on DC, it would
only be an issue with really long wires. But for the high currents found in DCC
bus wiring, or for the small wires found in DCC decoder installs, voltage loss is a
more significant concern. Distances in the table below are based on total
conductor length assuming two conductors (e.g., a 5m bus extends 5m from
origin to farthest point, and has 10m of total wire, 5 out and 5 back).

Note: as discussed on the Derivation page, there’s some additional loss on DCC
with larger gauge wires due to the “skin effect”, but this only becomes even
slightly significant at 12ga or larger wires, and in the worst-case of 10Amps on
10ga wire amounts to less than 1% of total voltage (an additional 0.8V lost to
be precise). For that reason, although the following tables are computed for
DC, they can be applied to DCC as well.

How much loss is too much? That’s going to vary, but in the following tables,
color-coding is performed based on a desired maximum level of loss and a
worst-case maximum acceptable loss. See the Derivation page for the
reasoning behind the numbers.

For bus loss, color-coding is based on a 12V supply with green being below 5%
loss (0.6V) and values above 15% (1.8V) being unacceptable.

Assuming you limit your track feeder bus to 10 linear meters (about 33 feet)
and place the command station in the middle, so that maximum distance from
the station is 5m (~16.5’) the following table shows the voltage lost in such a
bus based on simple DC resistance adjusted for wire temperature of 50°C.

Note: the following tables have not yet been corrected for maximum
acceptable ampacity due to heating effects. Do not exceed the numbers in the
Ampacity tables above regardless of the ratings shown here.

Voltage Loss in a Track Bus based on Load

Track feeders are shorter, and typically much smaller than the track bus. I’m
assuming no more than 2% loss (again on 12V) here is desirable, with 5% the
maximum acceptable. Less than 2% is color-coded green, with more than 5%
marked “N/A”. Other conditions as above. The table below is for 1m (39 inch)
feeders, which assumes some under-table wiring to circuit breakers and
occupancy detectors. For shorter wires multiply by the length in inches over 39
(e.g., a 12-inch, 22ga feeder carrying 3A will have 0.32*(12/39)=0.098V loss).
The dark-outline box around 24 gauge up to 3A is for Kato Unitrack feeders
(Unitrack is rated to 3A maximum).
Voltage Loss in Feeder Wires based on Load

See also the discussion on my DCC Layout Power Wiring page for a more in-
depth discussion of bus wiring and desired wire gauge for it.

Turning to decoders, the picture is very different. A typical motor decoder uses
less than 0.5 Amps in N-scale, although some older ones can be larger. A
function-only decoder operating only a few LEDs or one bulb at a time could
use only a tenth of an Amp. These can use very small wire, and even there the
voltage loss is miniscule over the short lengths of wire used inside a locomotive
or motor car.

Voltage Loss in 6” (15cm)


Again, this is a very optimistic table; I haven’t corrected for all of the factors
that could affect maximum current. While this says 30ga wire is usable for a
0.5A decoder, I’m deeply suspicious that this is below the desirable size under
some circumstances, despite the fact that many decoders come with 30ga wire,
and many people have made use of it. The ampacity table, which is the source
of the red-marked entries here, suggests that with derating, 30ga wire is
suitable for 416mA, which is still likely to be fine for a typical N-scale decoder,
but is below the 500mA here. Again this is a placeholder table until I can make
a better one.

Another case is power supply for accessories, building lighting, and similar
things. Here, small diameter wire is desirable for ease of installation, but wire
runs can be much longer, and thus loss will be higher. Here I’ve computed loss
for ten feet (3m) of wire, a reasonable length running around a layout. Loss
approaches 10% at the ampacity limit of the wire, so there’s a greater
advantage to the use of larger diameter wires than current alone would imply.

Note that wires could be much longer, but in that case it probably makes sense
to use a large-gauge set of wires to get power to an area on the layout, and
then smaller wires between accessories or buildings in that area.

Voltage Loss in 10’ (3m)

Voltage Loss
For very large current over long wires in layout wiring, the amount of power
lost in a wire may be more of a limiting factor than heating at the voltages
typical of a model railroad, particularly for layout bus wiring.

Voltage Loss per Meter at different Amperages

The above table shows the voltage lost in one meter of a pure copper
conductor at various current levels. As presently written, it is based on simple
resistance and does not correct for skin effect or temperature-based
alterations to wire capacity. When applying this to a bus or model wiring, keep
in mind that you need to count both wires, so a 30’ power bus is 18.2m, not
9.1m.

Model Railroad Wire Ampacity Derivation


Determining the effective capacity (ampacity) of wire used in a model railroad
is not a trivial task. And, as I’m not an electrical engineer, it’s easily one I could
have done wrong. For that reason I’m providing a detailed description of how I
came by the results on my Ampacity page here. If anyone sees anything I’ve
overlooked, or done incorrectly, please drop me a note to the address on the
About the Site page. Note that there’s a lot of math here. That’s kind of hard to
avoid, but I’ve stuck to simple algebra, using formulas derived by others for
specific cases. Hopefully I haven’t misused any of them.

And it should go without saying, but I’ll say it anyway: use at your own risk. I’m
not an electrical engineer, and I’m not providing professional advice. This
derivation is correct within the limits of my knowledge, but those limits may
not be as broad as I think they are.

Basic Tables
The tables presently provided are derived from online information. These will
ultimately serve as the sanity check on my own tables; if I differ significantly,
I’m going to need to determine why.

Normal Wire:
Information in this table came from Wikipedia’s entry for American Wire Gauge
(AWG) as well as the Wikipedia Ampacity table. It doesn’t entirely agree with
other tables I’ve seen, but that’s one of the problems: every table seems to use
slightly different assumptions and ends up with slightly different ratings as a
result. In particular, the numbers here are higher than the ones in the magnet
wire table down below.

Note that this table assumes copper (Cu) wiring. Additional derating would
apply for wires made of aluminum, and pre-tinned wire has slightly less
capacity as well.

Magnet Wire:
The magnet wire table is based on a list of standard dimensions for solid-core
wire, and ampacity is based on the range of current densities given on the
wikipedia page (see magnet wire link above). Skin effect should not be an issue
with wires of the size listed here, even at PWM frequencies. Temperature
derating is presumably included in these numbers, and I think the “interior”
number reflects a worst-case scenario, but I can’t be certain. The numbers
appear overly conservative to me.

Adjusting Standard Tables for Model Applications

Actual ampacity for high-frequency (DCC) current in small-gauge low-voltage


wire is hard to come by. Ampacity tables (like this one) describe the allowed
minimum size of wire for a given current under two conditions: in open air, and
in a confined space, given a number of assumptions, one of which is that wire
can be allowed to heat to some number up to 90°C. A wire that hot in contact
with a typical plastic model should not cause the plastic to deform since
polystyrene has a “melting point” of 100°C, but it turns out that that’s not a
safe bet, as we’ll see below in the discussion of acceptable heat levels.

Temperature Derating:
Standard ampacity tables typically (but not always) assume an allowed
maximum wire temperature of 90°C, multiply the ampacity by 0.82 to get the
ampacity at 75°C.
Paired Cable Derating:
If two wires are touching, as in a twisted pair, multiply the ampacity by 0.93.
Note that this does not apply if the two wires are separated by more than the
diameter of the wire, as they would be in zip cord. It’s interesting that there’s
only a 7% derating here, as a back of the envelope guess would suggest each
wire has half the ability to shed energy to the environment, and thus should be
derated by 50%. Clearly there’s something else at work.

The Hard Stuff


Now for how I did my own tables. I haven’t finished these yet (and the tables
aren’t published yet, since I’m still creating them), so the following material
may change before I’m done.

Even with a number of assumptions, the math for this isn’t trivial. Conceptually
it’s all very straightforward, but finding the equations and constants for various
materials, figuring out how to apply them, and putting it together kept me well-
occupied for a while. Hopefully I got it right: I haven’t had to do this kind of
analysis since college physics.

The basic concept is simple: the useful size of a wire for a given current is
limited by two things, the voltage drop in the wire (which gets larger the longer
the wire is and increases with the current being carried) and the heating of the
wire due to that resistance (which doesn’t depend on length but does depend
on the square of the current). For long wires, voltage loss is probably the
biggest issue. For short wires, heat may dominate. I’ve reported voltage drops
for different lengths and amperages to help identify where this becomes the
dominant factor.

In short, the ampacity of a wire depends on:


- Acceptable voltage loss in the wire, which depends on gauge, current,
material and length
- The heat produced in the wire, which depends on gauge, current and material
- The ability to remove that heat, which depends on the environmental
temperature, as well as how heat is removed:
-- via convection in open air
-- via conduction (or radiation) in a closed space, which additionally depends on
the surrounding material

Kinds of Wire
I’m going to look at four use-cases for model railroads:
- Track Bus Wiring
- Track Feeder Wiring
- DCC Decoder Wiring
- Accessory Wiring

The first three make up the train power supply system from command station
(or power pack for DC) to the train’s motor. The last applies when dealing with
control signals to accessories like switch motors and signals, as well as power
wiring to devices such block occupancy detectors or turnout motors that don’t
take their power from the track or to LEDs providing light in or on structures.
While I’ll look at the train power system in the context of DCC, most of this
applies similarly to DC layouts, the only difference being that currents will
typically be significantly less (DC block wiring has to support at most a couple of
train motors, perhaps ~1Amp, while DCC bus wiring can carry 5 or more Amps).

Environment
One assumption that must be made concerns “room temperature”. While
basements are often cool, and assuming 20°C (68°F) would be safe in many
cases, that’s not always true. Some model railroads are in garages, lofts or
spare rooms. And model railroading happens in summer as well as winter. To
provide a safety margin I’m going to use a higher temperature.

Since much modeling uses plastics, the effect of temperature from heated
wires on plastic models is of particular concern.

I’m taking a conservative perspective, and assuming a “room temperature” of


30°C (86°F), with a maximum allowed wire temperature of 50°C (122°F),
meaning a 20°C rise (more on wire temperature below). I could have relaxed
that to 20°C (68°F) room temperature and 75°C (167°F) wire temperature, and
probably still have been fine, but there’s some risk at the higher temperature.
Wires suspended in air, not touching insulating foam, can safely heat to 75°C
(or more, but I’ll use that number).

Room Temperature: 30°C

Wire Heating
As mentioned above, a final assumption is how hot to allow the wire to
become in use. The primary objective is to avoid damage to the wire or to
models, as this is a more conservative assumption than insulation failure or
causing a fire (the other reasons to limit temperature).

For wire in open air, I’m assuming the air can circulate freely past the wire. This
may not be the best assumption (particularly if the wire is glued to a ceiling), so
treat “free air” as a best-case and realize that a lot of situations may be less
than the best. For a wire in a structure (model building or train), I’m assuming
the wire is inside a styrene model and its cooling depends on the rate of heat
transfer through 2mm of styrene. For wire in or adjacent to a layout (e.g., bus
and feeder wires not in open air) I’m assuming the material surrounding the
wire is solid styrofoam insulation, as this is more restrictive than wood or
having material on only one side would be.

Note that the melting point of copper, 1,084.62°C, is far above the
temperatures that become problematic for these other materials. Thus the
“fusing point” of copper isn’t an issue here. We’ll have destroyed both model
and wire insulation, shorting out the power supply and either shutting the
layout down or setting it on fire, long before the wire itself melts.

Most electrical insulation is PVC, which has a melting point of 105°C (221°F). It’s
generally recognized that wire temperatures should be kept at least 10°C below
this, and often a safety margin of 30°C (a wire temperature of 75°C or 167°F) is
used. That’s actually pretty hot, and in most applications we’ll want to aim for a
lower temperature.

Plastics are a glass-like structure, meaning that they become “rubbery” above
their “transition temperature” (also known as the “glass temperature” and
“melting point” although the latter isn’t strictly true) and experience “creep” at
lower temperatures. The exact temperature depends on the type of plastic,
and what other substances it has been mixed with. Polystyrene tends to be
somewhat less adulterated the many other types (which often contain
materials to enhance flexibility or other properties), and has a slightly higher
acceptable temperature as a result.

Polystyrene plastic has a transition temperature of 100°C in its pure form, but
that can range as low as 75°C depending on the formulation and apparently
commercial formulations with a transition temperature of 85°C are common.
This temperature is the center of a range where the solid material transitions
into a rubbery form. Even below it, plastic may become soft enough to deform
under its own weight or other normal stresses applied to models (as noted
above for PVC). Staying at least 10°C below the transition temperature is
probably a good idea. Some other plastics are reputed to have issues above
60°C, but exact information is hard to come by. For plastic that means 75°C
might be safe, but 65°C is better. For insulated wire, staying below 95°C should
be fine.

For most of the tables, I’m actually going to calculate the results for a 20°C rise
over my assumed “room temperature”, meaning 50°C (122°F), to ensure a large
safety margin for wires used in or near plastic structures. For wires in control
panels or open air, not exposed directly to plastic of styrofoam, I’ll be less
conservative and allow temperatures up to 75°C.

For voltage loss only the wire temperature matters, and it’s at most a one-
gauge improvement from 50°C to 75°C, so for bus wires (the ones most
affected by voltage loss, and also the ones most likely to be in open air) the
result of allowing that higher temperature do not substantially alter the
ampacity, but there is an improvement so I’ll calculate those tables allowing for
it.

Wire Max Temperature: 50°C in structures, 75°C in open air

Acceptable Voltage Loss


This is a core assumption, and somewhat arbitrary. How much voltage are we
willing to lose in a wire? The answer depends on what we’re doing with it. For
normal household wiring, often a number of 3% to 5% is used, but this is only
part of an end-to-end transmission system. And in any case, we’re dealing with
low-voltage model trains, not lamps.

Let’s assume N-scale DCC as the most severe case (someone working with a
garden railway at much higher voltages might draw different conclusions). A
DCC power station (command station or booster) puts out a nominal 12V (DCC
RMS) signal. A decoder must respond to at least a 7V signal. That means we
could lose 5V (or 42%) of the source and still work, but clearly that’s not a very
desirable state. DCC decoders pass through a fixed percentage of track voltage
to the motor for a given throttle setting, which defines the speed. It’s probably
desirable for track voltage to be relatively consistent across a layout. There is
also going to be voltage loss in the track, in the on-train current pickups, in
various connectors, as well as in the bus wire, track feeders, and decoder
wiring.

Voltage loss in the track feeder is limited due to the relatively short length,
likely under a foot, but perhaps more if you include wiring to occupancy
detectors and circuit breakers between the bus and the track. The lower
currents typical in feeders (which support at most a couple of train motors
each) is also a factor. Even at four feet, loss is going to be under a tenth of a
volt with the wire gauges normally used. This can rise to around 0.2V for larger
or multiple motors totaling an Amp or so on typical wire (e.g., Kato’s 24ga
feeders). So I’m going to budget 2% as the normally acceptable voltage loss in
feeder wires (that’s 0.24V). Track and related connectors can be assumed to
lose several additional percent (hopefully not more), and completely arbitrarily
I’ll assume that’s another 3% (0.36V).

So, from the above I’m losing 5% (0.6V) in track and feeders. Let’s assume loss
in the decoder wiring is negligible (I think it is), then if I were willing to lose 20%
(2.4V, taking track voltage down to 9.6V) my buss loss budget would be 15%
(1.8V). Let’s assume that’s the worst case upper bound on loss. What this
means is that track voltage, and thus train speed, can vary by 15% from one
part of the layout to another. That seems a bit high to me, but not
fundamentally broken. However actually using this margin isn’t recommended.

In the interest of consistent behavior I’m going to set a lower target for
“normal maximum” loss of half that (10% overall, meaning 5% in the bus).
Thus, voltage at the decoder would vary from 10.8V at the “consistency” target
down to 9.6V using the worst-case loss. Even the worst is comfortably above
the 7V minimum. And keep in mind this is defining a worst case, and real-world
voltage loss isn’t likely to be that high. I’ll also allow feeder loss to be slightly
higher in the worst case and assume a small loss in decoder wires. That actually
puts me closer to 25% total loss in the worst case, taking voltage at the motor
down to 9V. I wouldn’t want to run trains that way, but I have no doubt they’d
work unless there was something seriously wrong in the track. My preferred
“worst” number works out to 11% total loss, meaning 10.7V at the motor.

Accessories are probably somewhat variable in their needs. Lets assume we


want voltage to be no less than 10V from a 12V supply, that’s about a 16% loss.
Allowing for some loss in connectors, I’ll use 10% (1.2V) as a maximum upper
bound on acceptable accessory wiring loss.

Thus, acceptable losses:


- Track Bus: 5% normal or 15% worst-case
- Feeders: 2% normal (a worst-case value of 5% is used for the table colors)
- Decoder wires: ~0% (meaning less than 1%, a worst case of 2% is used for
table colors)
- Accessory wires: 10%, 15% worst-case

More Assumptions
Finally, I need to account for the insulation used on the wire (insulation keeps
in heat, not just electricity, so it makes the wire hotter). And different kinds of
insulation conduct heat differently, and come in different thicknesses. I’m
going to assume PVC insulation (except for magnet wire, where I’m assuming
one of the usual compounds used for that). I’ve collected a lot of data on
typical PVC and magnet wire insulation thicknesses, and will use that for their
respective types of wire. For commercial AC wire, which is typically insulated
with PVC in a nylon coating, I’ve accounted for the nylon as well although it has
little actual effect.

Dimensions
When dealing with real-world objects like wire, sometimes the source material
isn’t using the same set of dimensions that I want to use. Metric measurements
can be in meters, kilograms and seconds (MKS) or centimeters, grams, and
seconds (CGS). I’m using MKS for all of my calculations. Converting between the
two is easy, but important to remember to do. Wires additionally usually use
dimensions in millimeters, which need to be converted to meters or square
meters for use. Again easy to do, but for space reasons I’m using the millimeter
and square millimeter numbers in the tables, even though my math is in MKS,
so there are conversions back and forth I need to remember to do. Thankfully
I’m using Excel for this, so once I get the formula right, it’s easy to apply it to a
whole table’s worth of sizes.

U.S. units use the English system (feet, pounds and seconds). Further, wire is
described in “mils”, which are thousandths of an inch (one mil = 0.0254mm).
And wire cross-section is in “circular mils”, which is a very odd unit referring to
the cross-sectional area of a wire with a diameter of one mil (and NOT a wire
with one square mil of cross-sectional surface). A circular mil is
0.000506707479 mm2.

Wire dimensions in American Wire Gauge (AWG) have equivalent dimensions


in mils or millimeters, but these vary slightly from one manufacturer to
another. There’s actually something of a standard behind this (although
apparently not always followed exactly). I’m computing my wire dimensions
based on typical stranded wires, using the “standard” thickness for the
individual strands. Real wire may vary somewhat from these numbers, but it’s
unlikely to have a major effect on capacity. I’ve also used data for some
common metric wire sizes where I could find it. There are other wire sizes in
use (and other standards, such as British Wire Gauge) than those I have listed.

Heating and Cooling

Wires carrying a current lose some power due to the resistance of the wire.
That lost power is converted to heat, which raises the temperature of the wire.
If a wire kept all the heat it produced, it would get hotter and hotter until it
melted. But a hot wire in a cooler environment will lose heat to the
environment, and the hotter it gets, the faster it loses heat. A heated object
will reach an equilibrium at the point where heat is being lost at the same
speed it’s being gained. Heat transfer is calculated in Watts per area (the area
being the surface of the hot object). Since the surface area varies linearly with
the length, and heat production does too (because resistance increases with
length), once we figure this out for a given length, like one meter, it’s true
regardless of the length of the wire.

So what we need to do is determine the rate of heat loss at the highest


temperature we want the wire to be (which will vary as described above based
on some assumed environmental factors), and then work backwards from that
number of Watts being exchanged to the environment at that temperature
(which additionally depends on the environment), and from that to the number
of Amps required to produce that many Watts. That, then, is one limit on the
ampacity of the wire: the current that produces the maximum acceptable level
of heat in a wire at thermal equilibrium with its environment. There are a
couple of complications to that.

First, a wire in air cools at a different rate than a wire surrounded by some
other object. For our environments, the maximum acceptable current (i.e., the
degree of cooling) will be highest in air, and lowest inside the solid materials
used in a model railroad layout (which tend to be good insulators, like wood or
plastic), so ampacity in a constrained environment will define our “worst”
maximum current.

Second, a wire cools at a rate that depends on the difference between its
temperature and the environment’s temperature, so we have to make an
assumption about what “room temperature” will be, as described up above. If
you model in a much hotter environment (like the Australian outback, or mid-
summer Florida) your wire can carry less current. Finally, a wire in air cools at a
different rate depending on its angle (air moves up when heated, so a vertical
wire doesn’t cool as well as a horizontal one). Most wires in air on a model
railroad will be horizontal, so we can probably simplify to the horizontal case as
our “best” value.

There are three mechanisms that transfer heat from a hot wire to the
surrounding environment: conduction, convection and radiation. These all
come into play for an insulated wire in open air. Because copper is an excellent
conductor of heat, we can assume that heat is available at the surface of the
wire for removal at the rate that heat is produced within the wire, as all other
transfer mechanisms will be slower that that of conduction through the copper
wire to reach the surface (see below for the numbers to back that statement
up).

Heat must conduct through the insulation on the wire, and then from the
surface of that it will transfer by both radiation and convection. The latter
depends on air moving past the wire, and will not apply if the wire is adjacent
to some other object. A wire against a solid on one surface may still transfer
heat by radiation in other directions, but will transfer via conduction to the
surface. As this is an intermediate case between open air and being embedded
within a solid, it won’t be considered further here.

A wire embedded in another substance can only transfer heat by conduction


from the insulation to that substance.
Cooling of a surface in air is by convection, where the air adjacent to the
surface of the wire is heated causing a density change, the hotter (less dense)
air rises, sucking in cooler (denser) air to contact the wire, and the process
repeats. With the right set of conditions this creates a “laminar flow” of air past
the wire, and a constant exchange of heat to “room temperature” air. In a
closed space, things get more complicated as the “room temperature” will
increase over time, unless it too can exchange heat somehow. I’ll cover this
issue more in the discussion of the application of the ampacity tables to various
situations.

In free air, some heat is still transferred by conduction. The ratio is reported to
be ~4.36:1 (convection:conduction), or about 81% by convection. Still, there’s
enough that the conductive rate of transfer to air needs to be considered as
well. A bit of reading suggests that it shouldn’t be that high, unless the wire is
corroded, as emissivity of bare polished copper is quite low. Also, as we’re
dealing with insulated wire, conduction will be the mechanism of transfer
through the insulation. And in wires embedded in some other substance,
conduction to that substance will likely be the limiting factor. There could also
be also conduction along the wire if the ends of the wire connect to something
cooler than the wire itself; with a long enough wire that can be ignored. In a
short wire connected to circuitry, the circuitry may be hotter than the wire, and
heat added via conduction though the wire.

Resistance
Heat is produced in a wire fairly simply: when volts are lost in the wire due to
resistance the “lost” power becomes heat. For DC currents this is calculated
quite simply, using our old friend Ohm’s Law: V=IR, for voltage in volts (V),
current (I) in amps, and resistance (R) in ohms. The energy turns to heat and
raises the temperature of the wire. This is called Joule heating, and the heat is
measured in Joules, or more usefully Joules per second. A Watt is one Joule per
second, and that’s commonly used as the unit for heat production and transfer,
which makes it easy to relate the heat to the power loss in the wire. The
amount of heat produced is described by a version of Joule’s Law, P = I2R,
where P is in Watts (and I and R are as above). Note that resistance in a wire
depends on the length of the wire. While this is usually given in ohms per
kilometer, this will be normalized to ohms per meter for use in these
equations. In the end, we’ll balance heat produced per meter against heat
transferred per meter, and the lengths will cancel out (and thus the length of
the wire won’t matter).

Resistance in a wire isn’t a constant. It’s derived from the composition of the
wire (e.g., copper, but even that can vary from one wire to another by several
percent). It decreases with increased cross-sectional area of the wire (meaning
based on thickness, or wire gauge: bigger wires have less resistance). And it
increases with temperature (hotter wires have more resistance), so we need to
factor in how high resistance will be at the maximum temperature of the wire,
as that’s the worst case situation. Fortunately there’s a simple relationship for
that.

The DC resistance (Rdc) of a length of wire depends on a number called the


“resistivity”, multiplied by the length and divided by the cross-sectional area
(Rdc = (ρL)/A, where ρ is resistivity; this is a form of Pouillet’s Law). Resistivity
for copper can vary with the type of copper, and is higher for tin-plated copper,
but the numbers are well documented for wires at a temperature of 20°C
(68°F). The resistivity of soft annealed copper (the typical material for the wire
in question) at 20°C is approximately 1.72 x 10-8, which comes from the
International Annealed Copper Standard (IACS). I’ve also seen 1.673x10-8 used,
but this appears to be for some other form of copper. The number for tinned
copper is not well documented, but working backwards from some published
resistances for one brand of tinned copper hook-up wire gave me a number of
about 1.88 x10-8.

Correcting for temperature is simply a matter of multiplying the difference in


temperature from 20°C times a constant (called the temperature coefficient,
0.00393 for annealed copper), adding one, and multiplying times the resistance
at 20°C. This is barely a 4% increase at 30°C, but it’s a 12% increase at 50°C and
a 31% increase at 100°C, so it needs to be accounted for when working with
higher temperatures, and I’ll include it for all.

Skin Effect and Resistance


There is another factor that can apply when AC current, such as DCC, is
involved: the “skin effect”. This occurs in wire carrying an AC current, and
reflects the tendency for the charge to move to the outside of the wire due to
“eddy currents” in the wire. The higher the frequency, the less of the actual
wire is carrying the current, and the higher the resistance. Remember the
resistivity bit above: conduction depends on the cross-sectional area; if you
divide by a smaller area, you get more resistance, which is why thin wires carry
less current than thick and why wires that aren’t using their centers carry less
than ones that are.

An exact solution for the impact of skin effect on resistance is rather hard, and
most formulas representing such solutions are for the special case of 60Hz or
for MHz frequencies, and the latter are described as not being applicable to
“low” frequencies. So I’ve used an approximation rather than an exact solution.

The current-carrying capacity of the wire’s material effectively decreases


logarithmicly as you move away from the surface towards the center, meaning
resistance increases in the same manner. The skin depth is the depth within the
wire at which current-carrying ability is reduced to 37% of nominal (1/e to be
precise). So a wire of twice that has an effective resistance slightly higher than
it would for a DC current, although the effect is relatively minor. As the wire’s
radius grows larger than the skin depth, the effect become increasingly
important.

A rule of thumb (see this series of blog posts) is that for wires of radius less
than the skin depth, the DC resistance can be used (it might not be exact, but
it’s within a couple of percent) and for larger wires it can be approximated as if
all of the current were flowing uniformly in the part of the wire down to the
skin depth. As we’ll see below, at DCC frequencies the skin depth is about the
radius of a 16ga wire, so wires of 16ga and smaller can ignore skin depth for
DCC.
So, assuming we know the skin depth, we can calculate the area of the inner
cylinder defined by the total radius minus the skin depth (Ai=(rw-s)2, where rw is
the radius of the wire and s is the skin depth) and then subtract that from the
total wire’s area (Aw=(rw)2) to get the area used for conduction (i.e., Ac = Aw -
Ai). From that, the AC resistance of the wire can be calculated.

There’s a formula (per wikipedia) for computing the skin depth from the
frequency of the alternating current, which is:

Where:
δ = skin depth (in meters, which I convert to mm for comparison to wire size)
ρ = resistivity of the conductor in ohm-meters (1.7241x10-8 for copper)
f = frequency (Hz)
μ0 = absolute magnetic permeability in Henrys/m (1.2566370614x10-6 )
μr = relative permeability of copper (0.999993585)

Note: as described here, and shown in the formula above, the formula can be
stated in terms of the absolute magnetic permeability of copper (μcu), or in
terms of absolute magnetic permeability (in vacuum) times copper’s relative
permeability (μ0 x μr ). The latter is more common, as copper’s absolute
permeability isn’t always given in texts. But the two formulas are saying the
same thing, and either can be used.

Also, as noted above I’ve seen resistivity defined as 1.673x10-8 (which I think is
for non-annealed copper) instead of 1.7241x10-8, but most wires use annealed
copper, and the number I’m using comes from the International Annealed
Copper Standard (IACS).

DCC is a variable frequency signal, so the actual skin depth changes from
instant to instant. Calculating for the peak DCC frequency (10,204 Hz, assuming
worst-case variation in signal), which gives us the shallowest depth, δ is 0.66
mm. Calculating for the more typical 8kHz DCC frequency it’s 0.74 mm. In a
long DCC track bus using heavy-gauge wire there will be some impact on
resistance, and hence voltage loss in the bus wire, from skin effect. This is
worth including in determining ampacity for bus wires, since voltage loss will be
the primary limiting factor in long wires.

As per the rule of thumb above, skin depth at DCC frequencies is about the
same as the radius of a 16ga wire (0.64mm) thus wires of that size are lower
can effectively have skin effect ignored at DCC frequencies. Some simple math
for larger wires shows essentially no change at 14ga, a 7% increase in
resistance at 12ga, and a 20% increase in resistance at 10ga. However the
improvement (reduction) in resistance going from 12ga to 10ga is about three
times the amount lost due to skin effect, so there’s still a substantial net
improvement in current-carrying capacity for the larger wire, even with DCC in
use. In the worst possible case of 10 Amps over a full-length (15 foot or 5m)
bus, the extra voltage lost to the skin effect is around a tenth of a volt, or
around 1% of the total voltage. This is low enough that the skin effect can be
ignored. In short: if you need heavy wire, use it, even for DCC.

Proximity Effect and Resistance


Related to Skin Effect is something called Proximity Effect that comes into play
when two (or more) wires are closely parallel, as can happen in a DCC bus if
you twist the wires. Data on this has been hard to find (most information is
about wires with different utility AC phases, rather than wires with phases that
are inverted relative to each other as is the case in a pair of wires forming a
DCC circuit). Some sources suggest that for two wires, this has negligible effect.
However that statement was likely made in the context of 50Hz or 60Hz utility
power, not 8kHz DCC signals. This is something I need to find out more about.
The effect of skin and proximity effects on effective resistance to an AC current
is nicely summarized in this PDF.

Radiation

No, not the kind that results in flesh-eating zombies. Radiation is a method of
heat transfer, but not a substantial one for solids that are not hot enough to
glow. Radiative cooling follows the Stefan-Boltzmann Law and depends on the
absolute temperature of the conductor and its coefficient of emissivity, which
is a measure of the ability of the surface to radiate heat relative to a “black
body”. Coefficients close to 1 are good radiators, coefficients close to zero are
not. Polished copper has a coefficient of less than 0.05. Plated copper of about
0.02. Plastics, however, have a coefficient around 0.91 which may affect
cooling of jacketed wire by radiation.

The SB law for power radiated by the surface of a cylinder is:

source: wikipedia

where:
P = power (watts)
2𝜋rL = surface of a cylinder of radius r and length L (in m2)
ε = emissivity coefficient of surface
T = thermodynamic temperature (temperature in Kelvins, 293.15K for 20°C,
303.15K for 30°C).

A bit of simple math shows that for bare wire, emission ranges from 9 W per
meter of wire for 10ga wire @ 100°C, to less than half that at 30°C, but with
insulation this drops to less than half a watt at 100°C and a quarter-watt at
30°C. The numbers drop rapidly for smaller wires, and at 20ga are about 1/3
the value of 10ga.

Since most of the wire in question is insulated, there’s going to be some


benefit. For a bare 30ga wire at a low temperature, about 22mW/m can be
radiated, and for plastic-jacketed wire this rises to 393mW/m. This is
considerably above the power loss in small wire (3mW/m in 30ga @ 100mA),
which suggests that radiative cooling of insulation is worth considering. Total
heat flow may still be limited by conduction from the wire to the insulation or
by environmental factors.

Conduction

Conduction is the principle method of heat transfer between solids. For a


cylinder wrapped in a jacket of material (e.g. insulation), the conduction
through the jacket is defined by:

source: Fund. of Momentum, Heat and Mass Transfer Fifth Ed., Welty et al, pg.
206, example 1.

where:
q = heat transfer (in W/m)
k = thermal conductivity of the jacket material (in W/m °C)
L = length of the cylinder (in m)
Td = difference between inner and outer temperatures
ro = outer radius (in m)
ri = inner radius (in m)

Note: for two wires in contact carrying the same current, multiply by 0.5. This is
conservative, but will do for now (as noted at the top of the page, this probably
isn’t a good assumption and I need to come up with a better one).

Some typical thermal conductivities (from insulators to conductors):


air: 0.024
insulation foam (XPS): 0.034
polystyrene: 0.14 (some sources have lower numbers, likely reflecting EPS/XPS)
hardwood: 0.15 (likely also applies to plywood)
PVC: 0.19
copper: 401

Note: 0.380 for non-pure sample at ~50C per Natick Labs doc (0.372 @ 20°C,
0.389 @ ~75°C), but these are in milli-Cal/cm-sec (need to convert).

Note that air is a really good insulator, which is why convection is more
important for it than conduction.
Conduction through PVC insulation of ordinary thickness ends up being around
17 to 72 Watts/meter @ 50°C. Since PVC has the largest value in the list of
conductivities above, it won’t be a limiting factor in conduction (i.e., if the wire
is buried in wood, wood will conduct less heat even in a thin layer, and thicker
layers conduct less). Thus this establishes an upper bound on conductive heat
loss unless we embed the wire in aluminum or some other conductor. As we’ve
already seen that radiation heat transfer is at least an order of magnitude
lower, that could be the limiting factor. However, we still have to look at
convection.

Convection
Convection is the principle method of heat transfer from a solid to a “fluid”,
which includes a free-flowing gas. And it’s hard to calculate.

One core formula for convection is Newton’s Law of Cooling, q = hc x A x dT,


where q is the heat transferred in Watts, hc is the convective heat transfer
coefficient (in W/m2°C), A is the surface area (in m2), and dT is the difference in
temperature (from wire to air in this case). While hc for air ranges from 5 to 50,
the specific value to use depends on the medium (air) and the situation (a
horizontal cylinder will be the assumption here; the values would differ for
vertical wires somewhat, but wires in open air on a model railroad are typically
horizontal). Calculating hc turns out to be hard, and the formula on wikipedia is
only valid for large diameter cylinders (like pipes).

References
In addition to the sources cited in-line, the following were used:

THERMAL CONDUCTIVITY OF POLYSTYRENE: SELECTED VALUES, Technical


Report 66-27-PR, by Carwile, Lois C. K. and Hoge, Harold J., U.S. Army Natick
Laboratories

Wikipedia, List of Thermal Conductivities

Thermal Conductivity of Some Common Materials and Gasses, The Engineering


Toolbox (www.engineeringtoolbox.com)

Potrebbero piacerti anche