You are on page 1of 9


Circuit Boards and Software for Heart Rate and Galvanic Skin
Response Measurements
Jon Spaulding
Undergraduate researcher (UROP) report
Synthetic Neurobiology, MIT Media Lab,
January 7, 2009

This undergraduate research project report demonstrates methods

developed to measure the heart rate and skin conductance of a
subject. Schematics and formulae will be presented. The method
for detecting heart rate is fairly straightforward, using a simply
operational amplifier and some single pole filters. The method
developed for GSR uses a logarithmic amplifier to provide a
reading for skin resistances up to 10 Mohm. This paper will also
briefly discuss the digitization methods used to transfer the
analog data to a computer as well as past methods for GSR
measurement which simply were not robust enough for our

1 Heart Rate Sensor

The EKG measures the electrical changes in the body through a heartbeat. Two electrodes (one on each hand) measure the electrical signals on different sides of the body.
A third reference electrode (on the pinky instead of the traditional right leg) sets the
ground for the system. The EKG signal is very low frequency. A typical heart beat
can be from about 40 bpm to 150 bpm. This corresponds to about a 0.66-3 Hz range.
This is nice as not very much noise is found within this range (so filtering is a much
easier process on the output). The EAGLE schematic corresponding to this design is
EKGv1.2. Electrodes were purchased from Mindpeak (printed screen image from the
order is included in the Images folder).

Figure 1: EKG Schematic


Circuit Description

The two hand electrodes are first run through an instrumentation amplifier. An in-amp
was chosen as it provides a very high common mode rejection ration (CMRR). This
means that all signals which are common to both inputs are greatly attenuated. This

includes 60 Hz noise which is inherent in the environment. Without a high CMRR, the
signals would be mixed in with high noise. The instrumentation amp also provides a
gain of 5 which is set by R1
Gain = 1 +
After this point, our signal simply needs to be amplified and further filtered. The signal
will pass through a series of filters provided by a quad op-amp. Each of these filters is
a single pole, from the combination of a resistor and capacitor.


Amplifiers and Filters

After the instrumentation amplifier stage, we have a series of filters. These are all
simple first order filters designed to block out unwanted noise. This section makes
heavy use of the equation:
f3dB =
where the 3dB point is the frequency at which the power is diminished by half (I.e.
amplitude down to 0.707 of peak). The 3dB points of the filters are found below. The
gain of each amplifier is defined by the classic R2 /R1 in an inverting form (4 inverting
stages result in correct signs).

2 Skin Conductance
When an individual feels nervous or fearful, their skin will release sweat, which increases the conductivity (1/resistance) of the skin. These changes in resistance can be
observed, and used as a measure of the state of the individual. These changes are a very
slow signal, less than 1 Hz typically. I have not layed out a GSR board for the current
design as of yet.

Figure 2: Current GSR Schematic


Circuit Description and Analysis

This design (see Fig. 2) makes use of the fact that VGS operates on a log scale based
on the current flowing through the transistor, which is in turn based on RL . If we use
the human skin as RL , then we have a device which can measure any skin resistance,
based on this log scale (see derivation below). As skin resistance doesnt take on any
value, we can cap our measurement at say 10Mohm, using a second leg so that we can
use a differential amplifier to get better resolution for the system.
The derivation for the human sensor side is as follows:

IC = IS e VT hermal




ln (VS )
ln (IS )
ln (RL )


As V2 is probably larger than VBE , we drop VBE from the right hand side, and end up
with (3). We then perform a similar analysis, with the variable RL held at 10 Mohm
for a reference value. Let us name these values VGS for the human sensor side, and
VREF for the fixed leg side. Running these into the op-amp configuration shown in
Fig. 2 allows us to yield a total output as:



By changing our RL term, we end up changing VGS logarithmically. This change is

multiplied by a factor of R2 /R4 when it gets to the output.

3 PIC18F Hardware and Design



Once I had my analog signals, I ran them through a PIC18F4550 chip, with an onboard
10-bit ADC and USB module. The PIC was powered through the USB port. The setup
I used can be seen in Fig. 3. To reset the chip, flip the two switches connected to
pins 1 and 37 (switches 1 and 2 on the 4-switch bank). The EAGLE package for this
board is found in the USB directory. All chips were obtained for free as samples from
Microchip. It should be noted that the D+ and D- ports are the USB connections. The
pins below it can be used for serial data transmission. BE VERY CAREFUL. If you
dont have the right capacitor values, the circuit actually wont work.

