Gas station without pumps

2012 July 15

EKG recording working

My son and I spent some time today debugging his data logger.  I also convinced him to add some documentation, though not nearly as much as I think is needed.  This version is just a text command interface, with no GUI—the PyGUI interface he was building seemed to slow things down a lot, and is not yet ready for use.

The data logger works fine as long as the sampling interval is at least 3msec.  With 2msec sampling, I think that serial communications (over a 115200 baud USB serial connection) is getting overwhelmed.  The Arduino seems to be capable of sending out data ok at 2msec/sample, though 1msec/sample causes it to miss some timer interrupts.

If the Python program can’t empty the serial port fast enough, I think that there operating system problems. My MacBook Pro sometimes gets wedged with long runs at higher sampling rates—I’ve had to reboot it a couple of times today. If the problem is with the MacBook Pro, it may be possible to run with slightly shorter sampling intervals on faster hosts, before hitting the limits of the Arduino.

I did manage to get a nice recording for about 8.5 seconds at 3msec sampling:

Recording of EKG trace on the Arduino. The value 512 represents the midpoint of the Arduino voltage scale. The EKG circuit and Arduino used separate power supplies, so the reference voltage is about 2.506V, while AREF on the Arduino was 4.96V, so the reference voltage should be about 517.  In a separate recording of the EKG signal and Vref, I found Vref to be 515±1.  The arbitrary units are about 4.844mV at the input to Arduino.  If my gain of my EKG is set to 591 as I expect from the resistor values, the arbitrary units should correspond to 8.2µV at the electrodes, and the biggest peak is about +1.6mV and the deepest drop is about -0.24mV.

I think that the signals were clearer today, because I was using a ground electrode on my chest, rather than on my elbow, reducing the common-mode noise a little. The 3msec resolution allows zooming in to get a pretty clear view of the structure of the pulses:

Detail of a couple of pulses showing the QRS complex and the T pulse. I’m not sure whether or not a P pulse is visible—if so it is almost buried in the noise. I’ve added a line where I believe that the reference voltage is, though it was not recorded on this run. The R-R interval here is about 1251±2msec for a pulse of 0.80 Hz or 48.0 bpm, which is about my usual resting pulse.

Although it took my son and me a little debugging to get everything working today, overall I’m quite pleased with the data logger code he wrote. He still has more documentation to add (both in-code and external), and there are some more features that could be added, but it is basically usable as is.

Incidentally, I found out today from Cardiology Explained by E.A. Ashley and J. Niebauer, that

ECG terminology has two meanings for the word “lead”:

  • the cable used to connect an electrode to the ECG recorder
  • the electrical view of the heart obtained from any one combination of electrodes

So it is not surprising that I was confused by the usage—I was only familiar with the first usage, which corresponds to normal engineering terminology.


  1. […] EKG recording working […]

    Pingback by Order and topics for labs « Gas station without pumps — 2012 August 16 @ 23:39 | Reply

  2. […] EKG recording working […]

    Pingback by EKG blinky boards work « Gas station without pumps — 2012 August 18 @ 11:51 | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: