Upside Down Labs BioAmp EXG Pill v0.7 Biopotential AFE: Hardware Overview and Interfacing with Arduino

This post gives you the hardware overview of BioAmp EXG Pill v0.7 and shows how it can be interfaced to Arduino Uno and run the examples to read ECG and heart beat.
CIRCUITSTATE-BioAmp-EXG-Pill-0.7-Interfacing-with-Arduino-Feature-Image
BioAmp EXG Pill v0.7

We had featured Upside Down Labs’ BioAmp EXG Pill in a previous post. EXG Pill is a biopotential Analog Front-End (AFE) designed to sense and amplify physiological signals produced by our body. Physiological signals are low magnitude electrical signals that controls various functions of living bodies such as the functioning of heart and muscles. Depending on the nature of these signals, they are classified to ECG, EEG, EMG etc. With the help of electrodes placed on the body, BioAmp EXG Pill can pick up these feeble signals and amplify them. The amplified signals can be then be fed to a microcontroller to control various input and output devices. Think of turning on a light with your mind, or opening a door or controlling a robotic arm or drone. All that, and many more is possible by non-invasively tapping into our body’s electrical signals.

The awesome people at UDL had sent us two of their BioAmp EXG Pill v0.7 modules for testing. We will test and review them in this post. At the time of writing this post, the version 1.0 of the BioAmp EXG Pill is already running a crowd funding campaign at Crowd Supply. BioAmp EXG Pill is a fully open source hardware project.

Specifications of BioAmp EXG Pill v0.7

  • Working Voltage: 5 V – 40 V
  • Input Impedance: > 35 MΩ
  • Compatible Hardware: Any 5 V MCU/ADC
  • Supported Biopotentials Voltages: ECG, EOG, EMG, and EEG (Configurable)
  • No. of channels: 1
  • Electrodes: 2/3 (Configurable)
  • Dimensions: 25.4 x 10.0 mm
  • Open Source: Hardware + Software
  • Castellated PCB: Yes

Kit Contents

Upside-Down-Labs-BioAmp-EXG-Pill-0.7-Feature-Image-1_2-1
BioAmp EXG Pill kit contents
  • 1/2 x EXG Pill boards
  • 1 x Red Crocodile Clip
  • 2 x Black Crocodile Clips
  • 2 x 3-Pin Straight Header Pins (2.54 mm)
  • 2 x 3-Pin Right-angle Header Pins (2.54 mm)
  • 1 x Red Multi-stranded Wire
  • 2 x Black Multi-stranded Wire
  • 3 x Rectangular Gel Electrodes

Schematic

Upside-Down-Labs-BioAmp-EXGPill-v0.7-Schematic-1_1
BioAmp EXG Pill v0.7 schematic.
Click the image to expand.

We are a little short of official documentation on the aspects of the design here. We don’t know exactly how the design choices were made, and how they were tested. But UDL is keep improving this design and let’s hope they release more hardware documentation in the future. For now, we will make our best guesses on how everything works.

Upside-Down-Labs-BioAmp-EXGPill-v0.7-Schematic-Instrumentation-Amp-1
Instrumentation Amplifier

The center of the design is the Texas Instruments TL074 quad low-noise JFET-input general purpose operational amplifier in a TSSOP-14 package. TL074 is a 40+ years old op-amp that is still production and wide use. There is a new version available though, the TL074H.

Specifications of TL074

  • Number of channels: 4
  • Total supply voltage (Max): (+5V=5, +/-5V=10) 30 V
  • Total supply voltage (Min): (+5V=5, +/-5V=10) 7 V
  • Rail-to-rail: In to V+
  • GBW: 3 MHz
  • Slew rate: 13 V/us
  • Vos (offset voltage @ 25 C) (Max): 6 mV
  • Iq per channel: 1.4 mA
  • Vn at 1 kHz: 18 nV/rtHz
  • Operating temperature range: -40 to 85 °C
  • Offset drift: 18 uV/C
  • Input bias current (Max): 200 pA
  • CMRR: 100 dB
  • Output current: 10 mA
  • Architecture: FET

The circuit for the instrumentation amp does not seem to be a standard design, but a modified one. In a standard INA design, two emitter-followers will be used as buffer amplifiers that offer high input impedance and the configuration offers better CMRR and differential gain. The standard design is modified in EXG Pill for some purpose, we assume. BIO- is the inverting input and BIO+ is the non-inverting input, which are not balanced due to, again, a modified design. The ampRef is amplifier reference which supposedly sets the idle output at the mid-point (half-level) of the supply voltage. The output inaOut is fed back to a differential gain amplifier.

Upside-Down-Labs-BioAmp-EXGPill-v0.7-Schematic-Bandpass-1
Second Stage Amplifier

The differential gain amplifier accepts the input from the buffer amplifiers and the ampRef. An input filter (R5 and C1) is used block DC and R7 and C2 set the gain and frequency range. Thus we have two filters, and they allow only the pass band to go through, filtering out other noises. In fact, the pass band range is very narrow.

Upside-Down-Labs-BioAmp-EXGPill-v0.7-Schematic-Reference-1
Amplifier Reference + Driven Right Leg

A fourth op-amp forms an emitter-follower or voltage-follower which derives a mid-point voltage for full output swing. vRef is a 2.5V coming from a simple voltage divider. The output is also used to drive the right leg. Driven Right Leg is a method used in bio-signal amplifier designs to eliminate common-mode signals. Bio-signal amplifier measures millivolt or microvolt ranges of voltages, and thus are sensitive to every small interferences. The human body itself can act as an antenna, picking up signals and causing a voltage to develop across it. If you measure between two different points on the body, they will register a voltage with reference to Earth/Ground. Mains supply is one such source of interference, inducing 50/60Hz noise.

Driven Right Leg Circuit for ECG Measurement - Illustration by CIRCUITSTATE Electronics. CC-BY-SA
Driven Right Leg circuit illustration. Image CC-BY-SA.
Click to open image viewer.

These type of unwanted signals can be eliminated by sampling the common mode voltage, amplifying it and then feeding back to the body. This acts as a negative feedback, thus essentially nullifying the unwanted signals. The right leg is chosen since it is the farthest from the heart where signals like ECG are concentrated. The DRL input has to be connected some place away from the BIO- and BIO+ inputs, usually towards the right side of your body.

Upside-Down-Labs-BioAmp-EXGPill-v0.7-Schematic-Power-Supply-1
Power Supply
Upside-Down-Labs-BioAmp-EXGPill-v0.7-Schematic-Header-Pins-1
Input and Output Connectors

Remaining portion of the circuit are decoupling capacitors, vRef voltage divider and the output connectors.

PCB

Upside-Down-Labs-BioAmp-EXG-Pill-0.7-CIRCUITSTATE-7-2
BioAmp EXG Pill v0.7 – PCB Top and Bottom

The PCBs were designed in KiCad open source EDA software and the design files are free to download. The PCB has two layers, 1.6mm thickness and all the components are arranged on one side. The beautiful purple PCBs were manufactured by OSH Park, USA and the quality is excellent as always. The connectors are conveniently placed on the ends. The PCBs are tinier than you would expect, with the size of a pill. Make sure you don’t lose them 😉

Wiring

No wiring instructions are provided by UDL as to where to place the electrodes etc, for each examples. But you can follow the standard electrode placements depending on the application. Also, there are some demo videos from UDL, from which you can determine the best placement.

For this post, we will be placing the three gel electrodes on the right hand to detect EMG and on the chest for pulse count. The gel electrodes are one-time use only, but we will use them a few times. Gel electrodes are easily available if you want to buy them. As the name suggests, these electrodes have a layer of hydrogel that facilitates better contact of the metal electrodes to the skin of a patient. The electrode adhesive has short gap at one end without any adhesive. This is to make it easy to remove the electrode easily from the body. Make sure you place that side away from the direction of the body hair on the skin, to prevent any ouchy moments.

BioAmp EXG Pill v0.7 electrode placement for pulse rate measurement. CC-BY-SA.
Electrode placement for Pulse Rate measurement and wiring with Arduino Uno.
Click to open the image viewer.
Image CC-BY-SA

You can either solder header pins (provided) or solder the wires directly to the board. If soldering the wires, you can loop them through the larger holes on the input signal side of the PCB. We soldered right-angle header pins and soldered a 3-pin receptacle to the wire ends. The power supply pins can be directly connected to your 5V microcontroller board. We are using Arduino Uno for this test, and used the onboard 5V supply for the EXG Pill. The analog output of the module is connected to A0 pin of the Arduino.

Example Code

There are multiple examples codes available at the UDL GitHub repository. Below is a list of examples available,

