This is only a preview of the September 2001 issue of Silicon Chip. You can view 35 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 "Build Your Own MP3 Jukebox; Pt.1":
Items relevant to "PC-Controlled Mains Switch":
Items relevant to "Personal Noise Source For Tinnitus Sufferers":
Items relevant to "Using Linux To Share An Internet Connection; Pt.4":
Purchase a printed copy of this issue for $10.00. |
PC CONTROLLED
Everyone, it seems, has an old computer, unused and unloved, gathering dust somewhere. Wouldn’t you like to do
something useful with it, like controlling external devices?
This project has both the hardware and software to do
exactly that – and it will work on anything from a 386 up!
Concept, hardware and software design by Trent Jackson
Words by Ross Tester
I
goes. Just remember, though, that this
nitially, this project was designed
is a mains-powered and mains-conto turn a swimming pool filter
trolling device and the circuit “floats”
pump on and off at appropriate
at full mains potential at all times.
times. Sure, you can buy a pretty
cheap mechanical or electronic timer
There are certain practices and proto do that but with an old 486 lying
cedures which must be followed for
idle and the possibility – no, make
your own safety and that of anyone else
that probability – of controlling a lot
using the device (not to mention the
more than a pool pump, I thought,
longevity of your computer!). Most of
why not?
all, be extremely cautious when testing
As it turned out, the hardware to do
or servicing the circuit with the cover
the job is relatively simple and
cheap – there are only about
twenty components required
FEATURES
to give a pretty nifty circuit.
build
Low cost, easy to
The software, though, is a little
more complicated – but as I
tection
Fuse and surge pro
have already done that part for
ion
you, all you need to do is build
Full optical isolat
the control box, dust off that old
ction
System enable fun
computer, fire it up and load the
itching
software.
Efficient relay sw
It uses the parallel (printer)
Precision timing
port of just about any PC from,
r events
say, 386 vintage onwards. It op Control up to fou
erates under good, old fashioned
er settings
Save and open tim
DOS (remember that?) – in fact,
I wouldn’t recommend it being
run under Windoze.
off. To be absolutely safe, I’d suggest
The hardware
you do all your testing with a 12V
battery powering it. At SILICON CHIP
There is nothing too difficult to either
we like our readers and want to keep
comprehend or build as far as hardware
all of them alive!
We’ll show you how to hook in a 12V
supply later on.
Speaking of safety, the circuit features fuse and surge protection and
has full electrical isolation (by means
of an optocoupler) between the mains
and the connection to your computer.
Now, let’s look at the block diagram,
Fig.1, in conjunction with the circuit
diagram, Fig. 2.
The first thing you will note
is that there is no transformer.
The 240V mains is applied
via a 10A fuse (for protection
against catastrophic failure) and a 275V varistor (to
suppress any mains-borne
spikes). A capacitor across
the mains also assists in
filtering out any noise.
Next there is an AC current limiter consisting of a
pair of parallel capacitors
which together add up to
about 1µF. From first principles, we know that series
capacitors in an AC circuit
offer resistance (or more
correctly impedance) to current flow.
This is expressed by the formula
XC = 1/2π f C, where XC is in Ohms,
f is the frequency in Hz and C is the
THIS IS A MAINS-POWERED DEVICE AND THE CIRCUITRY IS LIVE (240V AC) WHILE EVER POWER IS CONNECTED,
EVEN IF THERE IS NO OUTPUT VOLTAGE. DO NOT ATTEMPT TO BUILD THIS PROJECT IF YOU ARE NOT
ENTIRELY FAMILIAR WITH MAINS WIRING PRACTICES AND CONSTRUCTION TECHNIQUES.
36 Silicon Chip
www.siliconchip.com.au
D MAINS SWITCH
capacitance in farads. Therefore, at
50Hz, the two capacitors are going to
present an impedance of about 3.2kΩ.
From Ohm’s law (I=E/R), we can
then deduce that the current will
be limited to 240V/3200Ω or about
75mA.
The 47Ω resistor following the series
capacitors can be all but ignored for the
purpose of this equation – its job is to
limit the inrush current which would
otherwise occur at switch-on.
The four diodes (D1-D4) form a
bridge rectifier across the 240V AC
mains, resulting in a pulsating DC
voltage output of about 340V (240 x
1.414). Zener diode ZD1 is connected
as a shunt regulator across this supply,
clamping it to around 12V DC. The two
capacitors (C3 and C4) provide further
smoothing, resulting in a relatively
well-regulated 12V DC supply for the
rest of the circuit. A red LED across
the 12V supply shows that power is
applied.
So far, all we’ve looked at is the power supply – but there is not much else
to it! Turning back to the other input,
www.siliconchip.com.au
that from the computer, we see that two
pins, Data 1 and Strobe, of the parallel
port, provide the signal drive for the
switch. Under software control, when
Data 1 goes high and the Strobe goes
low, D5 and D6 are both forward biased,
lighting the LED inside the optocoupler
(the 180Ω series resistor limits current
from the parallel port to safe levels).
As you can see from this, there is
no electrical connection whatsoever
between the computer and this circuit.
The optocoupler specified, SFH601-3,
has been chosen because of its high
isolation. Lower rated optocouplers
should not be used.
When the LED in the optocoupler
lights, the transistor in the opto-coupler
Fig.1: the block diagram of the
PC-controlled mains switch
shows that there is complete
isolation between the mains and
the PC.
September 2001 37
PC CONTROLLED MAINS SWITCH
WARNING: THE MAJORITY OF THIS
CIRCUIT OPERATES AT 240VAC!
N
E
LED2
1.2k
ZD1
12V
5W
E B C
1000F
25V
BC548
0.1F
SC
2001
LED1
POWER
1.2k
½OPTO1
SFH601-3
RLY1
10
D5
1N4007
E
CONTACT WITH ANY PART OF THIS CIRCUIT
WHILE CONNECTED TO THE 240VAC MAINS
SUPPLY COULD KILL YOU!
240VAC
OUTLET
A
RLY1
250VAC
Q1
BC548
C
B
4.7k
4
5
D1 - D4
4 x 1N4007
½OPTO1
SFH601-3
1
2
PARALLEL PORT CONNECTOR
PIN NUMBERS.
*NUMBERS SHOWN INDICATE
0.1F
250VAC
CLASS 'X2'
20
12
13
11
10
PORT
TO PC
*PARALLEL
1
3
100
D7
1N914
180
E
240VAC
INPUT
N
D6
1N914
V1
V275LA20A
275VAC
A
F1
10A (MAX)
250VAC
100k
½
W
0.47F
250VAC
CLASS 'X2'
0.47F
250VAC
CLASS 'X2'
47
1W
K
A
LED
The software
Fig. 2: the complete circuit diagram of the PC-Controlled Mains Switch.
38 Silicon Chip
conducts. This transistor is connected
in “Darlington” fashion to Q1 which
is then turned on. Current flows from
Q1’s collector to emitter, through a 10Ω
resistor and then through the relay
coil, pulling it in and closing the 240V
active circuit. Therefore, whatever is
connected turns on.
At the same time, the green LED
between Q1’s emitter and ground also
turns on to give indication that 240V
power is available.
The reverse-biased diode across the
relay coil doesn’t normally conduct.
Its purpose is to protect Q1 when the
optocoupler turns off and the relay
de-energises. This can generate a quite
high voltage pulse which might destroy
Q1; when the relay de-energises the
diode becomes forward biased, safely
bleeding the pulse away.
Finally, you will note that all 4-bit
inputs to the PC parallel port are connected together and tied low, to pin 20.
This is essential for the port to operate
as we intended. Incidentally, the port
must be operated in the “ECP” mode,
which can normally be set up via the
computer’s CMOS setup. ECP, by the
way, stands for Enhanced Capabilities
Port.
If you don’t know how to do this,
refer to your computer’s manual (or
perhaps you shouldn’t be attempting
this project!).
The software, PCMS.EXE, does
the vast majority of the “work” – my
philosophy is minimum hardware
and maximum software! It is written
in Q-BASIC and a zipped version can
be downloaded from the SILICON CHIP
website.
As mentioned before, this should
be run in DOS mode. While I have
run it under Windows, it occasionally gets upset and freezes. You
shouldn’t have this problem under
DOS.
The software will run without the
controller hardware plugged in, so
you can get a feel for its operation and
features. There is a scrolling message
at the bottom of the screen which tells
you which keys to press for which
operations.
It’s also designed to be very user-friendly – once you’ve used it a
couple of times you will get the hang
of it. The heart of the program is the
timer settings box. When you first run
the program it will load up null settings
www.siliconchip.com.au
back and type over. (The backspace
key will delete characters in the files
box).
Files box
You can save current timer settings
in a file and recall it later – press the
F4 key to save your current settings
and F5 to open any presaved settings.
System box
The current time and date, read
from your PC’s real time clock, are
displayed in the top two boxes. You
cannot change these – you must go
into your PC’s time and date setting
procedure (via CMOS setup) to do
this.
The Port Address can be changed to
match the port address of your computer’s parallel port. The default is H378;
some computers have theirs at H278 but
pressing the F1 key will toggle through
the various addresses possible. If you
have a valid port address, the port data
(immediately underneath) should read
between H120 and H148.
Note that the port mode must first be
set to ECP (enhanced capabilities port)
mode via your CMOS setup.
The “Device Enable” box is not controlled by the timers; you have to set
The completed PC board with its connections to power, to the mains outlet
(GPO), the front panel LEDs and to the computer parallel port. There were some
minor differences between this photo and the final version shown below.
(0’s) for each of the four programmable
events.
are entered in the format MM-DD-YY
(eg, 19th September 2001 would be
00-19-01); times are in 24 hour format
(8.15pm would be 20:15).
To modify any setting, use the
arrow keys (keypad) to move the
flashing cursor to the unit you want
changed and enter the new setting of
the null setting. The backspace key
does not delete – move the cursor
Timer Settings box
There are two modes. MX is the normal mode and can handle both dates
and times.
DX is the alternate mode, used when
you want an event to occur on a daily
basis (so no date input is needed) Dates
GPO
(REAR VIEW)
E
A
CASE
CASE
LO
EL
/Y
EN
RE
(G
L
RA
UT
NE
)
UE
(BL
CORD
GRIP
GROMMET
www.siliconchip.com.au
180
SOLDER RESISTOR
ACROSS V1
D6
1.2k
10
4.7k
1.2k
100k
Q1
D5
F1
10A (MAX)
250VAC
1
*
*
3
OPTO1
SFH601-3
1
PIN NUMBER ON
*PC
PARALLEL PORT
CONNECTOR
0.1 F
250VAC
0.47 F
250VAC
0.47 F
250VAC
0.1 F
D3
25V
(BROWN)
1000 F
TIVE
D2
D7
1N
4148
+
ZD1
AC
47
1W
D4
Fig.3: follow this
component overlay and
wiring diagram when
building the project. Build
and test the PC board first
– but don’t put in the 5W
Zener (ZD1) until after
testing.
DATA
CABLE
ISOLATED SECTION
4 x 1N4007
D1
V1
E
TH
AR
N
1N
4148
250VAC
MAINS
CABLE
CORD
GRIP
GROMMET
)
W
A
LED1
K
A
LED2
1N4007 K
RLY1
10A / 250VAC
September 2001 39
Here’s what the software, PCMS.EXE, looks like on the screen. You can set the on and off times for up to four events as
well as change various parameters as described in the text. Download the software from www.siliconchip.com.au
this manually with the F2 key in order
to enable the hardware.
Finally, the “Device Status” box
should automatically come up with
a “connected” message if your port
is functioning correctly and the hardware is connected. If the software has
detected errors (eg, no hardware connected or a port malfunction of some
sort) it will read unknown.
The big box underneath the System box is a visual indication that
everything is working as it should:
when the timer turns the hardware
on, the box changes from red to green
and the message changes from “AC
POWER IS OFF” to, surprise surprise,
“AC POWER IS ON”.
If you don’t like the background
colour, toggle the F6 key. There are 16
different colours and styles to choose
from – there must be something there
you’ll like!
we specify nylon types – if a nut
works its way loose inside the case
and shorts out something, you or your
PC could disappear in a puff of blue
smoke.
As usual, start by visually checking
the PC board to ensure there are no
etching or drilling defects.
Then commence assembly with the
lowest profile components – resistors,
varistor and diodes (ensure the diodes
are the right way around!). At this
stage, don’t fit the Zener diode because
it will get upset with our checking
procedure later.
Next are the smaller capacitors
(watch the polarity on the electrolytics), the IC and transistor (ditto) and
the fuse clips. Some fuse clips have
little lugs on them which will stop a
fuse being inserted if they are back-tofront: check yours by inserting a fuse
before soldering.
All that’s left now are the larger
capacitors and the relay. Now we are
ready to move on to the wiring which
Construction
Before we start, another word of
warning. Please ensure that you follow the construction method to the
letter – we have gone to a great deal
of trouble to ensure that the design is
safe and construction methods echo
that safety.
For example, do not substitute
standard metal bolts and nuts where
40 Silicon Chip
The PC board is secured to the case lid with four nylon screws, as shown here.
Each screw has a nylon nut on the inside acting as a spacer before the PC board
is seated and secured with another nylon nut.
www.siliconchip.com.au
is where you have to be particularly
careful to make sure nothing is wrong.
The basic premise is that the wires
need to be only as long as necessary
to reach and not long enough to short
to something else if for some reason
they come adrift.
Before you do that, though, you
should prepare the jiffy box for the
external components and wiring.
A 6mm hole is required at each end
(for the mains cable and the computer
cable), each with a rubber grommet.
The bottom of the box is used as the
top (the lid becomes the base) and in
this you will need two 5mm holes for
the LEDs, two 3mm holes for the power
outlet mounting screws and finally a
30mm hole for the back of the power
outlet to poke through.
All labels should now be glued to
the box and left to dry. While that’s
happening, go over your PC board
assembly once more to make sure
everything’s where it should be. It
will be much more difficult to check it
later.
Prepare the red and green LEDs by
soldering a 100mm length of 4-way
rainbow cable to their respective
legs. Note which legs are the anode
and the cathode (the anode lead is
the longer) and then cut both legs
very short – say 3mm – and solder
the rainbow cable to them leaving as
much as the cable intact as you can.
Then wrap the soldered joints in insulation tape so that no exposed legs
or wire are visible. If necessary, put a
piece of tape between the legs to ensure they don’t short.
If you’ve now forgotten which leg
was which, the cathodes are the ones
adjacent to the flat on the LEDs! Write
down the colours of 4-way rainbow
cable which go to each leg, and which
colours go to which colour LED.
Fit LED mounting collars over them
and push them through the bottom
of the box. Lock them in place with
a dab of silicone sealant, super glue,
5-minute Araldite or other suitable adhesive.
Refer to the wiring diagram for the
mains wiring and follow it exactly.
Again, only make the leads as long as
you need to.
Remove the outer insulation from
the three-wire mains lead to a length
of 175mm. Cut off 100mm and put
it aside – you’ll need this as mains
hookup wire. Push the wires of the
mains lead through the appropriate
www.siliconchip.com.au
Parts List – PC Controlled Mains Switch
1 PC board, 101 x 57mm, coded 10109011
1 plastic case (Jaycar HB6013 or equivalent)
1 mini switched power outlet (GPO) (HPM 787 or equivalent)
2 cord-grip grommets to suit cables used
2 3AG fuse clips, PC mounting with protective cover
1 10A 3AG fuse
1 SPST relay, 12V coil (220Ω) with 10A 240V-rated contacts (Jaycar
SY-4050 or equivalent)
1 piece insulating material to suit – Elephantide or plastic (see text)
5 mini cable ties
6 M3 x 10mm nylon screws
10 M3 nylon nuts
6 spring washers
100mm length 4-way rainbow cable (colours unimportant)
2m length 240V 10A mains lead with moulded 3-pin-plug
2m parallel printer cable (D-25 plug) (without Centronics plug) OR
2m length 2-core shielded cable and 1 D-25 male plug
Semiconductors
1 SFH601-3 optocoupler (OPTO1) (DSE Z9023 – do not substitute)
1 BC548 NPN transistor (Q1)
1 12V 5W Zener diode (ZD1)
1 275VAC Varistor (V1)
5 1N4007 power diodes (D1-D5)
2 1N914 signal diodes (D6, D7)
1 5mm red LED (LED1)
1 5mm green LED (LED2)
Capacitors
1 1000µF 25VW PC mounting electrolytic
2 0.47µF 250V AC X2-class polyester
1 0.1µF 250V AC X2-class polyester
1 0.1µF MKT polyester
Resistors (0.25W, 1%)
1 4.7kΩ
2 1.2kΩ
1 180Ω
hole from the outside. You’ll need to
push through much further than the
end of the insulation – at least another
50mm or so, to give you enough room
to attach the power outlet.
Take the Neutral (blue) and Earth
(green yellow) wires through the
large hole in the box to the outside.
Remove 15mm of insulation from
both. The only connection to the Earth
terminal of the power outlet (labeled
“E” or perhaps with green or green/
(Code 474 or 470n)
(Code 104 or 100n)
(Code 104 or 100n)
1 100Ω
1 10Ω
1 47Ω 1W
yellow marking) is the Earth wire.
Bend the bare wire back on itself,
push it into the terminal and tighten
the grub screw. Ensure there is no
exposed wire (especially tiny strands
of wire).
Now take that blue length of mains
wire you cut off before and strip 15mm
of insulation from it. Tightly twist this
and the blue wire coming out of the
box together and insert them into the
Neutral terminal of the power outlet
Resistor Colour Codes
No.
1
2
1
1
1
1
Value
4.7kΩ
1.2kΩ
180Ω
100Ω
47Ω
10Ω
4-Band Code (1%)
yellow purple red brown
brown red red brown
brown grey brown brown
brown black brown brown
yellow purple black brown
brown black black brown
5-Band Code (1%)
yellow purble black brown brown
brown red black brown brown
brown grey black black brown
brown black black black brown
yellow purple black gold brown
brown black black gold brown
September 2001 41
(labeled “N” or perhaps with blue or
black marking) and tighten the grub
screw. Ensure there is no exposed wire
nor strands of wire.
Now take that brown length of
mains wire you cut off before and
strip 15mm of insulation from it. Twist
the strands together, fold them back
on themselves and insert the wire
into the Active terminal of the power
outlet (labeled “A”, perhaps with red
or brown marking). Tighten the grub
screw and ensure there is no exposed
wire nor strands of wire.
Push the power outlet down onto
the box and secure it in place with
two 3mm x 10mm nylon bolts and
nuts (don’t use metal ones!) and spring
washers (which should be metal).
Tighten completely and check that
the power outlet will not move around
at all.
Fig.4: wiring
the D-25
(parallel
port) plug
which
connects
to your
computer.
We’re not going to connect the mains
wiring to the board yet – that will come
later after completion and testing. First
we will solder the LED wiring (ie, the
4-wire rainbow cable) to the board in
the positions shown.
NOTE: a 100kΩ ½W resistor should
be connected across the Varistor as
shown in Figs.2 & 3, to safely discharge the X2 capacitors when power
is switched off.
Computer cable
Now it’s time for the computer cable.
In all probability, you’ll be using a
“ratted” Centronics printer cable but if
you have to make up a new one, that’s
not too difficult using a standard D-25
male plug and backshell assembly and
some 2-core shielded cable. See Fig.4
for the plug detail.
This cable must be passed through
the box in similar manner to the mains
cable but to hold things together, a
short length of heatshrink is first heated onto it. The essential thing about
this cable is that none of the wires
is long enough to reach the power
outlet should one come adrift later.
The distance from the side wall of the
box to the closest point on the power
outlet was 50mm so we cut our cable
to 45mm.
That makes it a tight job to solder
to the PC board, but it can be done.
Testing
Front and rear close-up views of case. You will note that for safety there are no
metal screws used – the warning on the back panel means what it says! You should
not build this project if you are not experienced in mains wiring construction.
42 Silicon Chip
As we said before, for safety’s sake
you really should check the operation with a 12V battery. The easiest
way to do this is with a pair of wires
temporarily soldered to the back of
the PC board across where the Zener
would normally go – just watch the
polarity.
Apply 12V power and ensure that
the red LED lights. The green LED
should not light nor should you hear
the relay click in.
If OK, plug the D-25 connector into
your computer’s parallel port and run
the pcms.exe software (in DOS mode).
Remember to set the port to ECP mode
at boot-up.
Following the processes outlined
above, ensure that the software does
indeed control the board as intended.
You can check the relay operation with
a multimeter.
If all is OK, turn off power, disconnect from the computer and remove
www.siliconchip.com.au
Same-size PC board pattern and labels for the back and front of the case. The
labels should be glued on before final assembly. On the front panel, the largest
hole is 40mm diameter, the LED holes are 5mm and the other two are 4mm.
Use a copy of the label as a template for drilling the case. The PC board
pattern and labels can be downloaded from www.siliconchip.com.au
44 Silicon Chip
SILICON
CHIP
www.siliconchip.com.au
OUTPUT
ON
POWER
APPLIED
PC CONTROLLED MAINS SWITCH
All parts of this circuit have 240VAC applied
even when the output is switched off.
Contact with this voltage could be lethal:
use extreme caution when servicing
or testing this apparatus.
WARNING
Almost ready to close – these two photos more clearly
show the wiring between the PC board and the power
outlet on the front panel, and also the wiring to the LEDs
and to the computer parallel port plug. At left is the sheet
of insulation material, a piece of elephantide or similar,
or it can be cut from a plastic sheet such as an ice-cream
container. which is inserted between the PC board
(component side) and the wiring to the power outlet. It’s
just another bit of insurance should the “impossible to
happen” happen – a wire works its way loose which could
jeopardise the inherent safety built into the switch.
www.siliconchip.com.au
Another view of the almost-completed project, this time
from above and with the insulation in place. Once again,
note the use of nylon nuts and bolts – for safety reasons.
the two wires you temporarily soldered to the back of the
board and solder in the Zener diode (the right way around).
Make sure you don’t leave any solder bridges or splashes.
Mains wiring
Follow the wiring diagram exactly. The brown wire from
the power outlet solders to the centre of the PC board, the
blue wire from the power outlet solders to the edge of the
board and the brown wire from the mains lead also solders
to the edge of the PC board. To complete, fit some form of
insulating cover over the fuse.
Final assembly
It is important to fit cable ties to hold the various
lengths of wiring together – this should ensure that
wiring cannot move around in the event of something
coming adrift. Cable ties must also be fitted to the mains
cable and the parallel cable on the inside of the grommets to prevent the cables from being either pulled
out or flexed unduly.
Now the PC board must be secured to the case “lid”
with nylon nuts and bolts. This again is not real easy given
the fact that the wiring lengths have been kept short. But
it can be done! First drill the case lid in the positions
shown and fit a nylon bolt and nut to each of the holes.
Tighten completely, then slide the PC board down onto
the nuts and fit another nut to the top side. Ensure these
are also tightened.
Before screwing this assembly into the box, cut a piece
of insulation material the size of the box with corners
trimmed for the mounting pillars. This goes between the
mains outlet and the PC board components. Elephantide has
been traditionally used for this role; a piece of thin plastic
(eg, cut from an ice-cream container) would serve as well.
Slide this insulation into the box, push the PC board and
lid assembly down on top of it and fit the four case screws.
Your PC controlled switch is now finished and should work
exactly the same way as when you tested it.
NOTE: updated software for this project is available
from: http://members.optushome.com.au/video1/macksprograms
SC
www.siliconchip.com.au
September 2001 45
|