This is only a preview of the January 2009 issue of Silicon Chip. You can view 31 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-Sensing Mains Power Switch":
Items relevant to "Remote Mains Relay Mk.2":
Items relevant to "Multi-Purpose Car Scrolling Display, Pt.2":
Items relevant to "433MHz UHF Remote Switch":
Purchase a printed copy of this issue for $10.00. |
By JIM ROWE & MAURO GRASSI
Power up your PC’s peripherals automatically with this . . .
USB-Sensing
Mains Power Switch
Do you have to manually switch your PC’s peripherals on (and
later off again) each time you boot your PC? If so, this project
will make life a lot easier. It monitors your PC’s USB port and
automatically turns all that other gear on and off as required.
M
ANY EARLY PCs had an IEC-type
240V outlet socket on the back
of the box that was switched by the
PC’s own on/off switch. This allowed
you to automatically switch power to
the computer’s monitor, printer and
other peripherals when the PC itself
26 Silicon Chip
was switched on or off.
All you had to do was plug a power
distribution board into this outlet and
then plug the peripherals into this
board. The power switch on the front
of the PC then controlled everything
– all very neat and convenient.
Unfortunately, this handy switched
power outlet disappeared when the
PC manufacturers changed over to
software-controlled power supplies.
So with most newer PCs, you’re now
forced to use a power distribution
board with its own master power
siliconchip.com.au
switch, if you want to control all your
peripherals with a single switch.
Of course, that means you have to
remember to manually switch on the
peripherals when you switch on your
PC and vice versa. And that can be a
real nuisance. If you forget to turn the
peripherals on, the computer won’t
recognise the monitor or any USB
peripherals when it boots and may
have to be restarted.
Apart from that, having to manually
switch everything on and off at the
wall socket can be a real nuisance. Not
only that, it can also be impractical if
the wall socket is inaccessible because
it’s hidden behind a desk or some other
piece of furniture.
That’s where this USB Sensing
Power Switch comes in. It connects
to one of your PC’s USB ports and
when it detects activity on that port,
it automatically switches mains power
through to a socket on its front panel.
By connecting a powerboard to this
socket, you can automatically switch
all your peripherals (including your
monitor) on when the PC itself is
switched on and then off again when
the PC is powered down.
This not only relieves you of having
to manually switch gear on and off
but also means that the wall socket
can be left on.
Life ain’t easy
At first glance, the circuitry required to do the job should be quite
simple – just monitor the USB port’s
+5V line and use it to turn a transistor
on when the PC is switched on. This
transistor could then turn on a relay
to switch the mains power through to
the outlet socket each time the PC was
switched on.
Unfortunately, it’s not that easy
in practice, unless you use a laptop
(more on this later). The reason is very
simple – most desktop PCs maintain
+5V standby power on their USB ports
even when they are powered down.
And that would mean that our USB
Sensing Power Switch would never
switch off if we simply sensed the
+5V USB rail.
In fact, the only way to “kill” the
+5V standby power on the USB ports is
to switch the PC off at the wall socket
(or at the back of the computer itself),
hardly the most convenient solution.
So why do desktop PCs do this?
Well, there are a couple of reasons.
First, by maintaining power to the
siliconchip.com.au
POWER DISTRIBUTION
BOARD FOR PERIPHERALS
USB OUT
USB IN
MONITOR
PC
USB SWITCH
(USB KEYBOARD CABLE)
USB EXTENSION CABLE
USB KEYBOARD
Fig.1: how the unit is used. All peripherals plus the monitor are plugged
into the power distribution board. Note that a USB keyboard or mouse
must be connected to the USB Switch if you are using a desktop PC.
USB ports, it allows the computer to
be booted simply by double-clicking
a USB mouse or by typing a password
into a USB keyboard. This is set up
in the PC’s BIOS (eg, “Power On By
Mouse” or “Power On By Keyboard”)
and is a very convenient way of starting the machine if the computer is
tucked away under a desk.
Second, it allows you to recharge
the batteries in a range of devices via
a USB port, even when the computer
is off. These devices include MP3
players, iPods, some GPS units and
cordless keyboard/mouse receiving
stations.
number of laptops indicate that powering them via a mains adaptor makes no
difference either – the USB ports are
still powered down when the machine
is switched off.
For laptops then, simply monitoring
the +5V USB line is valid and our circuit has an option to do just this. That
means that laptops are easy to cater for.
A few desktop machines also have a
jumper option on the motherboard to
disable USB standby power. However,
most don’t so we need to use some
other method to determine when the
machine is switched on.
Laptops are different
The answer for desktop machines is
to monitor the D- data line of the USB
port instead. To do this, however, we
must have a USB device plugged into
the USB port that the PC recognises,
typically a mouse or keyboard.
By contrast, laptop computers do
shut down the standby power to their
USB ports when they are powered
down. Presumably, this is done to
conserve the battery. Our tests on a
Monitoring a data line
The USB input and output sockets are accessed via cutouts in one end of
the case. The connection to the PC is via a standard type A to type B cable.
January 2009 27
mains on by default after the polling
signal is detected and by then using a
timer to turn it off a set period after the
polling signal ceases. In the case of the
USB Sensing Power Switch, this delay
period can be set anywhere between
33s and 67s but can easily be extended
if your computer is slow to boot.
Note that using the delay circuit
also means that the peripherals remain
powered up for a brief period after
the computer is turned off. So if the
delay period is 40s, for example, the
peripherals will remain on for 40s after
shut down.
Loop through sensing
Fig.2: this scope grab shows the polling signals with a full-speed USB device
connected to the USB Sensing Power Switch. The green trace is the signal on
the D- line of the USB port while the yellow trace is the signal at the collector of
transistor Q1. The polling frequency is 1kHz, as specified in the USB standard.
The reason for this is that when a
recognised device is plugged in, the
USB host (ie, in the PC) regularly
“polls” that USB port for activity. This
polling signal takes place at a 1kHz
rate (ie, 1ms frames) for low-speed
and full-speed devices and has an
amplitude of 3.3V.
By contrast, high-speed USB devices
use a differential 8kHz polling signal
that has an amplitude of just 0.3V.
This type of device can not be used
with this project – only low-speed and
full-speed devices can be used.
Fig.2 shows the USB polling signal
with a full-speed USB device connected. This signal appears shortly
after the machine is switched on. What
happens then depends on whether you
have USB mouse (and/or keyboard)
support enabled in the system BIOS. If
it isn’t enabled, then the polling signal
almost immediately ceases again and
stays off during the boot period until
well into the Windows splash screen,
at which point Windows loads its
own driver.
When that happens, the polling
signal reappears and remains on until
the machine is powered down again.
However, the polling gap during bootup can typically be 30-40 seconds long
or more, depending on how long it
28 Silicon Chip
takes Windows to load its driver.
Alternatively, if USB mouse (or
keyboard) support is enabled in the
BIOS, the polling signal remains
present as the machine boots and only
briefly ceases towards the end of the
splash screen as the Windows driver
takes over. So, in this case, the polling signal is almost continuous from
switch on.
By detecting the polling signal on
the D- line, we can thus reliably detect
when a desktop PC has been switched
on. But what about the gap in the polling signal that occurs during boot-up,
particularly if USB mouse/keyboard
support is not enabled in the BIOS?
Unless precautions are taken, the
peripheral devices would power up
shortly after the PC was switched on,
only to almost immediately switch
off again when the polling signal
ceased.
They would then remain off until
the Windows driver loaded for the
particular device that was plugged
into the USB port. For a plug and play
monitor, that could be a real problem
– if it isn’t turned on, Windows can
not recognise it and so loads a default
low-resolution desktop.
Fortunately, this problem is easily
solved by designing a circuit that re-
Fig.1 shows how the unit is used
with a desktop computer. Basically, it
uses “loop through” sensing via two
USB ports (one for USB in and one
for USB out).
As already mentioned, you must
have a USB mouse or keyboard (or
some other low-speed or full-speed
USB device) plugged in. You can
not use a high-speed device and that
includes most USB flash drives and
disk drives (the USB device itself
will work but the USB Sensing Power
Switch won’t).
Alternatively, for a laptop, all you
need to do is connect the unit to a USB
port on the computer and configure it
to monitor the +5V rail. In this case,
you don’t have to have a peripheral
connected to the USB Out socket but
you can if you wish. What’s more, you
can connect any type of USB device
you want, including high-speed devices – they will all function normally.
By the way, which ever method you
use to monitor the USB port, this unit
will also power down your peripherals
if the PC goes into hibernation. It will
then automatically turn them back on
again when the machine comes out of
hibernation.
Earlier unit
Before going further, we should
mention that this unit supersedes
the USB-Controlled Power Switch
described in November 2004. That
earlier unit was built into a modified
power board and used an optocoupler
to provide isolation and a Triac to
switch the mains power.
However, some readers have found
that the Triac fails under certain circumstances. Because of the confined
space inside the powerboard, the total
loading on the unit was specified as
siliconchip.com.au
N
E
WARNING: COMPONENTS & WIRING IN SHADED AREA
ARE AT 240V MAINS POTENTIAL WHEN THE
CIRCUIT IS OPERATING. CONTACT MAY BE LETHAL!
SLOW BLOW
F1 10A
A
GPO
E
S1
T1
12.6V/2VA
D1–D4
K
12.6V
*
FOR SY-4042 RELAY (20A)
USE 47 5W FOR
SY-4040 RELAY (30A)
6.3V
240V
RLY1
20A AC
CONTACTS
A
A
K +17V 68 5W
A
K
0V
K
470 F
25V
A
*
100 F
25V
D5 K
A
A
K
+5V (FROM USB)
10 F
16V
VR1
500k
1k
3.3k
IC1
555
2
Q3
BC337
4
10
12
4
11
22k
S
D
Q
IC2b
CLK
1
100 F
LL
Q
R
B
10k
C
Q1
BC549
E
USB IN
CON3
1
2
3
4
9
2
8
3
D
S
14
Vcc 5
Q
IC2a
CLK
R
13
150pF 10k
1k
E
3
6
JP1 JP2
2.2k
C
8
7
Q
Vss
1
7
A
2.2k
6
C Q2
B
2009
POWER
LED2
K
BC337
E
22k
IC2: 74LS74
TO TRIGGER FROM USB DATA: LEAVE OUT JP1 & JP2
TO TRIGGER FROM USB +5V RAIL: INSTALL JP1 ONLY
USB OUT
CON4
V+
1
2
3
4
D–
D+
0V
BC337, BC549
LEDS
SC
ACTIVE
LED1
2.2k
220 F
16V
1k
B
470k
1k
N
A
240V
INPUT
USB SENSING POWER SWITCH
D1–D5: 1N4004
A
K
K
A
B
E
C
Fig.3: the circuit can be triggered either from the +5V USB line (JP1 in) or from the D- data line (JP1 out) using
transistor Q1 and dual D-type flipflop IC2. When triggering occurs, Q2 turns on and this turns on relay RLY1 to
switch mains power through to the GPO. Q3 and its associated parts form the reset circuit for IC2, while 555 timer
IC1 switches the unit off after a preset time if no data is detected on the D- line.
700W maximum and it’s possible
that this rating was being exceeded
in some cases.
By contrast, this new project uses a
relay with 20A AC contacts to switch
the mains, which means that the outlet
is rated at a full 2300W. The relay also
completely eliminates the problem of
Triac failure. In addition, because it is
built into its own enclosure, this new
unit is easier to build than the earlier
version, since you don’t have to doctor
a powerboard.
Finally, the earlier unit monitored
the +5V USB line only. It’s suitable
for use with laptops but is limited to
those desktop machines in which the
USB standby power can be disabled
siliconchip.com.au
or where the PC itself is switched off
at the wall.
How it works
OK, let’s see how the unit works.
Fig.3 shows the circuit details and as
you can see, there’s not a lot to it.
The first thing to note is that the
electronic switching circuitry must be
electrically isolated from the mains, so
there’s no risk of 240V AC getting back
into the computer via its USB port.
That’s done by using a transformer in
the power supply plus a relay to switch
the mains through to the GPO.
As shown, a pair of standard USB
sockets, CON3 and CON4, allow the
unit to be connected between the
PC and an external peripheral using
standard USB cables. All of the USB
connections go “straight through”,
so the added circuitry is essentially
“transparent” as far as USB communication is concerned.
Let’s start by considering the simplest configuration, in which the unit
is used to monitor the USB 5V (V+) rail
(ie, it’s being used with a laptop). In
this case, jumper JP1 is installed and
IC1, IC2a, IC2b and transistors Q1 & Q3
are effectively bypassed and have no
role in the circuit’s operation.
When the laptop is powered up,
+5V DC appears on pin 1 of each of its
USB ports. We simply “steal” a couple
of milliamps from this convenient
January 2009 29
Parts List
1 PC board, code 10101091, 151
x 109mm
1 IP65 ABS sealed polycarbonate
enclosure with clear lid, 171 x
121 x 55mm (Jaycar HB-6248
or equivalent)
1 2851 12.6V 150mA (2VA) mains
transformer
1 chassis-mount 12V coil SPST
relay with 20A contacts (Jaycar
SY-4042)
2 PC-mount 2-way terminal blocks
(CON1,CON2)
1 PC-mount Type B USB
connector (CON3)
1 PC-mount Type A USB
connector (CON4)
1 snap-fit fused male IEC
connector with switch
1 M205 10A slow-blow fuse
1 10A flush-mounting mains outlet
socket with side wire entry
1 300mm length of 10A brown
mains wire
1 150mm length of 10A blue mains
wire
1 150mm length of 10A green/
yellow mains wire
12 Nylon cable ties
4 M3 x 6mm machine screws
2 M3 x 10mm machine screws
2 M4 x 10mm machine screws,
pan head
2 M3 hex nuts
3 M3 star lockwashers
2 M4 hex nuts
2 M4 star lockwashers
2 M4 flat washers
4 M3 x 10mm Nylon screws, pan
head
source of 5V DC and use this to turn
on transistor Q2 via a 2.2kΩ resistor
and jumper JP1.
Q2 in turn switches on relay RLY1.
As a result, RLY1 closes its contacts
(which are in the Active line) and so
power is switched through from the
mains input socket to the GPO (general
purpose outlet). In addition, Q2 turns
on LED1 (green) to indicate that the
relay is on.
Conversely, if the laptop is turned
off, the +5V DC disappears from USB
pin 1 and this removes the forward
bias on Q2 (its base is pulled down
to ground via the 22kΩ resistor). Q2
therefore stops conducting, turning
30 Silicon Chip
8 M3 hex Nylon nuts
2 6.4mm insulated spade
connectors for 1mm2 wire
7 4.8mm insulated spade
connectors for 1mm2 wire
1 4.8mm insulated piggyback
spade connector for 1mm2 wire
1 5.3mm ID eyelet terminal for
1mm2 wire
1 72 x 38 x 1mm sheet steel or
aluminium (for IEC connector
mounting plate)
1 3-pin header
1 jumper link
1 500kΩ miniature horizontal
mount trimpot (VR1)
1 14-pin machined IC socket
1 8-pin machined IC socket
Semiconductors
1 555 timer (IC1)
1 74LS74 dual D-type flipflop (IC2)
1 BC549 NPN transistor (Q1)
2 BC337 NPN transistor (Q2,Q3)
1 5mm green LED (LED1)
1 5mm red LED (LED2)
5 1N4004 1A diodes (D1-D5)
Capacitors
1 470μF 25V PC electrolytic
1 220μF 16V PC electrolytic
2 100μF 25V LL PC electrolytic
1 10μF 16V electrolytic
1 150pF ceramic
Resistors (0.25W, 1%)
1 470kΩ
3 2.2kΩ
2 22kΩ
2 1kΩ
2 10kΩ
1 68Ω 5W
1 3.3kΩ
off the relay (and LED1) and in turn
switching off the power to the GPO.
Simple.
Monitoring the D- line
Now let’s consider the more complicated case, where we monitor the “D-”
data line (ie, the unit is to be used with
a desktop machine). In this case, JP1
is left open so that the unit can not be
triggered by the +5V USB line. Instead,
IC1, IC2a, IC2b and transistors Q1 &
Q3 now come into play and transistor
Q2 is driven from the Q-bar output of
D-type flipflop IC2a.
It works like this: normally, when
the PC is off, the pin 6 Q-bar output of
D-type flipflop IC2a is low and transistor Q2 and the relay are off. However,
if the PC is turned on, transistor Q1
is rapidly pulsed on and off by the
polling signal that appears on the
D- line. Q1 inverts this polling signal
and applies a train of brief low-going
pulses to the reset pins (13 & 1) of
IC2b & IC2a.
As a result, IC2b & IC2a are reset,
thus forcing their Q outputs low and
their Q-bar outputs high. This turns
on transistor Q2 via a 2.2kΩ resistor
at pin 6 of IC2a and activates the relay
which now remains on.
IC1 is a 555 timer which is wired to
operate in astable mode. It is also reset
each time Q1 is briefly pulsed on by the
timing signal (ie, pin 4 is pulled low).
This sends pins 3 & 7 of IC1 low and
discharges the 100μF timing capacitor
on pins 2 & 6 via the 1kΩ resistor.
After the first brief reset pulse, Q1
turns off for a period of 1ms and so
pin 3 of IC1 switches high for 1ms
and clocks IC2b. Because IC2b’s Q-bar
output is connected to its D input, its
outputs immediately toggle, with Q
now going high and its Q-bar output
switching low (ie, a rising-edge clock
signal transfers the logic state on its
D input through to its Q output). This
has no effect on IC2a though, since the
flipflops only respond to high-going
clock pulses.
At the end of this 1ms period, Q1 is
pulsed on again by the polling signal
and IC1, IC2b & IC2a are again reset.
As a result, both Q2 and the relay
remain on while ever polling pulses
are present.
No polling signal
Now let’s see what happens if the
polling signal ceases. When that happens, IC1’s pin 3 output immediately
switches high and clocks IC2b, sending its Q-bar output low. At the same
time, IC1’s 100μF timing capacitor
begins charging towards the supply
rail via trimpot VR1 and the 470kΩ
and 1kΩ resistors.
The timing period for IC1 can be set
anywhere from 33-67s, depending on
the setting of VR1. If another polling
pulse occurs within this timing period,
then the circuit is reset and the relay
remains on. However, if no polling
pulse is detected (ie, the PC has been
powered down), the timing capacitor
continues to charge until it reaches
2/3Vcc. At this point, pin 3 switches
low and the 100μF timing capacitor
siliconchip.com.au
This view shows the fully completed prototype. Be sure
to build it into the specified plastic case to ensure safety.
quickly discharges into pin 7 via the
1kΩ resistor.
When the voltage on the timing
capacitor discharges to 1/3Vcc, pin
3 switches high again and the 100μF
capacitor begins recharging. This highgoing output from IC1 clocks IC2b
again, sending its Q-bar output (pin
8) high. This in turn clocks IC2a and
switches its Q-bar output low.
As a result, both Q2 and the relay
switch off, as does LED1.
Further clock pulses from IC1 now
have no further effect on IC2a. That’s
because its D input (pin 2) is tied high
and any further clock pulses simply
transfer this logic high to its Q output
and so Q-bar remains low.
In effect, IC1 functions as a missing
pulse detector. If the polling signal
is absent for longer than its timing
period, it applies two clock pulses to
IC2b – one almost immediately and the
other at the end of the timing period.
IC2b simply prevents this first clock
pulse from reaching IC2a and turning
off the relay prematurely.
Transistor Q3 and its associated
parts form a power-on reset circuit
for IC2b & IC2a. This might seem
siliconchip.com.au
rather complicated for a reset circuit
but is necessary to give a long time
constant (about 0.7s). This prevents
the USB reset pulse which appears on
the D- line almost immediately after
power is applied from falsely triggering the unit (ie, before the computer
is turned on).
Note that we originally used a simple RC reset network here but were
forced to use the more complicated
circuit when we discovered this problem. This accounts for some of the
differences between the unit shown in
the photos and the final version.
Power supply
All the circuitry involving IC1, IC2,
Q1 & Q3 is powered directly from a
+5V rail which is derived from the
USB port. By contrast, the relay circuit
(including transistor Q2 and LED1) is
powered from a 12V rail.
This 12V rail is derived from a
simple power supply based on mains
transformer T1. Its 12.6V AC secondary is rectified using bridge rectifier
D1-D4, the output of which is then
filtered by a 470μF electrolytic capacitor.
This supply provides about 17V DC,
so a 68Ω 5W dropping resistor is used
to reduce the effective relay voltage to
around 12V when it’s energised. The
specified relay draws about 75mA.
Note that it is also possible to use
a similar relay (Jaycar SY-4040) with
contacts capable of switching 30A
What Happens During Hibernation?
O
NE FEATURE of this device is that it will power down the peripherals
plugged into it if the computer goes into hibernation. That’s because all
data activity ceases on the USB data line during hibernation and because
laptop machines power down their USB ports.
This allows you to save power while the computer hibernates which is
worthwhile over long periods. The peripherals will automatically start up again
when the machine comes out of hibernation.
January 2009 31
JUMPER OPTIONS:
(1): TO TRIGGER FROM USB DATA
(D- LINE), LEAVE JP1 & JP2 OPEN
(2): TO TRIGGER FROM USB +5V
RAIL, INSTALL JUMPER JP1 ONLY
2
2
10k
470k
IC1
555
2
GM &
Q3
1k
2.2k
1
4
2
3
22k
Q2
MAINS WIRING CONNECTORS:
1: 6.4mm INSULATED SPADE CONNECTORS
2: 4.8mm INSULATED SPADE CONNECTORS
3: 4.8mm PIGGYBACK SPADE CONNECTOR
BC337
220 F
2
RLY1
IEC MAINS
CONNECTOR
WITH SWITCH
AND FUSE
(REAR VIEW)
CON3
100 F
IC2
74LS74
1
(ACTIVE: BROWN)
1
22k
USB IN
3
Q1
1k
3.3k
D5
3
2
150pF
10k
K
4004
DO NOT
LED1
SHORT
JP1 & JP2
AT THE
SAME TIME
M3 x 10mm SCREW
WITH LOCK
WASHER & NUT
JP2
JP1
4
BC549
10 F
A
2.2k
HCTIWS REWOP
2
VR1
500k
K
GNISNES BSU
2
1k
A
LED2
9002 C
CON4
4004
D1-D4
USB OUT
CON1
2.2k
19010101
4004
SECONDARY
(NEUTRAL: BLUE)
4004
2851
N
PRIMARY
A
4004
100 F
T1
1k
GPO
(REAR VIEW)
E
470 F
SEE DETAIL
DIAGRAM
68 5W
(EARTH: GRN/YELLOW)
1
CON2
BC337
2
M4 x 10mm SCREWS
WITH FLAT & LOCK
WASHERS, NUTS
NOTE: ALL WIRING TO THE IEC CONNECTOR, THE GPO AND THE OUTPUT
CONTACTS ON THE RELAY (1) MUST BE RUN USING 240VAC CABLE
Fig.4: follow this parts layout and wiring diagram to build the unit. Note that all wiring to the GPO, IEC connector
and relay contacts must be run using mains rated cable and this wiring must be secured using cable ties (see photos)
AC. However this relay needs 100mA
of energising current, so if it’s used
the dropping resistor value must be
reduced to 47Ω. There is no real advantage in using the higher rated relay
however, as the IEC mains input connector is only rated for 10A.
In any case, it’s very unlikely that
the current drain of the peripherals
connected to your PC will total 10A
– which corresponds to 2300W. So
the 20A relay we’re using is already
overkill.
Diode D5 is connected across the
relay coil to protect transistor Q2 from
the back-EMF voltage that’s generated
by the relay’s coil when it switches off.
LED1 (green) indicates when the relay
is on and mains power is present at the
GPO, while LED2 (red) indicates when
mains power is applied to the unit.
Finally, switch S1 (which is integral
with the IEC socket) allows you to
manually turn off the mains power.
32 Silicon Chip
This is handy if you want to boot
the computer but you don’t want to
power up certain peripherals, such as
a printer or external disk drive.
Construction
All of the parts used in the project
are housed in a sturdy polycarbonate
enclosure (171 x 121 x 55mm) with a
clear lid and a neoprene lid-sealing
gasket. Note that you must use the
specified plastic case for safety reasons – do not use a metal case.
As shown in the photos, the IEC
mains input connector (with inbuilt
switch S1 and fuse F1) mounts on one
end of the enclosure, while the 3-pin
GPO socket mounts in the lid. Everything else is mounted on a PC board
coded 10101091. This board measures
151 x 109mm and has corner cut-outs
at one end to allow it to sit on the base
of the box.
Fig.4 shows the parts layout and
CRIMP EYELET
M3 NUT
STAR WASHERS
TRANSFORMER
MOUNTING FOOT
PC BOARD
M3 x 10mm SCREW
Fig.5: an M3 x 10mm screw & nut,
two M3 star washers and a crimp
eyelet are used to secure the earth
wire to the transformer frame.
wiring. All the low-voltage circuitry
is mounted at the righthand end of the
board and there are square cutouts in
the end of the case to provide access
to the USB connectors. The indicator
LEDs are viewed through the transparent lid of the enclosure.
Two-way terminal blocks CON1
and CON2 are used to terminate
the connections from the secondary
winding of T1 and the coil of RLY1,
respectively. By contrast, one of T1’s
siliconchip.com.au
primary leads and the relay contacts
are connected to the mains wiring via
insulated spade connectors.
Begin the assembly by installing the
six wire links on the PC board, then
install the resistors. Table 1 shows the
resistor colour codes but you should
also check each one using a digital
multimeter before soldering it to the
board. The 68Ω 5W resistor should
be mounted with its square-section
ceramic body spaced up about 3mm
from the board, so that the air can
circulate beneath it (you can use a
cardboard spacer to do this).
Diodes D1-D5 can go in next,
followed by the three transistors
(Q1-Q3). Be sure to use the correct
transistor at each location. Q1 must
be a BC549, while Q2 & Q3 are
BC337s. Note that the transistors
and diodes are all polarised, so be
sure to install them with the correct
orientation.
Follow these parts with the two
ICs. We used good-quality machined
IC sockets on the prototype but you
can solder these devices directly to
the PC board if you wish. Be sure
to orientate these devices as shown
on Fig.4 (the dot or notch on each
device is at the pin 1 end).
The electrolytic capacitors are
next on the list, again taking care
with their orientation. Once they
are in, install the 150pF capacitor and the two LEDs (flat side as
shown). You can either mount
the LEDs close to the board or
leave their leads reasonably
long so that they will later
sit close to lid of the case for
improved visibility.
The 3-pin header can now
be soldered in place, followed by
screw terminal connectors CON1 &
CON2 and the two USB connectors
(CON3 & CON4). Be sure to install
CON1 & CON2 with their entry holes
Inside the completed prototype – note how the mains wiring is firmly
secured using cable ties, as are the leads to the transformer secondary and
relay coil. Note also that the PC board used in this prototype version differs
in several respects from the final version shown in Fig.4.
Table 1: Resistor Colour Codes
o
o
o
o
o
o
o
o
siliconchip.com.au
No.
1
2
2
1
3
2
1
Value
470kΩ
22kΩ
10kΩ
3.3kΩ
2.2kΩ
1kΩ
68Ω 5W
4-Band Code (1%)
yellow violet yellow brown
red red orange brown
brown black orange brown
orange orange red brown
red red red brown
brown black red brown
not applicable
5-Band Code (1%)
yellow violet black orange brown
red red black red brown
brown black black red brown
orange orange black brown brown
red red black brown brown
brown black black brown brown
not applicable
January 2009 33
(RIGHT-HAND END OF BOX)
31
10.5
15
8
CUTOUT FOR
TYPE A USB
CONNECTOR
15.5
CL
CUTOUT FOR
TYPE B USB
CONNECTOR
11
12
(BOX LID)
14
(LEFT-HAND END OF BOX)
10
A
5.5
27
47
10
A
13.5
A
5
18
50
A
A
CUTOUT
FOR IEC
CONNECTOR
6
30
5
A
HOLES A: 3.0mm DIAMETER
CORNER
RADIUS 2.5
A
18
CL
72
25
IEC CONNECTOR MOUNTING PLATE:
MATERIAL 1mm SHEET STEEL OR ALUMINIUM
5.5
A
26
6
40
18
38
33.5
16.75
10.9
4.5mm DIAM.
4.0
Fig.6: this diagram shows the cutout and drilling details for the GPO socket in the case lid, the access holes for the USB
connectors (righthand end), the IEC connector (lefthand end) and the metal mounting plate for the IEC connector. A
large cutout can be made by drilling a series of small holes around the inside perimeter, then knocking out the centre
piece and carefully filing the job to a smooth finish.
34 Silicon Chip
siliconchip.com.au
NOTE CABLE TIES
USED TO SECURE
NEUTRAL & EARTH
LEADS TO GPO
This view inside the prototype unit shows how the mains wiring is installed and secured. It’s a good idea to fit two Nylon
nuts to each Nylon screw that’s used to secure the IEC connector bracket, to firmly lock it into place.
facing towards the transformer and
relay.
The board assembly can now be
completed by installing transformer
T1 and the relay. First, transformer
T1 is mounted using two M3 x 10mm
long screws with lockwashers and
nuts. Note that the screw fitted to the
transformer’s “rear” foot is fitted with
an additional lockwasher, because this
screw is also later used to attach the
crimp eyelet of a mains (safety) earthing lead for the transformer frame.
Note also that the enamel must be
scraped off the transformer foot to
ensure a good contact.
Once the transformer has been
mounted on the board, the white
“centre tap” secondary wire can be cut
short and fitted with a short length of
heatshrink sleeving. The two yellow
secondary leads go to CON1. Keep
these two leads short and secure them
together using a couple of cable ties.
Relay RLY1 is mounted using two
M4 x 10mm machine screws with
flat washers, lockwashers and M4
nuts. Short leads fitted with 4.8mm
insulated spade connectors at one
end are then used to connect its coil
siliconchip.com.au
terminals to CON2. Once again, secure
these leads together with cable ties, as
shown in the photos.
Preparing the enclosure
Once the board assembly has been
completed, it can be placed aside
while you cut the various holes in
the enclosure and its lid. The size
and locations of all of these holes are
shown in Fig.6.
In summary, there are two small
rectangular cutouts at one end of the
case for access to USB connectors
CON3 and CON4, plus a single large
rectangular cutout at the other end
for the IEC mains input connector. In
addition, there are two holes in the lid
to mount the GPO socket.
The IEC fused male connector and
switch is a snap-in type intended for
use with a mounting plate thickness of
about 1mm. Unfortunately, the specified IP65 box has a wall thickness of
3mm, so the IEC connector cannot be
mounted directly to it. Instead, it is
fitted to a 1mm-thick metal plate and
this plate is secured to the inside of
the box using four M3 x 10mm Nylon
screws and eight Nylon nuts.
As a result of this arrangement, the
flange of the IEC socket is mounted
flush with the surface of the box, giving a neat finish.
As well as the box cut-outs, Fig.6
also shows the dimensions of the metal
plate for the IEC connector. It should
be made from 1mm thick sheet steel
or aluminium.
Having made the plate, the next step
is to snap the IEC connector into it and
then attach this assembly inside the
enclosure using the four M3 x 10mm
Nylon screws and nuts. It also a good
idea to then install an additional Nylon
nut on each mounting screw. These
will firmly lock the first nuts into position and ensure that the assembly can
not possibly come loose.
That done, mount the PC board
assembly inside the enclosure and
secure it using four M3 x 6mm machine screws. These screws go into the
integral threaded mounting bushes on
the base of the box.
The GPO outlet can now be fitted to
the lid. That’s done by first unscrewing the centre screw holding the front
plate to the rear moulding and then
screwing the outlet back together with
January 2009 35
nectors may have 6.4mm lugs and will
require 6.4mm spade connectors.
As shown in the photos, all this
mains wiring must be neatly installed
and secured using eight cable ties. This
is necessary to make it impossible for
any leads to come loose and make contact with the low-voltage components
on the PC board.
Note that the Neutral and Earth
wires are also tied to the GPO socket
using the holes in its moulding as
anchor points (see photo).
Additional cable ties are used to secure the leads to CON1 & CON2. Again,
the idea is to ensure they cannot come
loose and contact mains voltages.
Initial checks
The IEC connector is snap-fitted to a metal plate and this assembly is then
secured to one end of the case using M3 x 10mm Nylon screws and nuts.
the enclosure lid sandwiched between
the two sections.
Mains wiring
The final assembly step is to install
the mains wiring. This involves all
wiring to the IEC input connector, the
relay contacts and the GPO socket,
plus the primary winding of T1.
Note that all this wiring must use
250VAC 10A rated wire. Brown wires
are used for the Active connections,
blue for Neutral and green/yellow
for the Earth wiring – see Fig.4. Fig.5
shows how the Earth lead is attached
to the transformer mounting foot via a
5.3mm ID crimp eyelet terminal.
All leads to the IEC connector and
to the relay are terminated using insulated spade connectors. You must use
a ratchet-driven crimp connector to fit
these. Do not use a cheap automotivestyle crimp tool, as this will not give
reliable connections. The Earth wire
terminations, in particular, must be
well made in the interests of safety.
Fig.4 shows what type of spade connector to fit to each wire. Use 4.8mm
spade connectors to the IEC connector
as indicated. These spade connectors
should all be fully insulated.
If you are unable to obtain fully
insulated 4.8mm connectors, then
use non-insulated connectors but be
sure to fully insulate each one using
6mm-diameter heatshrink tubing after
its lead is crimped in place.
Note that the connector at the terminal marked “3” on the IEC connector
is a piggyback type. Again, it should
be fully insulated using heatshrink
tubing. Note also that some IEC con-
Before doing anything else, use your
multimeter (set to a low ohms range) to
check between the earth pin of the IEC
connector and the earth outlet of the
GPO. You should get a reading of zero
ohms here (this checks the integrity
of the earth connection). Similarly,
you should get a reading of zero ohms
between the earth pin of the IEC connector and the transformer frame.
Having verified the earth connection, fit the 10A fuse to the fuseholder
in the IEC socket. Note that this fuse
should be a slow-blow type.
Testing
It’s now time to test the unit. Here’s
the step-by-step procedure:
(1) Rotate trimpot VR1 fully anticlockwise (this sets the timing period
to minimum).
(2) If you are using a laptop, install
jumper JP1 to trigger off the +5V USB
rail. If you are using a desktop machine, leave JP1 out so that the unit
triggers off the D- line.
(3) Attach the lid to the case. This is
important – we strongly advise against
into MICROS OR PICS?
There’s
There’s asomething
reference to
to suit
suit every
every
microcontroller maestro in the
SILICON CHIP reference bookshop:
see the bookshop pages in this issue
Microcontroller LNOEW
Projects in C wPRICWE
as $
!
81
– by Dogan Ibrahim
Graded projects introduce microelectronics, the 8051 and
$
60 programming in C.
Programming 16-Bit
Microcontrollers in C –
by Luci Di Jasio
Learning to fly the PIC24. Includes a
CD ROM with source code in C,
Microchip C30 complier
$
90 and MPLAB SIM.
Hands-On ZigBee
– by Fred Eady
An in-depth look at the clever little
2.4GHz wireless ZigBee chip that’s now
being found in a wide range
$
equipment from
9650 of
consumer to industrial.
PIC in Practice –
by DW Smith
Ideal introduction to PICs. Based on
popular short courses for the PIC for
professionals, techs, hobbyists,
$
65 students and teachers.
PIC Microcontrollers –
know it all ( Newnes)
Newnes have put together the best of
subjects their authors have written on
over the past few years
$
90 into this one handy volume!
The PIC Micro – personal
intro course – by John Morton
A very practical guide which assumes
no prior knowledge. So it is an
introduction to the widely$
60 ideal
used PIC micro.
! Audio ! RF ! Digital ! Analog ! TV ! Video ! Power Control ! Motors ! Robots ! Drives ! Op Amps ! Satellite
36 Silicon Chip
siliconchip.com.au
Using The USB Sensing Power Switch
DESKTOP COMPUTER: trigger from the D- data line. Leave all jumpers out, connect the device to the computer via a standard USB cable and plug a USB mouse or
keyboard into the USB Out socket (see Fig.1). Set trimpot VR1 so that the green LED
(LED1) stays on continuously while the computer boots. Enabling USB mouse or USB
keyboard support (depending on which device you have plugged into the USB Out
port) will allow you to set VR1 to minimum (ie, to give the minimum delay period).
Silicon Chip
Binders
REAL
VALUE
AT
$13.95
PLUS P
&
LAPTOP COMPUTER: trigger from the USB +5V line. Install jumper JP1 and connect
the device to the computer via a standard USB cable. Use of the USB Out socket is
optional and you can plug in any device you wish. Note that plugging in a USB mouse
or keyboard will introduce a switch-off delay (as set by VR1), unless you leave out IC2.
connecting this unit to mains power
without the lid in place, to eliminate
the risk of electric shock.
(4) Connect the unit to a mains power
outlet, then switch on the mains out
let and switch on the IEC connector’s
switch (S1). The red LED should
light to indicate that the power is on
but nothing else should happen – ie,
the relay and LED1 (green) should
remain off.
(6) Connect the unit to your computer
using a standard USB type-A to type-B
cable. If you are using a desktop computer, then connect your USB mouse
or keyboard to the USB Out socket
(CON4) as well.
(7) Power up the computer. After a
brief delay (no more than several
seconds), you should hear a click as
the relay operates and the green LED
should light to indicate that mains
power has been switched through to
the GPO.
(8) If you have a desktop computer,
check the green LED as the computer
boots. If it goes out and then comes
back on again towards the end of the
Windows splash screen, then the delay
period is too short.
To adjust the delay, first unplug the
mains cord from the IEC connector,
then open the lid and adjust trimpot
VR1 slightly clockwise. Be sure to
replace the lid before testing the unit
again. Repeat this procedure if necessary, so that the green LED remains on
while the computer boots.
(9) Power down the computer. If you
are using a laptop, the green LED
should go out as soon as the machine
shuts down. You should also hear a
click as the relay switches off.
Alternatively, if you are using a
desktop machine, the green LED and
relay should remain on for the delay
period after the computer switches
siliconchip.com.au
P
Points To Check
(1) Be sure to use the specified ABS
plastic case & note that Nylon screws
must be used to secure the IEC connector
plate to ensure safety.
(2) Use mains-rated cable for all connections to the IEC socket, the GPO and the
relay contacts. Secure this wiring using
cable ties – see photos.
(3) Use fully-insulated spade connectors to terminate the leads to the IEC
connector and to the relay contacts. A
ratchet-driven crimping tool is necessary
to fit the spade connectors.
(4) Do not touch any part of the 230VAC
wiring while this device is plugged into
the mains. Also, DO NOT attempt to build
this device unless you know what you are
doing and are familiar with high-voltage
wiring.
off. This period will be somewhere
between about 33s and 67s, depending
on the setting of VR1.
Note: if your desktop computer is
very slow to boot and 67s isn’t long
enough, increase the value of the
470kΩ resistor in series with VR1.
Alternatively, enable USB mouse or
USB keyboard support in the system
BIOS, depending on which device you
have plugged into CON4.
If this all checks out, your USBSensing Power Switch is working and
can be put into service. All you have to
do is plug a power distribution board
into the GPO on the top of the enclosure and then plug your peripherals
into this distribution board.
Don’t forget to connect a USB mouse
or keyboard to the unit if you are triggering the unit from the D- line of the
USB port.
That’s it. Your peripherals will now
be automatically turned on and off
SC
with the computer.
These binders will protect your
copies of SILICON CHIP. They
feature heavy-board covers & are
made from a distinctive 2-tone
green vinyl. They hold 12 issues &
will look great on your bookshelf.
H 80mm internal width
H SILICON CHIP logo printed in
gold-coloured lettering on spine &
cover
H Buy five and get them postage
free!
Price: $A13.95 plus $A7 p&p per
order. Available only in Aust.
Silicon Chip Publications
PO Box 139
Collaroy Beach 2097
Or call (02) 9939 3295; or fax (02)
9939 2648 & quote your credit
card number.
Use this handy form
Enclosed is my cheque/money order for
$________ or please debit my
Visa Mastercard
Card No:
_________________________________
Card Expiry Date ____/____
Signature ________________________
Name ____________________________
Address__________________________
__________________ P/code_______
January 2009 37
|