This is only a preview of the October 2016 issue of Silicon Chip. You can view 39 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 "El Cheapo Modules From Asia - Part 1":
Items relevant to "Lure & Liquidate Lovelorn Zika Virus Mozzies":
Items relevant to "A New Transformer For The Currawong Valve Amplifier":
Items relevant to "Touchscreen Appliance Energy Meter, Pt.3":
Items relevant to "Two Micropower LED Flasher Modules":
Items relevant to "Voltage/Current Reference With Touchscreen, Pt.1":
Items relevant to "Micromite Plus Explore 100 Module, Pt.2":
Purchase a printed copy of this issue for $10.00. |
MICROPOWER
LE
L
ED
FLA
LASH
SHER
ER
We’ve used flashing LEDs for decades –
but alas, the LM3909 Flashing LED IC
is no longer available. What to do?
By JOHN CLARKE
N
ow we know that that there are
lots of LED flashers available and
that you can also obtain LEDs with
inbuilt flashing. But we still get regular
requests for a LED flasher, to provide
similar functions to the now obsolete
National Semiconductor LM3909
flasher/oscillator.
This new module provides similar
functions to the LM3909 but also
includes daylight detection with an
LDR (light-dependent resistor). Since
the LM3909 is no longer available,
we have employed a low-cost microcontroller and it drives the LED in a
similar way to the National Semiconductor device.
To be specific, it charges a capacitor, then “jacks it up” and dumps the
charge through the LED to give a much
brighter flash than would be possible
with the otherwise limited supply
voltage. In fact, you cannot normally
drive a blue or white LED reliably
with a 3V supply – you need to boost
the voltage.
By the way, this module does not
have to be battery powered. You can
run it from any fixed supply from 3 to
5V, so you can eliminate the button
cell and just connect it to any 5V USB
source. Alternatively, you can run it
from a much higher DC voltage if you
connect a suitable resistor in series
with the input.
Circuit details
The circuit is shown in Fig.1 and
uses a PIC12F675 microcontroller,
two diodes and several resistors and
capacitors. It runs from a lithium button cell, or you could run it from two
alkaline AAA cells or a 5V USB supply.
LDR1 is used to detect whether
the LED Flasher is in daylight or in
darkness. This is connected in series
with a 470kΩ resistor. In darkness, the
LDR resistance is typically well over
1MΩ. When the GP4 output is high
(ie, at the positive supply voltage), the
470kΩ resistor pulls the GP2 input sufficiently high for IC1 to detect this as a
high level. In daylight, the resistance
of LDR1 is around 10kΩ and so GP2’s
input is held near to 0V. IC1 detects
this as a low and then goes to sleep to
conserve power.
If the GP2 input is high, indicating
Features & Specifications
•
•
•
•
•
•
•
•
•
Flashes any colour LED
Flash rate set by resistor & capacitor values
Optional LDR to disable flash with high ambient light
Two PCB versions to suit different applications
Small and easy to build
Supply voltage range: 3-5.5V or higher with modifications (see text)
Fixed flash time: 65ms
Standby current: 10µA <at> 5V, 2µA <at> 3V
Operating current: typically 0.7-1.6mA (0.5-2Hz) (see Table 1)
62 Silicon Chip
that the module is in darkness, the micro provides the LED flasher function,
which we will come to in a moment.
If the LDR is omitted, this input will
always be high and so the flasher will
run as long as it has power.
The micro has an internal “watchdog” timer and this is used to wake
it up every 2.3 seconds so that it can
check the voltage level at the GP2 input
pin. If it is low, the microcontroller
goes back into sleep mode. If it is high,
LED flashing is enabled.
The Flasher section of the circuit
comprises diode D1, capacitor C1,
resistors R1 & R2 and LED1. We show
its operation in Fig.2 which depicts the
two modes of the circuit: charging the
capacitor and then jacking it up while
dumping its charge through the LED.
In the first part of the cycle, the GP5
output (pin 2) is taken high while the
GP0 output (pin 7) is held low. In
this state, capacitor C1 charges via R1
(6.2kΩ) and diode D1. The charge current path is shown in Fig.2 in green. No
current flows through the LED and R2
because this process reverse-biases the
LED, as its cathode terminal (labelled
K) is held high while the capacitor is
charging.
During this process, the voltage
across C1 is monitored by input pin
GP1 (pin 6). The software compensates
for the fact that the voltage at this pin
is higher than that at the capacitor’s
positive terminal due to the forward
voltage drop of diode D1.
Once the capacitor has charged to
the maximum possible level of about
2.2V, the comparator senses this and
switches the GP5 output (pin 2) low
siliconchip.com.au
Fig.1: complete circuit for the LED Flasher. IC1 charges capacitor C1 via pins 2 and 7 and diode D1. C1 is then discharged
through LED1 and R2, with a total flash voltage of about 5V when the circuit is powered from a 3V button cell. This is
sufficient to allow blue or white LEDs to be used.
and the GP0 output (pin 7) high (up
towards +3V). This has the effect of
“jacking up” the negative side of the
charged capacitor by about 2.6V or so,
which means that the positive terminal
will be at around 5V. This is fed to the
LED to give a brief and very bright
flash. The LED current path is shown
in red in Fig.2.
The cycle then restarts, with GP5
and GP0 swapping polarity, so that
capacitor C1 can charge up again.
Since the timing of this cycle is controlled by the component values, the
flash rate is set mainly by the values
of C1 and R1 but to a lesser extent, the
type of LED and the supply voltage.
Table 1 shows typical flash rates and
the corresponding component values
required for various different LED
types. Note that green LEDs require
values which are somewhere between
those specified for red and blue (depending on the exact construction).
To further demonstrate how this process works, see the scope grab, Fig.3,
which shows four traces. The top blue
trace is the voltage at GP0, pin 7, which
is zero most of the time and switches
high for about 65 milliseconds. The
green trace below is the voltage at GP5,
pin 2, which is high most of the time
and then drops low during the same 65
millisecond period. The yellow trace
shows the voltage at the positive side
of capacitor C1.
V+
1
I discharging
D1
INTERNAL
COMPARATOR
6
A
K
GP1
C1
100 F
(0.718Vcc)
IC1
PIC12F675
GP0
7
A
+
LED1
–
K
R1
6.2k
GP5
2
+
I charging
As you can see, each time GP5 (green
trace) goes high, the capacitor voltage
starts to ramp up and after slightly less
than one second, when GP5 goes low
(stopping the charge) and GP0 flicks
high, the capacitor voltage takes a
sudden jump up. The capacitor voltage then drops over a period of 65ms
as it discharges through the LED and
the cycle repeats.
The mauve trace is the difference
between the voltages at the positive
terminal of the capacitor (yellow) and
GP5 (green) and it shows a maximum
value of 3.6V. This is the effective peak
voltage applied to the LED and current
limiting resistor R2.
Referring back to Table 1, note that
the peak current is higher with a lower
voltage drop LED (eg, red) compared
to a higher voltage drop LED (blue or
white). Also be aware that electrolytic
capacitors typically have a wide tolerance range of -20% to +100%, so the
flash rate may vary from the calcu-
R2 100
–
8
Fig.2: the charge and discharge currents for timing/boost capacitor C1. The
charge current path is shown in green while the discharge current path is
shown in red. Output pins 2 and 7 reverse polarity to switch current flow
between the two paths while pin 6 monitors C1’s charge status to determine
when to switch between charging and discharging.
siliconchip.com.au
October 2016 63
Fig.3: scope grab showing the critical voltages. The blue trace is pin 7 (GP0),
green trace is pin 2 (GP5), yellow trace is the positive terminal of capacitor C1
while the mauve trace is the voltage across LED1 and R2. This shows a peak
value of 3.6V, despite the 3V supply.
lated rate, depending on the actual
capacitance.
Flash brightness can be increased
by reducing the value of R2 or using
a larger capacitor (up to 470µF) and
scaling down R1’s value proportionally. The minimum recommended
value for R2 is 100Ω. For example,
to flash a blue LED at 1Hz, you could
increase C1 to 220µF and reduce R1
to 33kΩ and this will roughly double
the LED current (as well as increasing
the supply current drawn).
Note that the flash rate is inversely
proportional to the supply voltage and
is about 50% faster at 2V and 22%
slower at 5V, compared to 3V.
Zener diode ZD1, across IC1’s supply, protects IC1 from reverse supply
polarity as it will be forward-biased
under this condition. Its typical leak-
age current during normal operation
with a 3V cell is around 10nA. JP1
functions as an off/switch.
ZD1 also provides protection against
over-voltage to the microcontroller and
it limits the supply to around 5.5V if
you are using a much higher DC input
voltage together with a series dropping
resistor. In that case, the dropping
resistor could be installed on the PCB
in the place of JP1 (see “Higher supply
voltages”). But we are getting a little
ahead of ourselves.
PCB assembly
The LED Flasher is constructed on
a PCB coded 16109161, measuring 45
x 47mm. If you wish, the PCB can be
clipped into a small UB5 case (83 x 54
x 31mm), although most constructors
probably will not bother.
Before you start assembling the PCB,
you need to select the components
required for R1, R2, C1 and the LED
colour, eg, red, yellow, blue or white.
Table 1 shows typical component
values.
Fig.4 shows the PCB overlay. Begin
construction by installing the resistors, using a multimeter to check the
value of each before inserting it into
the PCB.
Diodes D1 and ZD1 can now be
installed, taking care to orient these
correctly. The socket for IC1 is then
fitted, with the notch towards the top
of the board. Install the capacitors
and if using a polarised electrolytic
for C1, then this must be fitted with
the shown polarity, ie, the longer lead
inserted through the pad towards the
top of the board.
Then solder in the 2-way pin header
for JP1. The 4-way header is optional
and it can provide convenient test
points if you want to check the module’s operation or display the various
waveforms on a scope.
Install the cell holder, if using the 3V
lithium cell as the supply. The positive
side of the holder must be oriented as
shown, to the top of the PCB.
If you are not going to use the cell
holder, you can install two PC stakes
for supply connections instead. Note
that there are two 3mm diameter
holes in the PCB located where the
cell holder would otherwise sit. These
are for looping the connecting wires
through for stress relief. That’s so the
wires do not break off where they connect to the power PC stakes.
Alternatively, you can elect to
install an SMD mini-USB type B
socket on the underside of the PCB
(ie, instead of installing the cell
holder) for convenient connection
to a USB source.
LED1 is mounted with the anode
“A” oriented as shown and LDR1 can
Fig.4 (left): the larger of the two flasher boards. Use this as
a guide during assembly and take care with the polarity of
IC1, C1, D1 and ZD1.
64 Silicon Chip
IC1
PIC12F675
1k
POWER
ZD1
1F
JP1
+
Fig.5 (right): fit the
components to the
smaller flasher board
in this manner. Taller
passive components
such as C1 can be
fitted to the bottom
of the board and laid
over to save space.
5.6V
4148 D1
1nF
(R2)
(R1)
470k
C1
A
K
LDR1
LED1
siliconchip.com.au
Parts List
Table 1: LED Flasher Component Selection for 3V Supply
LED Colour
Supply Current
<at>3V Supply
Peak LED
Flash Current
C1
R1
R2
Flash
Rate
Blue/white
680µA
3.6mA
100µF
15kΩ
330Ω
0.5Hz
Blue/white
760µA
3.6mA
100µF
10kΩ
330Ω
0.75Hz
Blue/white
830µA
3.6mA
100µF
7.5kΩ
330Ω
1Hz
Blue/white
1.0mA
6mA
100µF
7.5kΩ
100Ω
1Hz
Blue/white
1.1mA
3.6mA
100µF
3.9kΩ
330Ω
2Hz
Red/orange/yellow
750µA
6mA
100µF
12kΩ
330Ω
0.5Hz
Red/orange/yellow
860µA
6mA
100µF
8.2kΩ
330Ω
0.75Hz
Red/orange/yellow
950µA
6mA
100µF
6.2kΩ
330Ω
1Hz
Red/orange/yellow
1.1mA
10mA
100µF
6.2kΩ
100Ω
1Hz
Red/orange/yellow
1.6mA
6mA
100µF
2.7kΩ
330Ω
2Hz
be installed now as well. Note that if
you do not want the circuit to switch
off in the day, omit LDR1.
If required, the PCB can be used fitted with four 9mm tapped spacers at
each corner of the PCB, attached with
short M3 machine screws.
A pre-programmed PIC12F675-I/P
can be purchased from our Online
Shop. Alternatively, if you intend to
program the PIC yourself, the firmware file (1610916A.HEX) can be
downloaded from the SILICON CHIP
website.
Powering it up
Insert IC1 into the socket, making
sure it is oriented correctly. Watch out
that you don’t bend any pins under
the IC. Now install the CR2032 cell
in its holder (or apply 3-5V DC) and
place the jumper link onto the 2-way
header (JPI). If all is well, LED1 will
begin to flash.
Version 2: a tiny PCB
For some applications where you
want a tiny flasher module, the PCB
with its on-board cell holder will be
too large. For example, you might
want to install the LED flasher inside
an HO/OO model diesel locomotive
or inside an HO/OO wagon at the end
of a train as a BOG (battery operated
guard).
For these other applications requir-
ing a tiny module, we have produced
an alternative PCB which measures
only 36 x 13mm and this board is
coded 16109162. We could have made
it even smaller if we had designed it
to use surface-mount devices, but we
know that some readers, and particularly model railway enthusiasts, are
not keen on soldering SMDs.
The same components are installed
on the smaller PCB, except that it does
not have provision for the button cell
holder or optional 4-way pin header.
Refer to Fig.5 when building this
version. Note that some components
could be installed laid over on their
side on the bottom of the PCB, to
reduce the overall size of the package
(eg, C1).
Higher supply voltages
If you want to run the PCB from
more than 5V, you will need to install
a suitable dropping resistor across the
input link, JP1. For a 12V supply, we
suggest a value of 1kΩ with a rating
of 1/4W.
If you want to run the tiny module in
a model railway locomotive or freight
wagon as an end-of-train device, you
will need to take account of the track
polarity. To do this, use a small bridge
rectifier from the track (eg, type W01).
Its two AC connections go to the track
connections inside the loco or wagon
and the DC wires go to the appropriate
RESISTOR COLOUR CODES
No. Value 4-Band Code (1%)
5-Band Code (1%)
1
470kΩ yellow violet yellow brown yellow violet black orange brown
1
1kΩ
brown black red brown
brown black black brown brown
siliconchip.com.au
1 PCB coded 16109161 (45 x 47mm)
OR
1 PCB coded 16109162 (36 x 13mm)
1 20mm button cell holder**
(Jaycar PH-9238, Altronics S 5056)
1 CR2032 Lithium cell** (3V)
1 SMD mini-USB socket* (CON1)
1 10kΩ light-dependent resistor*
(Altronics Z 1621; Jaycar RD-3480)
(LDR1)
1 DIL8 IC socket*
4 M3 x 9mm spacers*
4 M3 x 6mm machine screws*
1 2-way pin header, 2.54mm pitch
(JP1)
1 jumper shunt for JP1
1 4-way pin header, 2.54mm pitch*
2 PC stakes*
* optional component
** not fitted to smaller PCB
Semiconductors
1 PIC12F675-I/P programmed with
1610916A.HEX (IC1)
1 1N4148 diode (D1)
1 5.1V or 5.6V zener diode (ZD1)
(see text)
1 3mm or 5mm high-brightness LED
(LED1)
Capacitors
1 100µF 16V electrolytic capacitor^
(C1)
1 1µF multi-layer ceramic
1 1nF 63V or 100V MKT polyester
Resistors (0.25W, 1%)
1 470kΩ
1 1kΩ
1 6.2kΩ#
1 330Ω#
# change values to vary flash rate
and brightness; see text and
Table 1
DC input wires on the PCB.
Furthermore, to provide for operation when the track is not energised,
you could substitute a .047F or 1F
5.5V supercap for the 1µF MMC capacitor on the board. You will likely
need to connect it via insulated flying leads. In this case, change ZD1
to a 5.1V type to ensure the supercapacitor can not be charged beyond
SC
its 5.5V rating.
CAPACITOR CODES
Value
1µF
1nF
µF Value IEC Code EIA Code
1µF
1u0
105
0.001µF 1n
102
October 2016 65
|