No.ProgramDescription
1FixedSamplingSample from ADC at a fixed rate for easy processing of signal.
2EMGFilterA 74.5 – 149.5 Hz band pass filter sketch for clean Electromyography.
3ECGFilterA 0.5 – 44.5 Hz band-pass filter sketch for clean Electrocardiography.
4EOGFilterA 0.5 – 19.5 Hz band-pass filter sketch for clean Electrooculography.
5EEGFilterA 0.5 – 29.5 Hz band-pass filter sketch for clean Electroencephalography.
6EMGEnvelopEMG signal envelop detection for robotics and biomedical applications.
7LEDBarGraphLED bar graph showing EMG amplitude.
8ServoControlServo motor control with EMG.
9HeartBeatDetectionStandard deviation based heart beat detection algorithm.
10EyeBlinkDetectionEOG based eye blink detection.
11DrowsinessDetectionDrowsiness detection using eye blink detection.
12ClawControllerServo claw controller
BioAmp EXG Pill examples list

Testing

We will use the Heart Beat Detection (Pulse Rate) example and the wiring shown before. I placed the electrodes on my chest so that I could move my hands while doing this. The demo video from UDL shows the electrodes placed on the wrists. Let’s look at the code first.

There’s no code explanation available from UDL, but we will try to make our best guess again. The EXG Pill has a fixed analog band pass filter. This allows only certain range of frequencies of signal to pass through the circuit and reach the output. Multiple capacitors and resistors form this filter network and their values determine the frequency response. The values for the filters are chosen so as to only allow frequencies of the biological signals we are interested in. This means all the other unwanted interferences such as mains noise will be blocked. This is a crucial design aspect of any system design that has to sample important signals from a noisy environment.

In addition to the analog filters, we can also implement signal filters digitally in the form of IIR (Infinite Impulse Response) and FIR (Finite Impulse Response) filters. The basis of these filters is the mathematical model that exhibits the same behaviors as their analog counter parts (inductor, resistor and capacitor networks). Such mathematical models can be implemented in the software and be used to filter only the frequencies of interest.

  1. The EXG Pill continuously measures the voltages at the electrodes.
  2. The analog filter on the PCB blocks all the unwanted signals.
  3. The microcontroller samples the output voltage from the EXG Pill at a specific frequency that is enough to accommodate all other biological signal frequencies.
  4. This signal is again filtered through a 4th order IIR filter to extract only the signals of specific frequency range. For example, the expected frequency range of an ECG signal is 0.5 – 44.5 Hz and the IIR filter will only allow those signals to pass through.
Upside-Down-Labs-BioAmp-EXG-Pill-ECG-Band-Pass-Filter-Response-1
ECG filter (IIR) frequency response. Source: UDL – Hackaday

In the example program, Arduino Uno’s ADC samples the analog voltage at A0 pin at a specific rate (125Hz in the example we’re using). Every time, the signal change is monitored and filtered through the 4th order band pass filter (ECGFilter() function) whose coefficients are such that it will only allow the ECG pulse to pass. Using a data buffer as a window and standard deviation algorithm (getPeak() function), the program will try to identify peak values in the signal. These peaks correspond to the QRS complex of the ECG signal.

Both original filtered signal and peak signal values are printed to the serial monitor. If you open the text serial monitor, you can see the actual values being printed. But it is not read the values and determine what is happening. Instead, you can open the Serial Plotter and see the values printed as a continuous graph. There will be two lines on the graph; Blue indicating the original captured signal and the Red indicating the peak pulses. See the screenshot we captured.

Upside-Down-Labs-BioAmp-EXG-Pill-ECG-Pulse-Rate-Serial-Plotter-1
Blue shows the actual captured signal and red indicates the pulse.

By counting the rectangular pulses arriving in a minute, you can calculate the pulse rate. If you want to know how the filter coefficients are generated, checkout this link to a Python script that can be used to generate the code. In future posts, we will explore more of the capabilities of BioAmp EXG Pill. Below is the heart beat demo video from UDL.

Heart beat detection demo

Links

  1. Upside Down Labs BioAmp EXG Pill – Crowd Supply
  2. BioAmp EXG Pill – Featured on CIRCUITSTATE
  3. BioAmp EXG Pill – GitHub Repository
  4. BioAmp EXG Pill v0.7 Files – GitHub
  5. Upside Down Labs website
  6. Upside Down Labs YouTube channel

Short Link

Share to your friends
Default image
Vishnu Mohanan
Founder and Chief Editor at CIRCUITSTATE Electronics
Articles: 36

2 Comments

  1. You have done a phenomenal job at writing this truly wonderful tutorial Vishnu. I am glad you pointed out specifically where we have to improve. I will be publishing detailed documentation on how BioAmp EXG Pill works and description for each of the example code provided in the repository.

Leave a Reply