This is only a preview of the April 2026 issue of Silicon Chip. You can view 36 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:
Items relevant to "PicoSDR Shortwave Receiver":
Articles in this series:
Items relevant to "DCC/DC Stepper Motor Driver":
Items relevant to "Calliope Amplifier":
Items relevant to "Micromite-based Music Player":
Purchase a printed copy of this issue for $14.00. |
By Tim Blythman
Remote Controller
DCC Booster
Stepper Motor Driver
μDCC Decoder
Stepper Motor Driver
and Decoder
Stepper motors are capable of remarkably precise movement but are
more difficult to control than a brushed DC motor. This compact board
drives stepper motors with ease and can be configured to work with
different control inputs, including direct current and Digital Command
Control (DCC).
Image source: https://unsplash.com/photos/miniature-train-set-with-detailed-landscape-rNOwodoejTc
Y
ou might have seen that tiny stepper
motors are available quite cheaply
from online marketplaces like
eBay and AliExpress. A typical example is the assembly used to move the
laser head on a DVD drive (see the
photo below). This one is fitted with
a helical shaft for linear control of the
head assembly position.
I have been curious about whether it
would be possible to use such a motor
to drive a model locomotive. Tiny DC
motors are available, but are known
for high speed and low torque, which
is not a good match for the wheels on
a model locomotive.
Compact coreless DC motors
are often
used in
This stepper motor
is 15mm in diameter
and works well with our
Driver. The assembly is
similar to the type used in
CD/DVD/Blu-ray drives to
position the laser head.
50
Silicon Chip
quadcopters, where they only operate
at high speed.
Adding a gearbox can provide
appropriate speed and torque, but also
adds complexity and uses up valuable
space. Many stepper motors can be
driven slowly and still provide useful
torque directly from their output shaft.
Stepper motors require different
control circuitry; they typically have
two or more windings that are energised in sequence to control the speed
and direction of the motor. It’s not
possible to apply a DC voltage as can
be done for a simple brushed motor.
In this context, DC means a relatively
steady voltage of either polarity, or
perhaps a PWM (pulse-width modulated) voltage.
We’ve published articles about
stepper motors and the hardware
needed to drive them by Jim Rowe in
the past. The Quick Primer on Stepper
Motors (January 2019; siliconchip.au/
Article/11370) is a good place to start
if you aren’t familiar with how stepper motors work.
He also wrote about some stepper
motor driver modules in Part 22 of
the Cheap Modules series (February
2019; siliconchip.au/Article/11405).
This type of module makes it easy to
control a stepper motor using a microcontroller, but I thought it would be
handy to drive a stepper by applying a
DC voltage in the same way you might
power a brushed motor.
I realised that our recent DCC
Decoder (December 2025; siliconchip.
au/Article/19377) already has most of
This tiny board (shown at actual size in the lead
image and on the right) can run a small stepper
motor as though it were a DC motor. It can also
operate in DCC mode (with some parts left
off), using a stepper motor to power a model
locomotive. Some of the stepper motors and
assemblies that we were able to control with the
Driver are also shown in the lead; the largest is
15mm in diameter. The smaller two motors are only about
5mm in diameter and ran quite hot, so we recommend using
a lower current limit if driving such motors.
siliconchip.com.au
Features & Specifications
🛤 Four motor connections to suit bipolar
stepper motors
🛤 Two additional current-limited opendrain Mosfet outputs
🛤 Adjustable speed response
🛤 Selectable drive current limit
🛤 Can be configured for DC or DCC
operation
🛤 Maximum peak input voltage: 17V
🛤 Motor drive current: up to 500mA
🛤 Accessory outputs: up to 100mA
🛤 Module size: 24 × 13 × 4mm
the components needed for driving
a stepper motor. The firmware that
provides the DCC decoding function
would just need to be adapted to drive
a stepper motor instead of a DC motor.
So this Stepper Motor Driver and
Decoder (we’ll call it the Driver for
short) has two operating modes. It can
accept a DC voltage and generate a
waveform to drive a stepper motor as if
it were a DC motor. In other words, the
polarity of the applied voltage determines the direction of rotation, and
the magnitude determines the speed.
The other mode is to behave as a
DCC decoder. Instead of a brushed DC
motor, it has outputs that can be used
to drive a small stepper motor. Since it
has much in common with the earlier
Decoder design, we recommend that
you read the DCC Decoder article if
you have not already done so.
The Driver also has two open-drain
outputs that can sink current. In DCC
mode, these work in the usual fashion
as DCC function outputs (for lights or
similar accessories). In DC mode, one
switches on for one input polarity
and the other for the reverse polarity,
providing a similar directional lighting function.
DCC PROJECT KITS
DCC Decoder, December 2025 (SC7524, $25)
includes everything in the parts list
DCC Base Station, January 2026 (SC7539, $90)
includes everything in the parts list, except for the case, power supply, glue
and the CON4 & CON5 headers
DCC Remote Controller, February 2026 (SC7552, $35)
includes all required parts, except for the UB5 case and wire/cable
DCC Booster, March 2026 (SC7579, $45)
includes all required parts, except for the Jiffy box, OLED screen, power
supply and front panel. The OLED screen (SC7484, $7.50) and front panel
(SC7578, $5.00) are available separately.
DCC Stepper Motor Driver & Decoder, April 2026 (SC7601, $30)
includes all required parts for DC or DCC mode.
A with a positive voltage, then coil B
with a positive voltage. The next phase
is to drive coil A with a negative voltage, followed by coil B with a negative
voltage. The cycle then repeats. These
four phases correspond to the four
steps of the stepper motor’s rotation.
To drive the motor in reverse, the
sequence is reversed. Note that reversing the polarity of one coil will have the
same effect as reversing the sequence.
Most stepper motor drivers employ
micro-stepping, which effectively
interpolates the output between each
phase to create more, smaller steps.
Our Driver implements 256 microsteps, where the four phases noted
above correspond to microsteps 0,
64, 128 and 192. We use PWM (pulsewidth modulation) to interpolate
between the steps.
Scope 1 (with filtering applied for
clarity) shows the voltage at the four
stepper motor connections as the
Driver progresses through its cycle.
A+
6V
B+
A−
For example, microstep 32 (between
microstep 0 and microstep 64) drives
both coils A & B with a 50% duty cycle
in the positive direction.
Internally, the microcontroller has
a counter that dictates the current
microstep. Having 256 microsteps
means it is simple to loop around
when the counter overflows; we can
just ignore all but the lowest eight bits
of the counter.
The counter is incremented every
200μs (at 5kHz) and the increment
determines the rate at which the cycle
advances and thus how fast the motor
turns. Applying a negative increment
reverses the cycle and thus the direction of the motor.
It isn’t expected that the motor will
be precisely positioned to within 1/64th
of a step, but the choice of that many
divisions allows the speed to be set
with a reasonable resolution while
keeping the arithmetic simple for the
8-bit processor.
B−
A+
4V
Driving a stepper motor
The distinguishing feature of the
Stepper Motor Driver and Decoder is
that it can drive a stepper motor, so
let’s look at how that works in the firmware. The two H-bridge outputs are
intended to connect to the two coils
of the stepper motor, which are often
denoted as A and B. The outputs are
driven in a specific sequence to rotate
the motor’s shaft.
A typical waveform might drive coil
siliconchip.com.au
2V
0V
Microstep 0
Microstep 64 Microstep 128 Microstep 192
-2V
0.0ms
20.0ms
40.0ms
60.0ms
80.0ms
Scope 1: this shows a typical waveform for driving a stepper motor from the
unit. The shape of the waveforms means that the power draw is quite steady,
regardless of the current motor drive phase.
Australia's electronics magazine
April 2026 51
The PWM is applied in a complementary fashion, so that at any instant,
exactly one output is being driven,
which keeps the load relatively constant. This also ensures that the current
limit is applied uniformly at all times.
Circuit details
Fig.1 shows the circuit diagram for
the Stepper Motor Driver and Decoder;
it has a striking similarity to the DCC
Decoder noted earlier. The main difference is that this circuit boasts two
motor driver ICs to provide the fourwire connection needed by bipolar
stepper motors. Since it is so similar
to the Decoder, we’ll focus mainly on
the differences.
The incoming power supply connects to bridge rectifier BR1, which
provides a voltage that we’ve labelled
as a nominal 12V. In practice, the
incoming supply can vary from 0V
up to around 17V. The 17V limit is set
by REG1’s maximum input voltage of
16V (allowing for a 1V drop across the
bridge). REG1 provides a 3.3V rail –
both rails have 10μF bypass capacitors.
IC1 is a 14-pin, 8-bit PIC16F18124
(or -5 or -6) microcontroller that is
powered from 3.3V, while IC2 and
IC3 are DRV8231 motor driver ICs that
are powered from the 12V rail. Their
four outputs (available as motor connections A and B) require four control
signals from the microcontroller.
The keep-alive circuitry comprises
diode D1, a 100W resistor and an
optional capacitor. IC1 has a 100nF
bypass capacitor and a 10kW resistor
on its MCLR pin. This is exactly the
same as the corresponding circuitry on
the DCC Decoder. Similarly, the ICSP
connections to pins 1, 4, 12, 13 and 14
allow IC1 to be programmed if needed.
The two Mosfets, Q1 & Q2, are
driven from a further two digital outputs of IC1. In the Decoder article,
we described the current-limiting
circuitry on the Mosfets (enforced by
the 100W source resistors) and how
the 0.68W resistors on the ISEN pins
of the DRV8231 ICs set a 500mA limit
on their outputs.
The connections to sense the incoming voltage are different from the
Decoder, since we need to measure the
amplitude of that voltage. 100kW/10kW
dividers bring both voltages down to
a safe range for IC1’s ADC (analog-todigital converter) to measure, while the
10μF capacitor between the middle of
the dividers low-pass filters the signal.
This filter means that it is possible
to apply a PWM drive signal to the
inputs, and the filter will provide the
average input voltage to the microcontroller for measurement.
This chip has a differential ADC,
so we can directly measure the difference between the two voltages, giving
us the polarity and amplitude of the
applied voltage. When configured for
DCC operation, the low-side resistors
and the 10μF capacitor are left off, providing the same sensing configuration
as used in the Decoder circuit.
The 10kW/10kW divider across the
+3.3V rail, connected to pin 8 of IC1
(CONFIG) is used to configure the
adjustable speed response, as mentioned earlier. Using different values here will provide different speed
responses. Leaving the upper resistor
off will force CONFIG to 0V, and the
Stepper Motor Driver and Decoder
will then operate as a DCC decoder
instead of responding to the applied
DC voltage.
Firmware
In DC mode, we can expect a varying input (supply) voltage. Below 5V
Fig.1: the circuit of the Driver is similar to that of the DCC Decoder published previously. Since we need to control four
motor outputs, there are only enough spare I/O pins to provide two open-drain function outputs.
52
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
at the bridge rectifier inputs, there is
about 3.5V on the input to the regulator, and it is barely able to maintain
its 3.3V output. When it starts up, the
microcontroller samples the voltage on
its pin 8 input (the “CONFIG” signal),
to set its speed and mode.
The microcontroller repeatedly
measures the input voltage, but does
not drive any of the outputs. With less
than 4.5V on their supply pins, IC2
and IC3 stay in under-voltage lockout. Above 5V at the input, the micro
enables Q1 or Q2, depending on the
supply polarity. In a model railway
application, these would be used to
drive directional lights, with current
sourced from the 12V rail.
At 6V, IC2 and IC3 are now receiving
4.5V and will enable their outputs if
commanded to do so. The micro subtracts 6V from the input voltage and
uses that value, combined with the
speed setting and input polarity, to
generate an output waveform to drive
the stepper motor.
The 6V offset means that it is possible to easily achieve low-speed control. It also means that, for example,
applying 12V to the input will drive
the motor at double the speed compared to a 9V input.
The analog reading of the CONFIG
input is transformed into a ratio that
reflects the ratio of the resistors used
to set the voltage. Using ratios makes
it easier to calculate the values needed
to achieve a specific speed.
For example, if the default 10kW:
10kW divider gives a certain speed,
then changing it to a 20kW:10kW
divider will give double that. The
upper ratio limit is 10:1 (ten times
the default speed), while the lower
limit is about 1:100 (1% of the default
speed). If the upper resistor is a very
high value or left off (giving a lower
ratio than 1:100), the Driver starts up
in DCC mode instead.
In DCC mode, the Driver operates
like a DCC Decoder described in the
earlier article, except that its motor
outputs are arranged to drive a stepper motor. Since a DCC Decoder has
configuration variables (CVs) for setting the speed response, we don’t need
the CONFIG divider for this purpose.
Notes
In DC mode, the default speed (with
the 10kW:10kW divider fitted) at 7V (1V
above the 6V threshold) is 30 steps per
second, or 7.5 full cycles of the output
siliconchip.com.au
waveform per second. This becomes
300 steps per second at 16V (10V above
the 6V threshold). Of course, you can
change this by changing the divider.
In DCC mode, CV5 is used to set
the speed ratio. CV2 and CV6 are not
implemented, since the low-speed
behaviour of stepper motors does not
require the compensation that these
CVs offer. The default value of CV5
is 64, implying that the speed can be
increased approximately fourfold by
setting CV5 to 255.
A value of 64 for CV5 corresponds
to 155 steps per second at speed step
127. This also means that a value of
52 for CV5 gives 127 steps per second
at speed step 127; this value might be
easier to use as a base for calculations.
There is a very wide variety of
stepper motors available, with different numbers of steps per revolution,
winding resistances, output torque
and shaft arrangements. So we recommend doing your research before
connecting a stepper motor to ensure
it works as best it can and doesn’t burn
out or get damaged.
We tested various stepper motors,
ranging from a tiny unit measuring just
4mm across up to a so-called NEMA-8
unit. The NEMA-8 stepper motor looks
similar to the NEMA-17 motors used
in 3D printers, but is about half the
diameter.
The smallest motors worked well
enough but got quite hot. So we recommend changing the 0.68W resistors to a
higher value to reduce the current limit
with such motors. The current limiting is based on a 0.33V threshold, so
the formula is 0.33V ÷ I, where I is the
target current in amps. For example, a
limit of 100mA (0.1A) would require
the 0.68W resistors to be replaced with
3.3W resistors.
Don’t go any lower than 0.68W for
the current sensing resistors, since
that could result in the bridge rectifier
exceeding its 1A limit.
The NEMA-8 motor struggled to
generate torque and would stall easily. These have a very low winding
resistance and normally operate with
a much higher current than the 500mA
that is available from the Driver.
Motors in between these sizes,
around 8mm to 15mm in diameter,
seemed to work quite well and typically had coil resistances of around
20-30W. The motor shown at the bottom of page 50 has a 15mm diameter.
Motors with gearboxes will generally
Australia's electronics magazine
provide more torque; we found that
even the cheap and common 28BYJ-48
type motors worked well. These have
five wires, since they are arranged for
unipolar operation, but if the common (typically red) wire is left disconnected, the Driver can power them.
There are many varieties of stepper
motor around, and we cannot characterise all of them. Still, the above
should give you some idea about what
motors will work best and how to
adjust the Driver for the best operation.
You should also check the stepping
rate that your motor can support and
ensure that you are operating within
that range. Operating above the maximum stepping rate will cause the
stepper motor to lose torque and possibly stall.
Like the Decoder, connections to the
board are made by soldering directly to
surface-mount (holeless) pads. During
our testing, we soldered headers to
the various pads to easily try out different connections. Most connections
are close to 0.1in pitch (2.54mm), so
standard headers and sockets should
work if you want to experiment.
The firmware has been compiled
to fit in the smaller flash memory of
the PIC16F18124 (7kiB), but since
the register maps are the same, the
firmware should work without issue
on the PIC16F18125 (14kiB) and
PIC16F18126 (28kiB).
Construction
Being effectively set by a resistor,
the firmware operating mode is fixed
once construction is complete. To set
the Driver to work in DC mode, all the
parts listed should be fitted to the PCB.
This is seen in the overlay diagrams,
Figs.2 & 3. The resistors in the green
The DCC version of the
Driver leaves off three resistors and
one capacitor to allow the firmware to
switch to DCC mode and to properly
sense the incoming DCC signal.
April 2026 53
box are the CONFIG divider that can
be used to alter the motor speed.
To work in DCC mode, the high-side
resistor (10kW) of the CONFIG divider
is left off, as are the lower (10kW) resistors of the sense divider and the 10μF
capacitor that provides filtering on
the sense lines. These are labelled in
red in Figs.2 & 3. If these were left on,
they would interfere with sensing the
DCC signal.
We’ll describe fitting all the parts,
so be mindful of which parts to leave
off, depending on your intended use.
Like other SMD projects, we recommend that you have flux paste, solder
wicking braid, a magnifier, tweezers
and some sort of fume extraction on
hand. Working outside can help with
avoiding smoke and fumes if you don’t
have an extraction fan.
Start assembly with the side shown
in Fig.2, including REG1. Apply flux
to all the pads on that side. Start with
REG1, being careful not to mix it up
with the similarly packaged Q1 and
Q2. Rest it in place with the tweezers,
tack one lead and adjust as needed.
Then, solder the remaining leads.
Install the two 0.68W resistors (or
your other chosen value). These will
be tricky to get to if they are soldered
after IC2 and IC3. Next, fit the bridge
rectifier, observing its polarity, and
follow with the two 10μF capacitors
on this side.
Next solder IC2 and IC3, being sure
to locate their pins 1 correctly. When
the board is orientated as in Fig.2,
the chip markings are upright, with
the pin 1 dot at lower left. Then solder D1, making sure that its cathode
stripe faces to the left, towards the
bridge rectifier.
Complete this side with the three
resistors near D1. Note that it is only
the 10kW resistor below the SC marking that is omitted for DCC operation
on this side. Turn the board over and
apply flux to the pads on this side of
the board. Following Fig.3, solder IC1,
noting that its pin 1 dot is at top right.
Follow with the two SOT-23 transistors at upper right.
That just leaves the passives. The
CONFIG resistors are at upper left on
this side, with the high-side resistor
in the divider being the one closest to
IC1; this is left off for DCC operation.
The other two parts to be left off for
DCC are at lower left, below IC1. Take
care with the values of the remaining
passives and note that the sole 100nF
capacitor sits to the right of IC1.
Clean the board using an appropriate flux cleaner and allow the board to
dry. Inspect it for bridges and poor solder joints; repair any before attempting
to power up the Driver.
Testing and programming
A weak power source, such as a 9V
battery or current-limited supply set
to around 12V and 100mA, can be
applied to the T connections shown in
Fig.2. You should see regulated 3.3V
(3.2V to 3.4V) between the 3.3V and
GND pins on the ICSP header. If that
Figs.2 & 3: pay close attention to the components in the overlay diagrams and be
sure to leave off the components marked in red if you are building the version
for DCC. At a minimum, you should make connections to the T, A and B pad
pairs to drive a motor; the other connections are not mandatory.
54
Silicon Chip
Australia's electronics magazine
The DC version is populated
with all the components. The CONFIG
divider has been set to its default of
two 10kW resistors; these values can
be changed to alter the speed response
of the Driver.
siliconchip.com.au
is not right, or your power supply goes
into current limiting, check your construction again.
Further testing will require the chip
to be programmed. If you have bought
a programmed chip or kit from the Silicon Chip Shop, then this should not
be required. Otherwise, solder a fiveway pin header to the ICSP header and
connect it to a programmer such as a
Snap, PICkit 4, PICkit 5 or PICkit Basic.
The power supply noted above
should be adequate if your programmer cannot supply power. Program the
0911124S.HEX file and check that the
programming and verification complete successfully.
Connections
Figs.2 & 3 also show the connections that can be made. Note that the
two pads marked A must connect to
opposite ends of the same winding
on the stepper motor, while the pads
marked B connect to the two ends of
the other winding. The easiest way to
check the windings is to test for continuity, although this may not apply
to five-wire motors.
Just like the DCC Decoder, you can
connect a capacitor to the + and –
keep-alive connections to store and
later provide energy if the supply is
intermittent. While this was intended
to handle dirty tracks in a model railway, it can also be helpful if you are
trying to power the Driver with a PWM
power source.
The pad marked 12V is simply rectified DC from the bridge, so could vary
over a wide range, especially if the
Driver is being used in the DC configuration. If you want to use the Q1 and
Q2 outputs with a varying supply, you
Table 1 – supported configuration variables
CV# Notes
Default value
1
7-bit short address
3
3
Acceleration rate
0
4
Deceleration rate
0
5
Speed scaling: the default value of 64 results in 155 steps per second
at speed step 127. Other values scale proportionally; for example, a
value of 52 gives 127 steps per second at speed step 127.
64
7
Manufacturer version number (read-only)
0x5D
8
Manufacturer identification number (read-only)
13
11
Packet timeout
0
17
Most significant bits of long address
192
18
Least significant bits of long address
0
19
Consist address and direction
0
29
Configuration
2
33
Function mapping
1
34
Function mapping
2
35
Function mapping
0
36
Function mapping
0
37
Function mapping
0
49
Function effect bitmap for forward light output
255
50
Function effect bitmap for reverse light output
255
could use a constant current-circuit
instead of the resistors shown in Fig.3.
An alternative would be to feed the
LEDs from 3.3V on the ICSP header,
although this will offer much less
headroom. You shouldn’t draw more
than about 10mA from the 3.3V supply due to dissipation in REG1.
DC use
If you have a stepper motor connected, you can test out the Driver by
applying a voltage at the T input to the
bridge rectifier. We used a 9V battery
for much of our testing; it went flat
fairly quickly, but it was able to rotate
Parts List – DC/DCC Stepper Motor Driver
1 double-sided 13 × 24mm PCB coded 09111242, 0.8mm thick
1 PIC16F18124-I/SL (or 18125 or 18126) 8-bit microcontroller programmed
with 0911124S.HEX, SOIC-14 (IC1)
2 DRV8231DDAR motor driver ICs, SOIC-8 (IC2, IC3)
1 MCP1703A-3302E/CB 3.3V low-dropout linear regulator, SOT-23 (REG1)
2 2N7002 SOT-23 N-channel Mosfets (Q1, Q2)
1 1A SMD bridge rectifier (BR1) [MBS4 or CD-MMBL110S]
1 1N5819WS SOD-323 schottky diode (D1)
1 3cm length of 20mm diam. heatshrink tubing (to protect & insulate Driver)
Capacitors (all SMD M2012/0805 size MLCC)
3 2 10μF 25V X5R
1 100nF 50V X7R
Resistors (all SMD 1%, M2012/0805 size, ⅛W unless noted)
2 100kW
7 4 10kW
1 100W
2 10W
2 0.68W ¼W
n values are to suit DCC mode. The values of two of the 10kW resistors can
also be adjusted to change the speed response in DC mode.
siliconchip.com.au
Australia's electronics magazine
all the stepper motors that we tested.
DCC operation
You will need a DCC signal to test
out the Driver in DCC mode. The earlier parts of this series (siliconchip.au/
Series/455) describe a few options for
Base Station Hardware. Table 1 lists
the configuration variables (CVs) that
are implemented on the Driver when
it is operating in DCC mode.
Apart from CV5, the other CVs will
work in much the same fashion as
those described in the Decoder article
(December 2025). Thus, the remaining CVs have only brief descriptions
of their characteristics.
Note that we have used a different
version ID (CV7) so that you can tell
these Decoders apart. Otherwise, the
DCC code is much the same, and the
Driver should operate much like the
earlier Decoder in all other respects.
Conclusion
We don’t expect that all stepper
motor types will work well with this
Driver. It is something of an experimental device; it originally began as
a DCC Decoder that could be used to
drive stepper motors. Still, we think
that the ability to accept a DC voltage
for power and control will be adopted
for cases where basic operation of a
SC
stepper motor is needed.
April 2026 55
|