Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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).
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 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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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).
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.
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.
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.
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:
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.
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).
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.
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.
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.
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.
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.
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.
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 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.
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.
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.
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.
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.
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.
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.
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”.
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).
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.
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.
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.
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).
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.
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.
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.
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.
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.
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:
And thus you set up the transformer with 80 mH in the secondary, and 0.002
mH in the primary.
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.
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)
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.
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.
Note: the downward spikes are the ones triggering the transistor, a quirk of
how I set up the simulation.
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.
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”.
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.
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.
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
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.
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.
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.
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.
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).
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).
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.
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.
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.
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).
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.
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).
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.
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.
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.
I elaborated this into (and even published) a complete library for Charliplexed
signals, which is described in a Musing.
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.
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.
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).
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.
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.
What’s a Watt?
Basic Electrical Concepts for Model Railroading (DC edition)
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).
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.
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.
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.
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.
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).
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.
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.
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.
Note: an earlier version of this page had the capacity of the PS14 computed
incorrectly.
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.
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:
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:
- 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).
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.
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.
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.
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).
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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:
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.
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.
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.
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.
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.
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.
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
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Conduction
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).
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.
References
In addition to the sources cited in-line, the following were used: