circuit boards and software for heart rate and galvanic skin

Upload: jafar-sadiq

Post on 22-Feb-2018

213 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/24/2019 Circuit Boards and Software for Heart Rate and Galvanic Skin

    1/9

    Circuit Boards and Software for Heart Rate and Galvanic Skin

    Response Measurements

    Jon Spaulding

    Synthetic Neurobiology, MIT Media Lab,

    [email protected]

    January 7, 2009

    Abstract

    1

    SYNTHETIC NEUROBIOLOGY MEMO No. 3

    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

    purposes.

    Undergraduate researcher (UROP) report

  • 7/24/2019 Circuit Boards and Software for Heart Rate and Galvanic Skin

    2/9

    1 Heart Rate Sensor

    The EKG measures the electrical changes in the body through a heartbeat. Two elec-

    trodes (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

    1.1 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

    2

  • 7/24/2019 Circuit Boards and Software for Heart Rate and Galvanic Skin

    3/9

    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 byR1

    Gain= 1 +50K

    R1(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.

    1.2 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 = 1

    2RC (2)

    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 classicR

    2

    /R1in an inverting form (4 inverting

    stages result in correct signs).

    3

  • 7/24/2019 Circuit Boards and Software for Heart Rate and Galvanic Skin

    4/9

    2 Skin Conductance

    When an individual feels nervous or fearful, their skin will release sweat, which in-

    creases 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

    2.1 Circuit Description and Analysis

    This design (see Fig. 2) makes use of the fact thatVGSoperates on a log scale basedon the current flowing through the transistor, which is in turn based on RL. If we usethe human skin asRL, 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=ISe

    VBE

    VThermal

    VBE=KT

    q ln

    ICIS

    VBE= KTq ln

    VSVBE

    RLIS

    4

  • 7/24/2019 Circuit Boards and Software for Heart Rate and Galvanic Skin

    5/9

    VBE=KT

    q ln (VS)

    KT

    q ln (IS)

    KT

    q ln (RL) (3)

    AsV2 is probably larger thanVBE, we dropVBEfrom the right hand side, and end upwith (3). We then perform a similar analysis, with the variableRL held at 10 Mohmfor a reference value. Let us name these valuesVGSfor the human sensor side, andVREF for the fixed leg side. Running these into the op-amp configuration shown in

    Fig. 2 allows us to yield a total output as:

    VOUT =R2R4

    (VGS VREF) (4)

    By changing ourRL term, we end up changing VGS logarithmically. This change ismultiplied by a factor ofR2/R4when it gets to the output.

    5

  • 7/24/2019 Circuit Boards and Software for Heart Rate and Galvanic Skin

    6/9

    3 PIC18F Hardware and Design

    3.1 Hardware

    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 topins 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

    6

  • 7/24/2019 Circuit Boards and Software for Heart Rate and Galvanic Skin

    7/9

    3.2 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.

    3.3 Software

    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 ADCinto 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!)

    4.1 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.

    4.1.1 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 fin-

    gertip. 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,

    7

  • 7/24/2019 Circuit Boards and Software for Heart Rate and Galvanic Skin

    8/9

    a 400 Kohm resistor goes to ground, where it connects to the driven right pinky elec-

    trode. 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 op-

    amp, 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

    8

  • 7/24/2019 Circuit Boards and Software for Heart Rate and Galvanic Skin

    9/9

    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 currentGSR amplifier. V1 is the voltage beforeR 1, andV2is the voltage beforeR4.

    VOut = A[e1 e2]VOut e2

    R3

    =

    e2 V2

    r4

    e2

    1 +

    R4R3

    = VOut

    R4R3

    +V2

    e2 =

    VOut

    R4

    R3

    +V2

    R3+R4R3

    e2 =VOutR4+R3V2

    R3+R4

    e1 = R2V1R1+R2

    VOut = A

    R2V1R1+R2

    R4VOutR3+R4

    R3V2R3+R4

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

    0 = R2V1 R4VOut R3V2

    VOut =R2R4

    (V1 V2) (5)

    9