This is only a preview of the July 2022 issue of Silicon Chip. You can view 44 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. Articles in this series:
Items relevant to "Multimeter Calibrator & Checker":
Items relevant to "VGA PicoMite":
Items relevant to "0-110dB RF Attenuator":
Items relevant to "Secure Remote Mains Switch, Part 1":
Articles in this series:
Purchase a printed copy of this issue for $11.50. |
Secure Remote
Receiver
68m line-of-sight range
Up to 16 remotes per receiver
Mains-powered, quiescent power
typically 0.8W
Relay contact rating: 30A at 250V AC,
meaning it can switch large mainspowered devices like pumps
Relay on-timer ranges: 250ms to 60s
or 60s to 4.5h (see Tables 3 & 4)
Brownout protection: 192V AC switch
off, 220V AC switch on
DC supply current: 17mA with relay
off, 100mA with relay on
Part one: by John Clarke
T
HE SECURE REMOTE CONTROLLED
MAINS SWITCH (we’ll call it the
Switch from now on) is ideal for
switching motor loads such as pool
pumps, water pumps and any number
of applications where you find it convenient to switch power to an appliance remotely.
The high security of this design
means that it can be used for
remote-controlled doors, gates and
door strikes, maintaining the security
of your home or premises. As is typical for security remote controls, the
handheld unit is pocket-sized.
Many commercially-made remotecontrolled mains switches are available, such as Jaycar Cat MS6148
and Altronics Cat A0345. Wi-Fi controlled mains switches are also available, like the Blaupunkt smart Wi-Fi
plug BSP2EM. These rely on a mobile
phone app for control.
These are all fine for their intended
purpose, but the relays they use to
switch mains power are not suitable
for appliances that include motors.
While rated at 10A, the relay contacts
will quickly be destroyed when used
to power items such as a pool pump.
Also, controllers relying on a mobile
phone app could become obsolete
72
Silicon Chip
should support for that app be dropped
or become incompatible with newer
phones. We covered this phenomenon
in the February 2022 editorial.
Secure codes
The use of secure codes is not only
necessary for security applications;
it is also very useful to ensure that a
neighbour or passer-by using a similar
remote control does not inadvertently
switch your appliance on or off while
controlling their own equipment.
Editor’s note: our motorised security
shutters have rolled up or down more
than once when we were nowhere near
the remote control! So this is not just
a theoretical risk, and it definitely has
security implications.
The security of this design also
means that you can build more than
one Switch without being concerned
about interference between them. The
unique transmission code ensures that
the Switch receiver will not be activated by anything other than one of
the paired handheld remote controls.
Rolling codes for high
security
The remote control code sent by
the handheld remote units can be
Australia's electronics magazine
considered an electronic lock similar
to a physical key. This key is a specific code sent by the transmitter to the
receiver; it is a long sequence of on and
off signals sent in a particular order
and over a set period. The code must
be correct for the receiver to respond.
With a fixed remote control code,
an intending thief can receive and
store the code sent by the remote control and re-transmit it in an attempt to
operate the receiver. However, with a
rolling code, the reused code will not
trigger the receiver. That’s because
the receiver requires a different code
each time.
Each code that’s transmitted differs
markedly from one transmission to
the next. The codes sent are based on
an algorithm (calculation) that both
the transmitter and receiver have in
common, based on a unique numerical value that is stored within ICs
in both the remote control and the
receiver. The handheld remote will
have a unique identifier different from
any other handheld remote.
The code possibilities of a rolling
code system run into the trillions. This
renders any attempt to break the code
by sending out guessed codes totally
unrealistic. The odds of picking a
siliconchip.com.au
MAINS SW TCH
Transmitter
Professional-looking key-fob enclosure
Powered by a 3V CR2032 lithium cell, 200mAh+ recommended, giving more than two
years of life with typical use
Standby current: typically 60nA (526μAh/year)
Active (transmitting) current: 10mA average over 160ms (900nAh / transmission)
Registration current: 10mA average over 2.75s (15.5μAh per registration)
Transmission rate: 976.5 bits/s (1.024ms per bit)
Data encoding: Manchester code with a transmission time of 82ms
Unique code generation: secure UHF rolling code control with 48-bit seed,
24-bit multiplier and 8-bit increment value
This remote mains power switch uses secure
wireless transmission so that nefarious people
can’t intercept the commands and override your
control. It can also switch high current loads and includes an adjustable
timer. Up to 16 separate handheld remotes can control the same receiver.
correct code at random for our rolling
code transmitter, for example, is one
in 2.8 trillion.
Even then, the code needs to be sent
at the correct data rate, with the correct start and stop bit codes and other
transmission requirements, including
data scrambling that changes for each
transmission.
Other features
Our Switch comprises two parts: a
professional key-fob-style transmitter
and a separate receiver. The key-fob
has three pushbutton switches and an
acknowledge LED that briefly lights
up each time one of the switches is
pressed. Up to 16 different key-fob
transmitters can be used with one
receiver.
The receiver has a 30A mains relay
making it suitable for switching power
to motors. The relay can be switched
on or off, or switched on for a fixed
time, using the remote control or a
switch on the receiver. The on-period
can be adjusted from 1/4 second to 4.5
hours in two ranges.
Another feature is brownout detection; it automatically switches off
should a brownout occur. This is
when the mains voltage drops to a
siliconchip.com.au
lower than normal level, usually
because of a supply fault. This lower
voltage can cause motors to overheat
and burn out.
Motor burn-out occurs because the
current through a motor’s induction
windings increases when it is not
spinning at its correct speed, which is
likely when the supply voltage is low.
During severe brownouts, the voltage
can be so low that the motor will not
turn at all, but current is still flowing
in its windings. In that situation, the
motor will quickly overheat and suffer permanent damage.
The brownout detection protects
the motor by switching off its power if
the supply voltage falls below a preset
value. Brownout detection is vital for
mains-powered water pumps.
Security and registration
Each key-fob transmitter must be
allocated an Identity number from 0
to 15, set by coding links on the PCB.
Each transmitter is registered to the
receiver by sending a synchronising
code to the receiver when the receiver
is in registration or learning mode.
A facility is included to lock out a
particular transmitter after registration. This is useful if a transmitter
Australia's electronics magazine
has been lost. If the lost transmitter is
found, it can be easily re-registered.
If the identity of the lost transmitter
is not known, all transmitters can be
locked out, and the ones that are still
in use can be re-registered.
The data is transmitted using UHF
ASK as Manchester code. A zero bit
is sent as a 512µs period of no transmission followed by a 512µs burst of
433.9MHz carrier. In contrast, a one
bit is transmitted as a 512µs burst of
433.9MHz carrier followed by a 512µs
period of no signal.
Each transmission consists of four
start bits, an 8-bit identifier, a 48-bit
code and four stop bits, for a total of 64
bits. The start bits include a 16.4ms gap
between the second start bit and the
third start bit, while the code scramble
value is altered on each transmission
with 32 variations.
Unique codes are generated using
a 48-bit seed, 24-bit multiplier and
8-bit increment value initially set by
a unique identifier within IC1 on the
transmitter.
The registration code is sent as two
blocks. Block 1 sends four start bits,
the 8-bit identifier, a 32-bit seed code
and four stop bits. Block 2 sends four
start bits, the 24-bit multiplier, the
July 2022 73
8-bit increment and 8-bit scramble values and four stop bits. Again, the start
bits include a 16.4ms gap between the
second start bit and the third start bit.
Circuitry
The transmitter circuit is shown in
Fig.1. It mainly comprises microcontroller IC1 and a 433.9MHz UHF transmitter. For IC1, the PIC16LF15323 was
chosen for its very low standby current
and the inclusion of a unique identifier
called the Microchip Unique Identifier
(MUI). We use the MUI to generate a
rolling code sequence that is unique to
the IC and thus the transmitter.
IC1 is usually kept in sleep mode
with its internal oscillator stopped
and most of its internal circuitry
switched off. In this state, it draws a
typical standby current of 60nA from
the 3V cell.
You can verify this by connecting a
100kW resistor in series with the 3V
supply with a switch across it. Apply
power with the switch closed. After
about 10 seconds, when the micro goes
to sleep, open the switch and measure
the voltage across the resistor. We measured 6mV, indicating a sleep current
of 60nA.
Switches S1 to S3 connect to the
RA4, RC3 and RC1 digital inputs of
IC1 while the Identity switches (1, 2,
4 & 8) connect to the RA0, RA1, RA2
and RC0 digital inputs, respectively.
The Identity inputs are used to differentiate between different transmitters for a given receiver. If only one
transmitter is used, it can be set for
Identity 0, and none of the Identity
pins need to be connected to circuit
ground.
At power-up, each Identity input is
held high by pull-up resistors to the
3V rail that is inside IC1. The software
then disables the pull-up resistor for
any identity input that is kept low.
That prevents that pull-up continuous
sourcing current, which would otherwise be 25-200µA drawn from the cell
per low input.
The pull-ups for pushbutton
switches S1-S3 are left on since they
are only pressed momentarily. In contrast, at least one of the Identity inputs
is always held low for Identity settings
other than 0.
IC1 is programmed to wake up from
its sleep condition when any one of
switches S1-S3 is pressed, and that
corresponding input changes from
high to a low. It then runs the program to send the rolling code for the
function associated with the pressed
switch.
The rolling code and registration
codes are sent via the 433.9MHz transmitter module. This module is powered via the paralleled RC5 and RC4
outputs of IC1, which go high to provide a nominal 3V to the Vcc input of
the module. This way, it only draws
current from the cell when in use.
The code is applied to the data input
of the module from the RA5 output
of IC1. The antenna is a coiled length
of wire.
Fig.1: the transmitter circuit is quite simple, primarily comprised of a
PIC16LF15323 microcontroller and a 433.9MHz UHF transmitter module.
74
Silicon Chip
Australia's electronics magazine
The transmit indicator, LED1, is
driven via the RC2 output of IC2
through a 220W current-limiting resistor and is modulated at the code transmission rate of about 1kHz.
After sending the code, IC1 powers
down the UHF transmitter and returns
to sleep mode.
During transmission, the current
draw from the cell briefly rises to
about 10mA. If you keep holding one
of the buttons down after the transmission is complete, the current will
drop to about 220µA until the button
is released. This is due to the current
flow in the switch pull-up resistor.
Considering the quiescent current and intermittent bursts of higher
current when transmitting, cell life
should be more than two years with
typical use.
Receiver circuit
The receiver (see Fig.2) uses a
PIC16F1459-I/P microcontroller (IC1)
and UHF receiver module with an
onboard coiled wire antenna input to
provide a very good reception range.
When no signal is present, the
receiver’s output signal is random
noise since the module’s automatic
gain control (AGC) is at its maximum.
Upon reception of a 433.9MHz signal, the receiver gain is reduced for
best reception without overload, and
the coded signal from the data output
of the module is delivered to the RC7
digital input of IC1.
The Acknowledge LED (LED2)
indicates whenever a valid signal is
received.
The RC5 digital output of IC1 drives
NPN transistor Q1, which switches
the relay coil. When RC5 goes high,
it delivers current to transistor Q1’s
base and Q1 powers RLY1. Diode D5
clamps the back-EMF that causes a
voltage spike at the collector of Q1 as
the relay switches off. The relay contacts are rated at 30A and 250V AC.
The unit can be set up to power the
relay for a fixed period or just switch
it on or off continuously.
There are two ways to toggle the
relay on and off. The operation of
switch S1 on the receiver depends
on jumper JP3. When JP3 is open, the
relay switches on with one press and
off on the next. When JP3 is bridged
and S1 is pressed, the relay is switched
on for a fixed time and switches off at
the end of this period, or when S1 is
pressed again – see Table 1.
siliconchip.com.au
Fig.2: UHF transmissions are fed to microcontroller IC1 on the receiver, which decodes them.
If they are valid, it controls the mains relay by changing the level at digital output RC5,
which drives NPN transistor Q1 to power the relay coil.
Table 1 – JP3 settings
Table 3 – JP1 timer settings
JP3 in/out
Receiver switch S1 function
JP1 in/out
Timer period
Out
Off if already on, otherwise on with a timer, range per JP1
Out
0.25-60s (1x)
In
Toggle on/off
In
1m-4.5h (255x)
Table 2 – transmitter switch functions
Table 4 – Nominal period versus TP1 voltage
Switch
Function with JP2 out
Function with JP2 in
TP1
Time with JP1 out
Time with JP1 in
S1
Relay on with a timer,
range per JP1
Relay on with a timer,
0.25-60s
0V
0.25s
1m
S2
Relay on continuously
Relay on with a timer,
1m-4.5h
1.25V
15s
1h 7.5m
2.5V
30s
2h 15m
S3
Relay off
Relay off
3.75V
45s
3h 22.5m
5V
60s
4h 30m
siliconchip.com.au
Australia's electronics magazine
July 2022 75
433.9MHz receiver module, while the
+12V rail powers the relay. The outputs of REG1 and REG2 are filtered
and stabilised using 100µF capacitors.
A 100nF capacitor further decouples
the 5V supply for IC1.
Brownout detection
The receiver fits into an IP65 sealed ABS plastic case, so it could be installed
in a pool house or similar, to control a pool pump, among other possible uses.
Being splashproof could also come in handy if it’s controlling a gate or garage
door. It should be installed out of the elements, as the sockets and switches are
not sealed.
The remote control has three buttons, and usually, S1 on the remote
switches the relay on with the timer
to switch it off, S2 switches it on continuously (or for a much longer time if
JP2 is inserted), and S3 switches it off.
See Table 2 for more details.
The timer period is set using trimpot VR1. The trimpot wiper can be
adjusted from 0V through to 5V. This
voltage is monitored at the AN6 analog input of IC1, which converts the
voltage into a period from 0.25 seconds
to 60 seconds.
IC1’s digital input RA4 has an internal pull-up current from IC1. If JP1 is
inserted, this pin is pulled low instead.
In that case, the timing period ranges
from one minute to 4 hours and 30
minutes – see Table 3.
You can monitor the timer setting
voltage at test point TP1. Table 4 shows
the typical periods for selected trimpot positions.
Identity
The Identity selection is made using
a BCD rotary switch (S4) with 16 positions, labelled 0-9 and A-F (for 10-15).
This switch is only applicable to the
lockout selections; it plays no part in
the key-fob transmitter registration.
S4’s four contacts connect to the
RB7, RB6, RB5 and RB4 digital inputs
76
Silicon Chip
of IC1. When the BCD switch is set at
0, all four inputs are high. Position 1
on the switch has the ‘1’ output at RB7
pulled low, while Position 15 (or F)
sets all switch outputs at 0V.
S3 provides the lockout or deregistering function for a transmitter.
Pressing S3 will prevent the transmitter from operating the receiver identified by the number selected with the
BCD switch.
The Learn switch (S2) tells the program within IC1 to be ready to accept
the synchronising signal from a handheld remote. While waiting for a signal
from the remote unit, the Learn LED
(LED1) stays lit. The Learn LED extinguishes once the synchronising signal
has been received.
Power supply
Power for the receiver comes from
the mains via transformer T1. The
transformer’s 12V secondary voltage
is full-wave rectified using diodes
D1-D4 and filtered with a 470µF electrolytic capacitor at 3-terminal regulator at REG1’s input plus another 100µF
capacitor at REG2’s input.
The result is a pulsating 17V DC
rail applied to REG1 & REG2, which
in turn provide regulated +12V DC
and +5V DC rails, respectively. The
+5V rail is used to power IC1 and the
Australia's electronics magazine
IC1’s AN8 analog input is used for
brownout detection. This input samples the 17V DC rectified rail via a
voltage divider consisting of a 22kW
resistor and trimpot VR2. VR2’s wiper
voltage is filtered using a 10µF capacitor (to smooth out 100Hz ripple and
transients) and applied to the AN8
input via a 1kW resistor.
During the set-up procedure, VR2
is adjusted so that the voltage at AN8
is a DC voltage that is 1/100th that of
the mains AC voltage. For example,
the voltage is set to +2.35V if the mains
voltage is 235V AC.
If a brownout occurs and the mains
voltage drops below about 192V AC,
the voltage applied to AN8 will fall
below 1.92V DC. This is detected
by microcontroller IC1, which then
switches the relay off to disconnect
power from the mains output. The
relay can only be switched on again
manually when the mains voltage
returns to normal.
One small problem with monitoring the 17V rail is that while it does
vary with mains voltage, it also varies
with load. RLY1 has a coil resistance
of 120W, so there is an extra 100mA
drawn from the 17V rail when the relay
is on. As a result, this rail drops when
the relay is powered. Therefore, VR2 is
adjusted while the relay is on, so the
brownout voltage detection threshold
is accurately set.
When the relay is off, the voltage
is expected to rise by about 3V as the
relay load on the supply is removed.
However, as the relay is latched off
by a brownout and must be manually
switched on again, that doesn’t matter.
Next month
We still have quite a bit of ground to
cover as, besides assembling the two
PCBs, we also need to describe how
to fit them into their respective cases.
Then we’ll go over the testing procedure, set-up, remote registration and
de-registration and some more advice
for using the Secure Remote Mains
Switch. All of that will be in the second and final article in this series,
next month.
SC
siliconchip.com.au
Parts List – Secure Remote Mains Switch
Receiver
1 double-sided plated-through PCB coded 10109211,
159 x 109mm, 1.6mm thick
1 IP65 ABS enclosure, 171 x 121 x 55mm
[Jaycar HB6248, Altronics H0478]
1 433.9MHz UHF ASK receiver (RX1)
[Jaycar ZW3102, Altronics Z6905A or equivalent]
1 3VA PCB-mounting 12V mains transformer (T1)
[Altronics M7012A]
1 12V DC coil, 250V AC 30A contact SPST relay (RLY1)
[Jaycar SY4040 or equivalent]
1 momentary push-to-close 250V AC panel-mount mains
switch (S1) [Jaycar SP0716, Altronics S1080]
2 SPST PCB-mount tactile micro switches (S2, S3)
[Jaycar SP0600, Altronics S1120]
1 4-bit DIL BCD PCB-mount rotary switch (S4)
[Jaycar SR1220, Altronics S3000A]
1 SPST mains rocker switch (S5)
[Jaycar SK0984, Altronics S3210]
1 10A mains panel socket with side wire entry
[Jaycar PS4094, Altronics P8241]
1 panel-mount IEC mains socket with integral fuse holder
[Jaycar PP4004, Altronics P8324]
1 M205 10A fast-blow fuse (F1)
1 10A IEC mains cord
1 panel-mount 230/240V AC neon lamp
2 2-way screw terminals, 5.08mm pitch (CON1)
1 3-way screw terminal, 5.08mm pitch (CON2)
3 2-way pin headers, 2.54mm pitch (JP1-JP3)
3 jumper shunts (JP1-JP3)
1 20-pin DIL IC socket (for IC1)
Hardware
2 M4 x 6mm panhead machine screws and nuts
(for relay mounting)
2 M3 x 10mm panhead Nylon machine screws
(for IEC connector mounting)
6 M3 x 6mm panhead machine screws
4 M3 nuts
2 150mm cable ties (to hold down transformer)
Wiring
1 20mm length of 3mm diameter red heatshrink tubing
1 400mm length of 10A light blue mains-rated wire ●
1 400mm length of 10A brown mains-rated wire ●
1 200mm length of 10A green/yellow mains-rated wire ●
1 400mm length of 7.5A brown mains-rated wire
1 170mm length of 1mm diameter enamelled copper
wire
1 50mm length of 10mm diameter red heatshrink tubing
1 100mm length of 5mm diameter red heatshrink tubing
1 25mm length of 5mm diameter blue heatshrink tubing
1 25mm length of 5mm diameter green heatshrink
tubing
12 100mm cable ties
● can be stripped from a length of 3-core 10A mains flex
siliconchip.com.au
Semiconductors
1 PIC16F1459-I/P microcontroller, DIP-20, programmed
with 1010921R.HEX
1 7805 5V 1A regulator, TO-220 (REG1)
1 7812 12V 1A regulator, TO-220 (REG2)
1 BC337 500mA NPN transistor, TO-92 (Q1)
5 1N4004 400V 1A diodes, DO-41 (D1-D5)
2 3mm high-brightness red LEDs (LED1, LED2)
Capacitors
1 470μF 25V PC electrolytic
1 100μF 25V PC electrolytic
2 100μF 16V PC electrolytic
2 10μF 16V PC electrolytic
2 100nF MKT polyester (code 104 or 100n)
Resistors (all 1/4W, 1% metal film)
1 22kW
5 10kW
1 1kW
2 560W
1 330W
1 10kW miniature single turn top-adjust trimpot
(code 103) (VR1)
1 10kW top-adjust multi-turn trimpot (code 103) (VR2)
Transmitter (up to 16 per receiver)
1 double-sided plated-through PCB coded 10109212, 30
x 45mm, 1.0mm thick
1 RF Solutions ENCL_KIT3 3-switch key-fob enclosure
[RS Components 4510674, Mouser 223-ENCL-KIT3]
1 Renata HU-2032-LF PCB-mount cell holder (BAT1)
[element14 1319749, Mouser 614-HU2032-LF]
1 CR2032 3V lithium cell (BAT1)
1 433.9MHz UHF ASK transmitter (TX1)
[Jaycar ZW3100, Altronics Z6900 or equivalent]
3 SPST two-pin momentary PCB-mount tactile switches
(S1-S3) [Jaycar SP0611, Altronics S1127]
1 PIC16LF15323-I/SL microcontroller, SOIC-14,
programmed with 1010921A.HEX (IC1)
1 3mm high-brightness red LED (LED1)
2 100nF 50V through-hole ceramic
1 220W 1% SMD resistor, M3216/1206 size
1 162mm length of 0.5mm diameter enamelled copper
wire
Resistor Colour Codes
Australia's electronics magazine
July 2022 77
|