This is only a preview of the January 2025 issue of Silicon Chip. You can view 38 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. Items relevant to "Digital Capacitance Meter":
Items relevant to "Compact HiFi Headphone Amp":
Articles in this series:
Items relevant to "Gesture-controlled USB lamp":
Items relevant to "BIG LED clock":
Items relevant to "40A Current Probe":
Items relevant to "Battery-Powered Model Train":
Items relevant to "TCS230 Colour Sensor":
Purchase a printed copy of this issue for $13.00. |
Battery-Po
Battery-P
owered
Mode
dell Tra
Traiin
BY LES KERR
This modification eliminates the need to keep model railway tracks clean. If you let them oxidise,
power won’t get to the trains, causing all sorts of problems. By making the train battery powered,
it no longer needs to draw power from the tracks, making it much more reliable!
M
y grandson was visiting and he was at
me all the time to let him drive
trains on my OO gauge railway. As
it hadn’t been used for quite a time,
there was quite a build-up of debris
on the track and the engine pickups
that resulted in the first train running
erratically. After laboriously cleaning the track, the trains ran smoothly.
Most of my newer power tools are
battery powered, so I wondered if I
could power the train from onboard
rechargeable AAA cells. These could
be mounted in the carriage behind
the engine, and the speed and direction could be controlled by a simple
433.9MHz link. I calculated that four
fully-charged 900mAh NiMH cells in
series could run the train for more than
five hours on a charge.
With most model train layouts, the
433.9MHz transmitter will only be a
few metres from the train at any time,
so there is little chance of interference. To ensure the train doesn’t go
haywire, check bytes are sent so that
the Receiver can verify the speed and
68
Silicon Chip
direction data it is getting are correct.
This virtually eliminates the possibility that erroneous signals will result
in incorrect operation.
The NiMH battery voltage of around
4.8V is too low to run the motor, so
I selected a small step-up converter
module that produces 15V DC from the
battery voltage to power the motor. It
operates at about 1MHz with an efficiency approaching 90%. Another
small boost converter generates a
steady 5V rail to run the control circuitry.
To drive the engine, I looked at all
the standard H-bridges on the market
and selected the DRV8871 IC that is
mounted on a 24.5 × 20.5mm PCB.
It runs from 5-37V at up to 2A, driving a single motor bidirectionally.
Over-temperature and over-current
protection is built in. It is a bit overkill
for a 12V train that takes about 250mA
maximum, but it could be used with
higher power engines too.
The motor speed and direction are
controlled by a microcontroller on
Australia's electronics magazine
the same PCB as the motor driver that
mounts in the carriage, behind the
engine. This PCB also has a 433.9MHz
receiver to allow remote control.
To cater for various size carriages, I
designed two Receiver PCBs, a small
one using SMD components (carriage
length 185mm) and a larger one with
through-hole (TH) components.
The handheld controller (Photo
1) has a potentiometer that controls
the speed of the train and a toggle
switch to select forward or reverse.
The Transmitter has a PIC12F617
microcontroller that monitors those
controls and sends signals via a
433.9MHz transmitter within the
handheld controller.
A 3mm red LED on the carriage
lights when the battery needs charging.
The fourth PCB I designed is a
trickle Charger (Photo 2) that connects
to a socket on the battery carriage using
a 2.5mm jack plug.
This system of three modules –
Transmitter, Receiver and Charger –
provides everything you need to run
siliconchip.com.au
Photos 1-3: the transmitter (left &
right), and the charger (centre) box.
a model locomotive without requiring an electrical connection (for either
power or communications) through
the track. You can see a video of it in
operation at siliconchip.au/Videos/
Battery+model+train
Transmitter circuit details
The Transmitter circuit is shown in
Fig.1. It is powered by a 9V battery via
on/off toggle switch S1 and a 1N5819
schottky diode. The diode prevents
accidental battery polarity reversals
from destroying the circuit. A schottky
diode is used as its forward voltage
drop is a lot less than a standard silicon diode, so the battery lasts longer.
A 78L05 regulator provides +5V for
the microcontroller. The 100μF capacitors connected to its input and output reduce any ripple to a negligible
level, while the 100nF ceramic or MKT
capacitors reduce any high-frequency
noise that may be present.
So that potentiometer VR1 varies
the train speed, microcontroller IC1
measures the voltage at its wiper using
its internal analog-to-digital converter
(ADC) via analog input AN3. It converts the 0-5V on its wiper to an 8-bit
number between 0 and 255. That value
is sent out as pulses via digital output
GP0 (pin 7), to the transmitter module, to be picked up by the Receiver
on the train.
Digital input GP5 (pin 2) is pulled
Fig.1: the Transmitter circuit. It runs from a 9V battery; microcontroller IC1 and transmitter MOD1 convert the position
of speed potentiometer VR1 and forward/reverse switch S2 into a 433.9MHz-modulated ASK serial data stream for the
Receiver.
siliconchip.com.au
Australia's electronics magazine
January 2025 69
high by the 10kW resistor when S2
is in the forward direction or low, to
ground, by S2 when it is in the reverse
direction. The microcontroller senses
this level using its GP5 digital input
and sends different numbers via the
433.9MHz transmitter depending on
the switch state. The 100nF ceramic
capacitors at those two inputs prevent noise from affecting the readings taken.
The signal sent to the transmitter
module via the GP0 output is serial
data at 1200 baud that contains the
speed and direction variables, along
with preamble and check bytes. This
433.9MHz module transmits this using
amplitude-shift keying (ASK) via a
quarter-wavelength (173mm long)
wire antenna.
Receiver circuit
The Receiver circuit is shown in
Fig.2. Signals from the Transmitter
are received by the 433.9MHz receiver
module, and the demodulated serial
data is applied to the RC2 digital input
(pin 8) of the PIC16F1455 microcontroller (IC2).
The 8-bit train speed data and the
direction data are extracted and stored
in memory, then used to generate the
pulse-width modulated speed signal
and the direction signal.
Two logic inputs, IN1 and IN2, control the H-bridge driver (IC3). To turn
Fig.3: pulse-width
modulation (PWM)
involves setting the
output high at a fixed
interval, then leaving
it high for a period
ranging up to that
interval. The result
is a varying average
voltage, even though
the output only
switches between
two levels.
the motor in one direction, we apply a
pulse-width modulated (PWM) signal
to vary the speed to IN1 while holding IN2 high. If the train is to run in
reverse, the PWM signal is applied to
instead IN2 while IN1 is held high. To
stop the train, both input are kept at
the same level (both low or both high).
Fig.3 shows the signals for driving
the motor at various speeds.
The battery supply voltage is halved
by the two 10kW resistors and the
resultant ~2.4V is monitored by analog input RA4 (pin 3) of IC2 using its
internal ADC. If the voltage at that pin
falls below 2V (ie, the battery is below
4V), digital output RC4 (pin 6) is taken
low, switching on red LED2 to alert
you that the battery needs charging.
The micro also provides signals to
drive the DRV8871 H-bridge IC. To
turn the motor in one direction, the
PWM signal is applied to digital output RC3 (pin 7), while RC5 is taken
high (+5V). To reverse the motor direction, the PWM signal is applied to RC5
and RC3 is taken high. The higher the
speed value, the faster the motor turns.
When the speed control is near its
minimum position, both RC5 and RC3
are taken low (to 0V), causing the PWM
module to go into sleep mode, reducing the current drawn from the battery. The +5V supply for the receiver
and micro is provided by the S7V7F5
high-frequency voltage up/down converter (MOD4) that takes the 4-6V battery voltage and provides a regulated
+5V output.
If the battery has been recently
charged (it could be as high as about
6V), MOD4 steps down the voltage
Fig.2: MOD2 picks up the data from the Transmitter and feeds it to microcontroller IC2, which decodes it and produces
PWM waveforms for H-bridge motor driver IC3 on MOD5. MOD3 boosts the battery voltage to 15V to run the motor. IC2
also monitors the battery voltage and lights LED2 if it is low.
70
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
to +5V; if it is discharged below 5V,
it steps it up. The 100μF electrolytic
capacitor and 100nF ceramic capacitor reduce any noise or ripple on
the supply. Similarly, the U3V16F15
(MOD3) provides the +15V DC supply
for the motor.
We use 15V instead of 12V to overcome any voltage drop in the tiny
cables connecting the carriage to the
train motor. Polulu recommend in
their data sheet that you add a 47μF
capacitor across the battery input
when using these inverters, which I
have done. Both these modules are
available locally for around $9 each.
There is a 2.5mm switched jack
socket (CON1) so the battery can be
charged. It also allows the battery
power to the Receiver to be switched
off simply by inserting a jack plug.
With the jack plug in the socket, the
battery is connected to the Charger and
disconnected from the Receiver as its
positive side is disconnected.
Charger circuit
Looking at Fig.4, the battery is
trickle charged at C/10 (90mA) for 16
hours unless its output voltage exceeds
6V, indicating the battery is fully
charged. In that case, the charge current is switched off. When the power
pack is switched on, 9V is applied to
the 78L05 voltage regulator (REG2),
which reduces the voltage to +5V to
Photo 4: the 433.9MHz receiver
(above) and transmitter (below)
modules. They are sold under
various model numbers, but this
particular set is very common
to find online. As long as yours
look like these, and don’t have
low-quality soldering, they should
work (avoid the cheapest ones!).
siliconchip.com.au
power the PIC12F617 microcontroller, IC4.
The two 100μF capacitors smooth
out any residual ripple, while the
two 100nF capacitors provide high-
frequency bypassing.
On powering up, digital output GP4
(pin 3) of IC4 pulses the green LED
at 200ms intervals, indicating it is in
standby mode. Pressing the Start button (S3) pulls the GP2 digital input low
(pin 5), causing an interrupt routine
to be triggered that takes the Charger
out of standby mode and puts it into
charge mode. The 100nF capacitor
eliminates any contact bounce from
the pushbutton.
This results in the green LED switching off and the red Charge LED flashing at 500ms intervals. Mosfet Q1
(IRL540N) is switched on by digital output GP5 going high, and the
16-hour countdown timer starts.
When on, the drain of the Mosfet
goes low, connecting the 90mA constant current source to the battery. The
current source comprises the BD136
transistor (Q2), an LM285 2.5V reference diode and a 220W resistor in parallel with a 22W resistor.
It works by holding the PNP base
2.5V below the +9V supply. This sets
the emitter at 1.8V (2.5V – 0.7V), which
matches the voltage across the parallel resistors. They have a resistance of
20W (220W || 22W). With 1.8V across
20W, Ohm’s law (I = V ÷ R) tells us the
current must be 90mA (1.8V ÷ 20W).
The battery voltage is halved by the
two 10kW resistors and applied to analog input GP0 (pin 7) of IC4. Once per
second, it measures the voltage and if
it is above 3V (battery fully charged),
charging stops and the Charger goes
back into standby mode, shown by
the green LED flashing. If the battery
voltage doesn’t exceed 6V, the charging
stops after 16 hours.
The 1N4004 diode (D2) prevents
the battery from discharging if it is
left connected when the charger is
not powered.
The 1N4148 diode (D3) prevents
the ADC input from rising above 5.6V,
although that is unlikely because the
battery would have to be charged to
over 11V. Still, it’s possible CON2
could accidentally be connected to a
voltage source, so it’s better to be safe.
Sourcing parts
The receiver and transmitter modules are available from several suppliers under different part numbers.
Fig.4: this NiMH battery trickle charger will stop charging when the battery
voltage reaches 6V (1.2V per cell) or after 16 hours of charging. Q2, REF1 and
the surrounding components form a 90mA constant current source while Mosfet
Q1 controls whether charging is active.
Australia's electronics magazine
January 2025 71
Programming a microcontroller in-circuit
To program the micro with it in the circuit, you will need to solder wires to the +5V
and 0V rails as well as pin 4 (MCLR), and the pads on the ICSPCLK and ICSPDAT pins.
Those are pins 9 & 10 respectively for the PIC16F1455, or pins 6 & 7 respectively for
the PIC12F617. Connect those wires to your programmer, referring to its manual to see
which wire goes to which pin. For the PICkit 3, the pins are (starting from pin 1) MCLR,
VCC, GND, ICSPDAT and ICSPCLK.
You can download and install the free MPLAB IPE software from the Microchip website and then use the included MPLAB IPE software to open the appropriate HEX file
(which you can download from siliconchip.au/Shop/6/508) and flash it onto the target
chip via your programming hardware.
I have given a couple of examples in
the parts list, but there are many others. Sometimes the part number is for
a transmitter/receiver pair and the
individual parts don’t have individual codes (or they are not specified).
The main thing is to check that what
you are buying looks like the modules
shown in Photo 4. If you type “433MHz
modules” in a search engine, you will
find plenty of suppliers of modules
that look identical or nearly so. Be
careful, though, as I found that one
of the very cheapest suppliers’ modules were poorly soldered and were
unusable.
Construction
Let’s start by building the Transmitter. It is assembled on a single or
double-
sided PCB coded 09110241
that measures 49 × 36mm. During
assembly, refer to the PCB overlay
diagram, Fig.5.
Fig.5 shows the off-board components wired directly to the PCB.
You can do it that way, but it’s easier to instead solder pin headers in
those positions and then cut pairs of
female-female DuPont jumper wires
in half. That way, you can plug them
into the headers and solder the bare
ends to the other components.
You can see from the photos that
I soldered wires to header sockets
instead of using DuPont wires; either
approach can work, but it’s easier and
slightly neater to cut the jumper wires
in half. You can often get them joined
together in a ribbon, making it easy
to split off pairs or sets so they stay
together (like a figure-8 cable).
Start the PCB assembly by fitting the
headers, 8-pin IC socket and the capacitors. The IC socket makes it easier to
remove the microcontroller and reprogram it later if necessary. Take care to
orientate the socket and electrolytic
capacitors correctly. For the electros,
the longer positive lead goes into the
pad nearest the + symbol, with the
stripe on the can indicating the negative end opposite that.
Now add the resistors, which are
mounted vertically, then the 78L05
voltage regulator, 1N5819 diode (with
its cathode stripe facing as shown)
and the 433.9MHz transmitter module. As the clearance inside the Hammond box is less than the height of the
433.9MHz module, the module should
be mounted 20° from vertical towards
the edge of the board (it’s shown as if
it’s laid flat in Fig.5 for clarity).
Make sure all the semiconductors
and the transmitter are correctly orientated. Don’t fit the PIC12F617 microcontroller yet.
If you have purchased it from the
Silicon Chip Online Shop, it will
already have the firmware loaded. If
you wish to program it yourself, you
can download the firmware from:
siliconchip.au/Shop/6/508
To load the firmware onto the chip,
you will need a suitable programmer
and an adaptor socket. For the former,
Fig.5: this shows where components mount
on the Transmitter board and how to wire
it up. While wires are shown soldered
straight to the PCB, we recommend using
headers and wires with DuPont plugs to
make assembly and disassembly easier.
MOD1 is mounted about 20° off vertical so
it fits in the case; it is shown horizontally
here for clarity.
Fig.6: this view from the inside of the case front shows
where to drill the holes. The large one is for the pot
shaft, the 5mm holes are for the two switches and LED,
while the M3-tapped holes are for mounting the board.
If you would rather not tap them, drill them to 3mm
and use extra machine screws (ideally countersunk)
from the outside to fix the tapped spacers.
72
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
you can use a PICkit or Snap programmer (or similar); for the latter, see our
PIC Programming Adaptor (September
2023; siliconchip.au/Article/15943).
Finally, check for any dry solder joints
or solder bridges.
plug the DuPont connectors into the
headers on the board using Fig.5 as a
reference. Make sure everything goes
to the right location, or it won’t work
properly.
Case preparation
With the microcontroller (IC1) out of
its socket, check the orientation of the
battery connector, 78L05 voltage regulator and the 433.9MHz transmitter
module. Connect the 9V battery and
switch it on. The LED on the front
panel should glow. Connect a voltmeter with its red probe to pin 1 on the
IC socket and the black lead to pin 8.
The measured voltage should be very
close to +5V DC.
If not, verify that the 5V regulator is
the correct way round and there aren’t
any solder bridges shorting any tracks
or pins. Assuming it’s OK, switch off
the power and insert the microcontroller. If you have an oscilloscope,
connect it to pin 7 of the IC, with the
Earth connector to 0V.
Switch on and you should should be
able to capture a serial data waveform
at 1200 baud similar to that in Scope 1.
If all is good, attach the back of
the case using the supplied screws
and you are ready to move on to the
Receiver.
Drill and tap the Hammond 1593Y
case as shown in Fig.6. That shows a
view from the inside of the front part
of the case. The large (9.5mm) hole is
for the shaft of VR1, the three 5mm
holes are for the two switches and LED,
and the four M3-tapped holes are for
mounting the PCB.
If you would rather not tap the holes,
you can simply drill 3mm holes and
use screws from both sides (which is
accounted for in the parts list), but it
will look worse and the extra screws
will protrude outside the case unless
you countersink them.
Now refer to Fig.5 and Photo 3 to
see how everything goes together. Fit
the LED, PCB, potentiometer, knob and
toggle switches as shown. Split off the
DuPont cables into sets, cut them in
half, then solder them to the chassis-
mounted parts and battery clip, using
1.5mm diameter heatshrink tubing to
insulate the joints where necessary.
Solder a 173mm length of wire to
the aerial pad on the transmitter module and insulate the other end. Then
Photo 5: these are the Adafruit
DRV8871 (top), Polulu U3V16F15
(lower left) and S7V7F5 (lower
right) modules. We recommend
you solder the right-angle headers
so that they are parallel with the
board (see Fig.2 and Photo 7).
siliconchip.com.au
Testing the Transmitter
Receiver construction
First you must decide which version of the Receiver you want to build.
The all through-hole version is larger
at 74 × 23mm and uses a PCB coded
09110242, while the mixed SMD/TH
version measures just 23 × 30mm with
a PCB coded 09110243.
Both versions share many parts
(all the modules are the same). The
main difference is that the smaller
version uses an SMD microcontroller
and mostly SMD passives. The smallest parts are 2.0 × 1.2mm, so they are
not terribly difficult to handle, and
the IC has a fairly generous 1.27mm
lead pitch.
The surface-mount PCB is the one I
used to fit in my 85mm-long OO gauge
carriage. You will need to use the SMD
version if the TH board won’t fit in
yours; otherwise, the choice is yours.
The first task for both types of PCBs
is to solder the supplied header pins
to both of the Polulu DC/DC converter
modules. Assemble them as shown
in Fig.2, Fig.7 and Photo 6, making
sure that the pins are parallel with
the module PCBs. For the DVR8871
Australia's electronics magazine
Scope 1: this shows the serial data
that’s transmitted via a 433.9MHz
wireless link with the switch in
the forward position and the speed
control at about halfway.
module, you have to add a four-pin
right-angled header; again, make sure
that the pins are parallel with the
DVR8871 PCB.
SMD PCB assembly
Since I etched mine myself, it is a
single-sided design, although you can
get the double-sided version from Silicon Chip, which avoids the need to fit
the two wire links. The surface-mount
components go on the copper side of
the board, while the though-hole components and modules are inserted from
the opposite side. The overlay diagram
(Fig.7) shows both sides.
This is a good project if you are interested in improving your SMD soldering skills, since it has a few different
types and sizes of components. I am
79 and can still manage these parts.
The SOIC-package PIC16F1455
will need to be programmed at some
point. The easiest way is to purchase
a pre-programmed PIC, although it is
possible to program it in-circuit. See
the panel for details if you wish to
do that.
Use a flux pen or a syringe of flux
paste to coat the PIC16F1455 IC’s leads
and its associated pads. Hold the PIC
in place (eg, using tweezers) with the
correct orientation and use your soldering iron to tack solder one lead in
place, then check that it is positioned
correctly. If so, solder the remaining
leads.
Clean off the flux residue and
inspect the leads under magnification
to ensure that all the solder joints have
formed correctly. If you are not sure
about any of them, add more flux and
apply heat (and possibly more solder)
to reflow the joint. If you have bridged
any pins, use more flux and some solder wick to remove the excess solder.
January 2025 73
Fig.7: the SMDs are soldered to the underside
of the small Receiver PCB, as shown at right,
while the through-hole parts mount on the
top. MOD2 & MOD5 are shown on their sides
for clarity but actually mount vertically. You
can solder terminal blocks to MOD5 for the
outputs, or just solder wires directly.
Now use a similar procedure to fit the
remaining SMDs. They are all the same
size except the 47μF capacitor, which is
a bit larger. The 1kW resistors will have
a code like 102 or 1001 printed on top,
while the code for 10kW is 103 or 1002.
The capacitors will not be labelled.
Finally, using an ohmmeter on
its lowest range, check each passive
SMD component across its terminals
to make sure you haven’t accidentally
created any short circuits.
Turn the board over and solder in the
links (if you are using a single-sided
board), the two electrolytic capacitors, and the four modules. Make
sure all the components are the right
way around. The four modules are
mounted at right-angles to the main
board, although some are shown horizontally in Fig.7 for clarity.
The final task is to attach the headers and connect the wires to the red
LED and train motor. Disconnect the
wires that connect the train wheels to
the motor because we don’t want the
rails to act as aerials to radiate interference from the motor brushes.
For my 85mm carriage, the motor
wires are 12cm long, the wires from
the PCB to the connector are 7cm long,
the wires from the jack plug to the PCB
connector are 6cm long, the wires from
the jack plug to the battery connector
are 6cm long and the battery connector wire is 4cm long. All connections
are insulated using heatshrink tubing.
Inside the train engine, the manufacturer should have fitted two inductors in series with the motor wires
(typically around 30μH) and a 100nF
capacitor across the motor terminals
to suppress radiation from the motor
brushes often on a small PCB.
74
Silicon Chip
It is important to have such a circuit, as without it, the radiated signal
can be picked up by the receiver, causing potentially erratic operation. If it
is missing, the train’s manufacturer
should be able to supply a new one.
The wires to the wheels should
be disconnected from the two series
inductors. The engine is powered from
the carriage by a twisted pair of thin
cable that connects from a two-pin
male header to the two series inductors inside the engine.
Finally, connect a 173mm length
of multi-stranded wire to the antenna
terminal of the receiver module. All
connections should be insulated using
heatshrink tubing.
SMD version testing
Connect a voltmeter between the
LED anode (red) wire and the 0V
battery input, and a dual-trace oscilloscope to IN1, IN2 with the Earth connected to the 0V input. Connect a variable power supply to the 4.8V battery
input, with the red wire going to the
positive terminal and the black to the
ground terminal. Slowly increase the
voltage to about 5V; the meter should
read 5V.
Switch on the Transmitter with the
speed control set about halfway. The
oscilloscope should show a 5V peakto-peak 7kHz waveform with about a
50% duty cycle on either IN1 or IN2
(depending on the position of the forward/reverse switch). Increase the
speed to maximum, and the display
should change to a continuous +5V
DC. On reducing it to minimum, you
should see a 6% duty cycle square
wave.
If IN1 shows the 7kHz waveform
then IN2 should be at +5V, while if IN2
shows the 7kHz waveform, IN1 should
be at +5V. Reduce the input voltage to
less than 4V and you should see the
red LED switch on.
If you don’t have an oscilloscope,
you can instead connect a DVM to
either IN1 or IN2 (with the black probe
to ground) and vary the speed potentiometer. The DVM should read the
average voltage of the PWM signal,
meaning it should increase smoothly
as you advance the speed control
clockwise. If it’s stuck at 5V, switch
the DVM probe to the other terminal
(IN1 or IN2).
Through-hole version
If you have long OO gauge carriages
Fig.8: the larger Receiver
board uses all through-hole
parts that mount on the
top. You only need to fit
the three wire links if you
have a single-sided board.
All modules mount
vertically; MOD5’s
component side is
towards the bottom
of the PCB as
shown, while MOD2
has the majority of
its components near
the top edge.
Fig.9 (far right): the 3mm hole is for the LED, while
the 4mm hole is for the jack socket. The slot is for
the wires to exit the carriage and go to the engine.
These are suggestions only; you can customise them
for your carriage configuration.
Australia's electronics magazine
siliconchip.com.au
or a train that will take the board and
batteries, you might find building this
one a bit easier. Since I etched mine
myself, it is a single-sided design,
although you can get the double-
sided version from S ilicon C hip ,
which avoids the need to fit the wire
links. Refer to the PCB overlay diagram, Fig.8.
Solder in the links (if you are using
a single sided board), the three electrolytic capacitors, the 14-pin IC socket
and DC/DC converter modules, making sure they are orientated correctly.
Then add the headers, MKT/ceramic
capacitors and resistors.
Wire up the red LED and train motor
as shown. The length of the wires will
depend on the size of the carriage you
are using. All connections should be
insulated by using heatshrink tubing.
Through-hole version testing
Check that the components are the
correct way round and there are no
solder bridges on the PCB.
Connect the battery red wire to the
positive terminal of a 5V power supply and the black wire to the 0V terminal, switch it on and use a DVM to
measure the voltage between pin 1
and pin 14 of the IC socket. It should
be very close to 5V. Also check the
15V supply by measure the voltage
between the Vout and 0V terminals
of the U3V16F15 module. The result
should be very close to 15V.
If all is well, fit the DVR8871
H-bridge module, 433.9MHz receiver
and insert the PIC16F1455 chip into
its socket, making sure they are all
Fig.10: the ground wires from the battery pack and PCB are
joined at the ground tab for the jack socket, while the red wires
go to different pins so that the Receiver PCB is switched off
when the jack plug is inserted (for charging, or just to cut the power).
orientated correctly. Connect a 173mm
length of multi-stranded wire to the
antenna terminal of the receiver.
The rest of the testing is the same as
that for the surface-mount version of
the PCB, so refer to that section above.
The wiring lengths are different for this
version, as is the position of the red
LED and jack plug socket. These will
depend on your train’s dimensions.
Mounting the Receiver
The 3mm LED and 2.5mm jack
socket need to be mounted on the carriage, along with an access groove for
the cable connecting to the engine.
Fig.9 shows the suggested carriage
cover modifications to achieve this.
Fit the jack plug socket into the 4mm
hole so that pin 1 is as close as possible to the side of the carriage cover.
Once they are mounted, wire up
the jack socket and battery as shown
in Fig.10. Insulate any exposed connections with 1.5mm diameter heatshrink tubing.
Next, load the battery holder with
fully charged cells and connect the
battery to the jack socket. Connect the
black lead of a DVM to the negative
wire that will go to the Receiver PCB
in the engine, and the red lead to the
positive wire. You should get a reading close to 4.8V (the charged battery
voltage).
Now plug a jack plug into the
socket and check again; the voltmeter should read 0V. Next, measure
the voltage across the jack plug terminals and it should be once again
be close to 4.8V.
Insert the red LED into the 3mm
hole. Fit the PCB and battery holder as
shown in Photo 9. Connect the power
wires to the Receiver PCB, tucking
them and the excess wire down the
side of the battery holder.
Coil the antenna cable and tuck it
down between the PCB and the carriage end that holds the jack socket.
Leave the jack plug in, as this stops
power from the batteries flowing into
the Receiver.
Cover the wheel assembly with a
strip of insulating tape where the bottom of the PCB may contact it. You can
then fit the wheel assembly to the carriage cover.
Final testing
Switch on the Transmitter and set
the speed control to its minimum
position. With the engine laying on its
back, connect it to the carriage. Switch
on the Receiver by removing the jack
plug. Rotate the speed control on the
Transmitter and the engine wheels
should start to move, gaining speed
as the control is rotated further until
maximum speed is reached.
Photos 6 & 7: the top and bottom sides of the prototype SMD version of the
Battery-Powered Model Train Receiver PCB.
siliconchip.com.au
Australia's electronics magazine
January 2025 75
Photo 8: the through-hole version of the Receiver PCB is much larger than the
SMD version (about twice as wide), but it is easier to assemble due to using
through-hole components.
Photo 9: the SMD Receiver PCB and
four AAA cells just fit into a OO-gauge
train carriage.
Turn the control back down and
the speed should decrease to zero just
before minimum rotation. Repeat with
the forward/reverse switch in the other
position. Switch off the Transmitter
and insert the jack plug to switch off
the Receiver.
the same speed. Switch the Transmitter on again, rotate the potentiometer fully anti-clockwise and the train
should stop.
Insert the jack plug to switch the
Receiver off. If the red LED is lit, plug
in the Charger until the batteries are
charged.
Always stop the train before operating the forward/reverse switch; failure to do so may destroy the motor.
Always switch the Transmitter on
before switching the train on, and
always switch off the train off before
the Transmitter.
This avoids the train running by
itself if in the unlikely event of an
interfering signal that’s interpreted as
valid by the Receiver.
Running the train
Place the engine and assembled carriage onto the tracks and connect the
motor lead and socket. Switch on the
Transmitter and turn the speed control
to minimum and the forward reverse
switch to forward. Remove the jack
plug from the carriage (power on).
Rotate the potentiometer clockwise
and the train should move forward;
its speed should increase with the
advancement of the control.
If it goes in reverse, unplug the
motor leads from the train and reverse
the connections. It should now run
forwards.
Repeat the test with the switch in
the reverse position. With the train
running, switch off the Transmitter;
the train should continue running at
Charger construction
76
Silicon Chip
Fig.11: fit the parts to the
Charger PCB as shown here.
This also shows how to wire the
off-board parts. While wires are
shown soldered straight to the PCB,
we recommend using headers and
wires with DuPont plugs.
The Charger is built on a single- or
double-sided PCB coded 09110244
that measures 63 × 32mm. Its overlay diagram is shown in Fig.11. Once
again, headers are not shown in the
wiring but it’s easiest to use headers
and plugs. Start by fitting the headers,
IC socket, wire link (if needed) and
the capacitors. Take care to orientate
the socket and electrolytic capacitors
correctly.
...continued on page 78
Australia's electronics magazine
siliconchip.com.au
Parts List – Battery-powered Model Train
1 500mm length of 1.5mm diameter black or clear heatshrink tubing
various lengths & colours of light-duty hookup wire
(wire for the power to the engine can be from old USB and mouse cables)
Charger
Fig.12: the Jiffy box needs holes
at each end for the power input
and charging output, plus four
countersunk holes for mounting
the PCB, plus three more for the
pushbutton and two LEDs.
Now add the resistors, which are
mounted vertically, the BD136 transistor, IRL540N Mosfet, LM285-2.5V
voltage reference diode, 78L05 voltage
regulator, plus the 1N4148 and 1N4004
diodes. Make sure all the semiconductors are correctly orientated and in the
right places. Don’t fit the PIC microcontroller yet.
If you purchased the micro from
the Silicon Chip Shop, it will already
have the firmware loaded. If you
wish to do this yourself, the files can
be downloaded from siliconchip.au/
Shop/6/508 and we had some comments earlier about ways to program
the chip.
Once the PCB is fully assembled,
check for any dry solder joints or solder bridges. It mounts in a UB3 Jiffy
box that has to be drilled for the LEDs,
78
Silicon Chip
1 single- or double-sided PCB coded 09110244, 63 × 32mm
1 UB3 Jiffy box
1 9V DC 150mA+ plugpack
1 2.5mm mono jack plug (CON2) [Jaycar PP0100]
1 chassis-mount DC socket to suit plugpack (CON3)
1 chassis-mount SPST miniature momentary pushbutton (S3)
1 8-pin DIL IC socket
5 2-way pin headers, 2.54mm pitch
6 female-female DuPont jumper wires, ideally joined in a ribbon
4 M3 × 8mm countersunk head machine screws
8 M3 hex nuts
1 500mm length of single-core screened microphone cable
1 PIC12F617-I/P 8-bit microcontroller programmed with 0911024C.HEX,
DIP-8 (IC4)
1 LM285-2.5 voltage reference diode, TO-92 (REF1)
1 78L05 5V 100mA linear regulator, TO-92 (REG2)
1 IRL540N 100V 36A Mosfet, TO-220 (Q1)
1 BD136/138/140 45/60/80V 1.5A PNP transistor, TO-126 (Q2)
1 5mm green LED (LED3)
1 5mm red LED (LED4)
1 1N4004 400V 1A diode (D2)
1 1N4148 75V 200mA diode (D3)
2 100μF 16V low-ESR radial electrolytic capacitors
3 100nF 50V ceramic, multi-layer ceramic or MKT capacitors
4 10kW ¼W 1% axial resistors
3 2.2kW ¼W 1% axial resistors
2 220W ¼W 1% axial resistors
1 39W 1W 1% axial resistor (for testing)
1 22W ¼W 1% axial resistor
Transmitter
1 single- or double-sided PCB coded 09110241, 49 × 36mm
1 Hammond 1593Y plastic case [DigiKey, Mouser, RS]
1 3-pin 433.9MHz transmitter module, WRF43301R or XLC-RF5 (MOD1)
[Little Bird, AliExpress, eBay]
1 9V battery snap
1 9V battery
1 8-pin DIL IC socket
1 3-way pin header, 2.54mm pitch
4 2-way pin headers, 2.54mm pitch
7 female-female DuPont jumper wires, ideally joined in a ribbon
pushbutton, PCB mounting screws
and power input socket. The drilling
details are shown in Fig.12.
Once the box has been drilled,
attach the red and green LEDs, start
pushbutton and the barrel socket as
shown in the photos.
The PCB is held in place by four
8mm-long countersunk head M3
machine screws and eight M3 hex
nuts. The four extra nuts are used to
space the PCB off the case.
Use DuPont wires to make the
Australia's electronics magazine
connections between the PCB and
the offboard components, as shown
in Fig.11. Insulate all exposed connectors and the wire connections to
the LEDs with 1.5mm diameter heatshrink tubing.
Finish the Charger off by preparing the box, as shown in Fig.12, then
mounting the PCB and all the chassis-
mounting parts to it.
Testing the Charger
Make sure that the microcontroller
siliconchip.com.au
2 SPDT subminiature toggle switches (S1, S2)
1 10kW 16mm linear potentiometer with large knob (VR1)
8 M3 × 6mm panhead machine screws
4 M3 × 6mm tapped hex spacers
1 PIC12F617-I/P 8-bit micro programmed with 0911024T.HEX, DIP-8 (IC1)
1 78L05 5V 100mA linear regulator, TO-92 (REG1)
1 high-intensity 5mm LED, white recommended (LED1)
1 1N5819 40V 1A schottky diode (D1)
2 100μF 16V low-ESR radial electrolytic capacitors
4 100nF 50V ceramic, multi-layer ceramic or MKT capacitors
3 10kW ¼W 1% axial resistors
Receiver (common to both versions)
1 4-pin 433.9MHz receiver module, WRF43301R or XLC-RF5 (MOD2)
[Little Bird, AliExpress, eBay]
1 Polulu U3V16F15 15V output step-up DC/DC converter (MOD3)
1 Polulu S7V7F5 5V output step-up/down DC/DC converter (MOD4)
1 Adafruit DRV8871 motor driver module (MOD5)
4 1.2V 900mAh NiMH AAA cells [Jaycar SB1739]
1 2×2 AAA battery holder with flying leads
1 2.5mm mono switched chassis-mounting jack socket (CON1)
[Jaycar PS0105]
2 4-way right-angle pin header, 2.54mm pitch (for MOD2 & MOD5)
2 female-female DuPont jumper wires, ideally joined together
1 red 3mm LED (LED2)
available from Core Electronics
🔹
🔹
🔹
🔹
Receiver (TH version only)
1 single- or double-sided PCB coded 09110242, 74 × 23mm
1 PIC16F1455-I/P 8-bit microcontroller programmed with
0911024R.HEX, DIP-14 (IC2)
1 14-pin DIL IC socket
3 100μF 16V low-ESR radial electrolytic capacitors
2 100nF 50V ceramic, multi-layer ceramic or MKT capacitors
3 10kW ¼W 1% axial resistors
1 1kW ¼W 1% axial resistor
Receiver (SMD version only)
1 single- or double-sided PCB coded 09110243, 23 × 30mm
1 PIC16F1455-I/SL 8-bit microcontroller programmed with 0911024R.
HEX, SOIC-14 (IC2)
1 100μF 16V low-ESR radial electrolytic capacitor
1 100μF 6.3V radial electrolytic capacitor
1 47μF 16V X5R M3216/1206 SMD ceramic capacitor
2 100nF 50V X7R M2012/0805 SMD ceramic capacitors
3 10kW ⅛W 1% M2012/0805 SMD resistors
1 1kW ¼W 1% M2012/0805 SMD resistor
is not in its socket; at the same time,
check the orientation of all the semiconductors and electrolytic capacitors.
Connect the power supply and switch
it on. Take a voltmeter and connect
the red lead connected to pin 1 of the
empty IC socket, and the black lead to
pin 8. You should measure very close
to +5V DC.
If not, check that the 5V regulator
is the correct way round and there
aren’t any solder bridges shorting
the tracks.
siliconchip.com.au
Assuming it’s OK, switch off the
power, insert the microcontroller and
connect a 39W 1W resistor between the
battery terminals (eg, using clip leads).
Apply power again and the green LED
should flash.
Press the Start button; the green LED
should extinguish and the red LED
should flash, indicating ‘charging’.
There should be about 3.5V across
the 39W resistor, indicating 90mA of
current flow.
To simulate a fully charged battery,
Australia's electronics magazine
Photo 10: the Charger board easily fits
inside a UB3 Jiffy box (or a smaller
case) as shown here and in Photo 3.
disconnect the 39W resistor. The green
LED should then flash, and the red LED
will extinguish. If you want to check
that the timer is working, reconnect
the 39W resistor, press the Start button
again and wait for 16 hours. The red
LED should extinguish and the green
LED will flash.
Using the Charger
When the battery voltage in the carriage falls below 4V, the 3mm LED in
the rear of the carriage glows, alerting
you that the battery needs charging.
Connect the Charger to the carriage
via the 2.5mm jack plug. Switch on
the Charger and press the Start button to begin charging. The Charger
will revert to standby mode (with the
green LED flashing) when the battery
is fully charged.
SC
January 2025 79
|