This is only a preview of the May 2026 issue of Silicon Chip. You can view 44 of the 112 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. Items relevant to "Power Amp Clipping Indicator":
Items relevant to "Simple LC Meter":
Items relevant to "WiFi Alarm Monitor":
Articles in this series:
Items relevant to "μDCC Decoder":
Purchase a printed copy of this issue for $14.00. |
By Tim Blythman
Remote Controller
DCC Booster
Stepper Motor Driver
μDCC Decoder
microDCC Decoder
μDCC
The DCC Decoder design in the December 2025 issue is very small, but sometimes not small
enough. The μDCC Decoder is designed to be a bare minimum decoder to take up less space, but
we’ve still managed to squeeze in a couple of handy features that make it very useful beyond just
Image source: https://unsplash.com/photos/black-model-train-moving-through-a-garden-hc9xarcmpM8
being smaller than its predecessor.
W
e designed the DCC Decoder, from the
December 2025 issue, as a simple,
inexpensive but complete unit
that can add DCC capabilities to small
model railway locomotives in the HO
and N scales.
As I started adding them to my
fleet of models, I realised that I could
make a couple of changes that would
improve their usefulness. I’m not saying that this design is better or worse
than the original Decoder, but it is
smaller, and I have added some features that I think might be of interest.
I recently made the jump to N scale
after previously working with HO scale.
With the help of a 3D printer, I started
scratch-building some model trams,
which are even smaller than trains!
I thought that the original Decoder
would be a good size for what I wanted
to model, but those who have done
any work at this scale will know that
anything that can save space will
Features & Specifications
be helpful. So I looked at the earlier
design to see what I could take out to
make it even smaller.
First, I didn’t think that I really
needed four function outputs, so I
discarded two of them. This removes
four resistors and two transistors from
the board. Next, I removed the circuitry to sense the incoming supply
voltage; two more resistors removed.
This means that the μDCC Decoder has
only two function outputs and does
not have the ability to compensate for
supply voltage changes.
I also figured I could do without
the 100nF capacitor on the microcontroller since the micro would be close
enough to the existing 10μF regulator
output filter capacitor.
Hardware-wise, these are pretty
much the only differences between
the original Decoder and the μDCC
Decoder. The newer board is only 12
× 18mm, down from 13 × 28mm; only
In model railways, smaller
is generally better. The μDCC
Decoder is only 12mm ×
18mm with two function
outputs and even has a
basic sound function.
🛤 Size: 18 × 12 × 4mm
🛤 Two 100mA function outputs
🛤 Sound output
🛤 Standard DCC features like the December 2025 DCC Decoder
84
Silicon Chip
Australia's electronics magazine
60% of the area! Fig.1 shows the circuit diagram, and you can see that it
really is just a cut-down version of the
earlier design.
It looks like there are some unused
pins that are wasted, but I have redeployed I/O pin 11 to supply the 3.3V
reference that came directly from the
3.3V regulator in the earlier design; the
firmware simply holds this at a high
level (3.3V) at all times. This avoids
an awkward trace that would otherwise have had to cut across the board.
Having a few unused pins made
the PCB trace routing easier and more
compact, so it actually ended up being
a good compromise. I have made some
extra signals available on the RA0/PGD
and RA1/PGC pins; they have been
chosen mainly because they already
have external connections available
at the ICSP (in-circuit serial programming) header.
Just like in the earlier design, track
power is rectified by diode bridge
BR1. REG1 provides 3.3V to power
the microcontroller. The DCC signal
polarity is sensed via the two 100kW
resistors, and the micro drives the
outputs on pins 2, 3, 5 and 6 to control transistors Q1 and Q2 and motor
driver IC2. These would be connected
siliconchip.com.au
Fig.1: the μDCC Decoder circuit is very similar to the December 2025 DCC Decoder, with a few components removed. The
3.3V reference for the motor driver IC comes from a pin on IC1 to simplify the PCB routing.
to accessories (such as lights) and the
locomotive motor, respectively.
The 100W resistor and series diode
D1 allow a capacitor to be fitted to provide ‘keep-alive’ power that can help
compensate for intermittent contact
due to dirty track. In other respects,
operation is the same as the earlier
design.
Bonus features
The PIC16F181xx family of chips
has an 8-bit DAC (digital-to-analog
converter) that has reasonable drive
strength. It isn’t specified what current it can deliver, but tests indicated
that it would be possible to source and
sink up to 20mA.
After removing excess features
from the earlier Decoder firmware,
the PIC16F18126 has around 12kB
of unused flash memory, which is
enough to hold a fraction of a second of
8-bit sampled audio data. So I investigated driving a small piezo transducer
with the DAC to reproduce audio.
The DAC output is directed to pin
13, since this is broken out amongst the
ICSP pins. It has a ground pin next to
it on the ICSP header, so it’s fairly easy
to make the necessary connections to
the transducer. An electromagnetic
siliconchip.com.au
speaker will likely have an impedance
that is too low to work; you must use
a high-impedance device like a piezo
transducer.
The piezo I tested measures 9mm
square and 2mm thick. Its model
code is in the parts list; I’ve managed
to squeeze this device into several
N-scale models. The piezo transducer
has a peak response around 4kHz,
which is quite high, and I quickly
found that high-pitched sounds were
reproduced much better than lower-
pitched sounds.
This means that a high sampling rate
is needed; fortunately, the DCC firmware already includes a 22μs timer
interrupt, which (at 45.4kHz) is fairly
close to the 44.1kHz sample rate used
in audio from sources like CDs. This
made it easy to experiment with existing samples.
So, onboard audio production is
possible, but the result is not hifi! Still,
I was able to recreate some recognisable sounds for a model railway. The
best sound I could recreate was a tram
bell. This could also pass for the level
crossing bell used on some diesel locomotives. The μDCC Decoder would
also work well as a stationary decoder
for a level crossing’s lights & bells.
I figured that a steam locomotive
whistle might also be sufficiently highpitched to work, so I’ve synthesised
a sample that emulates this. We’ve
made a recording of these sounds being
played by the μDCC Decoder, so that
you can hear for yourself. It’s an MP3
audio recording from siliconchip.au/
Shop/6/3587
The 8-bit microcontroller has modest processing power and would struggle to mix the two sounds, so we have
DCC PROJECT KITS
DCC Base Station, January 2026 (SC7539, $90)
DCC Remote Controller, February 2026 (SC7552, $35)
DCC Booster, March 2026 (SC7579, $45)
DCC Stepper Motor Driver & Decoder, April 2026 (SC7601, $30)
microDCC (μDCC) Decoder, May 2026 (SC7617, $25)
includes all the parts and the optional piezo (wire not included). Specify if
May 2026 85
Australia's
electronics
magazine
you
want a bell
or whistle
sound programmed into the microcontroller.
Pay close attention to the resistor
values and component polarities.
Fortunately, the two capacitors are
of the same value. The regulator
and transistors are all in SOT-23
packages, so be sure not to mix them
up.
Screen 1: It’s incredible what is
possible with model trains; tiny LCD
modules like these add another element
of realism. The CV48 serial data feature
is intended to control features that don’t map well to traditional DCC
function outputs. Source: https://youtu.be/tC_t22RfQ0c
created two firmware files: one for
the bell sounds and one for the whistle sound. If combined, the samples
would also have to be shorter.
Sound is controlled by a function
output. The bell sound will repeat as
long as the function is active, and a
cheery “ding-ding” will be heard if
the function is held for about half a
second. The whistle sound will ramp
up and keep playing until the function
is switched off, after which it quickly
decays to silence.
We’ve also added another output to
the μDCC Decoder. It is intended to
allow communication with another
microcontroller that could implement
other features.
One application that came to mind
is a form of headboard or destination
display, such as a second microcontroller driving a small OLED module or
LCD. When it receives a byte over the
serial link, it can update the display.
This would only happen occasionally,
so would be easy to control with the
Base Station’s CV programming page.
The YouTuber diorama111 has
implemented this type of display in
HO scale models, although it is controlled through an infrared remote control. Screen 1 shows a still from the
video at https://youtu.be/tC_t22RfQ0c
The output is a UART (serial data)
signal that is available on RA1/PGC,
the other I/O pin that is free on the
ICSP header. It operates at 3.3V, 9600
baud with eight data bits. This protocol
EEPROM location
Stepper Driver
μDCC Decoder
Extra output
Decimal Hex
86
DCC Decoder
CV Default
Hex
CV Default Hex
CV Default Hex
0 0x00
29 2
0x02
29 2
0x02
29 2
0x02
1 0x01
1 3
0x03
1 3
0x03
1 3
0x03
2 0x02
19 0
0x00
19 0
0x00
19 0
0x00
3 0x03
18 0
0x00
18 0
0x00
18 0
0x00
4 0x04
17 192
0xC0
17 192
0xC0
17 192
0xC0
5 0x05
2 0
0x00
3 0
0x00
2 0
0x00
6 0x06
3 0
0x00
4 0
0x00
3 0
0x00
7 0x07
4 0
0x00
5 64
0x40
4 0
0x00
8 0x08
5 0
0x00
33 1
0x01
5 0
0x00
9 0x09
6 0
0x00
34 2
0x02
6 0
0x00
10 0x0A
33 1
0x01
35 0
0x00
33 1
0x01
11 0x0B
34 2
0x02
36 0
0x00
34 2
0x02
12 0x0C
35 4
0x04
37 0
0x00
35 4
0x04
13 0x0D
36 8
0x08
49 255
0xFF
36 0
0x00
14 0x0E
37 0
0x00
50 255
0xFF
37 0
0x00
15 0x0F
49 255
0xFF
11 0
0x00
49 255
0xFF
16 0x10
50 255
0xFF
50 255
0xFF
17 0x11
51 255
0xFF
11 0
0x00
18 0x12
52 255
0xFF
19 0x13
11 0
0x00
20
0x14 Chip47 0
Silicon
0x00
TableAustralia's
1: CV toelectronics
EEPROMmagazine
mapping
is simple and common enough that
any microcontroller should be able
to receive it and provide some custom functions.
It is controlled through a virtual configuration variable (CV), CV48. Operations mode programming allows this
CV to be programmed ‘on the mainline’. Any time the μDCC Decoder
receives a write command to program
CV48, it sends the corresponding data
byte over the serial output. That’s all
there is to it.
These pins are shown on the overlay/wiring diagrams later in the article. If you don’t want or need these
two features, you can just leave these
pins disconnected.
Construction
Like the earlier Decoders, this is a
small design using surface-mounting
parts, so you’ll need the gear and
expertise to handle that. Many of the
comments from the DCC Decoder also
apply here. For example, you can
increase the value of the 0.68W resistor to reduce the motor current limit,
although you should not decrease it
below 0.68W.
The μDCC Decoder is built on a
double-
sided PCB coded 09111247
that measures 12 × 18mm and is
0.8mm thick. Work through the overlay diagrams, Figs.2 & 3. Start with the
side that has IC2 and BR1. Solder these
first, noting their polarity. Follow with
D1, making sure its cathode stripe is
nearest the pads marked T.
Also on this side is one of the 10μF
capacitors, right next to the bridge rectifier outputs. The two 100kW resistors,
the 100W resistor and the 0.68W resistor are also on this side of the PCB.
Flip the board over and fit REG1 (near
IC1) and Q1 and Q2 (near the edge of
the board).
Solder IC1 in place with its pin 1
marker nearest to REG1. The resistors on this side are the 10kW and 10W
siliconchip.com.au
Programming a DCC Decoder without a DCC Programmer
We’ve presented a thorough series of DCC
system components over recent issues,
including the Base Station hardware, which
has comprehensive DCC programming capabilities. But it occurred to us that many of
our readers will probably have hardware at
their disposal that will allow programming
our Decoders (from this series) without a
dedicated DCC programmer.
Our Decoders are all based on PIC microcontrollers, which are easily programmed
with devices like the various PICkit programmers or even the Snap programmer (which we
now carry in the Silicon Chip Online Shop at
siliconchip.au/Shop/7/7588).
The configuration variables (CVs) that are
involved in Decoder programming are simply
locations in EEPROM and thus they can be
changed with the appropriate PIC programming hardware. So this guide explains how
to program the CVs in our Decoders using a
PIC programmer.
Table 1 shows which CVs correspond to
which EEPROM address on each Decoder.
Below we explain how to modify the EEPROM
values for programming. We’ll assume you’ve
used a programmer like this before, and know
how to make the necessary wiring connections to program a PIC microcontroller. It’s
also assumed that you understand the CVs
that you want to program.
Read-only locations like CV7 and CV8 are
not implemented in EEPROM, so cannot be
modified. Of course, we have provided the
source code for all three projects, so you
can modify the source code and recompile
the project (using MPLAB X IDE) to make
those or any changes you like. The default
values for all the CVs are set near the start
of the dcc.h file.
If you are simply looking to adjust some
of the CVs, we recommend just using the
MPLAB IPE (integrated programming environment) software. Screen 2 shows the IPE
with the PIC16F18126 selected; as you would
need for any of the Decoder projects.
Select the appropriate HEX file by using
the Browse button and then open the
EEPROM view from Window → Target Memory Views → EE Data Memory. From here,
you can edit the EEPROM values directly.
The hexadecimal values in Screen 2 correspond to the original DCC Decoder from
December 2025.
Editing the EE Data Memory window will
not directly change the HEX file, but you can
export the edited file from the File menu as
a new HEX file. The exported HEX file can
be reloaded later using the Browse button
noted above.
When you have made the necessary edits,
hook up your programmer to the Decoder,
press Connect and then press Program
to change the values stored on the chip.
Remember that you should not have anything else connected to the ICSP pins during
programming.
You can also download the contents of the
PIC’s non-volatile memory (including flash
memory, configuration bits and EEPROM)
with the Read button. You can then edit the
EEPROM values and program the new values
back into the chip.
While this is a slightly convoluted
method of CV programming, you can also
use it to save and restore program memory images and CV settings of the decoders
for safekeeping. We had a detailed guide
to CV programming in the Getting Started
with DCC guide in the January 2026 issue
(siliconchip.au/Article/19560).
◀ Screen 2: The MPLAB IPE can be
downloaded as part of the MPLAB
X IDE and provides an interface for
programming PIC microcontrollers (and
other Microchip parts). The EEPROM
entries at the bottom match the DCC
Decoder, with other locations left blank
(0xFF).
parts, so take care not to mix them up.
Don’t forget the other 10μF capacitor.
Clean the board of any excess flux,
inspect the board and allow it to dry.
If necessary, you can program the
chip at this point. Note that you cannot
use a PIC16F18124 or PIC16F18125 for
this project, since the larger flash memory of the PIC16F18126 is needed to
store the audio samples. You shouldn’t
need to program the chip if you have
purchased it from the Silicon Chip
Online Shop.
Also be sure not to connect the piezo
transducer or any other circuitry to
the ICSP pins (except a programmer)
siliconchip.com.au
during programming, since this will
interfere with the programming process. The remaining steps for testing
and wiring the μDCC Decoder to a
locomotive are much the same as the
DCC Decoder.
Operation
The μDCC Decoder operates in
much the same fashion as the DCC
Decoder from December; the implemented CVs all work the same. We’ve
given the μDCC Decoder a model
ID (CV7) of 0x5E (94 in decimal) to
differentiate it from the other two
Decoders.
Australia's electronics magazine
The other main differences (compared to the DCC Decoder) are that it
lacks CV47, CV51 and CV52. CV47 is
for voltage compensation, which the
μDCC Decoder can’t do. CV51 and
CV52 are not needed, since the corresponding function outputs have been
deleted.
The EEPROM Mapping panel in the
December issue has more information
about the CVs, see the panel on programming with a PIC programmer.
The audio output is equivalent to
the green wire function output (F1)
in other decoders. There are no effects
that can be applied, but it’s possible to
May 2026 87
Figs.2 & 3: the external connections
to the μDCC Decoder are via bare
solder pads as shown here. We
have been able to keep the main
DCC connections on the same side
of the PCB, with the audio output
using some of the ICSP pads on the
reverse.
Parts List – microDCC (μDCC) Decoder
1 double-sided 12 × 18mm PCB coded 09111247, 0.8mm thick
1 PIC16F18126-I/SL 8-bit microcontroller programmed with 0911124G.HEX
(bell sound) or 0911124W.HEX (whistle sound), SOIC-14 (IC1)
1 DRV8231DDAR motor driver IC, SOIC-8 (IC2)
1 MCP1703A-3302 3.3V LDO linear regulator, SOT-23 (REG1)
2 2N7002 N-channel Mosfets, SOT-23 (Q1, Q2)
1 MBS4 or CD-MMBL110S 1A SMD bridge rectifier (BR1)
1 1N5819WS 40V 1A schottky diode, SOD-323 (D1)
1 2cm length of 20mm diameter heatshrink tubing (to insulate Decoder)
2 10μF 25V X5R SMD M2012/0805 size MLCC capacitors
1 Same Sky CPT-9019A-SMT-TR piezo transducer (optional)
various lengths of wire as needed
Resistors (all SMD ±1%, M2012/0805 size, ⅛W unless noted)
2 100kW
3 10kW
1 100W
2 10W
1 0.68W ¼W
reduce the volume by adding a resistor
in series with the transducer.
The default setting maps the audio
to the F1 function output, so you can
use the F1 control on the Base Station to test the sound. The mapping
is due to the value of 4 appearing in
CV35. You can use other function outputs to control the audio by ORing
88
Silicon Chip
CV33-CV37 with a value of 4. For
example, to use F2 to control it, program CV36 with the value 4.
CV48 is not mapped into EEPROM,
so it can’t be read back. It will respond
to writes in all programming modes,
but we expect it will be most useful in operations mode on the main
track. Base Stations will typically send
Australia's electronics magazine
repeated programming packets, so the
μDCC Decoder may deliver multiple
serial bytes in response to this.
Custom sounds
It’s possible to change sounds, but
you will need to recompile the project files to do this. The audio samples
and config are in audio.c and audio.h.
The maximum sample size is around
13kB, which corresponds to around
300ms at 44.1kHz. Be sure to select
compiler optimisation level 2, which
is available even with a free license.
The samples are effectively 8-bit
unsigned values, but they should start
and end with a zero value (by ramping
up from zero and down to zero) so that
the DAC idles at 0V when not playing.
This will prevent power supply noise
from being produced at these times.
There are options to play the audio
either as a one-shot or as a loop. Note
that the one-shot will repeat if the
function stays on.
Use the bell sound as a template
for one-shot sounds and the whistle
as your guide for looping sounds. For
looping, you’ll need to set the AUDIO_
LOOP_START and AUDIO_LOOP_
END points. During playback of a looping sound, the sound will play up to
the loop end point and jump back to
the loop start to maintain a continuous sound.
Our process to generate the samples
is to use Audacity (free software) to
create an 8-bit, 44.1kHz mono WAV
file. We then use the HxD hex editor
program to strip out the 44-byte WAV
header and export the file contents as
a C byte array that can be pasted into
the assignment for the audioData variable in audio.c.
The code can automatically work
out the data size to stop playback
when the end of the data is reached.
The available sample space will be
slightly smaller for looping sounds,
since there is extra code needed to
handle the looping that will use up
some of the flash memory allocation.
Summary
While I had intended this design
to allow me to add DCC to some of
my smaller models, I’m quite proud
of being able to cram some simple
sound effects and other features into
a tiny 8-bit microcontroller. I’ve built
a few of these μDCC Decoders and
now all my N scale models are soundSC
equipped!
siliconchip.com.au
|