Building an Electrocardiograph I
After the biofeedback experiments a few weeks ago, I started thinking about a more flexible way to measure raw heart rate data. I am interested in more control of data sampling in order to make signal processing and analysis easier.
Fortuitously, the last issue of Make has a short article on page 157 on the topic of DIY electrocardiographs. So off we go…
I first decided to go with the instrumentation amplifier built from three 741 op amps as described in the article. I added the simple resistance-capacitance filter recommended in the article, got some conducting 3M Red Dot electrode pads and hooked the whole think up to the USB Bit Whacker for data collection (see Accelerometer from a few days ago.).
What were the results? Well, a qualified "it worked," but this needs some work.
The amplifier. We need a gain of about 1000 to get the signal in the range of the A/D capabilities of the UBW (0-5V, 10 bits resolution). And we need high fidelity differential amplification of the inputs. This is called the common-mode rejection ratio (CMMR). We need a CMMR of 100,000:1 (~100dB). Here is the schematic:
I added the recommended RC amplifier to the output to clean up the signal a little.
Here are some photos of the construction process. The circuit is point-to-point wired on a proto board and the whole think is mounted in a small aluminum case. The basic circuit is only a few components so it didn’t take long to build.
The amplifier is powered by two 9v batteries to provide +/-9V for the op amps. This means the output signal varies from something like -8 to +8 volts. Feeding the A/D of the UBW a signal between 0-5V is going to require some adjustments. I added two 10K ohm potentiometers for null offset to I1 and I2. (I now think this was a naive mistake because these have to be set very nearly equal for the amplifier to work.) I also added a 500 ohm gain adjust potentiometer in place of the 200 ohm fixed resister recommended.
When I tested the amplifier with DC input signals, I grounded one input and varied the input at the other with a simple voltage divider. This didn’t expose any of the weaknesses of my design decisions. The null offset adjustment worked well. The test showed a gain of 1000 was easy to attain and that the amplifier produced a nice looking linear response.
So I closed up the case and was off to measure my heart beats.
Contact pads. I started with some home-grown copper electrodes. While I did get a small signal–intermittently–this wasn’t going to work. To the Internet to buy the real thing from 3M.
I attached my new amplifier to the UBW analog input channel and modified my Python script (accelerometer.py) from the accelerometer experiment to capture data on one channel every 10 ms. Here are the results:
And some detail…
It is clear that external signals are swamping the desired heart beat signal. It also may be the case that the amplifier-A/D combination is so poorly matched that there is some distortion of the data.
What to do different:
* Shorten the input leads–they seem to be acting as large antennae to the 60 Hz AC line frequency
* Build a better filter (active)
* Build/buy a more robust instrumentation amplifier
* Use a smarter method to translate the output to the required A/D voltage range
* Best of all, have this experience