Figure 3: PIC18F4550 Schematic


MCHPFSUSB Installation

Find and download the MCHPFSUSB package online. My code makes use of the CDC
example project. I use all the same framework, making modifications to the user.c class.
To get a PIC18F chip talking to the computer, use the driver found in the MCHPFSUSB
package. The computer should then recognize the chip as CDC Demo and work from
there. To edit the code and compile it, I used the MPLAB compiler from Microchip.



The PIC makes use of the skeleton code provided in the Microchip MCHPFSUSB
CDC code package. The code will wait until a 1 has been sent to it from some other
system. At this point, it will turn on timers and enable interrupts for Timer0. Timer0
is set to fire an interrupt at 1 KHz. At each interrupt, one of the channels will be read
from. The channels will be interleaved (i.e. read from AN0, then AN1, then from AN0
again). This results in each channel being read at 500 Hz (for two channels), which is
more than enough for the waves we are looking for.
The ADC code comes from the adc.h package. It first opens the ADC using the
OpenADC command, followed by which channel the ADC reads from. It starts the
conversion, waits for the conversion to complete, then reads the result from the ADC
into a temporary int (either hr or gsr). There exists a buffer, which contains a letter
(either H or G depending on the channel) in the beginning. The ADC result is
added to the buffer, and a newline character ends the buffer. The entire buffer is then
placed on the USB line, and sent to the host PC. My user.c file can be found in the same
directory as this documentation, along with a compiled .hex version of my code.

4 Failed Designs (And Why They Failed!)


Wheatstone Bridge GSR

This particular design worked very well for a set skin resistance, or a small dynamic
range. However, it failed for skin conductances which varied by an order of magnitude.
Also, it correlated skin conductances on a 1/x scale, as opposed to a log scale. For these
reasons, the implementation described above was used instead.

Circuit Description

The GSR makes use of a wheatstone bridge to measure the change in conductance
of the skin. Two electrodes are placed on the same hand. One of these should be
connected to ground, this electrode acts as the driven right pinky (or driven right leg)
electrode for the EKG circuit. The other electrode can simply be attached to any fingertip. This circuit makes use of a 5V supply, which needs to stay steady as battery
power diminishes. The power supply is a 9V battery, so a 5V DC DC converter is used
to power the circuit. This 5V power is dropped across the 1K and 9K resistors for a
voltage of 0.5V on the top of the wheatstone bridge. Each leg starts out with a 100
Kohm resistor. On one leg the first (non-ground) electrode is added. On the other leg,

a 400 Kohm resistor goes to ground, where it connects to the driven right pinky electrode. As the conductance of the skin between the two electrodes changes, the current
through that leg of the bridge will have to increase to increase to get a balanced bridge.
In effect, the voltages above the 400K resistor and at the top electrode vary with time,
based on the conductance of the human skin. These two points are run into an opamp, which amplify their difference by a factor of 22. This op amp circuit is the same
configuration used in the new GSR technique (although resistor values are different).

Figure 4: Old GSR Schematic

5 Appendix A. Amplifier Math

This section is just a reminder for the op-amp math used in the differential amplifier
circuits found in the GSR system. This is just so I dont have to re-derive it every time
I want to use the circuit. The numbers [R1 , R4 ] come from Figure 2 with the current
GSR amplifier. V1 is the voltage before R 1, and V2 is the voltage before R4 .
VOut = A[e1 e2 ]

VOut e2
e2 V2

e2 1 +
= VOut
+ V2

VOut R
e2 =
R3 +R4


e2 =

VOut R4 + R3 V2
R3 + R4

e1 =
VOut = A

R2 V1
R1 + R2

R2 V1
R4 VOut
R3 V2

R1 + R2
R3 + R4
R3 + R4

Now if we let R2 = R3 , R1 = R4 , and A = large, we get it to simplify to:

0 = R2 V1 R4 VOut R3 V2
VOut =

(V1 V2 )