This is only a preview of the November 2021 issue of Silicon Chip. You can view 45 of the 96 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 "USB Cable Tester – Part 1":
Articles in this series:
Items relevant to "R80 Synthesised Aviation Band Receiver Kit":
Items relevant to "Pocket Weather Station":
Items relevant to "Model Railway Carriage Lights":
Items relevant to "Two- or Three-Way Stereo Active Crossover – Part 2":
Purchase a printed copy of this issue for $11.50. |
Model Railway
Carriage Lights
BY LES KERR
It’s nice to have carriage lights on a model train, to add to the realism.
These model train carriage lights (designed for OO-gauge) are batterypowered and can be switched on and off with an external magnet.
I
t might seem trivial to add lights to a
model railway carriage, but there are
a few considerations that make it a bit
more difficult than that. One important
factor is that the battery must be small,
so the circuit must avoid discharging
it when the lights are off. Also, you
need a way of switching the lights on
or off easily.
This little circuit powers five white
LEDs and only draws a couple of
microamps when off, and just 8mA
when on. The low off-current puts
a negligible load on the battery. The
low 8mA operating current means that
you can use two AAA batteries (cells,
really) in series giving 3V this will
power the circuit for about 100 hours.
If you lack the space for that setup, you
can use a single 3.7V Li-ion 800mAh
battery such as the Jaycar SB2300.
The carriage size determines which
batteries can be used. The circuit
stops working when the battery falls
below 2V.
Until recently, lights in model railway carriages were powered from the
track. This is because small incandescent lamps required a relatively large
current, so they couldn’t be battery
powered. To obtain the power, the
carriage needed to have metal wheels
60
Silicon Chip
with some form of voltage pickup
attached to them, and they had to be
insulated from each other.
Today, most carriage wheels are
made of plastic, so they need substantial modification to pick up power
from the track. Also, it isn’t that easy
to make a reliable pick up.
Now that efficient white LEDs are
available, it is practical to power them
from a small battery inside the carriage. The problem then becomes how
to switch the lights on and off.
My simple solution is to mount a
normally-open reed switch inside the
carriage, either under the roof or on the
floor. When a magnet is placed near
the reed switch, its contacts close, signalling the circuit to toggle the lights
on or off.
You can see a video of the prototype’s operation at siliconchip.com.
au/Videos/Carriage+Lights
With this arrangement, you can
add a magnet on the tracks just outside a tunnel so that when the train
approaches, it switches the lights on.
Another magnet placed near the tunnel
exit switches off the lights when the
train leaves the tunnel. If you want to
use the train at night, you can mount
the reed switch under the roof so that
Australia’s electronics magazine
you can manually switch the lights on
and off by waving a magnet across it.
Circuit description
Fig.1 shows the full circuit diagram. The LT1932 IC2 constant-current
DC-to-DC LED driver provides a fixed
current that drives the series LED lights
from the battery. It is about 70% efficient and will work down to a battery
voltage of 2V. It has a shutdown input
that, when taken low, switches off the
LEDs and reduces its current draw to
less than 1μA.
I have specified high-intensity white
LEDs which give adequate light when
driven with 1mA. The 70% efficiency
figure given above is for a 10mA LED
current. To reduce this to the 1mA
required without unduly affecting the
efficiency, the shutdown pin is fed
with a 10% duty cycle (1-to-9 markspace ratio) PWM waveform.
The driver oscillates at 1.2MHz and
uses inductor L1, schottky diode D1
and a 1μF ceramic capacitor to step
up the battery voltage to the 15V or so
needed by the LED string. To protect
IC2 in case the LEDs are accidentally
disconnected, 24V zener diode ZD1
clamps the maximum output voltage.
The peak current through the LEDs is
siliconchip.com.au
Fig.1: the Carriage Lights circuit is based on a 6-pin LT1932 (IC2) constant-current switchmode (boost) LED driver and an
8-bit, 8-pin microcontroller (IC1). The role of IC1 is twofold: it monitors the contact closure of reed switch S1 to switch the
lights on and off, and when the lights are on, it drives the SHDN pin of IC2 with a 10% duty cycle square wave, reducing
the LED current consumption without impacting the efficiency of the driver circuit.
set to about 10mA by the 2.2kW resistor
from IC2’s Rset pin to ground.
An inexpensive PIC12F617 8-bit
microcontroller is used to generate
the PWM waveform to drive the pin 5
SHDN input of IC2. When reed switch
S1 closes, it takes the GP2 digital input
(pin 5) of IC1 high. The 10kW pulldown resistor and 100nF capacitor
help to debounce the switch contacts.
This signals the microcontroller to
come out of sleep mode and provide
the switching waveform to IC2, turning
on the lights. If S1 is operated again,
IC1 goes back into sleep mode, and its
GP0 output at pin 7 goes low, switching off the lights. In sleep mode, IC1
draws about 1μA from the battery.
If you add to this the <1μA of IC2 in
shutdown mode, you get a total current drain of less than 2μA, which is
a negligible load on the battery.
Construction
There are components on both sides
of the PCB, so there are two overlay
diagrams, Figs.2 & 3. The Carriage
Lights controller is built on a 28 x
16mm PCB coded 09109211. It has
been deliberately kept small to fit
inside a typical OO-gauge carriage.
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
a wire link. To enable this PCB to be
kept small, most of the components are
SMDs. This is a good project if you’re
siliconchip.com.au
interested in improving your SMD soldering skills since it has a few different types and sizes of components, but
nothing especially difficult.
Perhaps unsurprisingly, the surface
mount components go on the copper
side of the board, while the throughhole components are inserted from the
opposite side.
The SOIC-package PIC12F617 micro
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 below if you plan to do it
that way.
Use a flux pen or syringe of flux
paste to coat IC1’s leads and its associated pads. Hold IC1 in place (eg, using
tweezers) with the correct orientation
and use your soldering iron to tack
solder one lead into place, then check
that it is positioned correctly (it’s also
a good idea to re-check its orientation).
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.
Here is an example of how you can
►
mount the project into a carriage. Note
the clear plastic insulation under the
battery and PCB.
Australia’s electronics magazine
November 2021 61
Parts List – Carriage Lights
Figs.2 & 3: the top and bottom side
PCB overlay diagrams (shown
enlarged). To save space and allow
the board to use single-sided copper,
all the SMDs are on one side and the
through-hole parts on the other. The
orange wire link does not need to be
installed if a double-sided PCB is used
(eg, from our Online Shop). Watch
the orientations of the ICs, diodes and
electrolytic capacitor during assembly.
Now that you’ve done that successfully, move on to IC2, which is slightly
trickier as its pins are smaller and
closer together. As its body is also quite
small, you might have trouble seeing
the pin 1 indicator. You will need to
make sure you’ve found that (eg, using
a magnifier) as it must be placed with
the correct orientation.
Use the same basic procedure to
solder it as IC1, but keep in mind that
it’s very difficult to avoid bridging the
pins with solder. If you have flux paste,
once the part has been tacked down,
you can drag-solder the three pins on
the opposite side and then the three
pins on the other side. Still, it’s also
acceptable to just solder them individually without worrying too much
about creating bridges.
After all, it’s pretty easy to remove
any bridges that have formed with solder wick, as long as you add a bit of
flux to make the process go smoothly,
and avoid heating the wick any more
than necessary to prevent damage to
the PCB.
Once again, clean the flux residue
away from IC2 and scrutinise its solder
joints, then go back and fix any that do
not appear to have formed correctly,
or are still bridged.
Now use a similar procedure to fit
all the remaining SMDs, except for
the 6.8μH inductor. The only remaining SMD where polarity is important is schottky diode D1; its cathode
stripe should be visible on the top of
62
Silicon Chip
1 single-sided or double-sided PCB coded 09109211, 28 x 16mm
1 6.8μH 200mA inductor, SMD 2.0x1.6mm up to 2.5x2.0mm, 200mA+ <0.5W
DCR [RS Cat 879-0742 or Taiyo Yuden LB2016T6R8M]
1 miniature single-pole normally-open (SP-NO) reed switch (S1)
[RS Cat 3622518 or Jaycar SM1002]
1 magnet suitable for use with a reed switch [RS Cat 118-7108]
1 3V battery pack [eg, 2 x AAA pack or 1 x 3.7V 800mAh Li-ion, Jaycar SB2300]
various lengths and colours of light-duty hookup wire
Semiconductors
1 PIC12F617-I/SN or PIC12F617T-I/SN 8-bit microcontroller
programmed with 0910921A.HEX (IC1)
1 LT1932ES6#TRMPBF LED driver, SOT-23-6 (IC2) [RS Cat 7618504]
1 1N4749 24V 1W zener diode, through-hole (ZD1) [Jaycar ZR1424]
1 SS14 40V 1A schottky diode, DO-214AC (D1) [RS Cat 6387915]
5 high-intensity 3mm or 5mm white LEDs (LED1-LED5)
Capacitors
1 100μF 6.3V radial electrolytic capacitor [RS Cat 390176]
1 1μF 50V multi-layer ceramic through-hole capacitor [Jaycar RC5499]
2 100nF 50V X7R SMD ceramic capacitor, M2012/0805 size [RS Cat 135-9033]
Resistors (all SMD 1% 1/8W M2012/0805 size)
2 10kW
1 2.2kW
the body, and this must be located as
shown in Fig.2.
As the inductor has only solder pads
on the underside at either end, it’s
harder to solder it in place compared
to the rest of the components. To enable
you to do this, I made the PCB lands
for the inductor larger than the component body, so there is room to get your
soldering iron tip in to heat the lands.
Coat both the lands and inductor
pads with flux and lightly tin the pads
with solder. Place the inductor on the
PCB and apply heat from your soldering iron to the land on one side until
you see the solder melt. Do the same
for the other side.
Depending on how much solder you
applied to the pads initially, you might
want to feed a bit of extra solder into
the sides while heating them.
Now make a final check of the SMD
components to verify there are no solder bridges or shorts, and if there are,
fix them up with a bit of flux paste and
the solder wick.
Turn the board over and solder in the
wire link (if you are using a single-sided
board), zener diode, 1μF ceramic capacitor and the 100μF electrolytic, making
sure the diode and electrolytic capacitor are the right way around. These
components are all shown in the underside overlay diagram, Fig.3.
Wiring it up
While Fig.3 shows the basic external wiring connections, there are more
Programming IC1 in-circuit
To program the micro in-circuit, you will need to solder wires to the +3V and
GND battery pads (see Fig.3), as well as the PCB pads provided to connect to
the PCLK pad (pin 6 of IC1), PDAT pad (pin 7 of IC1; the pad is also used for
the wire link) and the MCLR pad (pin 4 of IC1).
As IC1 is mounted over the PCLK pad, solder this wire first and use as little
solder as possible. Cut the part of the wire that projects from the solder joint
as short as possible so that when you solder IC1, it isn’t lifted above its pads.
With those wires in place and IC1 soldered to the board correctly, connect
the soldered wires to your programmer. For the PICkit series, the triangle indicates pin 1, and the connections are MCLR to pin 1, +3V to pin 2, GND to pin
3, PDAT to pin 4 and PCLK to pin 5.
With those connections made, load up the programming software, open the
HEX file, “carriage lights (0910921A).HEX” and upload it to the chip.
If you are using a pre-programmed PIC12F617, it isn’t necessary to solder
these extra wires to the board.
Australia’s electronics magazine
siliconchip.com.au
Here are both sides
of the finished
project shown
greatly enlarged for
clarity. While you
can definitely etch
the single-sided
board yourself
given the right
supplies, we will
be selling a doublesided version for
convenience.
That time of year is nearly here...
CHRISTMAS
Spice up your festive season
with eight LED decorations!
Tiny LED Xmas Tree
54 x 41mm PCB
SC5181 – $2.50
Tiny LED Cap
55 x 57mm PCB
SC5687 – $3.00
details shown in the wiring diagram,
Fig.4. So that you can work out the
length of the board connecting wires,
you need to decide how and where
the components fit into the carriage.
In my case, I glued the 5mm white
LEDs and the reed switch to the underside of the carriage roof and taped the
battery and PCB to the floor of the carriage. If you have a smaller carriage,
you might prefer to use 3mm LEDs.
Another solution for the LED mounting is to solder them to a thin strip of
Veroboard which can be attached to
the underside of the roof.
If the floor of your carriage is black
like mine, you can improve the radiated light by covering it with aluminium foil to reflect the light back up.
If you do this, insulate the PCB with
tape so that none of the tracks short
out on the foil.
Once you have decided on the layout, cut the wires to length and solder
them to the PCB.
Testing
Connect up the reed switch and
LEDs, and before connecting the battery, have a last look at the board for
any faults or dry joints. Make sure that
you connect the battery the right way
around, as the circuit will be destroyed
if you don’t.
If you now place the magnet parallel to the reed switch a few millimetres away, the LEDs should light.
Remove the magnet, then put it back
where you had it, and the LEDs should
SC
extinguish.
Tiny LED Stocking
41 x 83mm PCB
SC5688 – $3.00
Tiny LED Reindeer
91 x 98mm PCB
SC5689 – $3.00
Tiny LED Bauble
52.5 x 45.5mm
SC5690 – $3.00
Tiny LED Sleigh
80 x 92mm PCB
SC5691 – $3.00
Tiny LED Star
57 x 54mm PCB
SC5692 – $3.00
Tiny LED Cane
84 x 60mm PCB
SC5693 – $3.00
Fig.4: there are just three items to wire to the board; the power supply (in this
case, a 3V battery pack using two AAA cells), the reed switch and the string
of white LEDs. You can use just about any type of white LED as long as the
voltage required to power the string is in the range of about 5-20V. Various LED
mounting arrangements are possible, too – whatever suits your carriage(s).
siliconchip.com.au
Australia’s electronics magazine
We also sell a kit containing all
required components for just
$14 per board ➟ SC5579
November 2021 63
|