The personal website of Scott W Harden

DIY ECG Attempt 1: Failure

⚠️ Check out my newer ECG designs:

I followed-through on yesterday’s post and actually tried to build an ECG machine. I had a very small amount of time to work on it, so instead of building the fancy circuit (with 6 band-pass filtered op-amps and diodes posted in the previous entry) I built the most crude circuit that would theoretically work.

I used just one of the 4 available op-amps from a LM324. I built this, hooked it up to my sound card, and made electrodes by soldering wires to pennies. After a good lick, I attached the pennies to my chest with tape and tried recording. Every time the pennies made contact with my skin, I would see noise on the trace, but I couldn’t seem to isolate a strong heartbeat signal. This is what I saw and the circuit I build to see it:

Perhaps this project will be working soon. Many techno-savvy people have made these DIY ECG machines, but not many describe how to interpret the data. Since I’m planning on building it, testing it, recording ECG data, and processing/analyzing it, I’ll may have something unique on the internet.


⚠️ Check out my newer ECG designs:

Last night my wife put her head on my chest while we were watching a movie. A minute or two later I felt a light sinking feeling in my upper chest, and my wife looked up at me in horror. “Your heart stopped beating!” I assured her that everything was okay (it quickly resumed), and that it happens all the time. I feel the sinking feeling often, know it’s because my heart is briefly beating irregularly, and assume it’s normal. After all, your heart isn’t a robot, it’s a living organ doing the best it can. It’s never perfectly regular, and presumably everybody has momentary irregularities, they just don’t notice them. When I got in bed I began wondering how regular irregular heartbeats are. What would the chances be that I have some kind of arrhythmia? I’ve had a checkup not too long ago by a family practice physician who used a stethoscope on my back to listen to my heartbeat, and he didn’t notice anything. Then again, how often does a quick listen with a stethoscope detect subtle or occasional arrhythmias?

I know that whatever problem I have is likely too small to cause any serious troubles, but at the same time I’m becoming obsessed as to determining exactly what my problem is. How many times a day does my heart skip beats? What about nighttime? If only there were some way to record heartbeat data, then I could analyze it and determine the severity of my problem. But wait, data? That would be hours of heartbeat recordings… that means… YES! An idea for a DIY hardware that produces large amounts of data requiring the writing of data analysis software!

Naturally, my thoughts began to overwhelm my reality as soon as Python entered the scene. I wondered how I could use my PC to record my heartbeat, without spending much money on hardware, and only using software I write myself. I pondered this on the way to work this morning, and came up with two possible methods:

Method 1: acoustic recordings. This would be the easiest way to record my heartbeat. I could tape a stethoscope to my chest, insert a small microphone in the earpiece, connect the microphone to my PC, and record sound data for several hours. Theoretically it would work, but it would be highly prone to noise from breathing, and I would have to lay perfectly still to avoid noise caused by movements. The data (trace) would have to be smoothed, processed with a band-pass filter (to eliminate interference), and heartbeats could be calculated. However, this would only give me heart beat time information…

Method 2: electrical recordings. This would be a little more complicated, but generate much more information. I could record the electrical activity of my heart, and the charts would look like the cool electrocardiograms (ECGs) that you see on TV shows. I did a little Googling and found that similar things have been done before with common electrical components. I think I’m going to follow the guide on this page and build the circuit seen below:

Supposedly, the data I can obtain looks something like the image below. I’d attach 3 electrodes to my body (chest, arm, and leg), hook them up to my little circuit, then connect to circuit to my PCs sound card. I’d record the trace (maybe while I sleep?) and analyze it with Python/Numpy/Matplotlib. There are several websites which demonstrate how to build DIY ECG recording devices, but none of these seem to go into depth _analyzing _the data they obtain. Hopefully I could fill this little niche on the internet. We’ll see what happens. I have my thesis to work on, and a whole bunch of other stuff on my plate right now.

UPDATE: I found an much simpler ECG circuit I can make from parts I already have at my house. It has tons of noise, but maybe I can filter that out somehow?

RF Circuitry Links

PSK-31 receiver - sports a crystal filter front-end and active receiver

Neophyte Receiver - old article based around an NE602 / SA602 / SA612.

602 Primer - old document but very good about SA602, includes method to estimate capacitor values for Colpitts oscillator mode.

Hans’ 30m receiver where he used an inverting gate buffer oscillator to generate 5v square waves which he fed into a SA602

Making Friends with the SA602 - an attempt at a write-up of the circuitry behind the Ramsey receiver kits (which only do 1 band each), although the manuals (example for 40m) may be useful

3.5-10MHz receiver - around a few SA602s, uses IF transformers too

30m receiver design - “The Limerick Sudden 30m Receiver Kit” based around a SA602/LM386 very simple and pretty

Sudden Storm Receiver - tuna tun style, check out schem a few pages in… sa602 + LM386 + crystal

Etching PCBs with hydrogen peroxide, vinegar, and table salt (wow!)

Morse.exe - A good way to learn Morse code!

High Altitude Balloon

Oscillator page which has a section mentioning that the 7th overtone can be used in an oscillator. The 7th overtone of 18mhz (17m) is 144mhz (2m) smack dab in the CW region. Nice!

Path prediction - note that UF is 29.642276 latitude and -82.344949 longitude

Icarus - a HAB project run on advertising revenue that seems successful and has launched many balloons with some awesome photos. Robert Harrison knows his stuff!

Project Space Planes - launches paper airplanes from 30km above the earth which glide down and land all over the world!

HALO project - very well documented HAB with pictures/video

JBOT - An SSB linear amplifier made from Just a Bunch of Transistors. It’s pretty straightforward, cheap, and converts 1mW input to 5W output.

harmonic oscillator

