This is only a preview of the October 2018 issue of Silicon Chip. You can view 40 of the 112 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 "GPS-synched Frequency Reference Pt.1":
Items relevant to "Arduino-based programmer for DCC Decoders":
Items relevant to "Low-voltage, high-current DC Motor Speed Controller":
Items relevant to "Opto-Isolated Mains Relay":
Items relevant to "Intro to programming: Cypress' System on a Chip (SoC)":
Purchase a printed copy of this issue for $10.00. |
Keep the bitey bits out of harm's way!
Opto-Isolated Mains Relay
By Tim Blythman
If you need to switch
mains voltages,
say from a micro's
output or any other
low voltage source,
you need to isolate
them from each other. That's what
this project does – it's easy to build and keeps
mains voltages locked away from the controller . . . and
you! Virtually any low voltage source will do – from 2.7 to 10V.
A
rduino and Raspberry Pi modules
are popular because it's so easy to
get into them, even if you're a beginner.
But many people do not like working
with mains, and with good reason –
it’s easy to create an unsafe situation
if you don’t know better.
Incorrect wiring or inadequate insulation is a hazard not just to you but
to anyone who comes in contact with
your invention.
This project is an ideal way of
switching mains power, whether you
are a beginner or not. If you follow
the instructions in this article carefully, within an hour or two, you will
have a working and importantly, safe,
mains switch.
You could control a heater, light, fan,
pump, television, amplifier, computer
– just about anything that plugs into a
mains socket.
You can use a wide range of sensors
to decide when to switch those devices on and off; we've covered many
easy-to-use sensors in our El Cheapo
Modules series (siliconchip.com.au/
Series/306).
which do this job but they all seem to
be designed for 110-120VAC mains, as
used in the USA and some other countries. For example, Adafruit’s PowerSwitch Tail performs a similar function
to our design.
But you definitely wouldn't want to
use these with 230VAC mains as used
in Australia, Europe and elsewhere. It
would probably blow up and even if
it didn't, it wouldn't be safe.
In the past, when we needed to control mains outlets using a microcontroller, we modified a 433MHz remote
mains switch to do the job. The last
time we did this was in the November 2014 issue – see siliconchip.com.
au/Article/8063
While simple and elegant, it's more
expensive and more work, as you need
to buy and modify the remote mains
switch units.
So we have designed this unit
which is simple, cheap, reliable and
able to switch just about any mains
device, up to 10A rating. You could
even connect several units to one micro to switch multiple devices.
Other versions
How it works
There are some existing designs
74
Silicon Chip
The 230V Opto-Isolated Relay uses
Australia’s electronics magazine
a logic signal (eg, 3.3V or 5V or up to
10V) and switches a mains-rated relay on or off based on the state of that
signal.
The optical isolation ensures that
there is no chance that mains voltages
could appear on the logic input and
cause a shock hazard, or damage the
driving circuitry. The 4N25 optocouplers we are using have an isolation
rating of 5300V RMS.
It also has a logic signal output
which can be used by the driving circuitry to detect whether mains power
is present and also allows the phase
and frequency of the mains waveform
to be sensed. This output uses the same
type of optocoupler for safety.
An optocoupler consists of a LED
(usually infrared) and phototransistor
in a plastic package. The LED shines on
the phototransistor junction through
an insulating clear plastic section, so
that the phototransistor conducts when
the LED illuminates it. It behaves like
a transistor with separate base-emitter
and collector-emitter junctions.
But the gain (called the “current
transfer ratio” or CTR) is much lower
than a standard transistor, so the collector current is generally of a similar
siliconchip.com.au
magnitude to the LED drive current.
The CTR may be above or below
100%, depending on the particular
optocoupler used (it can vary from
sample to sample) and on the LED current; the CTR tends to peak at a few
milliamps of LED drive current.
Take a look now at the circuit diagram, shown in Fig.1. The control signal is applied to pin header CON2.
When a sufficient voltage is applied,
current flows through the 220W current-limiting resistor and through
OPTO1’s internal LED, which usually
has a forward voltage of around 1V. So
with 3.3V across CON2, around 10mA
flows through it.
Assuming the 24V mains-derived
power supply on the other side of the
optocoupler is present, the phototransistor then acts as an emitter-follower,
supplying voltage to the base of NPN
transistor Q1 via a 10kW current-limiting resistor.
Q1 provides some gain so that sufficient current flows through the coil
of RLY1 to latch its armature, connecting pins 1 and 2 of CON1, the mains
terminal and connecting the Active
pin of the mains output socket to the
mains input.
Diode D6 prevents OPTO1’s internal
LED from being reverse-biased if the
voltage at CON2 is reversed, mainly
to protect against damage from static
electricity.
The outgoing Active line also drives
the LED in OPTO2 via a 100kW 1W
mains-rated resistor and a simple halfwave rectifier consisting of diodes D7
and D8. So when the Active voltage is
above about 2V, D7 is forward-biased
and current flows through the LED in
OPTO2.
As a result, current flows between
the pins of CON3 during the positive
half of the mains waveform, if RLY1
is latched on. CON3 can be connected
between a microcontroller digital input pin and ground so that the micro's
pin is pulled low in this case.
A pull-up of some sort is required
on that pin, to ensure its state changes when OPTO2's output switches
off; many micros have built-in pullups which can be enabled in software.
That micro can also measure the
frequency of the pulses from CON3 to
determine the mains frequency (this is
usually pretty accurate, so it could be
used as a reference) and the transitions
are near the zero crossings.
There will be a slight phase shift
siliconchip.com.au
due to the threshold being 2V rather
than 0V but this can be compensated
for in software if accurate detection of
zero crossings is necessary.
Mains power supply
RLY1 has a 24V DC coil because a
higher coil voltage means a lower coil
current for the same power, and we
have limited current available to drive
it with such a simple power supply.
Neutral is connected directly to the
circuit ground and the supply current
comes from the Active conductor via a
470nF X2-class capacitor which limits the average current and a 150W series resistor which limits the inrush
current. The resulting voltage is then
rectified by a bridge rectifier comprising diodes D1-D4 and filtered to pulsating DC using a 100µF electrolytic
capacitor.
A 470kW resistor across the X2 capacitor discharges it when the unit is
unplugged, to minimise the risk of getting a (small) shock from the circuit.
If you consider what happens starting at a zero crossing, when the Active
voltage is rising, the right-hand side of
the X2 capacitor rises to around 350V
DC while the left-hand side is limited
to around 25V, due to zener diodes
ZD1 and ZD2 which are effectively
across the output of the bridge rectifier. Thus, the X2 capacitor charges up
to around 325V DC.
When the Active voltage starts to
drop again, current flow through this
part of the circuit ceases, until the Active voltage drops to around 300V DC.
The left-hand side of the X2 capacitor
will then be at about -25V and so current will flow through the other half of
the bridge rectifier and the X2 capacitor will start to discharge.
It will have fully discharged when
the Active voltage is around -25V and
then it will start to charge in the opposite direction and the whole process will repeat as Active reaches
-350V and then starts heading back
towards 0V.
This process repeats continually,
maintaining the charge across the
100µF capacitor at around 30V while
drawing just a few milliamps from
the mains.
Voltage regulation
When there is no signal at CON2
and RLY1 is off, the two zener diodes
keep the positive end of RLY1’s coil at
around 24V; this is more than enough
Australia’s electronics magazine
What do you
use it for?
Have solar panels and a pool? You can
use a light sensor and a real-time clock
(RTC) module to switch the pool pump
on during the day when solar power is
available, or during off-peak hours if the
weather is bad.
Own a different type of pump? Use a float
switch to control a pump. Turn it on when
a storage tank is full or off when empty.
Some float switches are light duty and may
fail when switching high currents. Using the
Opto-Isolated Relay to buffer the signal from
a float switch will save its contacts from
burning out
Need to control a heating/cooling
system? Add a temperature sensor (and/or
a RTC) to build a custom thermostat.
Own an amplifier (or other appliance)
without a power switch? Add a remotecontrolled on/off switch to an amplifier,
by merely adding an IR decoder to a
microcontroller module, hooking up our
isolated relay, writing a few lines of code
and using a spare TV remote.
Unreliable internet connection?
Automatically reboot your router if your
internet connection goes down, using a
micro board with a WiFi module.
What about a wireless power switch?
Controlled by a micro or handheld remote
control; just wire up a remote control
receiver to its logic-level control input (the
receiver needs a separate DC power supply).
Or you can implement a complex light
switching arrangement, with multiple light
switches controlling the same set of lights.
Wire the switches to perform low-voltage
signalling and then use this signal to drive
the lights via the Opto-Isolated Relay. You
could even use switches that are not mainsrated, incorporate remote control etc.
You don't even need a microcontroller to
use the Opto-Isolated Relay. Any logic
signal, from 2.7V up to about 10V can be
used to activate the relay. This could come
from an op amp output, logic gate, relay,
switch, battery, plugpack or any other
source of switched DC.
WARNING: this project involves mains
voltages which can be dangerous
if not handled correctly. Follow the
instructions in this article carefully.
October 2018 75
WARNING!
The Opto-Isolated Relay operates directly from the 230VAC mains
supply and contact with live components is potentially lethal.
Fig.1: the complete circuit and wiring diagram for the Opto-Isolated Relay. The control signal at CON2 drives the LED
in OPTO1 which switches NPN transistor Q1 to activate relay RLY1. The incoming mains Active voltage is applied to a
470nF X2 capacitor and then rectified by diodes D1-D4 and filtered by a 100µF capacitor to provide around 25V DC for
the relay coil. OPTO2 allows mains phase sensing and indicates when the load has mains power.
voltage to allow its armature to latch.
When Q1 does pull in, it diverts
some but not all of the current that
was flowing through the zener diodes
to the relay’s coil instead.
At 50Hz, the 470nF capacitor has
an impedance (reactance) of about
6.8kW, limiting the current drawn from
the mains (230VAC) to around 33mA.
The 24V relay draws around 22mA at
24V, so the current through the zener
diodes drops from around 33mA to
around 11mA.
This assumes the mains is at the
nominal 230V. These numbers change
if the supply voltage changes, and so
the extra current means the relay will
work reliably even with mains voltages
slightly below 230V.
ZD1 and ZD2 also limit the voltage
across the 100µF filter capacitor to a
safe level. We have used two 12V zeners rather than one 24V zener as the
total dissipation with RLY1 off is not
much below 1W and could be higher
if the mains voltage is elevated.
The second 150W series resistor, between the 100µF capacitor and relay
coil, helps to prop up the coil voltage
for the first few milliseconds after Q1
switches on, ensuring that it latches
76
Silicon Chip
correctly.
This works because the 100µF capacitor can charge a to a slightly higher voltage initially, due to the voltage
across this added resistor.
Diode D5 protects Q1 from voltage
spikes from back-EMF when RLY1
switches off, while fuse F1 blows if
there is a fault on the mains side of this
circuit, or if the load goes short-circuit,
preventing any further damage.
As noted, RLY1 requires around
22mA to operate. Q1’s hfe is typically
over 400, meaning a base current of
55µA is needed to activate the relay.
Assuming that OPTO1’s CTR is at least
20%, that means the driving circuitry needs to be able to supply around
0.3mA at a minimum voltage of about
2.2V, to switch on the relay.
Construction
As with any circuit involving mains
voltages, it is imperative that the case
and mechanical construction are completed correctly to ensure the safety of
the completed circuit.
Attention to detail when building
the PCB is critical too, as a single reversed diode could destroy other components in the circuit before the fuse
Australia’s electronics magazine
has a chance to blow.
The Opto-Isolated Mains Relay is
built on a PCB coded 10107181 which
measures 99 x 60mm. The PCB is designed to clip into the internal side
rails of a UB3 Jiffy box, leaving just
enough room at the end of the box to
fit two cable glands, which are used to
secure the mains cables. Use the PCB
overlay diagram, Fig.2, as a guide during assembly.
The first step is to fit the low-profile
passive devices, starting with the resistors. Table.1 shows the colour coding used on the resistor bodies but it's
best to double-check the values with
a multimeter before soldering them in
place where shown in Fig.2.
Fit diodes D1-D8 next. Take care to
insert them with the cathode stripe in
the orientation as shown in the overlay
diagram. Note that D1 and D2 face the
opposite direction to D3 and D4. Then
mount the two identical zener diodes.
Again, ensure that the cathode band is
orientated correctly.
Q1 is the only transistor, and it
should be orientated as shown in Fig.2.
You may need to bend and adjust the
legs to fit the holes on the PCB (eg, using smaller pliers).
siliconchip.com.au
The two optocouplers, OPTO1 and
OPTO2, should be soldered next.
Note that the notches on the packages both point in towards the centre of
the board.
The PCB has been slotted to reduce
the chance of leakage between the two
halves of the board (ie, increase the
creepage distance), so we have added
a dot adjacent to the number one pin
in each case. Align this with the dot
on the optocoupler packages.
If you are going to install header terminals for CON2 and CON3, now is a
good time to do so. You could instead
solder wires directly to these pads later. If you are installing the extension
pieces, fit the header terminals with
the long pins down.
Next, fit the fuse holder clips to the
board. Make sure the retention tabs
are facing towards the outside or else
the fuse will not fit. You can temporarily install the fuse to make sure the
holder clips are placed correctly but be
careful if you solder the clips with the
fuse in place, as the heat could damage the fuse (eg, you could accidentally
desolder the end caps). Remove the
fuse after soldering.
Install the electrolytic capacitor
next. It is polarised, so it must be fitted
the right way around. The stripe on the
capacitor body indicates the negative
lead while the positive lead is longer.
The positive lead should go into the
pad marked with a + sign. We have
specified a 50V capacitor, but a 35V or
63V rated capacitor would work fine.
Solder the barrier terminal in place
now. If you're using the Jaycar version, which we prefer, you should attach it to the board using two machine
screws, washers and nuts before soldering the pins.
These screws prevent any stress on
the solder joints. But the cable glands
we're going to use to clamp the mains
cords should also prevent stress so the
Altronics version without the moutning screw holes should be OK too.
The terminals on the barrier terminal
are quite large, so you may need a bit of
extra solder and heat to ensure a good
mechanical and electrical connection.
Finally, fit the X2 capacitor and relay. Both should be pushed down fully onto the PCB before soldering. The
capacitor is not polarised while the
relay can only go in one way.
Putting it in the box
You must mount the PCB in the Jifsiliconchip.com.au
Fig.2: use this overlay diagram to assemble the PCB. The safe, low-voltage side is
at the right while the rest of the board is connected directly to the mains. During
construction, take care with the orientation of the diodes and the electrolytic
capacitor. The PCB should be sealed in its box before plugging it in. The layout
has changed slightly since the prototype was built, to increase track clearances.
fy box to provide sufficient insulation
to make it safe. Start by drilling two
holes at the end of the UB3 Jiffy box
to suit the cable glands. The specified
glands require 16mm holes. If you are
using a different gland, you may need
a different hole size. Use the cutting
template, Fig.3, as a guide.
The two slots on one end of the
box are designed to provide access to
CON2 and CON3. You could simply
solder some light-duty figure-8 wires
to those pads, or use twin leads with
DuPont headers on the end to plug into
the pin headers.
We've also prepared two slim PCBs
which are supplied along with the
main PCB and these can be soldered to
the board in place of CON2 and CON3.
They then pass through slots in the
case and have mounting pads for small
terminal blocks, which sit just outside
the plastic case and make it easy for
you to attach wires for connection to
your control module.
Australia’s electronics magazine
Regardless of which approach you
take, we suggest you make the slots
anyway since you need some way to
get the control signals into the case.
They can be made by drilling a few
small holes in a row (eg, using a 2mm
drill bit) and then joining and shaping
them with a needle file.
You could drill a larger hole but
that would make it easier for dust and
debris to get inside the box. You certainly shouldn't make these holes any
larger than necessary to prevent wires
from accidentally poking inside the
case, which could (in an admittedly
unlikely scenario) make contact with
live portions of the board.
A step drill is handy for drilling the
larger holes for the cable glands but
if you don't have one, you can use a
tapered reamer instead. Fit the cable
glands to the enclosure and make sure
the nuts are done up tight. We found
that the lips on the mounting nuts
overlapped slightly, so we trimmed
October 2018 77
Left: the Opto-Isolated Relay
mounted inside a UB3 Jiffy box with
the mains power plug and power
socket wired up. Note the terminal
extension boards, as shown above,
are wired positive (+) to positive.
These are optional attachments to
make connecting your control module
easier.
them with a sharp pair of sidecutters.
Preparing the mains cable
It's up to you where to cut the mains
cable to form the two leads. You could
cut it in the middle to get two equallength cords, or you could make the
plug or socket end longer, depending
on your application. Make sure there
is at least 30cm of cable left at each
end after cutting it.
Once you have cut the cable, there
are exposed ends that present an electrocution risk if the plug is connected
to a socket. Take great care to ensure
that the plug cannot be plugged into a
socket while you are working on it (or
if you leave it unattended). It helps to
plug the plug end into the socket end
until you have finished wiring it up.
Feed the cut ends of the cable
through the glands. The plug end
should go through the gland closest
to the fuse. Make sure to thread the
domed nut onto the cable first, if you
had to remove it.
Strip back the outer insulation by
25mm on both ends, then strip the insulation back by 5mm on the Active
(brown) and Neutral (blue) wires. The
Earth wires (green and yellow stripes)
should be stripped back about 15mm.
Remove the clear barrier from the
terminal barrier and attach the wires as
shown in Fig.2. The top screw terminal takes the incoming Active (brown)
from the plug lead. The next screw terminal is for the outgoing Active wire to
the socket, also brown. Ensure both of
these are firmly screwed down.
The bottom two screws are for the
two Neutral wires (blue) and they are
connected together on the PCB. While
it will work regardless of which wire
goes to which screw, it is neater to connect the incoming (plug) Neutral wire
to the third terminal and the outgoing
(socket) Neutral wire to the bottom
screw terminal.
The two Earth leads should now be
joined using the BP-style double screw
connector. Twist the wires together
and then insert them into the connector, making sure that they both reach
all the way to the end, then do up both
screws tight and check that they have
both clamped the wires.
Now check your work to ensure
there are no exposed copper strands
from any of the wires either floating
around or touching the wrong terminals and then replace the transparent
barrier strip over the barrier terminal.
Fig.3: drilling and cutting diagram for the UB3 plastic Jiffy box, reproduced same size. The two 16mm holes are for the
cable glands that clamp the mains cords while the slots are for either figure-8 wires or extension PCBs to give access to the
isolated control and feedback signals. The slots can be made by drilling a series of small holes which are then joined and
shaped using a needle file.
78
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
Check also that none of the wires can
move around in their respective screw
terminals.
To test the unit insert a 100mA (or
similar current) fuse in the holder and
slot the PCB into the grooves in the enclosure, then tidy up the wires using
cable ties. You can tuck the BP-style
screw connector under the gland entry
inside the box. Check that around 5mm
of the outer mains cable insulation is
visible inside the box before firmly
tightening the glands. This ensures
that the glands grip the cables securely.
Testing
The first tests (with the low-value
fuse in place) are to verify there are no
problems with the PCB construction.
Don’t connect anything to the mains
socket yet. Place the unit somewhere
stable and during testing, stay well
away from it – don't touch anything
inside the box. Plug the unit into a
switched-off GPO and then switch
it on.
If the fuse blows or the relay activates (you will hear it click), you may
have mis-wired something. Turn off
the power point and unplug the plug.
You can test for the presence of residual charge by carefully connecting
a multimeter on a high DC volts range
across the Active and Neutral pins of
the mains plug. If there is voltage present after a few seconds, your bleed
resistor may not have been fitted
correctly.
If all is well, nothing obvious should
happen. Turn
off the power point, unplug the unit
and connect a 3.3-10V DC voltage
source to CON2 with the indicated
polarity. Turn on the power again and
check that the relay clicks as the armature pulls in. That shows that the
circuit is working.
Turn off the power, unplug the lead
and replace the fuse with the final value. For example, if you are using the
Jaycar 5A relay, the fuse rating should
be no higher than 5A. If you are using the 16A relay from Altronics, use
a 10A fuse, as the mains leads cannot
safely carry a higher current.
Testing the mains presence/
phase output
The easiest way to test that the
CON3 output is working is to connect
a high-brightness LED with its cathode to pin 1 of CON3, then connect
the anode to pin 1 of CON2 (the positive control signal input) and wire pin
2 of CON3 to pin 2 of CON2. You still
need to apply the DC voltage to CON2
since the CON3 output is only active
when the relay is latched.
If you plug the unit back into mains
and switch it on, you should find that
the LED lights when the relay is engaged and switches off when you cut
mains power. It will actually be flash-
ing at 50Hz with a ~50% duty cycle but
this may not be obvious to the naked
eye. The LED current will be limited
to one or two milliamps due to the
limited CTR of OPTO2.
Finishing it off
Before you put the lid on, if you
haven't already done so, make the control connections to CON2 and CON3.
If using our small extension boards, fit
the terminal blocks on the wider end,
then feed the boards through the slots
in the case (lining up + with + and −
with −) and place the holes in the extension PCBs over the header pins.
You can then solder them in place.
Note that once this has been done,
they need to be desoldered to remove
the PCB, so it is important that everything is working and the lid fits correctly before doing this.
If soldering wires to the pads for
CON2 and CON3, pull them tight and
then glue them into the holes in the
box with silicone sealant. This ensures
that if the solder joints fail, the wires
cannot come in contact with the high
voltage section of the PCB.
Now screw the lid on, to ensure
that no live parts are exposed. Also,
unwind the cable gland nuts and
add a few drops of super glue to the
threads, then do them up tight again.
This stops anyone from undoing them
while the device is plugged in. The
230V Opto-Isolated Relay is
now complete and can be
used for your intended
purpose.
The finished Opto-Isolated Relay. The
two small extension boards make it
very easy to connect the low voltage
isolated terminals to a suitable
controlling module.
siliconchip.com.au
Australia's
Australia’s electronics magazine
O
october
ctober 2018
2018 79
2018
79
79
Parts List – Opto-Isolated Mains Relay
1 double-sided PCB, coded 10107181, 99mm x 60mm
2 double-sided PCBs, coded 10107182, 38mm x 10.5mm (optional)
1 230V 10A extension cord (or mains plug and socket with leads)
2 cable glands to suit mains cord
[eg, Jaycar HP0724 or Altronics H4312A/H4313A]
1 UB3 Jiffy box [Altronics H0153/H0203 or Jaycar HB6013/HB6023]
1 4-way PC mount terminal barrier (CON1)
[Jaycar HM3162 or Altronics P2103]
1 BP-style double screw connector [Jaycar HM3192 or Altronics P2125A]
1 250V-rated 24V DC coil relay (RLY1)
[Altronics S4199 (16A, recommended) or Jaycar SY4051 (5A)]
2 M205 PCB-mount fuse clips (F1) [Jaycar SZ2018, Altronics S5983]
1 M205 slow-blow fuse to suit relay contact rating, no more than 10A
[Altronics S5662, Jaycar SF2178]
1 M205 100mA or similarly rated fuse (for initial testing only)
2 2-way headers, 2.54mm pitch (CON2,CON3)
2 M3 x 20mm Nylon machine screws
2 M3 Nylon hex nuts
2 M3 Nylon flat washers
Semiconductors
8 1N4007 1A 1000V diodes (D1-D8)
2 12V 1W zener diodes, eg, 1N4742 (ZD1,ZD2)
2 4N25 optocouplers (OPTO1,OPTO2)
1 BC549 100mA NPN transistor (Q1)
Capacitors
1 470nF 275VAC X2-class MKT/MKP
1 100µF 50V RB electrolytic
Resistors (all 1W, 5% unless otherwise stated)
2 150W
1 470kW
1 100kW
1 10kW 0.25W 1%
1 220W 0.25W 1%
Table.1: Resistor Colour Codes
No.
1
1
1
1
2
Value
470kΩ
100kΩ
10kΩ
220Ω
150Ω
4-Band Code (1%)
yellow violet yellow brown
brown black yellow brown
brown black orange brown
red red brown brown
brown green brown brown
If you are planning to use the output/phase sense signal from CON3
with an Arduino, you can enable an
internal pull-up current on the digital
input pin using a command like this,
within your setup() function:
pinMode(3,INPUT_PULLUP);
In this example, connect digital pin
3 to the + terminal of CON3 and GND
to the – terminal of CON3. When the
mains is off, pin 3 will read high (1),
while you would get a low reading
(0) during the positive-going half of
the mains cycle when the relay is on.
You could use a pin change interrupt
or counter function to detect the pin
toggling if you simply need to know
whether the load is powered.
80
Silicon Chip
Australia’s electronics magazine
5-Band Code (1%)
yellow violet black orange brown
brown black black orange brown
brown black black red brown
red red black black brown
brown green black black brown
In the event of a blackout or if, for
some reason, the relay fails to close,
that pin will remain high. You can detect that condition and flag an error (eg,
by sounding a buzzer).
Mains phase detection is possible
using this signal but it's a little bit
complicated due to the phase shift –
you need to use a timer to measure the
positive and negative times, calculate
the delay between the zero crossing
and the pin going low, then use another timer (or possibly the same one)
to compensate. That's a bit too much
detail to get into here.
You don’t necessarily need to use
the output sensing function, though.
You can leave CON3 disconnected if
you do not need that feature.
SC
siliconchip.com.au
|