USB-powered PIC programmer
This simple circuit can be used to program the PIC16F84 and
similar "flash memory" type parts. It uses a cheap 555 timer IC to generate the
programming voltage from a +5V rail, allowing the circuit to be powered from a
computer’s USB port.
The 555 timer (IC1) is configured as a free-running oscillator,
with a frequency of about 6.5kHz. The output of the timer drives four 100nF
capacitors and 1N4148 diodes wir-ed in a Cockroft-Walton voltage multiplier
configuration. The output of the multiplier is switched through to the MCLR/Vpp
pin of the PIC during programming via a 4N28 optocoupler.
Diodes ZD1 and D5 between the MCLR/Vpp pin and ground clamp the
output of the multiplier to about 13.6V, ensuring that the maximum input voltage
(Vihh) of the PIC is not exceeded. A 100kΩ resistor pulls the pin down to a valid logic low
level (Vil) when the optocoupler is not conducting.
The circuit is compatible with the popular "JDM" programmer, so
can be used with supporting software such as "ICProg" (see http://www.ic-prog.com).
Luke Weston,
Wycheproof, Vic. ($50)
Economical desk lamp for camping
This LED lamp was originally designed for use on a budget
solar-charged 12V electrical system. It is bright enough for comfortable reading
at night and features constant LED brightness with diminishing battery voltage.
The circuit uses six high-brightness white LEDs mounted in a
90mm diameter reflector. The upper half of a stainless steel ice cream bowl
makes a good reflector but almost any torch reflector of a similar size will
do.
As shown, two banks of three series-connected LEDs are powered
from a 12V (nominal) DC supply. The LEDs used are rated at 20mA maximum with a
measured voltage drop of 3.2V.
Each bank combines an inexpensive LM334 current source IC with
a BC558 transistor to provide a constant 20mA to the LED string. Basically, the
LM334 controls the base current of the BC558 such that 64mV appears between its
"R" and "V-" terminals. With the 3.3Ω resistor shown, this results in close to the
desired 20mA through the LEDs.
The components can be mounted on a small piece of Veroboard. An
old desk lamp makes an ideal body, with a metal disc used to cover the hole left
after the 240V lamp fitting is removed. The metal disc can also be used to mount
the power switch and rubber grommet for the power supply leads. Three M3 screws
and nuts spaced 120°
apart keep the reflector in place. John Amos, Kanahooka, NSW. ($35)
|
Quartz clock flasher protects equipment
Damage to battery-powered devices when unintentionally left on
is common. The battery runs down, leaks and causes widespread destruction.
This simple device, based on a quartz clock movement, flashes
two LEDs to indicate when power is switched on. It’s small, uses little power
and costs only a few cents to build.
Extract the circuit board from a discarded quartz clock.
Disconnect the coil and its fittings, noting the pads that it is connected to.
The circuit shown can then be connected across the pads.
The circuit requires a 3V supply rather than the original 1.5V
used by the clock movement. However, long testing has shown that it works
reliably at this higher voltage level.
When powered up, each output goes low in turn, with the LEDs
flashing alternately for 30ms at one-second intervals.
In the prototype, surface-mount LEDs (ex-equipment) were
mounted on a bit of strip board and stuck to the clock board with double sided
sticky tape. You could omit one LED and have a flash every two seconds to
further conserve power.
This circuit could have other uses, such as in a model railway
layout, a flashing badge, or as a reminder for all sorts of things. The LEDs
could be inside opto-isolators, rather than discrete components, opening up a
wide range of possible uses.
Old quartz clocks are often available from school fates and
scout jumble sales for a song. It doesn’t matter if the face is damaged or the
hands are mangled – you only need the movement!
A. J. Lowe,
Bardon, Qld. ($30)
Two switches share one pin
This circuit and program show how you can read two switches
from a single I/O pin of a PICAXE-08. As shown, the program simply echoes the
states of the switches on the LEDs.
To test if switch S1 is pressed, the program first sets P1 as a
low output to discharge the 100pF capacitor. The pin is then reconfigured as an
input and read. If the pin is low, the capacitor is still discharged, meaning S1
is not pressed.
Conversely, if the pin reads high, the capacitor has been
charged, indicating that S1 is pressed.
The procedure for testing S2 works in reverse. The program
first sets P1 as a high output, which charges the 100pF capacitor. Again, the
pin is switched to an input and read. If the pin is high, the capacitor is still
charged, so S2 is not pressed. However, if the pin reads low, the capacitor has
been discharged, so S2 is pressed.
If both switches are pressed at the same time, the result is
indeterminate. This usually isn’t a problem if momentary pushbutton switches are
used but it does make the scheme unsuitable for use with latching type toggle
and slide switches.
The capacitor is only necessary to make the arrangement more
reliable. Even without it, the input capacitance and impedance of the I/O pins
on the PICAXE-08 are sufficient to hold the previous input voltage long enough
for the program to work.
This idea will work with other PICs, such as the 16F84, but not
with other PICAXE chips, as they do not have bidirectional I/O pins. Andrew Partridge,
Kuranda, Qld. ($30)
'------------------------------------------------
' Two switches on one pin demonstration
'------------------------------------------------
read_S1:
low 1 'discharge capacitor
input 1
if pin1 = 1 then S1_pressed
low 2 'turn off LED1
goto read_S2
S1_pressed:
high 2 'turn on LED1
read_S2:
high 1 'charge capacitor
input 1
if pin1 = 0 then S2_pressed
low 4 'turn off LED2
goto read_s1
S2_pressed:
high 4 'turn on LED2
goto read_S1
|
Multi-level lock system
Fig.1: this diagram shows how to combine several circuits to provide a multi-layer system.
This circuit is a simple yet versatile adjustable lock. It can
be used either on its own or as part of a much larger multi-level lock
system.
There are many situations in which certain employees need to be
granted access to select areas of a building. Using conventional lock-and-key
security, this necessitates the issuing of large numbers of keys. It also means
that the persons who have the greatest freedom of movement must carry the
largest number of keys.
A less obvious yet potentially significant problem is that of
security. To select the right key out of, say, a dozen in an emergency could
present an unacceptable delay. Besides this, readers will already be familiar
with the problem of keys needing to be cut and locks needing to be changed. All
of these problems are obviated with the use of an electronic multi-level lock
system, such as the one described here.
The "key" consists of a single resistor housed inside a mono
jack or DC plug. A simple window comparator is used to detect a valid key. If
the value of the resistor lies between the values of VR1 (the lower cut-off) and
VR2 (the upper cut-off), the lock is opened. If any other value resistor is
wired to the plug – or none at all – an alarm sounds.
While this does not guarantee the highest level of security, it
arguably equals the security of metal keys, since the only way to be sure that
you will not trigger the alarm is to obtain a copy of an original key. Apart
from this, the chances of triggering the alarm are very high.
The main part of the circuit (IC1 & IC2) is not powered
until a "key" is inserted. This saves power and also enables simple open-circuit
key detection. Without a key in the socket, the gate of Q2 is grounded through
the normally closed contacts of the socket (SKT1). Therefore, Q1 is held in the
"off" state by the 100kΩ
resistor between its base and emitter.
When a key is inserted, ground is lifted from the gate of Q2
and it is pulled high through the 1MΩ resistor. Q2 then conducts, proving base current
for Q1 and powering up the remainder of the circuit.
A dual op amp (IC1) makes up the window comparator. It
determines whether the key lies above or below the potential of its two
non-inverting inputs. One element of a 4093 quad NAND gate (IC2a) combines the
results, going low at pin 3 if the key "fits".
A second NAND gate (IC2b) inverts the result at pin 4, taking
Q3’s gate high. This illuminates the LED and powers a relay or solenoid.
On the other hand, if the key doesn’t fit, pin 3 of IC2a goes
high, also driving the gate of SCR1 high. A 47kΩ resistor and 47μF capacitor in the gate circuit provide a short
delay, after which the SCR fires, illuminating LED2 and sounding the alarm.
Since the SCR latches when activated, the alarm will sound continuously until
de-activated by pressing S2 or disconnecting power.
S1 is most likely to be used as an indoor pushbutton to release
the lock on exit but could also serve as an emergency switch if the key is
lost.
Fig.1 shows how several circuits may be combined to provide a
multi-level system of entry or authorisation.
As shown, Key 1 contains a 10kΩ resistor and Key 2 a 22kΩ resistor. Lock 1 admits keys between
4.7kΩ and 15kΩ, while Lock 2 admits keys between
4.7kΩ and 27kΩ. Key 1 thus opens both locks, while Key
2 opens only Lock 2.
Similarly, Key 3 contains a 47kΩ resistor, while Lock 3 admits keys between
33kΩ and 56kΩ. Thus, Lock 3 excludes both Keys 1 and
2.
If a solenoid is used for the lock, take care to ensure that it
is not energised for longer than specified by the manufacturer. Q3 is rated at
12A, SCR1 at 2A and D1 at 3A, so any solenoid, relay or alarm should not exceed
these parameters – which they are unlikely to do.
The lock uses just 200μA on standby and so could run for months
at a time from a suitable 12V battery.
Thomas Scarborough,
South Africa. ($45)
PICAXE-controlled battery charger
This circuit converts a cheap car battery charger into an
automatic charger. It includes the following features:
-
Reverse battery
protection (green LED flashes).
-
Battery connected and
no power to charger (green LED flashes).
-
Battery not connected
and charger on (green LED flashes).
- Charging indicator
(red LED on steady).
- Charged indicator
(green LED on steady).
The PICAXE-08 microcontroller (IC1) is powered from REG1, a
78L05 +5V regulator. When charger power is present, REG1 receives power from the
output side of the bridge rectifier via D1. Alternatively, when the charger is
switched off, power is derived from the battery via D3.
Depending on the terminal voltage of the battery, the PICAXE
will connect or disconnect the battery from the charger output using RLY1. Power
for the relay coil is provided via a separate +12V regulator (REG2). Unlike the
+5V regulator, REG2 receives its power from the AC side of the bridge. This is
necessary to prevent RLY1 staying on if charger power is removed and the battery
is on charge (RLY1 contacts closed).
The presence of charger and battery power is sensed by the
PICAXE on digital inputs P5 (pin 2) and P4 (pin 3) respectively. Both inputs
utilise voltage divider networks to ground so as not to exceed the maximum input
voltage of the port pins. Input P4 also includes a zener diode (ZD1) clamp for
protection in the case of reversed battery leads.
Battery voltage is sensed on analog input P6 (pin 1) after
being divided down by 10kΩ
and 2.7kΩ resistors. The
PICAXE program monitors the battery voltage using this input and the
readadc command to determine the correct connect and disconnect
voltages.
The program listing is on the facing page. As shown, it
initiates charging at about 13.1V and disconnects at about 14.1V. To prevent
rapid relay switching when the battery is fully charged, a 5-second delay has
been included after each disconnect. After five consecutive "disconnect" cycles,
the program "sleeps" for about one hour before resuming.
At any point in the program, reverse battery connection, no
battery connected, charger power on, battery connected and charger power off
events are detected. If any of these events occur, the battery is disconnected
and the green LED will flash.
The circuit and program can easily be modified to suit
individual needs. All parts except the PICAXE came from my "useful" box. Ray Sonter,
Bundaberg, Qld.
PICAXE-Controlled Charger: Program Listing
'Picaxe-08 controlled lead-acid battery charger
start:
low 0 'red charge
low 4 'green charged
b1=0
b2=0
b3=0
red:
if pin3=0 then flash 'reverse polarity protect, no battery
if pin2=0 then flash 'charger not turned on & battery
connected
readadc 1,b0 'read battery voltage
if b0>155 then count 'about 14.1V, disconnect
low 4 'green led off
high 0 'charge connect
goto red
count:
b1=b1+1 ‘count # of connect to disconnect cycles
if b1>5 then delay
green:
b2=0
b3=0
low 0 'charge disconnect
high 4 'green led on
wait 5
if pin3=0 then flash
if pin2=0 then flash
readadc 1,b0
if b0<140 then red 'about 13.1V, go to charge
goto green
flash:
high 4 'green led flashes
pause 100 'battery reversed, no battery or
low 4 'charger not on & battery connected
pause 100
goto start
delay:
b1=0
if pin3=0 then flash
if pin2=0 then flash
low 0
high 4
pause 1000 'one second
b2=b2+1
if b2>59 then onehour 'about one minute
goto delay
onehour:
b3=b3+1
if b3>59 then green 'about one hour
b2=0
goto delay
|
CONTRIBUTE AND WIN!
As you can see, we pay good money for each of the "Circuit
Notebook" contributions published in SILICON CHIP. But now there’s an even
better reason to send in your circuit idea: each month, the best contribution
published will win a superb Peak Atlas LCR Meter valued at $195.00.
So don’t keep that brilliant circuit secret any more: send it to
SILICON CHIP and you could be a winner!
|
|
Notes & Errata - PICAXE-Controlled Battery Charger
The charger works as described if the battery has not been discharged below the normal terminal voltage range. However, the author has recently modified the program to detect and charge batteries that have been discharged down to 2V.
This update can be downloaded from the bottom of the article.
Note that the new program ignores input 3 (pin 4), so if building the circuit from scratch, all components associated with this input can be omitted.
|