This is only a preview of the October 2015 issue of Silicon Chip. You can view 29 of the 96 pages in the full issue, including the advertisments. For full access, purchase the issue for $10.00 or subscribe for access to the latest issues. Items relevant to "Ultra-LD Mk.4 Power Amplifier, Pt.3: 110W Version":
Items relevant to "An Arduino-Based USB Electrocardiogram":
Items relevant to "2-Way Crossover For Senator 10-Inch Loudspeakers":
Purchase a printed copy of this issue for $10.00. |
An Arduino-based USB el
Here’s an easy-to-build Arduino project which will let you take your
own electrocardiogram (ECG) and display it on a laptop PC. The
software lets you read, display, save and print the electrical waveform
generated by your heart – or anyone else’s. It connects to your laptop
via a USB cable, which also provides the low power it needs to operate.
A
N ELECTROCARDIOGRAM or
“ECG” is a piece of medical equipment used to measure and record the
voltages produced as a result of heart
muscle activity.
By attaching a pair of electrodes
(or “leads” as they are known in the
trade) to the skin of your wrists, ankle
or chest, this PC-Driven ECG project
can display, record or print out the
same kind of ECG waveform via your
personal computer.
Why would you want to build one?
54 Silicon Chip
Just looking at the waveforms generated by your heart can be both fun and
educational. You can monitor changes
to your heart under various conditions,
as your heart is affected by many things
including emotions and mental and
physical activity – even breathing.
All of these factors have a demonstrable effect on the heart’s ECG
waveform. Being able to show this
easily, safely and at low cost is an
added bonus.
Professional ECG machines can cost
anything from $5000 up and while
this project is not intended to be used
as a diagnostic device, the displayed,
recorded and printed waveforms are
of a quality approaching that of professional machines.
In many ways, this new ECG Sampler can be seen as a much improved
Mk2 version of the project described
in the February 2005 issue of SILICON
CHIP. The new design is based on a
low-cost Arduino Uno/Freetronics
Eleven microcomputer module, which
siliconchip.com.au
ectrocardiogram
By JIM ROWE
controls the actual sampling and sends
the samples back to the laptop.
Note that to ensure complete safety,
the unit should only be used with a
laptop PC running on batteries and
doisconnected from all other external
devices. It should not be used with a
PC (desktop or laptop) connected to
the 230V mains supply – see warning
panel later in this article.
(1000x/2000x) differential amplifier
input stage, plus a 3-pole low-pass
filter to reduce the sampler’s susceptibility to 50Hz hum.
DISCLAIMER
This project has not been designed for medical diagnosis.
Correct interpretation of ECG
waveforms and tracings is a complex and skilled procedure and
requires proper medical training.
The USB/ECG is presented here
as an instructive and educational
device only. If you are concerned
about the health of your heart,
consult your GP or a heart specialist.
The Arduino and our ECG Sampler
Shield are both powered from the laptop PC via the USB cable, so there’s no
need for a separate power supply. The
total current drawn by the sampler is
less than 65mA.
It’s easy to use, with all the Sampler’s functions controlled by a
Windows-based GUI program running
on the laptop PC and written in Visual
C++. Both the Arduino micro’s firmware program sketch and the Visual
C++ PC program executable can be
downloaded (free for subscribers)
from the SILICON CHIP website: www.
siliconchip.com.au
To allow the laptop to communicate
with the Arduino via a USB cable,
you’ll also have to download and install a special USB virtual COM port
driver. This can be downloaded from
either the main Arduino website or the
Freetronics website.
While you’re hooked up to the
Arduino website, you’ll also need to
download and install the latest version of the Arduino IDE (integrated
development environment) package.
Arduino shield
It does this under the direction of
a small firmware program “sketch”
stored in the micro’s flash memory.
To adapt the Arduino module for sampling the low-level signals picked up
by ECG electrodes, we have designed
a front-end “shield” module which
plugs into the top of the Arduino
module in the usual way.
The shield provides a high-gain
siliconchip.com.au
This is the Arduino shield board that you
have to build. It plugs into an Arduino Uno
or Freetronics Eleven module.
October 2015 55
DIGITAL I/O
K
A
5
6
8
1
2
3
K
A
5
6
7
8
LEDS
4
470Ω
K
SAMPLING
LED2
A
λ
1 µF
6.8 µF
1.2k
20k
1X/2X
AMPLIFIER
IC2a
ARDUINO ECG SAMPLER SHIELD
SC
SHIELDED LEADS
(EQUAL IN LENGTH)
ELECTRODE
2
20 1 5
TO
CON1
INSULATED
RCA PLUGS
ELECTRODE
1
IMPORTANT:
INSULATE ELECTRODE ENDS
OF LEAD SHIELD BRAIDS
10 µF
100nF
CON2
TO
CON2
20k
2.2M
2.2M
1nF
1%
4.7k
0.1%
1 µF
5%
47nF
1nF
1%
4.7k
0.1%
3.0k
+2.5V
HI
LO
2
100Ω
1
4
IC1
AD623ARZ
8
3
7
5
6
3.0k
100nF
BALANCED
INPUT
AMPLIFIER
MMC
GAIN
S1a 2 x100 µF
2
1 µF
100 µF
82Ω
LP FILTER
10k
3
8
1
100nF
SIL HEADER PINS
IN THIS AREA MATE
WITH HEADERS ON
ARDUINO UNO
OR COMPATIBLE
6
11k
IC2: NE5532D
2.7k
+5V
5
LP FILTER
10
S1b
9
HI
LO
SDA
4
AREF
7
IO13
GND
IC2b
IO12
ELECTRODE
LEAD
INPUTS
CON1 1 µF
5%
Fig.1: the ECG Sampler Shield circuit uses just two ICs. The low-level ECG signals from the electrodes are first amplified by differential amplifier IC1, a specialised
instrumentation amplifier. Its output is then low-pass filtered and amplified by op amp IC2a, while IC2b provides additional low-pass filtering to reduce 50Hz hum.
8
3
4
1
IC1, IC2
2
6
5
4
1
2
3
A
7
1N5711W7F
1
4
A5
A4
A3
A2
A1
A0
Vin
GND
8
GND
7
6
5V
3.3V
4
5
RST
IOREF
3
IO11
SCL
1
100 µF
IO10
PWM
2
ANALOG
INPUTS
K
K
IO9
PWM
A
POWER D2
λ LED1 1N5711
W7F
IO8
PWM
A
IO7
2.2k
IO5
IO6
470Ω
PWM
PWM
D1
1N5711
W7F
IO3
IO4
K
PWM
+5V
IO2
POWER
TXD
IO1
L1 100 µH
RXD
IO0
56 Silicon Chip
That’s because you’ll need this to
upload our sampling firmware sketch
to your Arduino micro (more about
all this later).
How it works
As mentioned above, the project is
essentially in two parts: (1) a standard Arduino microcomputer module
which does the ADC (analog-to-digital
conversion) sampling and sends the
samples back to the laptop PC; and
(2) the high-gain ECG Sampler Shield
which you need to build. We’ll discuss
the operation of the shield first.
The muscles of the human body are
controlled by electrochemical impulses which are distributed by the nervous
system. On reaching their destination,
the nerve impulses cause the muscles
to contract and produce much larger
electrical voltages. A small proportion
of these voltages is conducted out to
the surface of the skin, where they can
be detected using sensitive equipment
like an ECG.
Because the heart is a large, complex
group of muscles which contract cyclically in a preset sequence (see panel),
it’s possible to study its overall condition by measuring the amplitude, timing and waveform of the heart muscle
voltage components found on the skin.
This is the reason for capturing ECG
waveforms, which are obtained using
two or more electrodes attached to the
skin via a conductive saline solution
or paste.
Capturing ECG waveforms is quite a
challenge, because the voltage components found on the surface of the skin
are quite low in amplitude – around
1mV peak-to-peak, depending on the
positions of the electrodes and the
resistance between them and the skin.
That’s about 1/10,000th of the voltage
of a standard 9V battery!
So we need to feed these tiny voltages through a high-gain amplifier, to
display or record them. To make the
job that much harder, the tiny voltages
we want to measure are usually completely swamped by 50Hz hum, picked
up by our bodies from the fields surrounding the AC wiring in our homes
and offices etc.
Fortunately, we are only interested
in the voltage differences between the
two electrodes that are being used,
whereas the 50Hz hum picked up by
the electrodes is virtually the same
regardless of their position on the
body. In other words, the 50Hz hum
siliconchip.com.au
siliconchip.com.au
50kW
A1
Fig.2: inside
the AD623ARZ
instrumentation
amplifier. Op
amps A1 & A2 are
matched gain input
stages and these
feed a balanced
subtractor output
stage based on
op amp A3. The
resistors are lasertrimmed to achieve
the required pre
cision.
50kW
50kW
1
Rg
6
A3
50kW
Vout
8
NONINVERTING
INPUT
50kW
A2
OUTPUT
REF
50kW
5
3
AD623ARZ INSTRUMENTATION AMP
leads (or the subject’s body). This is the
purpose of the 1nF bypass capacitors
on each input of IC1 and also the 47nF
capacitor between the two inputs. All
three capacitors form a balanced lowpass filter, in conjunction with the two
4.7kΩ input series resistors.
The rest of the ECG Sampler Shield’s
amplifier and filter circuitry is based
around IC2, an NE5532D dual lownoise op amp. The output from IC1 is
fed to the input of IC2a via a low-pass
filter formed by a series 10kΩ resistor
and a 1µF capacitor, to give a corner
frequency of about 17Hz and an attenuation of about 9dB at 50Hz.
IC2a provides a small amount of
DC VOLTS
INPUT
fixed amplification for the ECG signals. The gain here is 1x or 2x, as set
by switch S1. The LO position of the
switch gives unity gain (1x), while
the HI position provides a gain of 2x.
The overall ECG signal gain for the
two switch positions is thus 1000 and
2000 times, respectively.
IC2b provides additional low-pass
filtering, to further reduce 50Hz hum.
With the R and C values shown, this
filter stage has a corner frequency of
about 15Hz and provides a further attenuation of about 21dB at 50Hz. At
the same time, it has unity gain for the
low-frequency ECG signals.
So at the output of IC2b (pin 7) we
RESET
1
VIN
RESET/PC6
SCL
POWER
CONTROL
AND
5V
REGULATION
AREF
GND
3.3V
VUSB
+5V
SDA
SCLK/PB5
RESET
MISO/PB4
+3.3V
MOSI/PB3
+5V
GND
PD5
GND
VIN
PD4
TX
LED
11
MICRO
USB-B
30
29
ATMEGA PD3
8
16U2
D–
D+
PD2
XTALI
XTAL2
A5
A4
A3
A2
A1
A0
PB2
RX
λ LED
PB1
PB0
10
9
1
2
3
4
5
λ
1
2
ATMEGA
328P
RXD/PD0
TXD/PD1
16MHz
PD7
PD6
9
XTAL1/PB6
PD5
PD4
16MHz
10
28
27
26
25
24
23
XTAL2/PB7
PD3
ADC5/PC5/SCL
PD2
ADC4/PC4/SDA
TXD/PD1
ADC3/PC3
RXD/PD0
19
18
17
16
15
14
13
12
11
6
5
4
3
2
IO13
IO12
IO11/
PWM
IO10/
PWM
IO9/
PWM
IO8
DIGITAL I/O
You can see how this is all done by
referring to the circuit of Fig.1. The
shielded electrode leads are brought
into the ECG Sampler Shield via connectors CON1 & CON2 and then fed
through 1µF capacitors and series
4.7kΩ resistors to the inputs of IC1.
IC1 is an Analog Devices AD623
ARZ, a specialised instrumentation
amplifier offering very highly balanced
differential inputs and hence very
high common-mode signal rejection,
combined with high gain.
A simplified version of the circuitry
inside the AD623 is shown in Fig.2
and it is essentially three op amps in
one: two matched-gain input stages
feeding a balanced “subtractor” output stage. The overall AD623 gain
for differential-mode signals is set
by external resistor Rg, which gives a
gain of 1000 times (60dB) when using
a value of 100Ω.
To ensure that IC1 can deliver maximum undistorted output level (and
to ensure that the Arduino ADC used
for sampling the amplified signals can
handle the largest signal swing), we
connect IC1’s reference signal input
(pin 5) to a low-impedance source
of +2.5V DC (ie, half the 5V supply).
This is provided by a voltage divider
comprising the two 3.0kΩ resistors
and thereby sets the zero-signal output
level of IC1 to the same level. The two
2.2MΩ input bias resistors for IC1 are
also returned to the same +2.5V point.
Since IC1 operates with such a high
gain, we also need to prevent it from
amplifying any stray RF signals that
may be picked up by the electrode
2
POWER
Circuit details
INVERTING
INPUT
ANALOG INPUTS
is a “common mode” signal, while
the tiny ECG voltages are “differential
mode” signals.
By using a highly-balanced differential amplifier as the input stage of
the ECG amplifier, we can cancel out
most of the common-mode 50Hz hum
before the differential ECG voltages are
amplified. By the way, the connections
between the electrodes and your skin
play an extremely important role in
this hum cancellation, because if one
connection is poor, this can upset the
balance of the input amplifier.
Most of the remaining 50Hz signals
are removed by low-pass filtering in
the later stages of the amplifier. So
the output of the amplifier provides
relatively clean amplified ECG signals,
with little residual 50Hz hum.
IO7
IO6/
PWM
IO5/
PWM
IO4/
PWM
IO3/
PWM
IO2/
PWM
IO1/
TXD
IO0/
RXD
ADC2/PC2
ADC1/PC1
ADC0/PC0
Fig.3: block diagram of the Arduino Uno/Freetronics Eleven module. It’s based
on two Atmel microcontroller chips: an ATmega328P and an ATmega16U2.
The 328P micro is used as the module’s main CPU, while the 16U2 handles
communication with the PC via the module’s USB port.
October 2015 57
ELECTROCARDIOGRAM
SAMPLING SHIELD
For Arduino Uno
RXD
TXD
IO2
IO3
IO4
IO5
S1
GAIN
20k
CON1
+IN
1nF
A5
1
A3
1
IC1
623
100 µF
100nF
100Ω
1nF 47nF
100nF
1210
10 µF
2.2M
2.2M
3.0k
82Ω 10k
20k
IC2
5532
4.7k
4.7k
CON2
–IN
A4
D1
A2
1N5711
1N5711
D2
A1
GND
GND
1.2k
100nF
+5V
1 µF
3.0k
MMC
A0
2.7k
11k
2.2k
RST
+3.3V
100 µH
A
IOREF
470Ω
100 µF
H
1 µF
2x100 µF
1 µF
470Ω
LED2
L1
R
102 C
C 52015
15180170
07108151
SILICON
CHIP
A
LED1
POWER
SAMPLING
REV1.2
6.8 µF
C 2015
07108151
IO6
IO7
IO8
IO9
IO11
IO10
I012
GND
IO13
SCL
SDA
AREF
L
1 µF
Fig.4: follow this parts layout diagram to build the shield PCB. Fit the SMD
devices first before installing the larger through-hole components (see text).
Compare this photo with Fig.4 when building the shield PCB. The completed
PCB is shown here plugged into the Arduino module on the case lid.
end up with reasonably clean ECG
signals (although still with some residual 50Hz hum), amplified either
1000 or 2000 times, depending on the
setting of S1.
Diodes D1 & D2, together with the
series 2.2kΩ resistor, ensure that the
amplified ECG output signals fed out
to the Arduino ADC via the A0 pin are
prevented from swinging below -0.3V
or above +5.3V. This is to protect the
Arduino’s ADC input from overload
damage.
The purpose of the second pole of
gain switch S1b is to allow the Arduino
to sense the current switch position,
so that it can inform the software running in the laptop. As shown, S1b’s
rotor is connected to the Arduino’s
58 Silicon Chip
IO7 pin (used as an input), so this
pin is pulled low (ie, to 0V) in the LO
switch position and high (+5V) in the
HI gain position.
The only other main circuit components are indicators LED1 & LED2.
LED1 is a power indicator, to show
that the ECG Sampler is connected to
your laptop and “ready to roll”. LED2
is turned on by the Arduino during
sampling via the IO8 pin, to indicate
that sampling is taking place.
Arduino in brief
Now let’s take a quick look at the
other half of the ECG Sampler: the
Arduino Uno microcomputer module
or its 100% compatible Australian
incarnation, the Freetronics Eleven.
Arduino Uno seems to have been the
one primarily responsible for Arduinos
becoming a worldwide phenomenon
so quickly. The Freetronics Eleven is
a direct equivalent of the latest version
of the Uno, so when we talk about one
we’re also talking about the other.
Basically, they’re a very compact (69
x 54mm) single-PCB microcomputer
based on two Atmel microcontroller
chips: an ATmega328P and an ATmega16U2. The 328P device is used
as the module’s main CPU, while the
16U2 is used to handle communication with the laptop via the module’s
USB port.
There’s not much else, apart from
a few low-level chips used for power
control and regulation.
Inside the 328P there’s a reasonably
fast 8-bit RISC processor with 32 8-bit
working registers, 32K bytes of flash
memory, 1K bytes of EEPROM and 2K
bytes of static RAM. There are also two
8-bit timer/counters, one 16-bit timer/
counter, a real-time counter with its
own oscillator, six PWM channels, six
10-bit ADC input channels, a programmable serial USART, a master/slave
SPI serial interface, an I2C compatible
byte-orientated 2-wire serial interface
and an on-chip analog comparator.
The 16U2 device is actually not far
behind the 328P in capability, with
16K bytes of self-programmable flash
memory, 512 bytes of EEPROM and
512 bytes of internal SRAM. It also provides 8-bit and 16-bit timer/counters,
three 8-bit PWM channels, an analog
comparator and so on.
More importantly, it provides a
full speed USB 2.0 communications
module, with a 48MHz PLL (phaselock loop), 176 bytes of USB DPRAM
for endpoint memory allocation, four
programmable endpoints and the
ability to handle bulk, interrupt and
isochronous transfers with a programmable packet size of up to 64 bytes and
single or double buffering.
Fig.3 shows the simplified Uno/
Eleven configuration. On the right is
the 328P CPU, with its 14 digital I/O
pins brought out on its right and its
six ADC inputs at lower left. It uses a
16MHz crystal for its main clock (on
pins 9 & 10), while a tiny reset switch
is connected to pin 1 (for emergency
use only).
At centre left is the 16U2, with its
USB data pins (29 & 30) connected to
the corresponding pins on the USB
socket. It also uses a 16MHz clock
siliconchip.com.au
crystal, which forms the reference for
the internal PLL (3 x 16MHz = 48MHz)
driving the USB module.
The Uno/Eleven provides a choice
of either deriving its power from the
laptop via the USB cable or from an
external 7-12V DC source via a 2.1mm
concentric power socket (at upper left
in Fig.3). The latter is used mainly
when the Arduino is being used in
free-standing applications, ie, not
connected to a PC.
In the case of the ECG Sampler circuit, we derive power from the laptop
PC via the USB connector.
If you compare the pin header labels of Fig.3 with those at the right
and lower right of the main circuit of
Fig.1, you’ll see how the two parts of
the ECG Sampler are interconnected.
The shield derives its +5V power via
pin 5 of the 8-pin power header and its
earth/0V from pins 6 & 7 of the same
header (plus pin 7 of the 10-pin digital
I/O header).
It provides the amplified ECG signals to pin 1 of the 6-pin Analog Inputs
header (A0/ADC0), while S1b’s switch
rotor connects to pin 8 of the 8-pin
digital I/O header (IO7) and LED2 is
driven from pin 1 of the digital I/O
header (IO8).
When the ECG Sampler is working,
the sequence of events is quite straightforward. Before the PC software initiates sampling, it sends a request to
the Arduino to report the position of
gain switch S1. The Arduino sends
back a 1-character response, giving
that information.
Then, each time the software wants
an ECG sample to be taken, it sends a
1-character “take a sample” command
to the Arduino, which gets its ADC to
take a 10-bit sample of the amplified
ECG signal at its ADC0 input. The
sample value is then sent back to the
laptop, the overall sampling cycle taking less than 4.13ms.
Construction
All the ECG Sampler circuitry,
except for the Arduino Uno/Eleven
microcontroller board, is mounted
on the PCB shield. This is designed
to plug into the top of the Arduino
board in piggyback fashion. The shield
PCB measures 93 x 54mm (only 24mm
longer than the Arduino itself, and the
same width) and is coded 07108151.
The stacked board assembly fits easily
inside a standard diecast aluminium
box measuring 119 x 93 x 34mm.
siliconchip.com.au
Your Heart & Its Electrical Activity
R
T
P
Q
S
ONE HEART BEAT/PUMPING CYCLE
Most people are aware that the
heart is basically a pump which
pushes blood around the body via its
blood vessel “plumbing” – the arteries
and veins.
A typical human adult heart is about
the size of a clenched fist and weighs
about 300 grams. It’s located near
the centre of your chest and pumps
about once per second, although this
can vary widely due to age, fitness,
exertion, health etc.
The pumping action is triggered
mainly by a nerve centre inside the
heart, called the sino-atrial (SA) node.
Each pumping cycle is initiated by a
nerve impulse which starts at the SA
node and spreads downwards through
the heart via preset pathways.
The heart itself is made up of millions of bundles of microscopic muscle
cells, which contract when triggered.
The muscle cells are electrically polarised, like tiny electrolytic capacitors
R
(positive outside, negative inside), and
as the trigger pulse from the SA node
passes through them, they depolarise
briefly and contract.
With each beat of the heart, a
“wave” of depolarisation sweeps from
the top of the heart to the bottom.
Weak voltages produced by this wave
appear on the outside surface of your
skin and can be picked up using electrodes strapped to your wrists, ankle
and the front of your chest. It’s these
voltages (about 1mV peak-to-peak)
which are captured and recorded as
an electrocardiogram or ECG.
The actual shape and amplitude of
the ECG waveform depends on the
individual being monitored and the
positioning of the electrodes but the
general waveform is as shown above.
The initial “P” wave is due to the
heart’s atria (upper input chambers)
depolarising, while the relatively larger
and narrower “QRS complex” section
is due to the much stronger ventricles
(lower output chambers) depolarising.
Finally, the “T” wave is due to repolarisation of the ventricles, ready for
another cycle.
Doctors are able to evaluate a number of heart problems by measuring
the timing of these wave components
and their relative heights. They can
also diagnose problems by comparing the way the wave components
change with the various standard
electrode and lead connections, as
shown below.
L
V1 V2 V3
V4
CHEST
CROSS-SECTION
V5
V6
SINO-ATRIAL
(SA) NODE
HEART
STANDARD
CONNECTION
POINTS
V6
V5
V1
F
V2
V3
V4
LEAD NAME
ELECTRODE 1
ELECTRODE 2
LIMB LEAD 1
L
R
LIMB LEAD II
F
R
LIMB LEAD III
F
L
LEAD aVR
R
L+F
R+F
LEAD aVL
L
LEAD aVF
F
R+L
PRECORDIAL (x6)
V1 — V6
R+L+F
October 2015 59
Fig.5: this diagram shows
how the Arduino module
and the ECG Sampler
Shield board are mounted
on the lid of the case. Note
that the Arduino module
sits on M3 Nylon nuts
which are used as spacers
(do not use metal nuts).
BASE OF 119 x 93 x 34mm DIECAST BOX
(BECOMES THE COVER)
ECG SAMPLER
SHIELD
MODULE
CON2
M3 NUTS
LED1
RFC1
USB MICRO-B
PLUG
15mm x M3
TAPPED
SPACERS
ARDUINO UNO OR
FREETRONICS ELEVEN
ADHESIVE
FEET
CROSS-SECTIONAL VIEW
OF BOX LID
(BECOMES BASE)
M3 NYLON NUTS
(AS SPACERS)
2 x 20mm
M3 SCREWS
The box is used upside down, with
the PCB assembly mounted on the
inside of the box lid and the box itself
lowered down over the assembly to
form a shielded enclosure.
The two RCA connectors (CON1
and CON2) used for the ECG electrode
leads are accessed through two 12mmdiameter holes in one end of the box,
with miniature toggle switch S1 accessible via a 6.5mm-diameter hole in
the same end. The two indicator LEDs
protrude up through a pair of 3.5mm
holes in the “top” of the box, while a
small slot at the far end allows entry
of the USB cable.
Most of the components on the
ECG Sampler’s front-end shield PCB
are surface-mount devices, the exceptions being input connectors CON1
and CON2, mini toggle switch S1, the
two 1µF MKT input capacitors, the
two LEDs and the four SIL headers
used for the interconnections to the
Arduino module.
Fig.4 shows the parts layout on the
shield PCB. We suggest that you fit the
SMD resistors first, followed by the
SMD capacitors and then the diodes
(D1 & D2) and ICs (IC1 & IC2). The
main thing to watch with the diodes
and ICs is to orientate them correctly,
as shown on the overlay.
When these smaller parts have all
been fitted, you’ll find it quite easy to
add the largest SMD component: L1.
The leaded/through-hole parts can
60 Silicon Chip
2 x 10mm
M3 SCREWS
M3 NYLON
NUTS
2 x 6mm
M3 SCREWS
(2 MORE ON TOP OF
ECG SAMPLER PCB)
then be added, taking care to fit CON1
& CON2 so that their moulded spigots
pass down through their corresponding holes, thereby ensuring that each
connector sits flat against the PCB.
Note that you may need to enlarge
the PCB holes to allow this and it may
also be necessary to bend up the centre
earthing pin of each socket to clear the
top of the PCB.
When you’re fitting the two LEDs,
keep their leads quite straight and position each LED so that the underside
of its body is 10mm above the top of
the PCB. A 10mm-wide cardboard
spacer inserted between their leads
can be used to ensure that the LEDs
are soldered in at the correct height.
Finally, the four interconnecting SIL
headers can be added. These mount
on the top of the PCB with their pins
passing down through it and soldered
underneath. Make sure you don’t apply too much solder to the pins themselves though, because they will need
to mate with the SIL sockets on each
side of the Arduino board.
That completes the shield PCB assembly. It can now be placed to one
side while you drill the metal box.
Preparing the box
There aren’t very many holes to be
drilled in the aluminium case but they
must be accurately positioned so that
the PCB assembly will fit without problems. We’ve prepared a drilling and
cutting template for the case and this
diagram can be downloaded in PDF
format from the SILICON CHIP website
and printed out. It can then be attached
to the case and the holes drilled.
Note that it’s best to use a small (eg,
1mm) pilot drill to start the holes to ensure accurate positioning. The 6.5mm
and 12mm-diameter holes in one end
of the box can be initially drilled out
to 4mm and then carefully enlarged to
size using a tapered reamer. The square
cut-out at the other end of the box can
be made by drilling a series of small
holes around the inside perimeter,
then knocking out the piece and filing
the job to a smooth finish.
Mounting the modules
Once the box has been prepared,
you’re ready for the final assembly.
This mainly involves mounting the
two PCB modules on the inside of the
box lid but this needs to be done in a
particular order.
Fig.5 shows how it all goes together.
Just follow this assembly diagram and
the internal photos and you shouldn’t
have any problems.
Begin by attaching M3 x 15mm
tapped spacers to the two holes spaced
18mm apart at one end of the lid. These
should be secured using M3 x 6mm
machine screws, as shown in Fig.5.
That done, feed M3 x 10mm machine screws through the next pair of
holes (spaced 28mm apart) and fit an
siliconchip.com.au
M3 Nylon hex nut on each of these
screws. These Nylon nuts act as short
spacers, to position the Arduino PCB
just clear of the lid.
Similarly, feed M3 x 20mm M3
machine screws through the final two
holes in the lid (spaced 48mm apart)
and fit these with M3 Nylon hex nuts
as well, again to act as short spacers
for the Arduino module.
The next step is to turn the Arduino
module upside down and check that
the mounting lugs on its 2.1mm power
connector don’t protrude down from
the underside of the PCB by more than
about 1.5mm. If they do, trim them
back using a pair of sharp side cutters. This is necessary to ensure that
they don’t contact with the metal lid
when the Arduino module is mounted
in position.
Once that had been done, plug
the USB cable’s micro-B plug into
the matching socket on the Arduino
module. The module can then be fitted to the four mounting screws on the
lid, so that it rests on the four Nylon
nut spacers. A pair of Nylon nuts can
then be fitted to the shorter mounting
screws at one end of the module to
secure it in place.
You won’t be able to fit nuts on the
two longer screws though, because
there isn’t room on the Arduino module for this to be done. Instead, this
end of the assembly is secured later.
The next step is to plug the ECG
Sampler Shield PCB into the Arduino
board, as shown in Fig.5. Make sure
that all the SIL header pins go into the
SIL socket holes on the Arduino. Make
sure also that the mounting holes at the
“LEDs end” of the shield PCB go over
the two M3 x 20mm mounting screws.
Push the shield PCB down until
its input end rests on the two 15mm
spacers. The other end (the LEDs end)
should rest on top of the 2.1mm DC
power socket. Once it’s in position,
attach a pair of M3 hex nuts to the M3
x 20mm mounting screws, to hold both
PCBs in place.
The final step is to use another pair
of M3 x 6mm machine screws to fasten
the input end of the shield PCB to the
two M3 x 15mm spacers. It’s a good
idea to fit a small star lockwasher
under the screw between CON1 and
CON2, to make sure that the screw
makes a good electrical connection
with the earth copper of the PCB.
This connection is used to connect
the metal case to the PCB earth, for
siliconchip.com.au
Fig.5: the photo at top shows the Arduino module (a Freetronics Eleven
has been used) mounted on the case lid, while immediately above is the
completed assembly with the shield board plugged in and secured in place.
proper shielding. Both screws should
be firmly tightened.
Final assembly
Once the lid assembly has been
completed, it can be fitted into the
case. That’s done by first tilting it
at an angle of about 20° at the RCA
connector end, then lowering it into
position so that these connectors and
switch S1 pass through their respective holes in the case. The other end
can then be lowered into position, at
the same time making sure that the two
LEDs on the shield PCB go through
their 3.5mm holes in the base (which
becomes the top).
It’s then simply a matter of screwing the cover and lid together using
Datafelex/Datapol Labels
(1) For Dataflex labels, go to:
www.blanklabels.com.au/index.
php?main_page=product_info&
cPath=49_60&products_id=335
(2) For Datapol labels go to: www.
blanklabels.com.au/index.php?
main_page=product_info&cPath
=49_55&products_id=326
the four supplied countersunk-head
M4 screws.
Front panel
The front panel artwork is available
for download as a PDF file from the
SILICON CHIP website. You can then
October 2015 61
15
40
15
5
40
MATERIAL: 0.15mm BRASS SHIM
DIMENSIONS IN
MILLIMETRES
Fig.6: the electrodes are made using
40 x 40mm pieces of 0.15mm thick
brass shim (see text).
outer sleeve and the earth braid wires
by about 15mm from the end, then fit
a 25mm length of heatshrink sleeving
so that the shield braid cannot make
contact with anything. Only the centre
conductor is soldered to the rear of the
crocodile clip and you will need to remove not more than 5mm of the inner
dielectric insulation before doing this.
This view shows the
completed unit with
the front-panel label
fitted. The electrode
leads are terminated
in RCA connectors.
either print it out and hot-laminate it
to protect against scratches and finger
grease or you can print out a synthetic
Dataflex or Datapol self-adhesive label
(see above panel).
Once you have the label, cut out the
holes for the LEDs with a hobby knife
and then attach it to the case. You can
attach a laminated label using either
double-sided tape or silicone adhesive.
It’s also a good idea to fit four small
self-adhesive rubber or plastic feet to
the box lid (which becomes the base),
so that the heads of the PCB mounting
screws cannot scratch any surface the
unit is placed on.
Electrode leads
Although it’s easy to obtain commercial ECG electrodes at relatively low
cost, this doesn’t seem to be the case
with electrode leads. So regardless of
which type of electrodes you use, the
simplest approach is to make up a pair
of leads yourself.
For this, we suggest you use a 3m
62 Silicon Chip
length of reasonable-quality figure-8
stereo audio cable – the kind with
a decent earth braid around each of
the two centre conductors. Don’t use
“el cheapo” ready-made stereo leads,
because many of them don’t provide
adequate shielding.
The first step is to split the figure-8
cable apart over a distance of about
120mm at one end and fit each lead
with an insulated RCA plug. The other
end of the cable is then split over a
distance of about 1.5m and the leads
connected to the ECG electrodes.
The simplest approach is to fit the
electrode ends of the cable with small
insulated crocodile clips. That’s because this type of clip is the easiest
way to connect commercial ECG electrodes, which all seem to be fitted with
a small metal contact stud. Presumably,
commercial electrode leads have a
matching clip for these studs but small
crocodile clips make a good substitute.
When you’re fitting these clips to
the lead ends, strip back the cable’s
The electrodes
Although you can use the adhesive
electrode pads sold in pharmacies for
use with TENS machines, these are
generally rather expensive. Adhesive
ECG electrode pads are also available
via a number of suppliers on eBay and
these come at a much more reasonable
cost. However, when we tried these
electrodes, they didn’t seem to give a
reliable low-resistance skin connection, resulting in a surprisingly high
level of hum pick-up.
In practice, we found that we could
get much better results using a pair of
simple home-made electrodes, each
made from a 40 x 40mm piece of
0.15mm brass shim. Fig.6 shows the
details. Use tin snips to trim the shims
to size, then make two 15mm-long cuts
along one side of each one, leaving a
10mm space between the two cuts in
the centre.
Next, bend the two ends of the 15 x
5mm strips up and towards each other,
to form a pair of loops as shown in
the diagram. These loops then make
convenient attachment points for the
alligator clip at the end of each lead.
Before they’re used, be sure to snip
off each corner and smooth the edges
with a small file and/or fine garnet
paper, so they won’t scratch the skin.
And that’s it – they are simple to make
siliconchip.com.au
SILICON CHIP
ECG SAMPLER
CONTROL & DISPLAY
APPLICATION
ARDUINO IDE
(NEEDED TO UPLOAD
ECG SKETCH FIRMWARE
TO THE ARDUINO)
WINDOWS OPERATING SYSTEM AND
GUI (GRAPHICAL USER INTERFACE)
ECG
ELECTRODES
ECG SAMPLER
SHIELD
(PCB MODULE)
ARDUINO USB
VIRTUAL COM
PORT DRIVER
(USB
CABLE)
LAPTOP PC
ARDUINO UNO OR
FREETRONICS ELEVEN
(WITH ECG SKETCH
IN FLASH MEMORY)
ECG SAMPLER
Fig.7: the software block diagram. The large box on the left represents a laptop PC running Windows XP/SP3 or later,
while the ECG Sampler unit is shown at right. Follow the instructions in the text to install the software.
and they work extremely well.
Before each electrode is applied to
an ankle or wrist, or any other part of
the human anatomy, both the underside of the electrode and the surface
of the skin should be well moistened
with saline solution, to ensure that a
good low-resistance contact is made.
If you don’t do this, you’ll see a lot of
hum in the ECG traces.
So how do you hold the electrodes
firmly (but not-too-firmly) against the
subject’s skin? The answer is two simple adjustable straps, each made from
a 250mm length of 20mm wide Velcro
felt strip, along with a 50mm length of
the matching hook-strip affixed to the
back of one end of each strip.
In practice, each strap is run around
the subject’s forearm or ankle and
over its electrode, before being pulled
reasonably tight to hold the electrode
in place. It’s simple but it works surprisingly well.
Installing the software
As mentioned earlier, there are a
number of software items that need to
be installed on your laptop in order to
use it to take ECG samples. In addition,
a software “sketch” has to be uploaded
to the Arduino in the ECG Sampler so
that it can carry out its tasks.
Fig.7 shows the software block diagram. The large box on the left represents a laptop PC, with its Windows XP/
SP3 or later operating system and GUI
shown at lower left. The ECG Sampler
is shown on the right, linked to the
laptop via a USB cable.
The ECG Sampler Application (upper left of Fig.7) needs to be installed
on the laptop, together with a virtual
COM port driver (lower right, in the PC
siliconchip.com.au
box) to allow it to communicate with
the Arduino module. These are the two
main items of software required in the
laptop for the ECG Sampler to run.
However, there’s another item of
software which needs to be installed
on your laptop, at least temporarily:
the Arduino IDE. This is needed so
that you can upload the ECG Sampler
sketch to the Arduino.
We suggest that you download and
install this software in the following
order:
(1) Download the Arduino IDE from
the main Arduino website at https://
www.arduino.cc/en/Main/Software
We used the 1.6.5-r2-windows.exe version of the IDE but there may be a later
version available by the time you read
this. There’s also a zipped-up version.
When you download and install the
Arduino IDE, it comes with a USB virtual COM port driver to suit the Arduino
Uno. This is installed in the /Drivers
folder of the IDE installation. As a result, if you are using an Arduino Uno in
your ECG Sampler, you’ll already have
its matching USB port driver.
Alternatively, if you’re using a
Freetronics Eleven, you will have to
download the matching USB driver
from http://www.freetronics.com.au
At the time of writing, this was in a
zip file named FreetronicsUSBDrivers_v2.2.zip. After downloading it,
unzip it into a folder so that it’s ready
for installation – see below.
(2) Plug the cable from your ECG
Sampler into one of the USB ports on
your laptop. The ECG Sampler’s power
LED should immediately light but the
Windows OS will probably flag a problem, indicating an error when it tried
to install the driver for this “new and
SAFETY WARNING
To ensure complete safety, this
ECG Sampler should be used only
with a battery-powered laptop PC;
ie, one that’s NOT connected to the
mains via its charger. You should
also disconnect all external cable
connections to the laptop, eg, printers and network cables.
Do NOT use it with a desktop or
laptop PC that’s connected to the
230VAC mains, either directly or
indirectly.
These precautions are necessary to eliminate the remote possibility that a fault in the power
supply of a mains-powered device
could result in a high AC voltage
being applied to the electrodes.
unknown” device. Even if this doesn’t
happen, you still have to install the
correct driver, though.
(3) Go to Control Panel on the laptop
and then to Device Manager. This
will show an error icon alongside an
“Unknown device” listing. If you rightclick this item and open Properties,
you’ll see that the problem lies with
the driver for the device – it’s either not
properly working or not installed at all.
To install the driver, click on the
“Driver” tab, select “Update Driver”
and then click “Browse my computer
for driver software”. You then browse
to either the /Drivers folder of your Arduino IDE installation (to get Arduino’s
Uno driver) or to the folder where you
unzipped the Freetronics driver (to get
the Freetronics Eleven driver).
In either case, you should be able to
October 2015 63
Fig.8: this screen grab shows the ECG Sampler program running in Windows 7 on a laptop PC and displaying a typical
ECG waveform. The tiny regular oscillatory noise component in each cycle is residual 50Hz hum.
see the .inf file that Windows needs to
install the new USB driver. When you
return to the Device Manager, Windows
should be able to install the driver and
you should then see the “This device
is working properly” message.
(4) Point your web browser to www.
siliconchip.com.au and download
both the Windows software for the
ECG Sampler (SiliconChipECGSamplerSetup.zip) and the matching
Arduino firmware sketch (sketch_for_
ECGSampler.ino). These files should
be saved in your /Documents folder, in
a sub-folder called /Arduino sketches.
(5) Launch the Arduino IDE and
direct it to that sub-folder to find the
sketch. Open this and upload it to the
flash memory in your ECG Sampler’s
Arduino (you’ll find this process is
quite straightforward).
(6) Finally, unzip the SiliconChipECGSamplerSetup.zip file and
double-click the .msi file to install our
Windows ECG Sampler application.
That’s it – you should now be ready
to roll with your new ECG Sampler.
Taking an ECG
Apart from the Sampler’s gain
switch, which is set to either LOW
(1000) or HIGH (2000), all functions of
the USB/ECG Sampler are controlled
using the ECG Sampler program. This
is easy to use because when you fire
it up, it provides a GUI window (see
Fig.8) which provides combo-box buttons along the top so you can set the
sampling configuration: the Baud rate
to be used (115,200) for communication with the Sampler, the COM port
it’s connected to (usually either COM3
or COM4) and the sampling time you
want (5, 10 or 20 seconds).
You then start an ECG recording simply by clicking on the “Start Sampling”
button. The software then shows a
progress bar at the top of the application window and a sample plot display
which “grows” in the accompanying
graph graticule.
As shown on Fig.8, there are two
drop-down menus at the top, with the
familiar labels “File” and “About”. As
usual, the first menu gives you options
for saving, reloading and printing your
ECG recordings, plus an option to close
the application when you’re finished.
The “About” menu item simply brings
up a small dialog box which shows the
version number of the software.
Lead configurations
The electrodes can be held in place on the forearm or on an ankle using
adjustable straps made from Velcro hook and loop material.
64 Silicon Chip
Finally, which lead configuration
should you use, just to take a basic
look at your own ECG or that of someone else?
Our recommendation is that you use
the “Lead II” limb configuration, with
lead 1 connected to the subject’s left
siliconchip.com.au
Parts List
1 PCB, code 07108151, 93 x
53mm
1 set of Arduino stackable shield
headers (1 x 10 pin, 2 x 8 pin, 1
x 6 pin)
1 diecast aluminium box, 119 x 93
x 34mm
1 Arduino Uno or Freetronics
Eleven module
1 USB cable, type A to micro-B
connectors
2 RCA sockets, PCB-mount
(CON1, CON2)
1 100µH 1.6A SMD inductor (L1),
Murata 48101SC (element14
2112367)
1 miniature DPDT toggle switch,
PCB-mount (S1)
2 M3 x 15mm tapped spacers
4 M3 x 6mm machine screws
(round head)
2 M3 x 10mm machine screws
(round head)
2 M3 x 20mm machine screws
(round head)
6 M3 Nylon hex nuts
1 M3 metal hex nut
4 adhesive rubber/plastic
mounting feet, small
ECG electrode parts
2 insulated RCA plugs
3 metres of figure-8 shielded
stereo cable
2 40 x 40mm squares of 0.15mm
brass shim (see text)
ankle and lead 2 connected to their
right wrist or inside forearm. This
usually gives the largest waveform
amplitude, providing your electrodeskin connections are good.
If you get weak waveforms with a
relatively large amount of hum, this
is usually a sign of poor electrode
contact. So take them off, apply a bit
more saline solution and try again.
The exact positioning of the limb
electrodes is not critical, as the limbs
are really just being used as convenient
conductors joined to the four “corners”
of the subject’s trunk. The most important thing is to get the best possible
contact to the skin.
If you want to try some of the chest
positions for the lead 1 electrode, the
electrode positions are then fairly
critical. You really need to have some
medical background to know the right
siliconchip.com.au
2 32mm insulated alligator clips
(one red, one black)
2 50mm lengths of 20mm wide
Velcro hook strip
2 250mm lengths of 20mm wide
Velcro felt strip
2 25mm lengths of 4mm diameter
heatshrink sleeving
Semiconductors
1 AD623ARZ instrumentation op
amp, SOIC-8 package (IC1)
1 NE5532D dual op-amp, SOIC-8
package (IC2)
1 3mm green LED (LED1)
1 3mm red LED (LED2)
2 1N5711W7F Schottky diodes,
SOD-123 package (D1,D2)
Capacitors (1206 SMD)
4 100µF 6.3V X5R ceramic
1 10µF 6.3V X5R ceramic
1 6.8µF 16V X7R ceramic
2 1.0µF 5% 100V MKT (leaded)
2 1.0µF 16V X7R ceramic
3 100nF 16V X7R ceramic
1 47nF 50V X7R ceramic
2 1nF 1% 50V C0G ceramic
Resistors (0.125W, 1%, 1206 SMD)
2 2.2MΩ
1 2.7kΩ
2 20kΩ
1 2.2kΩ
1 11kΩ
1 1.2kΩ
1 10kΩ
2 470Ω
2 4.7kΩ 0.1%
1 100Ω
2 3.0kΩ
1 82Ω
chest electrode positions, so it’s best to
leave this to the professionals.
Note that if lead 1 is used with
a chest electrode, lead 2 should be
connected to electrodes in all three of
the limb positions so that it provides
a “whole body” reference signal. In
practice, this means that you’ll need to
make up at least two more electrodes
and connect them in parallel with
the original lead 2 electrode. That’s
done by connecting the additional
electrodes to the ECG Sampler’s CON2
input socket via leads that are the same
lengths as the original leads.
If you really want to play around
with all the lead configurations, you
might want to make up a set of nine
electrodes and leads, plus a small
switch box to allow you to select any
of the standard lead configurations (see
SC
diagram on page 59) at will.
MaxiMite
miniMaximite
or
MicroMite
Which one do you want?
They’re the beginner’s computers that the
experts love, because they’re so versatile!
And they’ve started a cult following around the
world from Afghanistan to Zanzibar!
Very low cost, easy to program, easy to use –
the Maximite, miniMaximite and the Micromite
are the perfect D-I-Y computers for every level.
Read the articles – and you’ll be convinced . . .
You’ll find the articles at:
siliconchip.com.au/Project/Graham/Mite
Maximite: Mar, Apr, May 2011
miniMaximite: Nov 2011
Colour MaxiMite: Sept, Oct 2012
MicroMite: May, June 2014
plus loads of Circuit Notebook ideas!
PCBs & Micros available from On-Line Shop
LOOKING
FOR A
PCB?
PCBs for most recent (>2010)
SILICON CHIP projects are
available from the
SILICON CHIP On-Line Shop
– see the On-Line Shop pages
in this issue or log onto
siliconchip.com.au/PCBs
You’ll also find some of
the hard-to-get components
to build your SILICON CHIP
project, back issues,
software, panels, binders,
books, DVDs and much more!
Please note: the SILICON CHIP On-Line Shop
does not sell kits; for these, please
refer to kit supplier’s adverts in this issue.
October 2015 65
|