This is only a preview of the August 2022 issue of Silicon Chip. You can view 41 of the 104 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Articles in this series:
Items relevant to "Wide-Range Ohmmeter, Part 1":
Articles in this series:
Items relevant to "isoundBar with Built-in Woofer":
Items relevant to "SPY-DER: a 3D-printed Robot":
Items relevant to "Secure Remote Mains Switch, Part 2":
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 two: by John Clarke
T
HE SYSTEM COMPRISES ONE
RECEIVER AND UP TO 16 KEY-FOB
TRANSMITTERS. You can build
multiple receivers if you have different equipment to control. There is no
possibility of a transmitter triggering
the wrong receiver due to the secure
rolling-code system.
The assembly of both modules is
relatively straightforward due to the
use of mostly standard parts. The
transmitter PCB is small (30 x 45mm),
and the onboard microcontroller is in
an SMD package (SOIC-14). Still, anybody with reasonable soldering skills
and proper equipment should be able
to build it.
Transmitter construction
All the parts for the transmitter
mount on a 30 x 45mm double-sided
PCB that’s coded 10109212 – see Fig.3.
Once assembled, this will be housed in
a 65 x 25 x 17mm remote control case.
This enclosure is designed for use
with a 12V N battery, but we are using
a button cell instead. So you will need
to remove the curved plastic mouldings inside the front lid of the enclosure at the key ring end that locate the
N-sized battery, using side cutters, to
provide space for the cell holder to fit.
80
Silicon Chip
Most of the parts except for the
UHF module are mounted on the top
of the PCB. The IC and 220W resistor
are surface-mount devices.
IC1 will need to be programmed
before soldering it in place. This IC can
be obtained pre-programmed from Silicon Chip, or you can program it yourself if you have a suitable programmer.
Start by soldering the 220W resistor in place. Tack solder one end of
the resistor and remelt the solder to
straighten it, if necessary, before soldering the opposite end. Then add a
bit of fresh solder (or flux paste) to the
first joint and heat it to reflow it so that
it is nice and shiny.
Next, fit IC1, making sure it is orientated correctly. Solder pin 1 to the
PCB and check the alignment to ensure
the IC pins all line up with the pads on
the PCB before soldering the remaining
pins. If any pins have a solder bridge,
you can remove it with a bit of flux
paste and some solder wick.
Next, install the three switches,
S1-S3. These are installed close to
the PCB. Then fit LED1, ensuring its
polarity is correct (the longer lead is
the anode [A]) and positioned with the
top of the LED lens 7.5mm above the
top surface of the PCB.
Australia's electronics magazine
Mount the two 100nF ceramic
capacitors next. The capacitor adjacent to S3 needs to lie over toward IC1.
The UHF transmitter can now be
installed on the underside of the PCB,
with its pins bent so that it lies flat
against the back of the PCB with 1mm
of clearance. Check that it is correctly
orientated before soldering its pins.
Then mount the cell holder on the top
of the PCB.
The board assembly is completed
by fitting the antenna. Make it from
a 162mm length of 0.5mm diameter
enamelled copper wire. Strip the insulation from one end by about 2mm
using a sharp hobby knife, emery paper
or sharp side cutters. Close-wind it on
a 3mm mandrel (eg, a 3mm drill bit)
and then stretch it out to 28mm overall length.
Install the wire coil from the underside of the PCB with the stripped end
into the antenna hole.
Place the PCB assembly into the
enclosure base before attaching the lid.
The assembly is held together with the
two self-tapping screws supplied with
the key-fob enclosure. Then affix the
front panel label that came with the
enclosure to the lid.
Note that the switches may not
siliconchip.com.au
MAINS SW TCH
Transmitter
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 Switch uses a high-security
rolling-code system, so it is suitable for
triggering motors that open doors or gates. It’s also
very robust, allowing it to switch motor-based appliances like pool pumps
and water pumps. Last month, we described the circuitry; this article
concentrates on its construction, testing, set-up, and use.
initially all be operable; some adjustments might be required. In particular, switch S2 may not be able to be
pressed due to the corner of the cell
holder adjacent to S2 being a little too
high to allow the bending of the enclosure lid lever for S2. In this case, file
down that corner of the cell holder a
little so the switch can be pressed (as
seen below).
Additionally, you might find that
the switches are pressed in when the
lid is attached. To avoid this, we will
be supplying PCBs that are thinner
than usual (1.0mm instead of 1.6mm).
This thinner PCB should prevent the
switches from being pressed by the lid.
But if you still experience this problem, you will need to trim the tops of
the plastic pins on the lid of the enclosure that press on the switches with a
file, sharp side cutters or a craft knife.
Take care not to remove too much
material, and test the switch operation
after shaving off some of this plastic.
Note that if you touch the junction
of the two halves of the coin cell (the +
and – contacts), that will cause a higher
than expected leakage current due to
oils from your skin being deposited on
the insulating surface. This will discharge the cell quicker than expected.
If you touch it like that, clean the cell
with methylated spirits or isopropyl
alcohol and avoid making contact
across the cell halves your fingers.
Receiver construction
Many of the parts (but not all) fit on
the PCB coded 10109211 that measures 159 x 109mm – see Fig.4. The
off-board parts are the IEC mains input
socket, GPO mains output socket,
pushbutton switch S1, power switch
S5 and the neon indicator lamp.
Install the resistors first, taking care
to place each in its correct position.
The resistor colour codes are shown
in the parts list, but you should also
use a digital multimeter to check each
resistor before mounting it in place.
Fig.3: the top and
bottom view of the
PCB overlay and
actual prototype
PCB for the
Transmitter half of
the Secure Remote
Controlled Mains
Switch.
siliconchip.com.au
Australia's electronics magazine
August 2022 81
Diodes D1-D5 are next. Make sure
these are orientated correctly before
soldering their leads. Then install a
socket for IC1, ensuring its notched
end matches the position shown in
Fig.4. Do not fit IC1 yet – that step
comes later, after the power supply
has been checked.
Regulators REG1 & REG2 are both
mounted horizontally on the PCB.
The first step is to bend their leads
down through 90° so that they will go
through their PCB holes. In each case,
the regulator’s two outer leads are bent
down 8mm from its body, while its
centre lead is bent down 5mm from
the body.
Secure each regulator to the PCB
using an M3 x 10mm machine screw
and nut. Be careful not to get the regulators mixed up – the 7805 (REG1) is
on the right-hand side.
Tighten each assembly firmly before
soldering and trimming the leads. Do
not solder the regulator leads before
tightening the mounting screws, as
that could stress the soldered joints
and fracture the board tracks.
Next, install trimpots VR1 and VR2
(VR2’s screw adjuster toward the top
of the PCB), transistor Q1 and the BCD
switch. This must also be orientated
as shown.
The capacitors can then be mounted.
The electrolytic capacitors are polarised and must be installed with the
polarity shown (the longer lead is positive). You can install the two 100nF
MKT polyester capacitors either way
around. The two LEDs (LED1 and
LED2) are mounted with the tops of
the lenses 12mm above the surface of
the PCB and the anodes (longer leads)
to the holes marked “A”.
CON1 and CON2 are 4-way and
3-way screw terminals. CON1 is
made of two 2-way screw terminals
dovetailed together by sliding them
together along the side mouldings.
Orientate CON1 with the wire entry
toward RLY1.
CON2 has connections made only
to the two outside terminals. This is
to increase the separation between the
Active and Neutral connections. On
our prototype, we removed the centre
pin from the terminal. But if you find
it difficult to remove, it can be left in
place. The wire entry for this connector is on the left.
Then fit the headers for jumpers JP1,
JP2 and JP3.
Now install the 433.9MHz receiver
module, again ensuring it goes in the
right way around. The pin designations are all clearly labelled on the
back of the module, and you can also
match the orientation of the module
against the photographs.
The antenna is made from a 170mm
length of 1mm diameter enamelled
copper wire. Form it into a spiral by
winding it over a 6mm (or similar
diameter) mandrel, such as the shank
of a 6mm or 1/4-inch drill bit. As shown
in Fig.5, it extends from the antenna
PCB pad to another pad adjacent to
REG1.
Be sure to scrape away the enamel
insulation from both ends of the
antenna wire before soldering it into
position.
For safety reasons, the antenna must
be fully enclosed in the plastic case.
Under no circumstances should it be
mounted externally, nor should any
part of the antenna protrude from the
enclosure. Otherwise, if a mains wire
comes adrift inside the case, it could
contact low-voltage circuitry and the
antenna might also become live at
230V AC.
The transformer mounts on the
PCB and is held in place using two
cable ties that are joined to provide
a sufficient length wrap around the
transformer body and PCB via holes
provided on the board. The cable ties
prevent the transformer from coming
Fig.4: the overlay diagram
for the receiver section of the
Secure Remote Controlled
Mains Switch.
82
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
Rolling Code Systems – frequently asked questions
One question that’s often asked about
rolling code systems is what happens
if one of the switches on the transmitter is pressed when the transmitter is
out of range of the receiver. Will the
receiver still work when the transmitter is later brought within range, and
the button pressed again?
This question is asked because the
code the receiver was expecting has
already been sent (but not received),
and the transmitter has rolled over to
a new code. How does the system get
around this problem?
The answer is that the receiver will
process a signal that is the correct
length and data rate, but it will not
trigger the relay unless it receives
the correct code. So if the signal format is valid, but the code is incorrect,
the receiver then calculates the next
code that it would expect and checks
this against the received code. If it
matches, the receiver will trigger the
relay; that means it missed one button press.
If the code is still incorrect, the
receiver calculates the next expected
code, and it will do this up to 10 times,
to handle cases where there have
been multiple transmitter button
presses out of range.
If none of these are correct, the
receiver then changes its operation to
allow for a possible valid signal more
than 10 codes ahead. The receiver
waits for two valid separate transmission codes before restoring correct operation.
On the first receipt of a valid transmission, it looks ahead up to 200
codes, so it is more likely the required
valid code will be found, but it doesn’t
trigger the relay. The Learn LED lights
during this look-ahead operation. If a
valid code is found, the receiver waits
for the next code sent by the transmitter. This following code must also be
correct before the receiver will operate the relay.
If only one or neither code is correct,
the receiver will not take action. If it’s
more than 200 codes ahead, the transmitter will need to be re-registered to
operate the receiver.
You can test this process by switching the receiver off and pressing one of
the remote control switches 10 times
or more. Then switch on the receiver
and press one of the switches again.
siliconchip.com.au
The Learn LED will light, indicating that
the look-ahead feature beyond the initial 10 times is activated. The selected
function on the remote should operate
on the next press of the switch, and
the Learn LED extinguishes.
While two successive transmission codes could be intercepted,
recorded and re-sent in an attempt
to activate the receiver, these codes
will not be accepted by the receiver.
That’s because they have presumably
already been received and processed,
and the receiver has already rolled
past those codes. It will look forwards
but not backwards.
Another transmitter with a different
identity will still operate the receiver
(provided it has been synchronised
in the first place). That’s because the
receiver tracks each transmitter’s rolling codes separately.
Calculating the code
Another question that’s often asked
is how the receiver knows which code
to expect from the transmitter since
it changes each time. The answer is
that the transmitter and the receiver
both use the same series of calculations to determine the next code. They
also both use the same variables in
the calculation; unique values that no
other transmitter uses.
Without going into too much detail
about how the actual rolling code
works, here are the basics. We use a
linear congruential generator (LCG)
in conjunction with a 31-bit pseudo-
random number generator (PRNG).
The LCG uses an initial seed value,
an addition value and a multiplication factor to produce a nominally
random result.
For example, if consecutive codes
have the number 3 added and then
multiplied by 49, with the same starting number, both the transmitter and
receiver will go through the same
sequence. But the actual numbers
used are very large, making it difficult
to predict the next code by peeking at
a few values in the sequence.
The code is 48 bits long, with
281,474,976,710,656 possible values (that’s over 281 quintillion or 2.8
x 1014).
One problem with the LCG is that it
can produce recurring values; depending on the factors, it can produce the
Australia's electronics magazine
same number more than once within a
few hundred rolling code calculations.
To prevent this, we include a second
layer of randomisation. So once we
have the value from the LCG calculation, this value is used in the PRNG
to generate a pseudo-random number
for the rolling code.
The PRNG randomisation runs
between one and 256 times before
providing the ‘random’ number for
the rolling code value. The number
generated is then used as the seed in
the LCG for generating the next number in the sequence. Using the PRNG
makes it difficult to predict the rolling
code sequence even if the multiplier or
addition value for the LCG is known.
We throw further complications by
also using code scrambling. The calculated code is not sent in the same
sequence each time. There are 32
possible scrambling variations that
are applied to the code, so predicting
the next code becomes very difficult.
What if the transmitter rolling code
is identical for two consecutive codes,
and the first of these identical codes
is intercepted and re-transmitted to
open the lock? Our system has safeguards to prevent the same code from
appearing twice in succession. There
is a check for the same code repeating
itself for consecutive codes. If the code
is the same, the duplicate is effectively
skipped, preventing this possibility.
Multiple transmitters
Wouldn’t the receiver lose its synchronisation if several transmitters
were used? No, because each transmitter operates independently. Each
of the 16 possible transmitters used
with a given receiver has its own different identity from one to 16.
The codes sent by each transmitter
are different due to the unique identifier
within each transmitter IC that sets the
rolling code calculation. Also, the code
includes the transmitter identity value
that differs between each transmitter.
The receiver stores up to 16 different
rolling code and calculation parameters, one for each identity, so each
transmitter is treated independently.
Therefore, even if one transmitter is
not used for months while other transmitters are used frequently, its rolling
codes will remain synchronised with
the receiver.
August 2022 83
adrift if the assembled unit is dropped.
Without them, the transformer is only
held by small pins that are secured in
the plastic of the transformer body.
The next step is to install the relay
with its coil terminals toward CON1.
Secure the relay to the board using M4
machine screws and nuts.
Final assembly
The Secure Remote Controlled
Mains Switch is housed in an ABS
enclosure measuring 171 x 121 x
55mm.
You will have to drill and shape
holes in one end of the case for the
mains switch and IEC connector. The
lid also needs holes drilled for the GPO
socket, the neon indicator and pushbutton switch S1.
A template for these cut-outs is
shown in Fig.6. This can also be
downloaded from siliconchip.com.au/
Shop/11/6418 and printed out.
The large cut-outs (for the mains
GPO and IEC connector) can be made
by drilling a series of small holes
around the inside perimeter, knocking out the central piece and filing
the job to a smooth finish. The switch
hole must not be oversized so that it
stays clipped in when inserted into the
cut-out. So take care with shaping it.
Once the drilling and cutting is
finished, install the PCB and power
switch in the case. The PCB is secured
using the integral brass inserts and four
M3 x 6mm screws. The IEC connector must be secured using Nylon M3
x 10mm screws, although you can use
metal nuts. The Nylon screws avoid
the possibility of ‘live’ screws should a
mains wire inside the enclosure come
adrift and contact them.
Before attaching the mains GPO,
switch S1 and the neon indicator,
you can print out the front panel label
shown in Fig.7. Again, this is available
for download from our website.
Print it onto photo paper and cut
out the holes for the switch, neon and
GPO with a sharp craft or hobby knife.
The panel will be held in place by the
switch and the GPO. If the label is
prone to drooping, use a small amount
of clear tape to affix the corners or dabs
of clear neutral-cure silicone sealant
or glue.
The wiring marked in Fig.5 must
be run using 10A mains-rated cable.
That includes the wires for switch
S1. Note that brown wire is used for
Active while the light blue wire is
Fig.5: the wiring diagram for the
receiver section of the Secure
Remote Controlled Mains Switch.
Note how the antenna is wound on
the right-hand edge of the PCB. You
can do this by winding it over a
6mm drill bit.
84
Silicon Chip
Australia's electronics magazine
siliconchip.com.au
for the Neutral leads. The green/yellow-striped wire is for Earth wiring
only, and the Earth lead from the IEC
connector must go straight to the GPO.
For the wiring not marked as 10A
(for switch S1 and the relay coil), you
can use lighter-duty 7.5A rated mains
wire.
Be sure to insulate all the connections with heatshrink tubing for safety,
and cable tie the wires to prevent
any broken wires from coming adrift.
Secure the Active and Neutral leads
to the GPO using cable ties passing
through the holes in its moulding. Use
neutral-cure silicone (eg, Roof & Gutter
silicone) to cover the Active bus piece
that connects the active pin to the fuse
at the rear of the IEC connector.
Take great care when making the
connections to the mains socket (GPO).
In particular, be sure to run the leads
to their correct terminals (the GPO
has the A, N and E terminals clearly
labelled) and do the screws up nice
and tight so that the leads are held
securely. Similarly, make sure that
the leads to CON2 are firmly secured.
Testing
Before applying power, check your
wiring carefully and ensure that all
mains connections are covered in heatshrink tubing. Then install the 10A
fuse inside the fuse holder. Leave IC1
out of its socket for the time being.
The Remote Mains Switch will be
operated with the lid open when testing and making adjustments. During
Fig.6: the lid needs to be drilled for the GPO socket, neon indicator and switch S1, while one side of the ABS
enclosure needs to be drilled and shaped for the mains switch and IEC connector.
siliconchip.com.au
Australia's electronics magazine
August 2022 85
Assembling the receiver is not difficult, but make sure you use mains-rated wire in the correct colours and add insulation
and cable ties, as shown here and in the wiring diagram.
this procedure, you must not touch any
of the 230V AC wiring. This includes
the transformer primary leads plus all
wiring to the mains socket, neon lamp,
switch S1, the IEC connector, the relay
and CON2. Although all connections
are insulated, it’s wise to be careful.
In particular, note that the relay’s
contact connections, the fuse holder’s
terminals and switch (S2) could potentially all be at 230V AC. That applies
whenever the device is plugged into
the mains, even with switch S2 and
the relay off.
If your premises does not have a
safety switch (Earth leakage detector, residual current detector or RCD)
installed, consider using a portable
safety switch for this part of the test.
Rotate the timer trimpot (VR1) fully
clockwise and apply power. Use your
DMM probes to check for 5V DC (4.95.1V is acceptable) between pins 1 &
20 of IC1’s socket. If this is correct,
switch off, disconnect the mains plug
from the wall socket and install IC1.
Take care to ensure that IC1 goes in
the right way around – refer to Fig.4.
86
Silicon Chip
Power the circuit back up and, with
your DMM set to read DC volts, adjust
multi-turn trimpot VR2 so that the
voltage between TP2 and TP GND is
around 3V. This ensures that the relay
can switch on so that you can proceed
with calibration.
Next, set the DMM to a high AC
voltage range suitable for measuring
mains voltage and carefully check the
voltage between the Active and Neutral sides of the CON2 screw terminal
Australia's electronics magazine
block. Press switch S1 to turn on the
relay, set your DMM to read low DC
volts again and adjust multi-turn trimpot VR2 until the DC voltage between
TP2 and TP GND is 1% of the mains
voltage reading you got earlier.
For example, if you measured 250V
AC, adjust VR2 for a reading of 2.50V
DC at TP2. Alternatively, if the mains
voltage was 230V AC, set VR2 for a
reading of 2.30V at TP2. This sets the
brownout cut-out level to 192V AC.
siliconchip.com.au
The Acknowledge LED will light
continuously during a brownout. The
relay can only be switched on again
via a (registered) remote transmitter
or the switch on the receiver once
the mains voltage has recovered after
a brownout.
Now that you’ve calibrated the unit,
you can set jumper options JP1-JP3
and adjust the timer with VR1 (see
Tables 1-4).
Fig.7: you can either
copy the front panel
label from here, or
download it from
siliconchip.com.au/
Shop/11/6418
Registering a transmitter
When registering a transmitter and
for regular use, it is essential to have
the transmitter and receiver apart by
at least 1.5 metres. If the transmitter
is closer than this, it could overload
the UHF receiver and corrupt the signal, leading to incorrect registration or
intermittent remote control operation.
To register the transmitter with the
receiver, press Learn switch S2 on
the receiver. The Learn LED (LED1)
will light. On the transmitter, remove
the cell from its holder and reinsert it
while pressing and holding switch S1.
This will set the transmitter to Synchronisation mode (with the acknowledge LED lit) and send the registering
code when S1 on the transmitter is
released and then pressed again.
The rolling code is continuously
updated during the synchronisation
time between when S1 is released and
it is pressed again. This randomises the
rolling code generation sequence to an
undetermined point, due to the rapid
rate that the code is recalculated – on
average, around 500 times per second.
The rolling code sequence is then
well into its generating sequence. This
makes it hard to guess the code based
on possible MUI values, even if the
initial seed value for the code generation is known.
The acknowledge LED on the
receiver will flash twice, and the Learn
LED will extinguish once registration
is complete. Test the transmitter and
check that the receiver responds by
switching the relay on and off. It will
take a couple of attempts before the
transmitter and receiver start working together.
De-registering a lost
transmitter
Any transmitter that has been registered can be prevented from operating
the receiver, for example, if a transmitter is lost and you don’t want it to be
used by an unauthorised person.
Deregister the lost transmitter by
selecting the transmitter identity using
BCD switch S4. The switch is labelled
0 to F; the labels A-F correspond to
identities 10-15. Then press and hold
the Clear switch (S3) for more than
one second. The Clear LED will light
initially, then extinguish after S3 is
Table 1 – JP3 settings
released and the transmitter is deregistered.
If you are unsure of the identity of
the lost transmitter, you can deregister all the registered transmitters, one
at a time, then re-register the required
transmitters again.
Jumper options
There are three jumper positions on
the receiver board, and we’ve reproduced Tables 1 – 4 from last month, so
you can recall what they do. JP1 selects
the timer length multiplier (see Table
3). The range is 250ms to 60s with JP1
out (the x1 range) or 60s to 4.5 hours
with JP1 in (the x255 range). Table 4
shows typical timeouts versus TP1
voltages as trimpot VR1 is adjusted.
JP2 affects the function of the buttons on the remote control, as shown
in Table 2. JP3 affects the function of
switch S1 on the receiver, as shown
SC
in Table 1.
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
August 2022 87
|