tuned oscillator example

overtone oscillator

amplifier design walk-through

Lessons in Electric Circuits - A very good (free) textbook. Anyone starting to learn about electronics should start by skimming over relevant chapters of this text!

1W CW transmitter kit - Although I don’t own one, I appreciate the kit and love the schematic. This guy uses a buffer chip (a 74HC04n, similar to a 74HC240 often used in QRP too) to act as an oscillator and small amplifier. The output is then further amplified by a 2n3866 transistor.

30M Solar QRSS transmitter - such an inspiring project! This guy uses a buffer chip (74hc245) to amplify the output of CKOUT of a microcontroller clocked at the transmit frequency. The thing is solar powered, and has a unique temperature compensation mechanism which uses the chip’s built-in thermosensor to adjust its offset. I haven’t seen this technique used anywhere else in a QRP transmitter!

HansSummers.com - Everything this man does is impressive! His QRSS section is wonderful, and I won’t detract from it by trying to describe it here. He also has a simple QRSS receiver circuit based upon a SA602, something I replicated (tuned front-end not shown) to operate my W4DFU QRSS Grabber at the University of Florida.

MOSFET “Switched Mode” Amplifiers - a wonderful document, read it multiple times! Transistors are traditionally used in many QRP circuits as amplifiers, but MOSFETs have some unique qualities which in many ways makes them easier to work with in simple circuits. I found this guide EXTREMELY helpful!

Amplifier design - a cool walk-through of the design of an amplifier with the math described every step of the way

IRF-510 QRP transmitter design which looks pretty interesting… Note that increasing efficiency lets the MOSFET run cool!

Similar IRF-510 transmitter I like as well….

SA602 as an oscillator - clever, clock with tank, mix with nothing, output (mixed?) is clock only!

JFET Rainglasz/Colpitts Oscillator Design which looks interesting


Battery info - useful for calculating life of batteries under load

Battery tests - tests common batteries at different loads to determine real (not optimal) amp hour ratings!

Filter design software I use for low pass filter design

Mini ring and core calculator very convenient for designing inductors with toroids or calculating resonance of LC networks

Knights QRSS Compendium - Live image feeds of QRSS grabbers all around the world, often situated at the QRSS watering hole of 10.140MHz

Knights QRSS Mailing List - Sign up for this mailing list to see who’s transmitting what on which frequency. People also often post photos of their transmitters, and interesting captures from grabbers that you may have missed!

Experimental Methods in RF Design - Only $32 on Amazon.com right now, this book is an amazing resource for anyone interested in building RF circuits. It goes from extremely simple transmitters, receivers, and amplifiers all the way through advanced topics, modulation methods, etc. It even describes how to build your own test equipment, and even how to use an oscilloscope and assess various stages of your transmitter designs. Flipping through the pages of this book gives me new ideas every time! I requested it many times from my university library (interlibrary loan, often came from Vanderbilt University) before I broke down and got it. I highly recommend this book!

Fixing Slow Internet in Ubuntu

I recently swapped my two main PCs in my house. The “headless” (no monitor) media PC (whose job consists of downloading, storing, and playing movies) connected directly to my TV, and our standard desktop PC which my wife uses most of the time. I decided to do the swap because the media PC was way nicer than our desktop PC, and since the media PC is just playing movies and downloading torrents, I figured the extra processing power / ram / video acceleration could be put to better use. Anyhow, I decided (in both cases) to completely start fresh by wiping hard drives clean and reinstalling Ubuntu linux (I’m using 8.10 currently). However, after the installation I noticed a peculiar problem. I’ll quote it to emphasize it…

Browsing the internet was very slow. When I’d click a link on a website, it would take several seconds before it seemed to even try to go to the next page. The same thing would happen if I manually typed-in a new website. I tried disabling IPv6 in firefox’s about:config and in the /etc/init.d/aliases file, but it didn’t help!

The solution for me was simple, and since I spent a lot of time searching forums I know I’m not the only one with this problem. Disabling IPv6 was suggested in 99% of similar posts. My solution took a while to uncover, so I figured I’d write it here. The basic problem is that my DHCP (auto-configured IP address) settings were screwed up, and my manually setting them I fixed the problem. Here’s what I did…

Start by right-clicking your network icon (wireless in my case) and selecting connection information

Check out your current configuration. Is a local address (192.168.*.*) set for the primary DNS server? If so, that’s your problem! Note your secondary server. We’ll set it as your primary…

Continue by right-clicking your network icon (wireless in my case) and selecting __edit connections*. Open the tab corresponding to your internet connection (wired or wireless - wireless in my case), select your connection, and click __Edit

Use this screen to manually enter the information from the information screen you saw earlier, but making sure not to list any local IP addresses as the DNS servers. Save your settings, close the windows, and the problem should be immediately corrected. Leave “search domains” blank, that’s important too. Good luck!!!

Compress and Store Files in Python

While writing code for my graduate research thesis I came across the need to lightly compress a huge and complex variable (a massive 3D data array) and store it in a text file for later retrieval. I decided to use the zlib compression library because it’s open source and works pretty much on every platform. I ran into a snag for a while though, because whenever I loaded data from a text file it wouldn’t properly decompress. I fixed this problem by adding the “rb” to the open line, forcing python to read the text file as binary data rather than ascii data. Below is my code, written in two functions to save/load compressed string data to/from files in Python.

import zlib  
def saveIt(data,fname):  
def openIt(fname,evaluate=True):  
    if evaluate: data=eval(data)  
    return data  

Oh yeah, don’t forget the evaluate option in the openIt function. If set to True (default), the returned variable will be an evaluated object. For example, [[1,2],[3,4]] will be returned as an actual 2D list, not just a string. How convenient is that?