This is only a preview of the April 2025 issue of Silicon Chip. You can view 45 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 "Discrete 555 timer":
Items relevant to "The Pico 2 Computer":
Articles in this series:
Items relevant to "Weather monitor":
Articles in this series:
Articles in this series:
Items relevant to "Rotating Light for Models":
Articles in this series:
Items relevant to "433MHz Transmitter Module":
Items relevant to "Power LCR Meter, Part 2":
Purchase a printed copy of this issue for $13.00. |
Rotating Light
for Models
Here’s a simple circuit that has various applications, such as for
a model lighthouse, or as a siren on top of a model emergency vehicle. It sequences eight LEDs, using
PWM brightness control, to form a pretty convincing imitation of a rotating light.
T
his project originated from a family
member’s desire for a white revolving light atop a miniature lighthouse.
Kits to build this sort of thing are available, but we hadn’t published such a
circuit, and I thought it might have
other uses. I also thought it could be
done simply, on a tiny PCB.
We could use a single logic IC if all
we wanted was essentially a circular
LED chaser. However, I have seen that
approach used (eg, on garbage trucks);
while eye-catching, it doesn’t provide a convincing illusion of rotation.
Moreover, most digital logic ICs can’t
deliver much current, meaning the
LEDs wouldn’t be that bright without
extra transistors.
With a microcontroller, we can fade
the LEDs in and out, creating a much
more impressive effect, even with just
eight LEDs at 45° intervals. We can
also make it adjustable; not just the
rate of rotation, but also the direction
and the brightness/beam angle. We can
even have multiple ‘beams’ by lighting opposite LEDs, as shown in Fig.1.
Adjusting the beam angle effectively
controls how many LEDs can be lit at
once. It can range from just one (with
varying brightness) up to almost all of
them being lit at once, with just a dim
spot rotating.
If you build it with white LEDs, it’s
suitable for a model lighthouse, and
with a compact, black PCB that’s just
20mm in diameter, it will fit in most
models unless they are tiny. If you
want to make a siren, you could use
amber, blue, red, yellow or green LEDs,
or even unusual colours like cyan or
pink (yes, they’re available).
Fig.1: by fading in one LED at the edge of each beam and fading out the opposite one, we create the illusion of a smoothlyrotating light with just eight fixed LEDs. The ‘beam’ brightness and width varies depending on how many LEDs are lit at
any given time.
58
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Features & specifications
» Simulates a rotating light with one or two ‘beams’
» Adjustable rotation speed, from about 10 rotations per second to 30
seconds per rotation (0.03Hz to 10Hz)
» Reversible rotation direction
» Adjustable beam brightness
» Adjustable beam angle from 45° to nearly 360°
» Runs from 5-12V DC, typically drawing 10-20mA
» Compact circular PCB: 20mm in diameter and less than 10mm tall (with
SMD LEDs)
» Can use SMD (M3216/1206/SMA) or through-hole (3mm/5mm) LEDs
» Use any colour LEDs
Project by Nicholas Vinen
Suppose you want a really special
effect. In that case, you could build it
with differently coloured LEDs, so the
colour shifts as it rotates!
It can run from a small DC supply
from 5V up to about 12V, including
most small battery packs, such as standard 9V batteries or 6V batteries of
four AA/AAA cells. The current draw
depends on the brightness, but it’s typically around 10mA. So four AA cells
would power it for quite a while; possibly as long as two weeks for really
high-capacity cells. Four AAAs might
last 5-7 days.
You can see a video of our prototype in operation at siliconchip.com.
au/Videos/Rotating+Light
Circuit details
The complete Rotating Light circuit is shown in Fig.2. A 14-pin, 8-bit
PIC16F15224 was chosen as it has
just enough pins, is inexpensive and
draws very little current. It can drive
the LEDs directly with fairly decent
brightness (its maximum per-pin current is 25mA). It’s also easy to program
with the free version of Microchip’s
XC8 compiler and MPLAB X IDE.
The eight LEDs are connected to
eight of its digital outputs via 68W
current-
l imiting resistors. Their
anodes connect directly to the 5V rail,
and they light when the microcontroller pulls that output pin low, to 0V.
This configuration was selected as the
micro’s output transistors are better at
sinking current than sourcing it, as is
typical. So they will deliver a higher
maximum current like this.
Assuming white or blue LEDs with
a forward voltage of around 3.3V and
a 5V supply, there will be around 1.7V
(5V – 3.3V) across the combination of
the 68W resistors and the micro’s output transistors.
With a 3V supply, the data says that
those output transistors can sink 10mA
with a 0.6V saturation voltage, implying an output impedance of 60W (0.6V
÷ 10mA). It might be lower with the
higher 5V supply voltage used in this
circuit, but let’s use 60W as the worstcase value.
That means the 1.7V is across 128W
(68W + 60W), so we can expect the
LEDs to be driven with a peak current of about 13mA (1.7V ÷ 128W).
LEDs with a lower forward voltage,
like red or amber, would receive more
current, likely around 20mA. So the
peak current is limited to a safe level.
The microcontroller can control the
average current using pulse-width
modulation (PWM).
One nice feature about this microcontroller is that its two PWM peripherals can be dynamically mapped to
any of its I/O pins. So as the light
‘rotates’, we can determine the two
edge LEDs and assign them to the
PWM peripherals to dim them. The
other LEDs are either fully off or full
on, as determined by the states of the
other digital outputs.
That means that all the LEDs are
controlled by hardware, with the software just needing to periodically recalculate which LEDs should be lit. It can
then update the PORT and PWM registers to advance the rotating light to
the next position.
Two trimpots, VR1 & VR2, connect
across the 5V supply with their wipers
Fig.2: the circuit is little more than eight LEDs driven by the microcontroller via current-limiting resistors, two
potentiometers to set the parameters and a simple linear power supply.
siliconchip.com.au
Australia's electronics magazine
April 2025 59
Parts List – Rotating Light
1 double-sided black PCB coded 09101251, 20 × 20mm
8 high-brightness LEDs, 3mm/5mm through-hole or SMD
(SMA, M3216/1206 or M2012/0805 size), colour to suit application
1 PIC16F15224-I/SL 8-bit micro programmed with 0910125A.HEX, SOIC-14
(IC1)
1 MCP1703AT-5002E/CB 5V 250mA low-dropout linear regulator, SOT-23
(REG1)
1 RB491D 20V 1A schottky diode, SOT-23 (D1)
2 1μF 16V X7R ceramic chip capacitors, M3216/1206 size
2 10kW TC33X-2-103E SMD trimpots (VR1, VR2)
1 5.1kW SMD chip resistor, M2012/0805 size
8 68W SMD chip resistors, M2012/0805 size
1 length of light duty figure-8 wire, to supply power
1 5-12V DC 100mA power source
At upper right, the top side of
the PCB is shown at actual size.
The underside views of the SMD
and through-hole versions of the Rotating
Light project are shown enlarged.
LED selection
SMD LED kit (SC7462; $20 + postage) | TH LED kit (SC7463; $20 + postage)
Both kits includes all the parts listed above, except the power supply and wire
going to pins 8 & 11 of IC1. These are
both analog-capable pins, so we can
use the micro’s internal analog-to-
digital converter (ADC) to measure
these voltages. VR1 controls the speed
& direction of ‘rotation’, while VR2
controls the beam width & brightness.
Usually, you would put capacitors
on these pins to keep the AC impedance low, making the ADC results more
precise, but there isn’t a lot of room
on the PCB, so we’ve left them off.
We don’t need to make super accurate
measurements, and we can compensate for the lack of capacitors either by
tweaking the software or by eye when
making the adjustments.
In practice, we found that the ADC
measurements were close enough to
what you would expect based on the
trimpot positions without these extra
capacitors.
The 5.1kW pull-up resistor on the
MCLR pin (pin 4 of IC1) prevents
spurious resets, while the 1µF capacitor across its supply pins provides
60
Silicon Chip
If you’re going to power it from a regulated 5V supply like USB, you could
omit REG1 and solder a bridge between
its input and output pads. You could
also bypass D1, or replace it with a 0W
resistor, if you are certain that the supply polarity can’t be reversed.
The maximum recommended supply voltage is 12V due to REG1’s
absolute maximum rating of 16V.
With a 12V supply and 50mA average current draw, REG1 will dissipate
350mW ([12V – 5V] × 0.05A), giving
an expected temperature rise of nearly
120°C, which would put it close to its
shutdown temperature of 150°C at an
ambient temperature of just 30°C.
The PCB draws enough heat away
from REG1 that it’s unlikely to
shut down unless the current draw
exceeds 50mA. Still, if you intend
to run the Light with a bright, wide
beam, you’d be better off with a supply voltage below 12V; 6-9V would
be ideal. If you manage to overheat
REG1, it won’t be damaged; the light
will just shut off and then restart
when it cools down.
bypassing for stability. The 5.1kW
value is not critical; it could be 4.7kW,
10kW or another similar value.
All that remains is the simple
power supply. 5V low-dropout regulator REG1 ensures IC1 receives a
steady and safe voltage, even if the
incoming supply at CON1 varies.
Schottky diode D1 prevents any damage from occurring if the supply polarity is accidentally reversed at CON1,
while also having a modest (~0.3V)
voltage drop.
REG1 requires an input bypass and
output filter capacitor for stability, so
we have provided 1μF in both cases.
That is the minimum value for unconditional stability on the output, and is
more than enough for input bypassing.
The circuit can be run from a 5V supply (eg, from USB), although the LED
brightness will be reduced somewhat
as IC1 and the LEDs will only have a
supply of about 4.6V, ie, 5V minus D1’s
forward voltage (~0.3V) and REG1’s
dropout voltage (<100mV).
Australia's electronics magazine
The LEDs are arranged around the
outside and can be through-hole (3mm
or 5mm) or SMD types (M3216/1206
or M2012/0805). While side-emitting
SMD LEDs exist, we reckon it’s easier just to use regular SMD LEDs and
mount them on their sides, with the
emitters facing out. That’s how we
built our SMD prototype, shown in
the photos.
Some reasons we don’t think it’s
worth getting side-emitting SMD
LEDs are:
1. They are many times pricier than
the normal top-emitting type.
2. They aren’t that much easier to
solder than a top-emitting type facing sideways.
3. Many of them have a central pad
for extra support that could short out
the anode and cathode pads.
4. There are much more limited
choices of size and colour compared
to regular SMD LEDs.
5. Only the largest component sellers stock them.
Through-hole LEDs can be soldered
on either side of the board, while
SMD LEDs have to go on the top. You
could perhaps get away with soldering smaller SMD LEDs across the pads
on the bottom if you have a particular
reason to do that.
siliconchip.com.au
PCB design
The PCB is circular with a 20mm
diameter (10mm radius). By making
it black, we can hide it inside models,
so you only see the light when it’s on.
In the middle of the top side of the
PCB is the microcontroller, the two
small SMD adjustment trimpots, one of
the 1μF capacitors and the 5.1kW resistor. All the other components, like the
LED current-limiting resistors and the
remainder of the power supply, are in
the middle of the underside.
The power connections are two solder pads to which wires can be soldered from either side of the PCB, to
suit the installation.
Software
The software (from siliconchip.au/
Shop/6/1837) is just under 200 lines
of C code. The PIC runs at 8MHz with
its internal Timer0 used to control the
rotation speed of the light and Timer2
to run the PWM peripherals used for
LED dimming. At power-up, it sets the
pins as analog inputs and digital outputs as required. It then initialises the
two timers and the ADC.
The main loop waits for Timer0 to
roll over, which happens every 4ms
or so. Each time, it adds the rotation
speed/direction to a 16-bit accumulator. It uses the accumulator value to
calculate the brightness for the eight
LEDs, then updates the output and
PWM states. The 8-bit PWM runs at
around 2kHz.
When Timer0 rolls over, it also measures the voltages at the two analog
inputs and applies a low-pass filter to
remove noise and glitches from those
readings. The new readings are used
for future light update calculations.
The code compiles to 1276 instruction words, taking up 2552 bytes of
the 8kiB of the available flash memory
(31.2%). The pro version of the XC8
compiler is not required.
The critical part that generates the
‘rotating’ light is actually quite simple.
If you mentally unwrap the circular
light pattern into a line, you end up
with a bi-directional chaser that ‘wraps
around’ from one end to the other. The
mathematics to calculate that, even
with the LED brightness smoothly
changing, is relatively simple.
In twin-beam mode, with VR2 closer
to the clockwise end than anti-clockwise, the chaser shifts so that there are
two lit areas exactly four LEDs apart.
Many lighthouses and sirens that use
siliconchip.com.au
actual rotating lights will emit light
from both ends, so this mode better
simulates that appearance.
Construction
The Rotating Light is built on a
double-
sided PCB coded 09101251
that measures 20 × 20mm. The top and
bottom component overlay diagrams
are in Fig.3, with two versions shown
to suit SMD or through-hole LEDs.
Refer to those during construction to
see which parts go where.
If you find the small board slides
around while working on it, use a little Blu-Tack to temporarily stick it to
your work surface.
None of the components are terribly
hard to solder individually. We found
the main challenge to assembly was to
avoid accidental bridges between adjacent pads because they are quite close
together due to the small size of the
PCB, especially the two trimpots and
the two SOT-23 devices that mount
side-by-side. So it’s best to feed in solder carefully and use the minimum
necessary to form good fillets.
The microcontroller IC has fairly
widely spaced pins, on a 1.27mm
pitch and other parts have larger or
more widely spaced pins. So the actual
soldering of individual components is
not too difficult.
As there are parts on both sides,
once you have fitted the parts on one
side, the PCB won’t easily sit flat and
will tend to rock as you work on it.
To deal with this, you can either use
Blu-Tack as mentioned, or you could
do what we did and place the PCB on
top of a roll of solder-wicking braid.
This has a hole in the middle for the
components to fit in, so it can rest on
its edges and sit flat.
Of course, that depends on you having a similarly sized roll of braid to us,
but it worked surprisingly well for us.
Fig.3: the top side of the PCB has
the microcontroller, both trimpots,
one capacitor, one resistor and
either SMD or through-hole LEDs,
although TH LEDs can also be inserted from the bottom side. All the currentlimiting resistors are on the underside, along with most of the power supply.
Australia's electronics magazine
April 2025 61
There is no provision to program
the microcontroller on the board, so
you’ll need to either purchase a pre-
programmed micro (from our Online
Shop, either individually or in a kit),
or program it yourself before soldering it. Our article on the PIC Programming Adaptor in the September 2023
issue (siliconchip.au/Article/15943)
explains how you can do it.
Once programmed, make sure you
have identified pin 1 on the chip and
lined it up with the marking on the
PCB (very important!). Also check it
against Fig.3, then tack-solder one pin.
Adding a little flux paste will help the
solder flow. Check the alignment of all
the other pins with their pads (now is
also a good time to double-check that
pin 1 is in the right place!).
If the positioning is not perfect,
remelt the solder joint and gently
nudge the chip into position. Once it’s
located correctly, solder the diagonally
opposite pin, then spread a little flux
paste down both sides of the chip, over
all the pins, and solder the remaining
pins. You can drag solder them, or do
them one at a time.
If solder bridges have developed
between any pins, clean them up by
adding a dab of flux paste and then
using a clean piece of solder wick to
remove the excess solder. Clean off the
flux residue with a suitable solvent,
then inspect the pins under magnification to ensure all the solder joints are
good (solder has flowed onto both the
pin and pad) and no bridges remain.
Solder the two trimpots similarly,
being careful to avoid bridges to adjacent pads due to their proximity to
IC pins and LED pads. We found the
trimpots were the trickiest parts of all
to solder because the pads didn’t stick
out very far from underneath them.
We’ve extended them in the final
version of the PCB, but there was limited space available to do so. Add flux
paste on both the PCB and component
leads before soldering need to be careful to check that the solder has flowed
down on the PCB pads before moving
on to other components.
With the trimpots soldered correctly, add the sole top-side capacitor
and one resistor. Finally, if you are fitting SMD LEDs, you can do that now.
Soldering the LEDs
We recommend soldering standard
SMD LEDs on their side, like in our
photos. First, figure out which end of
62
Silicon Chip
the LED is the cathode. You can do
this with a DMM on diode test mode.
When the LED lights up, the black
probe is on the cathode. It must go to
one of the pads marked “K” in Fig.3.
Start soldering each SMD LED by
adding solder to one of its pads. Due
to the through-holes, you’ll need to
add more than you might expect until
you get sufficient solder on the top
surface. You want a visible bulge so
enough solder will reach the pad on
the side of the LED, rather than the
bottom as usual.
The hardest part of soldering the
SMD LEDs on their side was picking
them up with the tweezers. We found
the easiest way was to pick them up
from the bench with one hand, rotate
them on their side, then grab them with
tweezers using the other hand. Make
sure the tweezer tips don’t extend past
the bottom of the LED or you won’t
be able to get it to sit flat on the PCB.
Once we had picked them up correctly, we found that soldering them
wasn’t too hard. Position the LED with
tweezers while keeping the solder on
that initial pad molten with your soldering iron. Remove the iron for a few
seconds to let it solidify, then check if
the position is good. If it is, add a fillet
to the other pad. The LEDs don’t need
to be perfectly aligned but it helps if
they are close.
If you aren’t happy with the LED
position, you can grab it again with
the tweezers, reheat the initial joint
and nudge it into place.
Once both sides are soldered, you
may need to add a dab of flux paste
to the first pad and heat it to reflow
the solder and form a nice, shiny fillet.
With all the top-side components
fitted, flip the board over and add the
remaining SMDs, as shown in Fig.3.
Don’t get D1 & REG1 mixed up. None
of the other components are polarised.
If using through-hole LEDs, bend
their leads consistently and solder
them in place now. You can insert them
from either side of the PCB but make
sure when you bend the leads that the
shorter (cathode) lead will always go
into a pad marked “K” in Fig.3.
Now solder the power leads to their
pads. They are marked with + and –
symbols on one side of the PCB. You
can solder them from either side.
Testing
If you have a current-limited supply,
set it to 6V and 25-50mA. Otherwise,
Australia's electronics magazine
you could include a series resistor
(eg, 100W 5W from a 12V supply) to
limit the current in the event of a fault.
Apply power and check the current
flow. Depending on the trimpot positions, it should be around 10-20mA
and should definitely not exceed
50mA. Verify that the LEDs light up
and start to sequence.
If the current draw is too high,
switch off and inspect the board for
faults, such as solder bridges between
pads or pins, or incorrectly placed or
orientated components. Perform similar checks if there is no current draw
or nothing happens. Also check that all
solder joints have been made correctly.
If it operates but some LEDs don’t
light, likely they are faulty, their solder joints are bad, or they are shorted
to an adjacent pad. If it appears to be
working, try adjusting VR1 & VR2 to
verify that you can change the rotation
speed, direction and beam brightness/
width as expected.
We found that many of our Phillips
head screwdrivers of various sizes
failed to actually rotate the trimpot.
We had to search around until we
found a slotted screwdriver of the perfect size before we could get sufficient
purchase. After that, we could make
easy and precise adjustments.
Usage
With VR1 centred, rotation is very
slow; if it is perfectly centred, the
light will not rotate, or just barely. It
‘accelerates’ in either direction as you
move towards the clockwise or anti-
clockwise extremes. This gives a reasonable range of speed options without
making the adjustment super fiddly.
With VR2 centred, you will have
a narrow (45°), dim beam. As you
move it anti-clockwise, the beam will
first start to brighten, then widen. At
about halfway between anti-clockwise
and the centre, you will have a bright
45° beam. As you move closer to
anti-clockwise, the beam will get
wider and wider until it occupies
almost the whole circumference.
Rotating it from the centre clockwise is similar except that you will
have two opposing 45° beams that get
brighter, then wider.
If you want to power this board from
a USB supply, we have an upcoming
article on USB Power Adaptors. You
would need to join the two boards
with a short length of light-duty twin
lead or similar.
SC
siliconchip.com.au
|