This is only a preview of the January 2019 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 "DAB+ Tuner with FM & AM and a touchscreen interface!":
Items relevant to "ATtiny816 Breakout and Development Board with capacitive touch":
Items relevant to "Zero Risk Serial Link":
Items relevant to "The PicoPi Pro Robot":
Purchase a printed copy of this issue for $10.00. |
ZERO RISK
SERIAL LINK
by
Tim Blythman
Want to communicate with and/or program a micro that’s connected to
mains or a high-voltage supply? Hmmmm . . . r-i-s-k-y – not just to the
device, but to you as well! Here’s the SAFE way to do it!
B
ecause small computer boards
like the Micromite, Arduino
and Raspberry Pi are so flexible, chances are you will eventually
find yourself using them to control
some mains-powered or high voltage
battery-powered circuitry.
But there’s always the risk that those
higher voltages could find their way
back to your computer, doing untold
damage – and in the worst case, it
could be YOU that suffers the untold
damage!
This nifty little project allows you
to send serial data over an optically
isolated link, entirely preventing the
dreaded 230V-in-the-USB-socket syndrome.
It can be used for programming the
project you are working on, or for monitoring and feedback from a finished
project to your computer.
Either way, it provides total isolation.
It can also translate 5V serial signals
to 3.3V and vice versa. You can even
use it to pass data between the USB
ports on two separate computers without having to make an electrical connection between the two, avoiding
the possibility of Earth loops or other
similar problems.
You may have seen our USB Port
Protector project in the May 2018 issue
(siliconchip.com.au/Article/11065). If
so, you’ll understand our motivation
for this project (sob!).
But this provides even better protection for your PC. It doesn’t try to
shunt excessive voltages and currents
– it won’t even let them near your
computer!
We’ve had laptop USB ports fail
while plugged into certain Arduino
work-in-progress projects which involved mains and battery power.
We aren’t exactly sure how it happened, but it appears that some voltages got to certain pins that they were
not supposed to.
We wish we’d had this Isolated Serial Link then; it’s an expensive lesson to learn!
Projects that feature high voltages
and high currents always have the potential for damage to delicate components like microcontrollers and even
computers. Where possible, it is best
to separate the two.
This circuit is simple, easy to build
and does just that.
It’s also useful for situations even
where there are no USB ports involved,
eg, to allow two microcontrollers to
communicate via a serial link, even if
they are running from different supplies which may not share a common
ground.
What does it do, exactly?
The Isolated Serial Link provides two
optoisolated data lines suitable for fullduplex serial data (ie, simultaneous
The isolated serial link is being used to
program an Arduino Uno. While the isolated Serial Link
can provide power, a USB cable (as shown) is used here.
68
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
sending and receiving). Typically,
these connect to the TX and RX pins
of a microcontroller or USB/serial converter, although they could be used to
pass just about any logic-level signal
with a switching frequency up to a bit
over 100kHz.
There is also a third isolated data
line which can be used to get an Arduino (or similar) board to go into programming mode, so that new firmware
data can be sent over the isolated serial link. The board includes circuitry
to automatically generate a reset pulse
on the target board when required.
The board also has an optional
small isolated power supply, capable of providing up to about 100mA
at 5V. This circuit is based around a
555 timer IC driving a Mosfet, which
in turn drives an isolating transformer. This supply can power some (but
not all) Arduino boards without the
need for a separate power supply.
5V and 3.3V isolated outputs are provided, to suit various situations.
Alternatively, you can omit the 555
IC and transformer (and associated
components) and instead mount a
pre-built 5V isolated DC-DC converter module capable of delivering up to
200mA (at 5V and/or 3.3V).
While this module can provide
more current, it is a specialised part
(compared to the generic parts used
in the transformer-based power supply) and its pins are quite close together, so despite its 1kV isolation
rating, it cannot physically provide
the same degree of isolation that the
transformer does.
Shown here
significantly over size for
clarity (actual board size is
74mm square), this version has a
transformer-based power supply (in case
the target PCB doesn’t have its own supply.)
mon; many SILICON CHIP designs use
this arrangement.
But this makes it very difficult to
debug your software since you have
no way of getting feedback on what’s
happening in the microcontroller
while it is powered from the mains;
at least, not safely.
Why do I need one?
Besides the risk that you could have
The advantage of having an Isolated an accidental short between the inSerial Link is that it allows bidirec- coming mains Active and a (suppostional digital communications with edly) low-voltage connection, even
no electrical path for current to flow something as simple as a mains cord
between the two halves of the circuit. or socket with swapped Active and
This can be handy if the two sides Neutral wires (which is not uncommight be at different voltage levels, mon!) could create a lethal situation.
Making connections
whether fixed or changing.
But now, with the Isolated Serial
To connect the external circuitFor example, let’s say that you have Link, you can safely get serial data
ry, the board has two connectors at
designed a circuit which uses a mi- from the microcontroller, even if it’s
the left and two at the right. All four
crocontroller and some other circuit- floating at mains potential, so you can
have pin-outs that match the ubiquiry, which is powered from the mains see what it’s doing.
tous CP2102-based USB/serial modusing a “transformerless” power supIt isn’t just mains circuits where it’s
ule, available from the SILICON CHIP
ply with a current-limiting capacitor useful either.
Online Shop (siliconchip.com.au/
feeding a rectifier. This is quite comFor example, you might have a miShop/7/3543).
crocontroller with its positive rail conOne of the two headnected to the positive
ers on the left side usu- Features & specifications
terminal of a battery,
ally interfaces with
for example, to sim• Provides a fully electrically isola
ted, bi-directional serial link
one of these USB/serial
plify monitoring the
• Galvanic isolation up to several hund
red volts
modules to connect to a
current drawn from
• Baud rates up to 115,200
computer.
that battery via a high• 3.3V or 5V signalling at either end
This module can be
side shunt.
• USB/serial interface module can
plugged in or permaIf the battery bank
be fitted at either end
• Powered from 5V (eg, a USB port
nently soldered to the
is
Earthed, you can’t
)
board, depending on
connect to the micro
• Can be built with isolated 5V & 3.3V
supplies for the remote end
your requirements.
in the usual manner,
• Two isolated power supply options,
either 100mA total or 200mA total
On the other side
as you will short out
siliconchip.com.au
of the board, one of the communications headers will accept a second
CP2102 USB/serial module while the
other can be used to plug in where a
CP2102 module would. Alternatively,
you can just wire up the RX/TX/GND
serial connections using jumper leads.
Australia’s electronics magazine
January 2019 69
Fig.2: a scope
grab showing the
operation of the
circuit in Fig.1.
The yellow trace
shows the input
signal and the
green trace, the
output. Note that
the output rise
time is much
shorter than the
fall time, which
stretches the
length of the
output pulse. The
higher the signal
frequency, the
more this affects
signal integrity.
VccB
OPTOCOUPLER
3
1
SIGNAL
IN
2
SC
NO ELECTRICAL
CONNECTION,
ONLY BY LIGHT
20 1 9
GndA
SIGNAL
OUT
4
RL
GndB
Fig.1: the traditional method of
optoisolating a digital signal.
When the input signal is high,
current flows through the
series current-limiting resistor
and LED, lighting up the
phototransistor, which pulls the
output high. But using a resistor
to pull the output low when
the phototransistor switches off
severely limits switching speed,
allowing it to handle serial
signals up to only 19,200 baud.
the batteries (and that’s a big no-no!).
But if you connect it via the Isolated
Serial Link, that is no longer the case
and you can communicate with and
re-program that micro as usual.
An Isolated Serial Link can even be
useful if both devices are nominally at
the same potential.
If a circuit has more than one ground
connection, there is the potential for
a ground loop which can cause electrical noise, possibly interfering with
the integrity of the serial data or other
signals in the circuit.
The Isolated Serial Link avoids the
introduction of an extra ground connection, thus eliminating the possibility of any ground loops being caused
by the serial connection.
Isolating high-speed digital
signals
The usual method of optocoupling
a digital signal is to apply the incoming signal to the optoisolator’s internal LED via a current-limiting resistor, then connect the output transistor
either as an emitter-follower or as a
common-emitter amplifier, with a pullup or pull-down resistor respectively.
The common-emitter version of this
method is shown in Fig.1.
When the input signal goes high, the
internal LED switches on and the light
it produces causes the output transistor to switch on, connecting the output
to VccB and so pulling it high. When
the input signal goes low and the LED
switches off, resistor RL pulls the output signal line low, to GndB.
Because the output transistor is ac70
Silicon Chip
tuated by light, clear plastic between
it and the LED provides a high degree
of electrical insulation while still allowing signals to travel from one side
to the other.
But there is a problem with this configuration: the output arrangement is
not symmetrical – the transistor pulls
the output up much faster than the resistor can pull it down. You can use a
lower resistor value to speed it up but
that increases current consumption
and you can only lower it so far before you overload the output transistor.
A scope grab of this configuration
operating is shown in Fig.2. The input signal is yellow and the output
signal is green.
You can see how the pulse is
stretched due to the slow switch-off
time, despite a relatively low resistor
value of 220being used (drawing
nearly 25mA when the output is high).
This signal distortion will prevent
the receiving end from decoding the
serial data above a particular data rate.
The fastest baud rate we could achieve
reliably with this arrangement was
19,200 baud.
The common-emitter version of this
circuit would suffer from the opposite
problem, ie, a slow switch-on, resulting in short pulses (“runts”). The outcome is the same: high-speed serial
data will not pass through such a link.
A better method
To solve this without resorting to
specialised high-frequency optoisolators, we are using pairs of optocouplers in a totem-pole configuration, as
Australia’s electronics magazine
shown in Fig.3. One pulls the output
high and the other pulls it low. That
gives fast, symmetrical drive with a
much-reduced supply current.
When the input signal is high, the
upper LED is forward-biased and so
current flows from VccB, through its
output transistor and to the output
signal line, quickly pulling it up. And
when the input signal is low, the bottom LED is forward-biased and so its
associated output transistor quickly
pulls the output signal line low, to
GndB.
Fig.4 is a scope grab of this type of
circuit in operation and as you can see,
the rise and fall times are now essentially symmetrical. While there is a delay of around 5µs, this will not affect
serial decoding as the critical logic level thresholds are delayed consistently.
The 115,200 baud limit of this type
of circuit is because the delay starts to
extend into the next bit time, and at
230,400 baud (the next standard baud
rate), the bits are just over 4µs wide,
meaning the bits overlap and distort.
The only case where this delay
might be a problem at lower baud
rates is if the outgoing data is synchronised with the incoming data, either
through system design or perhaps a
carrier sense bus arbitration design,
where the transmitter is listening in
on the receiver to see that it has full
control of the bus.
But that’s a rare situation. For normal serial communications, the delay
doesn’t matter.
By the way, while it might appear
that there is a risk that the supply rails
siliconchip.com.au
VccA
1
2
SC
2
Fig.4: a scope
grab showing the
same signal as
Fig.2 but using
the coupling
circuit shown
in Fig.3. While
there is a slight
delay between
the incoming
and outgoing
waveforms, the
rise and fall times
are now similar
and short, so the
signal can be
properly decoded
by the receiver at
the output end.
VccB
3
4
3
1
SIGNAL
IN
20 1 9
OPTO1
SIGNAL
OUT
4
OPTO2
GndA
GndB
Fig.3: this shows the push-pull
digital optoisolator configuration
which we’re using instead. It is
a symmetrical arrangement of
two optoisolators in a totem-pole
configuration. When the input signal
is high, the upper optocoupler
conducts, pulling the output signal
high. A low input signal activates
the lower optocoupler, pulling the
output low. This will pass a serial
stream of up to 115,200 baud.
could be shorted out if both optocouplers are switched on simultaneously
(eg, with an open-circuit input), phototransistor current is limited to around
20mA by the light intensity generated
by the LEDs.
With the input floating, the current
through the phototransistors is around
4mA, which is insignificant.
Circuit description
The circuit diagram for the Isolated
Serial Link is shown in Fig.5. Connections are made to the Isolated Serial
Link at one end via either CON1 or
CON2 and at the other end, via either
CON3 or CON4.
We’ll explain the reason for the pairs
of connectors later. At the moment, it’s
easiest to ignore CON2 and CON4 and
just consider the signals and power
flow between CON1 and CON3.
Both ends are essentially interchangeable except for the power flow;
CON1 receives 5V power to operate
the circuit, between pins 1 & 2, while
CON3 delivers 5V and 3.3V to any
connected circuitry, at pins 1 and 6.
Power flows across the isolation barrier from left to right either via transformer T1 or isolated DC/DC converter
module MOD1, depending on which
is fitted.
Serial data signals pass in both
directions in the manner described
earlier, using optocouplers OPTO1OPTO4.
Data delivered to pin 3 of CON1 appears on pin 3 of CON3 and data delivered to pin 4 of CON3 appears on
pin 4 of CON1.
siliconchip.com.au
While these connectors can be
wired to just about any circuit which
uses TTL serial communications, the
pinouts are specifically designed to
suit the cheap and readily available
CP2102 USB/serial bridges. So you
can solder or plug such a device at
either end of the circuit to provide a
USB interface.
You can choose whether the serial
signals at either end have a 3.3V or 5V
swing, to suit the type of device that
you’re connecting. This is selected on
the CON1 side using JP1, and with JP2
for the CON3 side.
Note that when you have one side
operating at 3.3V and the other at 5V,
the optoisolator drive currents are
not the same in both directions but
we haven’t found this to be a problem – after all, you’re usually applying the signal to a digital input pin
on an IC, which has a very high input
impedance.
Reset signal for
micro programming
The fifth optoisolator (OPTO5) is
used to pass the DTR flow control signal from CON1 to CON3.
This is often used with Arduino
boards, to reset the micro and put it
into bootloader mode, so that the chip
can be reprogrammed without any additional user intervention.
The DTR signal from a USB-Serial
converter is high when the device is
idle and no communication is occurring and goes low for the duration of
a transmission.
It does not just pulse low when data
Australia’s electronics magazine
is being transmitted but is usually held
low any time an application has the
serial port open.
On typical Arduino boards, an RC
network converts the DTR positive-tonegative transition from its onboard
USB interface into a brief reset pulse.
But this connection is not “broken
out” for use with external serial ports
or USB/serial converters. However,
the RESET pin connection is available, so if we can generate this reset
pulse from DTR, we can provide the
same function.
That’s precisely what D1 and its associated 10nF capacitor and 220 resistor do. Normally, with DTR high, the
10nF capacitor is discharged and the
DTR pin on CON3 (pin 5) is held high
by a 10kpull-up resistor.
If the DTR pin on CON1 is externally pulled low, this pulse is coupled
through the 10nF capacitor and it powers OPTO5’s internal LED. Its associated phototransistor conducts, pulling the DTR pin on CON3 low briefly.
So if this is connected to the Arduino (or other micro’s) RESET
line, the micro will be reset.
C1 charges up quite quickly and
so after a short time (around 1-2ms),
OPTO5 turns off and the RESET line
is released.
This is shown in scope grab Fig.6,
with the DTR pin of CON1 shown in
yellow and the DTR pin of CON3 in
green. You can see that both traces
drop to 0V around the same time but
the green trace returns to a high level
shortly afterwards.
The reset pin on an Atmega328 miJanuary 2019 71
cro (as used in an Arduino Uno) only
needs to be low for 2.5µs to guarantee a reset, so this pulse is more than
adequate.
Note that this pulse must be shorter than one second for the programming sequence to complete correctly.
D1 discharges the 10nF capacitor
when the DTR pin of CON1 goes high
again.
If this function is not required
and you want to pass the DTR signal
through the isolation barrier unaltered,
simply replace the 10nF capacitor with
a wire link.
Isolated power supply
We’ve provided two means of getting power ‘across the gap’. The simplest approach is to use a self-contained, isolated DC/DC converter module (MOD1), which has a 1kV isolation rating.
In this case, the components in the
blue shaded box at the top of Fig.5
are not needed. The 4.7µF capacitor
at left bypasses its input supply while
REG1’s 1µF bypass capacitor provides
1
D3 1N5819
T1
3
K
IN
K
7
2.4k
REG1 MCP1700
10
K
A
820
D2
1N4148 A
some output filtering for the module.
REG1 at right is a 3.3V low-dropout
regulator which provides a 3.3V rail
for any circuitry connected to CON3
or CON4.
This is included since many USB/
serial converters also provide a 3.3V
supply and it’s useful for powering
certain microcontrollers or other circuitry.
As an alternative to using this module (eg, if you have trouble obtaining
it), we have included the circuitry
in the box at the top of Fig.5, which
8
4
VCC RST
3
OUT
IC1
THR 555
5
CV
2
TRIG GND
DIS
A
1
10nF
4.7 F
GND
D4
1N5819
10 F
K
ZD1
6
1 F
A
Q1
IRF1405
G
1 F
5.1V
4
2
D
OUT
10 F
S
1
NOTE: FIT EITHER MOD1 OR
COMPONENTS IN BLUE SHADED BOX
2
3
4
CON5
CON4
GND 5V GND 5V
IN IN OUT OUT
1
220
CON1
3.3V IN
DTR
RX
TX
GND
5V IN
6
2
5
4
220
2
1
2
TX
GND
5V IN
CON3
3
6
3.3V OUT
5
220
1
4
5
3
4
3
DTR/RESET
4
RX
3
2
TX
220
2
IN
JP2 1
OPTO5 PC817
2
3
JP1
5V 3.3V
SIGNAL LEVEL
1
K
D1
1N4148
2
A
2
3
IRF1405
SIGNAL LEVEL
3
A
K
G
ZD1
1N4148
A
K
GND
OUT
3.3V 5V
4
1N5819
ISOLATED SERIAL LINK
5V OUT
MC P1700
10k
1
GND
1
1
220
2
10nF
SC
3.3V OUT
4
OPTO4 PC817
6
1
20 1 9
6
2
CON2
RX
(DTR)
3
OPTO3 PC817
3
DTR
RX
5
OPTO1 PC817
1
3
4
3.3V IN
TX
4
4
GND
3
OPTO2 PC817
1
5V OUT
2
B0505S
ISOLATED DC/DC
CONVERTER
(MOD1)
A
K
D
D
S
4
PC817
1
2
Fig.5: this circuit of the Isolated Serial Link has the optional isolated power supply at the top (blue box). The alternative
isolated DC/DC module which can be used instead is near the centre (grey box). The isolated bidirectional serial data
link is provided by OPTO1-OPTO4. OPTO5 couples the DTR signal from left to right.
72
Silicon Chip
Australia’s electronics magazine
siliconchip.com.au
comprises a complete isolated power
supply.
If these components are fitted, you
do not need MOD1.
Timer IC1 is configured as an astable
oscillator and it drives the gate of Mosfet Q1, which sinks current through
the primary of transformer T1 in brief
pulses. These induce pulses of current through the secondary winding,
which are rectified using schottky diodes D3 and D4 to produce a ~6V DC
rail, which is then regulated to 5V by
zener diode ZD1.
IC1 uses pretty much the traditional
method for a 555-based oscillator except that we’ve added diode D2 from
pin 7 (discharge) to pins 2 & 6 (trigger/threshold) to reduce its duty cycle
below 50%.
That’s necessary to limit the output voltage at the secondary of
T1 to an appropriate level and
also to keep current consumption reasonable (around 100mA).
IC1 uses a 10nF timing capacitor
which is charged up via the 820 resistor and diode D2 when IC1’s output
pin 3 is high.
IC1’s off time is determined by the
2.4kresistor and 10nF capacitor, as
the discharge pin (pin 7) goes low
when output pin 3 is low, so the 820
resistor and D2 do not affect the capacitor discharge rate.
The result is a square wave with a
high period of around 8µs and a low
period of around 15µs, giving a frequency of around 40kHz.
Schottky diodes are used to rectify
the output of transformer T1 to minimise power loss, as they have a lower
forward voltage and faster switching
Fig.6: the yellow
trace is the signal
applied to the DTR
pin of CON1 while
the green trace shows
the signal at the DTR/
RESET pin of CON3.
The falling edge
of the DTR input
generates a 1-2ms
low pulse at the reset
output, which can
be used to reset the
microcontroller in an
Arduino-compatible
board, activating
its bootloader and
allowing the chip to
be reprogrammed.
CON1 and CON2 are wired identically. They are both included to provide you with different options for
making connections to the board. You
would generally fit one or the other
but not both.
CON1 is near the edge of the board
and you can fit a male or female six-pin
header which may be vertical or horizontal (eg, using a right-angle type).
We recommend fitting a horizontal
female header socket to CON1. You
can use a vertical socket but bend its
leads by 90° before fitting it. It is then
possible to plug a CP2102 module fit-
ted with a right-angle male pin header into this socket (see below). Or you
can plug jumper leads into the header.
CON2 is placed further inboard and
can be used when mounting a CP2102
USB/serial converter module directly
on the board. In this case, you would
fit a vertical header and then solder
the CP2102 module on top.
Turning now to CON3 and CON4 on
the opposite side of the board, these
are arranged slightly differently. For
a start, they are reversed compared to
each other but also, the TX and RX pins
are reversed between them.
So if you fit a male pin header to
CON3 (ideally a right-angle type), it
has the same pinout as a CP2102 module. So by fitting a CP2102 to CON1/
CON2, the Isolated Serial Link is essentially “transparent” and you can
treat it as a simple CP2102 module, but
with the added isolation layer.
You could also fit some other type
The Isolated Serial Link can be used as a “null modem” to allow
communication between two computers. Note that two USB/serial converter
modules are needed for this application. Since each side is supplied with power,
the power transfer circuitry is also unnecessary.
ERRATA:
When using the Isolated Serial Link for isolating circuitry floating at mains potential,
the following precautions must be observed:
1) It must be mounted in an Earthed metal
or double-insulated case before connecting
it to the mains-powered equipment (ideally,
within the same enclosure). Only the isolated connections should be brought outside
the case. If mounting in a separate
case, the wiring to the mains-powered
equipment must be mains-rated and
properly insulated at both ends.
2) Either omit the isolated power supply
circuitry or build the version using MOD1,
not transformer T1.
3) If using MOD1, lengthen the slot underneath it until it nearly touches OPTO1 (the
slot is already lengthened on RevH boards).
siliconchip.com.au
than typical silicon types. The 5V rail
at the cathode of ZD1 is not only fed
to the 5V output pins of CON3 and
CON4 but also to the input of regulator REG1, which as mentioned earlier, supplies the 3.3V output pins on
CON3 and CON4.
Connector options
Australia’s electronics magazine
January 2019 73
D3
T1
820
5819
D4
5819
2.4k
10
D2
4148
IC1
555
ZD1
5.1
10 F
10nF
4.7 F
10 F
4.7 F
Q1 IRF1405
1 F 1 F
OPTO1
220
220
JP1
OPTO2
REG1
SILICON
CHIP
CON4
220
10nF
220
OPTO4
OPTO5
MCP1700-3.3
+5V
GND
TXD
RXD
220
5V 3.3V
CON3
10k
24107181
+5V
220
JP1
3.3V5V
3.3V
5V
+3.3V
DTR/RST
RXD
TXD
GND
+5V
1 F 1 F
OPTO1
220
+3.3V
JP2
OPTO3
3.3V 5V
3.3V5V
CON2
CON1
+3.3V
DTR
RXD
TXD
GND
+5V
MOD1 B0505S
MCP1700-3.3
USB to UART
+3.3V
SERIAL
DTR
RXD
CP2102
TXD
GND
CONVERTER
+5V
OPTO2
REG1
CP2102
DTR
RXI
TXO
10nF
220
OPTO4
OPTO5
GND
+5V
RXI
DTR
3.3V
CONVERTER
JP2
220
CON2
USB to UART
SERIAL
TXO
SILICON
CHIP
CON4
OPTO3
3.3V
GND
220
5V 3.3V
CON3
10k
24107181
+3.3V
DTR/RST
RXD
TXD
GND
+5V
Fig.7: this shows where to fit the components for the
version of the Isolated Serial Link which uses a transformer to provide isolated power to circuits connected via
CON3 or CON4, drawing power from CON1 or CON2. This
shows all four connectors fitted but you don’t have to fit
them all – and you can also use different types, to suit your
application.
Fig.8: if you’re building the version which uses the isolated
DC/DC converter module (MOD1) instead of transformer
T1 and associated components then you only need to fit the
parts shown here. This time we’re showing a CP2102-based
USB/serial module mounted on the board via CON2 and
another plugged into CON4 but that’s just an example of
how you can use it.
of header to CON3 and wire it up to another board using
jumper leads.
Alternatively, you can fit a female socket for CON4
(right-angle preferred), you can then plug a CP2102 module in, potentially giving you a USB socket at both ends
of the module.
That is why the TX and RX pins are reversed; the two
sides can then communicate with each other normally.
This is a bit like the old “null modem” cables (remember them?) that allowed two computers to communicate
via their serial ports.
Note though that if you do fit a CP2102 to the right-hand
side of the module, it will provide the 3.3V and 5V supplies, so you should leave out all the power supply circuitry on the Isolated Serial Link board (including both
T1 and MOD1) so that they do not try to “fight” each other.
Because the DTR/RST signal is not useful in this configuration, it isn’t connected to CON4 at all. It’s up to you
whether you want to leave D1 and its associated capacitor
and resistor off the board, since they won’t be used.
In the absence of a commercial model, we wound our own
transformer using a 5A 100µH toroidal inductor. After
insulating the winding with tape, we wound on a secondary
which matched the number of turns on the “primary”.
74
Silicon Chip
Winding the transformer
Since we couldn’t find a suitably small transformer for
T1, we decided to make one ourselves, starting with a prewound inductor, which forms the primary. The secondary
is then wound on top.
If you are building the unit with the isolated DC/DC converter module, you can skip to the next section.
Start with a 3A or 5A 100µH toroidal inductor (we used
Jaycar Cat LF1270). Take a roll of electrical tape and cut
it into lengths of approximately 250mm, then cut those in
half lengthwise, so you have two thin strips.
The completed transformer is held in place on the PCB
with a pair of small cable ties through the holes provided.
Cut the excess from the ties on the underside of the board.
Don’t use wires to hold it in place because they could form
shorted turns and seriously degrade performance.
Australia’s electronics magazine
siliconchip.com.au
Parts List – Isolated Serial Link
4.7 F
+5V
GND
OPTO1
220
220
JP1
3.3V5V
3.3V
5V
USB to UART
+3.3V
SERIAL
DTR
RXD
CP2102
TXD
GND
CONVERTER
+5V
TXO
CP2102
OPTO2
SILICON
CHIP
CON4
220
CON2
DTR
RXI
TXO
10nF
220
GND
+5V
OPTO4
OPTO5
RXI
DTR
3.3V
CONVERTER
JP2
OPTO3
3.3V
USB to UART
SERIAL
220
5V 3.3V
CON3
10k
24107181
+3.3V
DTR/RST
RXD
TXD
GND
+5V
Fig.9: this shows which components you need to install
if you’re supplying 5V power to both sides of the board,
and do not need an isolated supply to transfer power from
CON1/CON2 to CON3/CON4. For example, you would
use this configuration if you’re connecting a USB/serial
converter module at both ends, as shown here.
Wind those strips around the inductor with a slight overlap, forming a complete isolation barrier over the windings,
except for two small areas where the leads emerge.
Next, cut a 2m length of 0.4mm diameter enamelled copper wire. It’s important to start with the correct length; if
it’s too short you won’t have enough wire, and if it’s too
long, it will be difficult to wind.
If you start with a different inductor, you may need to
wind on a different number of turns and will, therefore,
need a different length of wire. The number of turns you
add should match the number of turns already on the inductor (which will become the primary winding).
Starting winding on the opposite side of the core to the
existing leads, so that the tails will match up with the pads
on the PCB. Leave about 25mm of free wire to connect to
the PCB, then wind 50 turns on top of the existing windings, keeping them as tight as possible.
The direction of winding is unimportant, as the output
is rectified.
When finished, cut the remaining wire to match the
25mm initial length, then scrape about 5mm of the enamel
off the ends of the two leads and tin them.
PCB assembly
Fig.7 shows where to fit the components on the PCB for
the version using the transformer to pass power across the
isolation barrier. If you are building the version that uses
the DC/DC converter module, refer to Fig.8 instead.
Fig.9 shows how to assemble the PCB if you have 3.3V
or 5V DC power available at both ends of the Isolated Serial Link.
All three versions are built using the same PCB,
which is coded 24107181 and measures 74 x 74mm.
The following instructions describe fitting all the parts;
ignore the instructions to fit any components which your
version does not require.
Start by soldering the resistors in place. It’s a good idea
siliconchip.com.au
1 double-sided PCB coded 24107181, 74mm x 74mm
2 6-pin female headers (CON1,CON4) [Altronics P5374]
2 6-pin male headers (CON2,CON3)
[Altronics P5430, Jaycar HM3212]
2 3-way pin headers with jumper shunts (JP1,JP2) [Altronics
P5430 and P5450 or Jaycar HM3212 and HM3240]
Capacitors
1 4.7µF 16V electrolytic capacitor
2 1µF MKT or multi-layer ceramic
1 10nF MKT
Semiconductors
5 PC817 opto-isolators (OPTO1-OPTO5) [element14]
1 MCP1700-3.3V LDO 3.3V regulator, TO-92 (REG1)
1 1N4148 signal diode (D1)
Resistors (all 1% 1/4W metal film)
1 10kW
5 220W resistor
Extra parts for version using MOD1 (optional)
1 B0505S-1W 5V-5V DC-DC isolated converter or
LME0505SC [element14] or RFM-0505S [Mouser]
Extra parts for version using T1
1 100µH 5A toroidal powdered iron inductor (T1) [Jaycar
LF1270]
1 2m length of 0.4mm diameter enamelled copper wire (T1)
2 small cable ties
1 NE555 or equivalent timer IC, DIP-8 (IC1)
1 IRF1405 N-Channel Mosfet, TO-220 (Q1)
[Jaycar ZT2468, Altronics Z1545]
1 5.1V 1N4733 Zener Diode (ZD1)
[Jaycar ZR1403, Altronics Z0614]
1 1N4148 signal diode (D2)
2 1N5819 1A schottky diodes (D3,D4)
2 10µF 16V electrolytic capacitors
1 10nF MKT capacitor
1 2.4kW 1% 1/4W resistor
1 820W 1% 1/4W resistor
1 10W 5% 1/2W resistor
1 500mm length of electrical tape
to check each value using a multimeter before fitting them,
as the colour bands can be difficult to read. Be sure to trim
all the leads neatly after soldering, as stray leads left over
could potentially compromise the isolation barrier.
Mount the diodes next. D1 and D2 are small 1N4148
types while D3 and D4 are larger schottky diodes. They are
all polarised, so check that each cathode band is facing as
shown on the relevant overlay diagram before soldering it
in place. Note that D3 and D4 face in opposite directions.
There is also one zener diode, ZD1, and now is
a good time to fit it, with the orientation as shown.
The five optoisolators can be mounted next. They are not
all orientated the same way. OPTO1, OPTO2 and OPTO5
have their pin 1 facing the top of the board while OPTO3
and OPTO4 have the opposite orientation.
Line up the dots and notches on the optoisolators with
the PCB and ensure they are sitting flush before soldering
all the pins.
Australia’s electronics magazine
January 2019 75
USB to UART
SERIAL
3.3V
DTR
RXI
CP2102
TXO
GND
CONVERTER
+5V
D3
T1
2.4k
5819
5819
D4
10
D2
4148
820
Fig.10: here’s how to
drive an Arduino
board using the
Isolated Serial Link,
with a CP2102 module
to provide the USB/
serial interface. The
RST pin connection
on the Arduino board
allows the board to be
placed in bootloader
mode, to allow the
host computer to
program the micro.
IC1
555
SC
20 1 9
DC VOLTS
INPUT
SCL
SDA
ZD1
5.1
4.7 F
Q1 IRF1405
10 F
(MOD1 )
220
JP1
MCP1700-3.3
1 F 1 F
OPTO2
REG1
JP2
220
220
OPTO4
OPTO5
+5V
SILICON
CHIP
CON4
220
5V 3.3V
CON3
GND
24107181
The MKT and/or ceramic capacitors are next on the list.
These are not polarised. Install them where shown, then
mount small regulator REG1 with the orientation shown.
You will need to bend its leads to suit the PCB pad pattern
(eg, using small pliers).
Now you can fit the electrolytic capacitors, which
are polarised. The longer lead is positive, so feed it
into the pad marked with a “+” in each case. The
stripe on the can is on the side with the negative lead.
IC1 can be soldered directly to the board (preferred) or
mounted using a socket.
Regardless, the notch in IC1 and the socket should face
towards the bottom of the PCB. You may need to straighten
the IC legs slightly so that they fit through the holes in the
PCB or into the socket.
Next, fit the sockets for CON1-CON4. The exact arrangement used will vary depending on how you are planning to
use the unit. If you are not sure, fit all the sockets as shown
in our photos and on the overlay diagrams and then you
have various options later. Figs.7-10 show some examples
of various ways to use the board. At the same time, solder
the two 3-pin headers for JP1 and JP2 to the board.
Solder the primary windings (made with thicker wire)
to the pads on the left-hand side of transformer T1 with
the thinner secondary connections on the right. Secure the
transformer to the board using two cable ties, through the
holes in the PCB.
If fitting DC/DC converter module MOD1, line up its outline with the footprint marked on the PCB, noting that the
leads are closer to one edge than the other. The component
markings should face towards the middle of the PCB. Solder it in place, keeping it flat and level.
Now mount Q1 with its metal tab facing towards the top
of the PCB, as shown. If you like, it can be bent forward to
sit parallel to the PCB. In this case, the tab will face up. No
heatsink is required.
Using it
Before plugging it in, install the jumper shunts for JP1
and JP2 to match the voltage of the serial signals that will
Silicon Chip
IO 12/MISO
ARDUINO UNO,
UNO ,
DUINOTECH UNO,
FREETRONICS ELEVEN
OR COMPATIBLE
IO 11/MOSI
IO 10/SS
IO 9/PWM
IO8
GND
VIN
IO7
IO 6/PWM
ADC0
IO 5/PWM
ADC1
IO 4/PWM
ADC2
10k
IO 13/SCK
RESET
+3.3V
OPTO3
10nF
GND
+5V
(B0505S)
OPTO1
220
3.3V 5V
3.3V5V
CON2
CON1
+3.3V
DTR
RXD
TXD
GND
+5V
AREF
10 F
10nF
5
3
IO 3/PWM
1
IO 2/PWM
ADC3
ICSP
ADC 4/SDA
ADC 5/SCL
76
USB TYPE B
MICRO
6
4
2
IO 1/TXD
IO 0/RXD
be applied to each side of the board. We found the 5V selection to work best for CP2102 USB/serial modules.
If in doubt, test the voltage of the TX line of the equipment you are planning to connect while it is powered but
not transmitting. Serial data lines usually sit at a high level when idle, so this will give you an accurate reading of
the voltage level.
Typically, you would connect a computer or other device
which can supply power to run the circuit to the left-hand
side of the unit (via CON1 or CON2).
If you have installed either T1 or MOD1, the unit can
supply a modest amount of power to devices connected to
either CON3 or CON4, up to around 100mA at 5V. This is
enough to power something like a bare Arduino board but
it will be overloaded if you try to power a board with a lot
of extra accessories such as an LCD screen or motor.
In this case, you can power the circuit at the “remote”
end using a battery pack, keeping in mind that if you wish
to maintain isolation, no part of the two sides should be
connected. In this case, you only need to make connections
to the following pins on CON3/CON4: RX, TX, GND and
RST (if needed).
It’s always a bit tricky connecting the TX and RX lines between two boards because there are some cases where you
connect the pin labelled TX to TX and other times when you
connect TX to RX, depending on the labelling scheme used.
So to help remove some of the confusion, we’ve printed
small arrows on the PCB (visible in Figs.7-9) which show
the direction of data travel on each pin.
Treating the unit as an isolated CP2102 board
If you have a setup where you would normally use a
CP2102 module to communicate with a device but you need
isolation, you either plug a CP2102 module into CON1 (female header) or solder it to CON2. CON3 then provides a
more-or-less identical function to the original CP2102 pins
except for the added isolation layer.
So if you have a socket which will accept a CP2102 mod-
Australia’s electronics magazine
siliconchip.com.au
ule header, CON3 will have a matching pin-out and can be
used as a direct replacement.
Connecting to an Arduino
This is especially helpful if your Arduino is connected
to circuitry operating at much more than 5V (especially a
battery which can supply a lot of current), or even mains.
The isolation barrier will prevent any accidental shorts or
component failures on the Arduino or any connected modules from damaging your computer.
In this case, we suggest you use the board with a CP2102
USB/serial module attached to either CON1 or CON2. Run
jumper wires from either CON3 or CON4 to the Arduino
board, connected as follows: GND to GND, RX to TX and
TX to RX.
The reason why TX is not connected to TX and
RX to RX is that the signal that is being transmitted by one side is being received by the other.
This arrangement is shown in Fig.10.
To be able to reprogram the Arduino while it is connected over the Isolated Serial Link, you will also need to connect the pin labelled RST on the Isolated Serial Link to the
RST pin on the Arduino.
Note that this will only work with Arduino boards that
communicate via a USB-Serial IC which is separate to the
main processor IC.
We have tested this on the Uno and Mega compatible
boards but it will not work with boards such as the Leonardo because they do not expose their serial programming
lines directly.
Boards such as the Nano should allow programming, as
siliconchip.com.au
they use a similar designto the Uno and Mega, although
we have not tested this.
Other Arduino variants may or may not work, depending on how they are configured.
Note that the power supply built around T1 may be able
to supply enough power to the Arduino during programming but it’s possible that it can’t, as Arduino boards can
be quite power hungry, even when doing nothing.
Using it to connect two computers
To provide an optoisolated link between two computers
(or a computer and Raspberry Pi), you will need to connect two CP2102 modules to the Isolated Serial Link. Connect one to either CON1 or CON2 and the other to CON4.
Since both computers can supply power, none of the
power transfer circuitry is needed. Note that the DTR/RST
signal will not be used either, so OPTO5 and its associated
components could be omitted.
Using other USB/serial converters
While the board was designed to suit CP2102-based modules, other types can be used. Note though that this unit
has been designed to work with TTL level signals, and will
not work with RS-232 voltage level signals.
Just make sure to set the correct voltages on each side
and also connect the correct power and signal connections.
Using jumper wires with socket ends onto the pin headers
is an easy way to do this.
You can even use a minimal amount of cyanoacrylate
glue (superglue) to join the socket ends of the jumper wires
together, to create a removable harness.
SC
Australia’s electronics magazine
January 2019 77
|