This is only a preview of the December 2025 issue of Silicon Chip. You can view 35 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Articles in this series:
Items relevant to "RGB LED Star Ornament":
Items relevant to "Earth Radio, Part 1":
Items relevant to "DCC Decoder":
Items relevant to "Digital Preamplifier, Part 3":
Purchase a printed copy of this issue for $14.00. |
By Tim Blythman
Decoder
Base Station
Using DCC
Remote Controller
DCC Booster
DCC Decoder
for model locomotives
DCC is a great way to control model trains in a realistic fashion. You need a DCC Decoder for every
locomotive and a base station to produce DCC signals on the track. This DCC Decoder project
provides the first essential part. We will follow up with a DCC Base Station project and a guide to
getting started with DCC using these in our next issue. Image source: https://pixabay.com/photos/steam-locomotive-model-series-23-3627896/
F
or many years, model railways were limited to a simple DC system. The two rails
formed conductors that carried
power from a controller directly to the
motor of a model railway locomotive.
The controller would simply provide
a voltage and polarity to control the
loco’s speed and direction. It’s simple
and elegant, but only allows one train
to be operated at a time.
Of course, real railways run more
than one train simultaneously and,
over time, different technologies have
been used to allow this. One wellknown example divides the track into
sections called blocks. A switch panel
routes power between the blocks and
multiple controllers. As you can imagine, this can get very complex.
In the late 1980s, Lenz Elektronik
of Germany developed the early versions of what would later become digital command control or DCC. The US
National Model Railroad Association
(NMRA) took an interest and developed
DCC as a standard under its auspices.
The NMRA had previously worked
on standards relating to matters
such as wheels and trackwork for
model railways, intending to foster
70
Silicon Chip
compatibility and interoperability
between manufacturers. With its promotion as a standard, DCC continues
to be one of the most popular systems
for operating model railways.
The NMRA continues to develop
and publish updates to the DCC standards and these, along with their other
standards are available to download
from siliconchip.au/link/ac7w
We have published several articles
related to DCC, including feature articles and projects for boosters, programmers and even a computer-based base
station. However, this is the first DCC
decoder we have published, which
means that all you need to build a complete DCC system can now be found
within Silicon Chip.
The Complete Arduino DCC Controller can round out a working system (January 2020; siliconchip.au/
Article/12220), but it relies on a computer, so might be excessive for readers looking for a straightforward starter
system. Thus, we have also designed
a standalone Base Station based on a
Raspberry Pi Pico 2 microcontroller
and touch panel LCD, which we will
introduce next month.
Australia's electronics magazine
That unit can control up to five
locomotives when paired with a suitable power supply, and can also perform decoder programming; more
than enough for most small layouts.
If you are not familiar with DCC terminology, refer to our glossary later
in this article.
DCC operation
The Arduino-based DCC Programmer from October 2018 (siliconchip.
au/Article/11261) included a panel on
how DCC works. Fig.1 is a comparison
between so-called DC operation (using
a controller providing an analog DC
voltage) and DCC operation. Fig.1(a)
shows DC operation.
This project deals with the decoder
shown in Fig.1(b). Its main role is
receiving power and data as a varying
voltage sent from the DCC base station, and decoding the data to drive
the motor and function outputs. The
latter might be incandescent globes or
LEDs. Note that the motor and lights
are not part of this project; they will
be part of the locomotive to which you
are adding the Decoder!
Our Decoder and Base Station can
siliconchip.com.au
Features & Specifications
🛤 Suitable for N and HO/OO scales
🛤 Has support for a keep-alive
capacitor
🛤 Long, short and consist addressing
🛤 Acceleration control and speed
curve adjustment
🛤 Configurable lighting outputs and
flashing effects
🛤 Voltage compensation option
🛤 Supports operations, paged,
physical and direct programming
modes
🛤 Supports 14-step, 28-step and
128-step speed control
🛤 Robust design with current
limiting on all outputs
Fig.1: (a) shows the typical wiring
inside a DC-only (non-DCC)
locomotive, while (b) shows how
this changes when a DCC decoder
is fitted. If two locomotives were
on the track in (a), their motors would run together. The decoder allows the
lights and motors in the two locomotives to run independently. The vertical red
lines show where wires need to be cut to install the Decoder.
be the electronic basis of an economical but complete DCC system. The
Decoder design is robust, with current
limiting provided for both the motor
and function outputs.
Commercial DCC decoders include
a multitude of features, including
sampled and synthesised sounds and
complex lighting effects. Our Decoder
provides some basic lighting effects
and is an inexpensive option if you
assemble it yourself.
We’ve also designed the Decoder
with the idea that our readers might
want to extend or modify it by adding
circuitry. Thus, the Decoder provides
connections for rectified DC from the
track as well as regulated 3.3V, something not commonly seen on commercial decoders.
Alternatives
These days, RF (radio frequency)
controls have become more accessible
and microcontrollers more powerful.
We have published a few projects relating to RF control of model railways,
including Les Kerr’s Battery-Powered
Model Train from the January 2025
issue (siliconchip.au/Article/17607).
siliconchip.com.au
We have also seen systems based
on WiFi. These typically use low-cost
ESP8266 or ESP32 WiFi processor
modules. Still, we are yet to see uniform standards for these sorts of systems, so you will likely be committed
to building all the parts yourself if you
choose one of these options.
Our DCC Decoder and Base Station
have both been designed according to
the DCC standards, and tested with
their commercial counterparts. So they
can be used as part of an existing DCC
system, or further expanded in the
future with other products.
The Decoder
A locomotive decoder (also known
as a mobile decoder) is intended to be
used with a model railway locomotive
or perhaps a motorised railcar. It could
be fitted into the tender behind a steam
locomotive, if there is space, or if that
is where the motor is installed.
🛤 Size: 28 × 14 × 4mm
🛤 Input voltage: up to 17V peak
🛤 Motor current: up to 500mA
🛤 Function outputs: four, up to
100mA each
There are other types of decoders,
such as accessory decoders, that can
operate line-side equipment, such as
points motors and signal lights. An
accessory decoder could even control
lights or other effects in model buildings and such.
A function-only decoder is another
type of decoder that does not drive
a motor, but can operate lights or
other effects. A typical use would be
for internal or marker lights in a carriage, or perhaps to control a smoke
generator in a guard’s van to emulate
a wood stove.
Since a locomotive decoder can also
control these functions, there is no reason our Decoder cannot be used as a
This tiny DCC Decoder board can be
fitted to a model railway locomotive,
allowing it to be controlled by a DCC
Base station. It’s only 14mm wide
(shown here at twice actual size), so is
suitable for HO/OO and N scale models.
Australia's electronics magazine
December 2025 71
function-only decoder in other rolling
stock. Still, we expect that many readers new to DCC will be most interested
in adding the Decoder to their locomotives as a starting point.
As a rough guide to getting started,
you will need a locomotive decoder
for each locomotive or other item of
motorised rolling stock, plus a base
station to coordinate them all. This
article will present the Decoder design;
for those who already operate a DCC
system, we’ll provide a wiring guide
and some information about its operating parameters; particularly its configuration variables (CVs).
This information should be enough
to allow our Decoders to be customised and integrated into an existing
DCC layout. For those new to DCC,
we’ll provide a more complete user
guide alongside the DCC Base Station
in the next article.
Circuit
Fig.2 shows the circuit of our
four-function DCC mobile Decoder.
Some of the connections are marked
with colours; these correspond to
the wire colours used by the DCC
standards. Each connector on the
Decoder is just a PCB solder pad. With
space at a premium, the expectation is
that wires are soldered directly to the
Decoder PCB.
The DCC track signal is an AC square
wave of about 12V-15V in amplitude
(24V-30V peak-to-peak) with its frequency varying around 6kHz. The
actual voltage is not too important,
although our design limits it to about
7V minimum and 17V maximum.
Just over 12V is typical, since this is
the nominal operating voltage of the
motors in many locomotives.
The track connections to the
Decoder (red and black) feed into
bridge rectifier BR1 and then REG1,
an MCP1703 3.3V LDO (low-dropout)
regulator, providing our nominal 12V
and 3.3V rails. The MCP1703 has a
maximum operating input voltage of
16V; our 17V maximum track voltage
is due to this, with a drop of at least
1V due to the bridge rectifier.
Note that some DCC systems operate at up to 22V peak, so you should
check this before using our Decoder
with an existing system. Some systems
can provide a wide range of supply
voltages, so it may be possible to simply reduce it.
The 3.3V rail powers IC1, a
PIC16F18126 microcontroller, at its
pins 1 and 14. This is the 14-pin sibling of the 20-pin PIC16F18146 micro
we have used in numerous other
projects. The firmware we have created will work in a PIC16F18124 or
PIC16F18125 (with less memory), but
we will supply the PIC16F18126 parts
in the kit as it’s only slightly more
expensive.
The three capacitors provide the
necessary bypassing for the regulator
and microcontroller, while a pair of
100kW resistors connect pins 10 and
11 of the micro to the track connections. The 100kW resistors limit current flowing into the pins, and allow
the micro to safely detect the polarity
of the higher track voltage and thus
receive the DCC signals.
An 11:1 divider (10kW/1kW) on the
12V rail connects to pin 9 on IC1,
allowing the voltage on this rail to be
measured by the 3.3V micro.
IC2 is a DRV8231 3A full-bridge
motor driver IC, powered at its pins
1 and 5 from the 12V rail. Digital
Fig.2: despite its simple design, the Decoder includes current limiting on its motor and function outputs. The 100W resistor
provides charging current for an external capacitor that can feed power back to the circuit via D1, allowing the Decoder
to continue operating through brief contact losses, as might occur with dirty track.
72
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
signals from IC1 (pins 5 and 6) feed
control pins 2 and 3 on IC2. Pins 6
and 8 are the outputs, which are connected directly to the motor pads
on the PCB (orange and grey); it is
expected that a brushed DC motor is
connected here.
IC2 sets our lower voltage operating limit. At about 4.5V, it disables
its motor outputs, so we can guarantee operation down to 7V as required
by the DCC standards. In practice, we
expect that everything will work down
to about 6V on the track.
The 3.3V rail also connects to pin 4
of IC2 (Vref). This is used by the circuitry inside IC2 to provide a current-
limiting feature. The motor current
flows to ground via pin 7, so a 0.68W
current measuring resistor (shunt)
between pin 7 and ground develops
a voltage proportional to the motor
current.
An amplifier internal to IC1 multiplies this by 10 and compares it to the
Vref voltage. If Vref has been exceeded,
the power to the motors is shut off
briefly to limit the current.
A current of 485mA develops 0.33V,
sufficient to trip the current-limiting
circuitry, hence the nominal 500mA
motor current limit specification,
which is well within the limits of this
chip. The DRV8231 can also detect
short circuits and, to limit damage,
it provides a longer shut-off time in
that case.
The circuitry around N-channel
Mosfets Q1-Q4 is for the function
outputs. Q1-Q4 are in an open-drain
configuration for switching 12V loads under the control of a 3.3V microcontroller.
The 10kW gate pull-down resistors
ensure that the Mosfets are switched
off any time the micro is not driving
the control signals from its pins 2,
3, 7 and 8.
A typical load would be a light of
some sort, such as a string of LEDs and
their dropping resistors, or a small
‘grain of wheat’ incandescent globe,
connected between the 12V pad (blue)
and the function output (white, yellow, green or purple).
The 10W resistor between each Mosfet source and ground provides the
current-limiting feature. The 2N7002
Mosfets require a source-to-gate voltage of about 2.3V to fully switch on,
so if more than 100mA flows through
one of the 10W resistors, there is no
longer sufficient voltage (out of the
3.3V logic level signals) to turn on
the Mosfet, and the current is limited
to this level.
The Mosfet will not handle a short
circuit to 12V indefinitely, even with
current limiting, but will survive longer than if it were exposed to a direct
short circuit. With four 100mA outputs, a 500mA motor plus some tens
of milliamperes consumed by the
microcontroller, the Decoder is also
kept under the 1A limit of BR1.
The remaining circuitry is a so-called
keep-alive that allows another larger
capacitor to be connected, so that
the Decoder can operate over dirty
track or in other cases of intermittent
This Decoder
is fitted with a
full complement of the
wires that have colours set
out in the DCC standards. There
is also a small capacitor fitted to the
keep-alive connections.
DCC power. The capacitor is charged
via the 100W resistor, limiting the
peak charging current. The power is
returned to the circuit when needed
via D1, a schottky diode.
We haven’t specified a capacitor
here, since the circuit is fully functional without it. If needed, the capacitor can be chosen based on the space
available in the locomotive. It is completely optional and unnecessary in
most cases. This is also a handy location to pick off 12V if needed for other
circuitry.
The pins needed for in-circuit
serial programming (1, 4, 12, 13 and
14) are connected to the ICSP header
pads, with the standard 10kW pullup
resistors between pins 4 (MCLR) and
1 (Vdd); pin 14 is ground. The 3.3V
power and ground connections on the
ICSP header can also be used to power
other circuitry if required. Connection
diagrams Figs. 3 & 4 show these locations on the PCB.
Firmware operation
1 double-sided 14 × 23mm PCB coded 09111241, 0.8mm thick
1 PIC16F18126-I/SL 8-bit microcontroller programmed with 0911124A.HEX,
SOIC-14 (IC1)
1 DRV8231DDAR motor driver IC, SOIC-8 (IC2)
1 MCP1703A-3302 3.3V SOT-23 LDO regulator (REG1)
4 2N7002 SOT-23 N-channel Mosfets (Q1-Q4)
1 1A SMD bridge rectifier BR1 [MBS4 or CD-MMBL110S]
1 1N5819WS SOD-323 schottky diode (D1)
1 3cm length of 20mm diameter heatshrink tubing
Capacitors (all SMD M2012/0805 size MLCC)
2 10μF 25V X5R
1 100nF 50V X7R
Resistors (all SMD 1%, M2012/0805 size, ⅛W unless noted)
2 100kW
6 10kW
1 1kW
1 100W
The DCC Decoder
4 10W
shown at actual size.
1 0.68W ¼W
The main role of decoding the
incoming DCC signal is performed by
an interrupt service routine (ISR) that
is triggered every 22μs. DCC uses pulse
widths of 58μs (nominal) to encode a
binary ‘1’ bit, with widths over 100μs
encoding a ‘0’ bit. By counting the
time between DCC polarity changes,
the bits can be decoded.
The Decoder then assembles the bits
into packets, looking for a long string
of 1s (‘preamble’) as the start marker.
Since each byte is preceded by a zero
bit, the firmware can easily determine
its position within a packet.
Each packet also includes a checksum; if this doesn’t match what the
Decoder calculates, the packet is
rejected as the data has been corrupted.
Finally, the packet address (encoded
as the first one or two bytes) is used
to determine how the packet should
be treated.
siliconchip.com.au
Australia's
electronics
magazine
DCC Decoder Kit (SC7524, $25): includes
everything
in the parts
list
December 2025 73
Parts List – DCC Decoder
DCC Glossary
Accessory Decoder: A DCC decoder that is designed to be used in a fixed location; for
example, to control points or signals, or fixed lights like streetlights. They operate within a
separate address space to the decoders used in locomotives.
Analog: Describes the traditional mode of model railway operation, where a voltage is applied
to the track that directly drives the locomotive’s motor via wheel pickups. The analog
controller sets the voltage and polarity to determine the speed and direction.
Base Station: A device that drives tracks with a DCC signal and has the means to accept user
input to control the decoders. Many also incorporate programming features as well.
Booster: A device that can drive tracks with a DCC signal but has no user input. It might take
its signal from a separate Base Station or other system. A booster is often used to increase
the amount of power that can be delivered to the track.
Consist: In full-scale railway parlance, a consist is a grouping of rolling stock that operates
together and might include locomotives, passenger cars and freight cars. In DCC, it describes
a grouping of mobile decoders with a common consist address, allowing them to be operated
as though they were a single unit.
CV (Configuration Variable): A non-volatile variable (typically stored in EEPROM) that
determines a decoder’s operating behaviour. This includes the address (fleet number) that it
responds to and how its motors and functions react to user input.
DC: See Analog.
Decoder: A device that receives power and data from a DCC signal and drives lights, motors
etc. Mobile decoders can be fitted to rolling stock, while accessory decoders can control
trackside equipment.
Keep-Alive: A means of providing power to a mobile decoder if the track contact is poor
or intermittent. It usually consists of a capacitor and some circuitry to keep the capacitor
charged, feeding power back to the decoder as needed.
Locomotive: For DCC, this typically includes any item of rolling stock that is fitted with a
motor and mobile decoder, including passenger railcars and motorised tenders.
Long Address: A 14-bit address with valid values from 0 to 10239. This range includes all
four-digit numbers.
Mobile Decoder or Multifunction Decoder: Also known as a locomotive decoder, it is a
decoder designed to operate the motor and lights of a mobile item of rolling stock, such as a
locomotive, although it could be fitted to a passenger railcar or other powered unit.
Operations Mode: A form of CV programming that can occur on an operating track. The
programming packets are addressed and can target a specific decoder. This is the only form
of programming that can occur while the locomotive is active.
Programmer: A device that can perform CV programming. This might include a Base
Station that includes programming features or a standalone device like our Arduino-based
Programmer from October 2018 (siliconchip.au/Article/11261).
Service Mode: Address-only, Physical, Paged and Direct modes do not program decoders by
address, so they must occur on a segregated track in service mode to ensure that only the
target decoder receives the programming commands.
Short Address: A 7-bit address in CV1. It is the only CV that is mandatory. Addresses up
to 127 are valid, but values above 111 conflict with the addresses used for service mode
programming packets and are best avoided.
As well as commands addressed
to specific locomotives, there could
also be broadcast packets on address
0. These allow all trains to be stopped
quickly. Some packets are used to program configuration variables.
The 22μs timer is also divided down
into 7ms intervals to manage the acceleration and deceleration of the motor.
This is a feature of DCC that allows the
locomotive speed to be ramped up or
down at a rate to simulate inertia.
A separate 4Hz timer is used to
allow the function outputs to be modulated in various flashing patterns. An
74
Silicon Chip
eight-bit CV is used to set whether
or not a function output should be
switched on, so flash rates from ½Hz
to 2Hz are possible, as well as other
sequences.
Using these timers, the Decoder also
monitors how long it has been since it
has received a valid packet addressed
to it. This can be used to stop the loco if
a packet has not been received within
a certain period.
If the firmware sees a correctly
addressed packet, it is decoded and
the internal state is updated. This
could involve changing the speed or
Australia's electronics magazine
direction, or switching some of the
function outputs on or off.
IC1’s internal analog-to-digital converter is used to measure the voltage
on the 12V rail. This can be used to
compensate the motor and function
outputs, to even out variations on the
12V rail. This can happen with dirty
track or if the Decoder needs to source
current from the keep-alive capacitor.
The motor driver is provided with
a PWM (pulse-width modulated) signal to vary the motor speed. This raw
speed value received is altered by the
acceleration, deceleration and compensation features and can also be
adjusted by means of CVs that can
be used to alter the speed mapping
profile.
There are also CVs that can be used
to remap the function commands
(as received in the DCC packets) to
specific function outputs, so this is
another processing step that occurs,
as well as applying any flashing patterns that have been set.
CV programming
CV programming involves modifying the configuration variables (CVs) to
change the Decoder’s behaviour. The
CVs are kept in non-volatile EEPROM,
so are not lost during a power cycle.
The list of CVs supported by our
Decoder is shown in Table 1. These
operate as described in the DCC standards, except for those set aside for
manufacturer-specific features.
For example, CV1 is used to hold a
7-bit value that is known as the short
address. Thus, changing CV1 allows
the Decoder to respond to a different address. This is key to how DCC
allows multiple locomotives to operate on the same tracks. Typically, the
address will correspond to the fleet
number painted on the locomotive or
item of rolling stock.
The firmware also looks for the specific sequences needed for CV programming and updates the EEPROM
and all live operating parameters.
Since CV programming can make
permanent changes, extra checks are
made to validate these commands.
One check that is performed (and
required by the standard) is to only
make changes when two consecutive,
identical packets are received.
There are several different programming modes, but our Decoder fully
supports Address-only, Physical,
Paged and Direct modes. These fall
siliconchip.com.au
Table 1: configuration variables supported
CV
Notes
Default
1
A 7-bit value for the short address (the eighth bit is ignored). Values above 99 are not recommended because some
of them conflict with the addresses used for service mode programming. Many systems restrict this to the range 0-99
and use the long address (CV17 and CV18) for all 3- and 4-digit addresses. The default address of 3 is standard.
3
2
Start voltage. This value (as a fraction of 255) dictates the proportion of voltage that is applied at the lowest speed
setting.
0
3
Acceleration. A value of 0 means acceleration is disabled (the speed is updated instantly). Different systems are in
use, but this Decoder applies a speed step every (7ms × value of CV3). Higher values mean slower acceleration, so a
setting of 3 will result in one speed step every 21ms.
0
4
Deceleration. Works the same as Acceleration, but allows a different rate to be applied for deceleration.
0
5
High voltage. This value (as a fraction of 255) dictates the proportion of voltage that is applied at the highest speed
setting. If it is 0 or 1, it is treated the same as 255, ie, full voltage.
0
6
Mid voltage. This value (as a fraction of 255) dictates the proportion of voltage that is applied at the middle speed
setting. If it is 0 or 1, it is ignored (only the start and high voltages are used in calculations).
0
7
Manufacturer version number (read only).
0x5C (‘SC’)
8
Manufacturer identification number (read only). The value of 13 has been allocated by the NMRA for the identification
of DIY decoders.
13
11
Packet timeout. This value dictates how many seconds a decoder will maintain speed without receiving a validly
addressed packet. When set to 0, the decoder will not time out and will continue to maintain speed.
0
17
Most significant bits of the long address. The long address is nominally 14 bits and the top two bits of CV17 are set.
The range of valid values for CV17 is restricted to 192-231, allowing the meaningful bits to represent the values 0-39.
This gives an address range from 0-10239, which includes all four-digit decimal numbers.
192
18
The least significant bits of the long address.
0
19
Consist address and direction. Consisting allows multiple locomotives to be allocated to a train under the control
of a single address, the consist address. The lower seven bits form a short address that can be used for consist
addressing. When these seven bits are set to 0, consist mode is off; otherwise, the Decoder will respond to its consist
address instead of its short or long address. When the upper bit is set, the locomotive operates in the opposite of its
normal direction (eg, for running back-to-back with another locomotive).
0
29
Basic configuration. The bits in this CV each correspond to a basic configuration setting. Our Decoder implements:
Bit 0: When set, the locomotive reverses its direction of travel.
Bit 1: When set, the Decoder interprets baseline speed packets as 28-step; when clear, as 14-step. The Decoder will
also respond to 128-step packets at all times.
Bit 5: When set, the Decoder responds to its long address; otherwise, it uses its short address.
2
The default values for CVs 33-37 are 1, 2, 4, 8 and 0 respectively, meaning the functions are mapped across each row. It is possible to
configure multiple commands to control a single output or for a command to control multiple outputs.
33
Headlight forward command → F0F output (RA5)
1
34
Headlight reverse command → F0R output (RA4)
2
35
F1 command
→ F1 output (RC3)
4
36
F2 command
→ F2 output (RC2)
8
37
F3 command
→ Mapped to none
0
CVs in the range 47-64 are free for custom use by designers. We have implemented them as follows.
47
Voltage compensation. When enabled, the Decoder adjusts the PWM duty cycle to counteract changes in the supply
voltage.
Bits 0-3 (values 1-15): when set, the Decoder sets the function outputs to match the voltage to the setting. For
example, if the Decoder’s supply voltage (measured at the bridge output) is 14V and bits 0-3 are set to 7 (0111),
then the functions will be driven with a 50% duty cycle output.
Bit 4: when set, the decoder compensates the motor PWM to make the full speed value correspond to 16V.
When either value is set to 0, the corresponding compensation is disabled.
0
For CVs 49-52 each bit corresponds to a time slice of ¼ second over a two-second period, with the MSB occurring first.
A set bit means the function output is on and thus different values will give different flash patterns. Where two different
values are provided, they will operate out of phase. All values 0-255 are valid, see the right-hand column for what some
example values will output.
255: solid on
85 or 170: 2Hz
51 or 204: 1Hz
15 or 240: ½Hz
49
F0F output (RA5) → Flash pattern
255
50
F0R output (RA4) → Flash pattern
255
51
F1 output (RC3)
→ Flash pattern
siliconchip.com.au
52 F2 output (RC2) → Flash pattern
Australia's electronics magazine
255
December
255 2025 75
Figs.3 & 4: there is little room on the PCB for silkscreen markings, so you
will have to pay close attention to these overlay diagrams, shown at ~400%
scale. The Decoder will typically be wired into a locomotive as shown here.
If using lamps, the polarity doesn’t matter & series resistors are not needed.
into the category of what is known as
service mode programming.
These modes do not use the Decoder
address, so are typically done on a segregated programming track to target
a single Decoder. They would most
often be used during initial setup of
the locomotive after the Decoder is
installed, before it is placed on the
mainline track.
Our Decoder also supports the long
form of operations mode programming, which is intended to be used on
a mainline track. It thus includes an
address parameter, to ensure that the
commands are directed to the correct
decoder amongst the many that might
be on the main track.
This mode could be used to tweak
76
Silicon Chip
the speed or acceleration profile and
then perform testing without having
to shuffle the locomotive to and from
the programming track. As such, this
mode does not permit changes to critical CVs like addresses.
Decoder assembly
The Decoder is built on a double-
sided PCB coded 09111241 that measures just 14 × 23mm. It has been
deliberately kept as small as possible,
to fit in tight spaces (it’s even thinner than a normal PCB at 0.8mm), so
there isn’t much room for designators
on the silkscreen. You will have to
closely follow the overlay diagrams
(Figs.3 & 4) to ensure all parts are fitted correctly.
Australia's electronics magazine
The passive components are all
M2012/0805 size (2.0 × 1.2mm), while
the rest are in SOT-23 or SOIC packages. None are too difficult to solder,
but it would be ideal for prospective
constructors to have some SMD experience.
We recommend that you have on
hand flux paste (ideally in a syringe),
solder-wicking braid, a magnifier, finetipped tweezers and the usual SMD
gear. We found it easier to start assembly with the top side of the PCB; this
has the track and motor connections
(M and T) and the SOIC-8 chip, IC2.
A PCB holder or some Blu-Tack will
be handy to secure the board and prevent it from moving around.
IC2 has an exposed pad on its underside. We have placed a large hole under
that pad so that you can flow solder
through from the other side, or melt
solder paste via that hole.
To ensure that solder will flow
through this hole from the other side
of the board, add plenty of flux paste
to the pad under the IC and inside
that hole. That should help to draw
solder through from the other side of
the board.
Solder this first so that you can
check that this joint is secure before
starting on any other pins. This could
also be soldered with a reflow oven, if
you have one. We secured the chip flat
against the PCB with polyimide (Kapton) tape and then flipped the board
over to feed solder through the pad
hole on the other side.
Flow solder into the hole and apply
heat for a few seconds. If the chip is
properly soldered, after removing the
tape, the chip remains in place. Then
solder the remaining leads. After that,
fit REG1 as shown. The single diode,
D1, has its cathode towards the bridge
rectifier and track connections.
The two capacitors on this side
are both 10μF parts. Once they are
in place, solder the bridge rectifier,
being sure to orientate it correctly.
Follow with Q4 and the resistors on
this side, being careful to match their
values. Flip the PCB over and solder
Mosfets Q1-Q3 and IC1. Note that both
ICs have their pin 1s towards the centre of the PCB.
The sole 100nF capacitor is in one
corner of the PCB. The seven remaining resistors can then be fitted. Clean
off the excess flux with an appropriate solvent and allow the PCB to dry,
inspect it carefully and rectify any
siliconchip.com.au
We have wired up this compact N-scale motorised chassis (Kato 11-107) using our Decoder, allowing us to run tests on a
short length of track. We removed two folded metal strips from inside the chassis to break the electrical connection between
the track pickups and the motor. For clarity, we have left off the heatshrink, but we recommend you fit it to prevent short
circuits. For views inside the mechanism, see www.hookstonemodels.co.uk/dcc-conversion/kato/11-107-chassis
solder bridges or dry joints before powering up the Decoder.
Programming IC1
If you have purchased a kit or programmed IC, IC1 will be programmed
and programming will not be needed.
Otherwise, you can use a Snap, PICkit
BASIC, PICkit 4 or PICkit 5 to program the 0911124A.HEX file onto
the chip.
We were able to program one of
our prototypes by fitting a 5-way pin
header strip to a PICkit 5’s header
socket and then pressing that against
the Decoder’s ICSP header pads. We
used the PICkit 5 to provide 3V power.
If that doesn’t work, then you may
need to temporarily solder a header
strip to the Decoder’s ICSP header
pads. The pad spacings are slightly
narrower than 0.1in (2.54mm), but a
standard 0.1in header can be made to
fit without too much trouble.
Testing
If you would like to run some tests
on the Decoder, you can apply power
from a 9V battery to the ‘T’ pads that
feed into the bridge rectifier. Because
of the bridge, the polarity does not
matter.
This should power up the Decoder
and you should see about 7.5V across
the keep-alive pads. The output of the
3.3V regulator should be available on
pins 2 and 3 of the ICSP header. You
can see these connections in Figs. 3
& 4. If these voltages are present and
nothing is getting hot, all is as well as
can be expected.
Connections
The connections to the Decoder are
shown in Figs.3 & 4, with the wire
colours chosen to match those set
out in the DCC standards. The other
siliconchip.com.au
connections are not part of the standard, but could be useful. If you have
previously installed a decoder in a
locomotive, these colours should be
familiar.
There is a lot of detail in fitting a
Decoder to a locomotive. We can only
provide some general advice, but anyone with a reasonable understanding
of electronics should be able to figure it out.
It’s a good idea to check the voltage
and current demands of the locomotive and any additions before making
any changes. We expect that LEDs
and most small, modern motors will
satisfy the requirements, but incandescent globes and older motors may
draw more current than the Decoder
can provide.
One of the most important things
is to ensure that all existing connections between the wheel pickups (to
the track) and the motor or lights are
broken. An existing connection may
conflict with a connection made by
the Decoder, causing a short circuit.
In Fig.1(a), the red lines show the
wires that might typically need to be
cut; note that the diodes will probably be discarded in this case, as the
Decoder provides rectified DC to the
function outputs. Check the polarity
of any LEDs carefully as well, since
they may need to be reversed.
In practice, the red and black (track)
wires will go to the wheel pickups
on the locomotive. They are effectively interchangeable, but the standards specify that the red wire should
connect to the right-hand rail when
the locomotive is travelling in the forward direction.
The grey and orange wires go to
the motor and, again, they are interchangeable in practice. The standards
say that it should be wired up so that
the locomotive moves forward when
the orange wire has the more positive
voltage.
We suggest you connect these wires
in whatever way is easiest. If it turns
out that the locomotive drives the
wrong way, that can be fixed by simply changing a configuration variable.
The blue wire effectively provides
a positive supply, with the various
function outputs connecting to negative when active. Thus, LEDs should
have their anodes connected to the
blue wire; common-anode LEDs are
typical. There is usually enough voltage to allow two or maybe three LEDs
to be connected in series with a single
ballast resistor.
The default configuration makes the
white wire active when the locomotive is going forward and the yellow
Fig.5: wire up a Pico 2 and a 9V
battery like this to use the Arduino
sketch to test the Decoder. The
resistors are simply provided for protection against
damage to the Pico 2 or a connected computer. You
should also connect some lights or a motor as per
this diagram to see the outputs working.
Australia's electronics magazine
December 2025 77
Silicon
Chip
PDFs on USB
wire active when the locomotive is in
reverse. Again, it might make sense to
use whatever wire is convenient and
change the function mapping using
the configuration variables.
Remember to thread heatshrink tubing over the wires before soldering
them, then shrink it into place once
everything is tested and operational
to prevent accidental short circuits.
If you don’t plan on wiring an
external capacitor to the keep-alive
pads, you might be able to fit another
surface-
mounting capacitor (similar
to the 10μF parts already on the PCB)
directly across these pads. That will
give the Decoder a small extra power
reserve.
Arduino test sketch
The USB also comes
with its own case
¯ A treasure trove of Silicon Chip magazines on a 32GB
custom-made USB.
¯ Each USB is filled with a set of issues as PDFs – fully
searchable and with a separate index – you just need a PDF
viewer.
¯ Ordering the USB also provides you with download access
for the relevant PDFs, once your order has been processed
¯ 10% off your order (not including postage cost) if you are
currently subscribed to the magazine.
Receive an extra discount If
you already own digital copies
of the magazine (in the block
you are ordering).
Conclusion
THE FIRST SIX BLOCKS COST $100 OR PAY $650 FOR ALL SEVEN (+ POST)
NOVEMBER 1987 – DECEMBER 1994
JANUARY 2005 – DECEMBER 2009
JANUARY 1995 – DECEMBER 1999
JANUARY 2010 – DECEMBER 2014
JANUARY 2000 – DECEMBER 2004
JANUARY 2015 – DECEMBER 2019
OUR NEWEST BLOCK COSTS $150
→
JANUARY 2020 – DECEMBER 2024
WWW.SILICONCHIP.COM.AU/SHOP/DIGITAL_PDFS
78
Silicon Chip
We are providing an Arduino test
sketch (DCC_ADD3_TEST) that can
be used if you have a locomotive (or
motors and lamps) and Decoder, but
not a base station. It is written for a
Pico or Pico 2 using the arduino-pico
board profile. It is based on the code
we have developed for the upcoming
Base Station.
The sketch produces a logic-level
DCC signal between GP0 & GP1 pins
and expects power to be provided by
other means. We can use the keep-alive
connections for this purpose; something like a 9V battery would work and
provide a limited current. Note that the
polarity is important when connecting
to the keep-alive pads.
Fig.5 shows the wiring needed to
run a test with the Arduino sketch.
You will also need to connect a motor
or lights to see any effect. The sketch
produces commands with the default
address of 3, and drives the motor outputs in both the forwards and reverse
directions. The function outputs are
activated in turn, with the actions
shown on the serial monitor.
Australia's electronics magazine
Readers who already have a DCC
system will quickly integrate DCC
Decoders into their layout and have
their own ideas about how to set
them up.
A DCC Decoder is not much fun
on its own, so we will be following
up with the DCC Base Station next
month. We will also provide more
background with a feature article for
getting started with DCC in case you
have not worked with a DCC system
SC
before.
siliconchip.com.au
|