This little article aims to show how easy it is to use the ECG Front End by interfacing to a Microchip PIC16F1826 microcontroller. The microcontroller reads the Heart Rate in two ways. Firstly, it uses the AD converter to send the data as an 8 bit stream over the UART for a PC to display. Second, it uses the built in comparator to detect the pulse and flash an LED on every beat. This article won't go into all the characteristics of the ECG waveform but that information can easily be obtained by a simple google search or on Wikipedia. As built, the demo circuit was drawing about 2mA of current not including the LED current which is about 7mA. But the LED is only on for milliseconds and should not draw too much power over time.
You can download the source code for the demo circuit at the end of the article. Also the .NET sourcecode for the PC can be downloaded here.
Disclaimer: This product is for educational purposes ONLY.
It is NOT to be used for diagnostic or for life saving operations of any sort.
Always consult a qualified medical professional for any medical concerns.
Here is an idealized image of the ECG waveform.
The part that is of the most interest is the QRS portion of the waveform. It's this peak that is used to determine heartrate.
Below is the schematic of the demo.
Above is an image of the demo circuit as built with the ECG front end on the left, the PICThe number one issue with this ECG measurement is line noise. 60Hz can swamp the signal and make it unreadable. The quality of the electrodes can make all the difference between a clean looking signal and a noisy mess. Access to medical grade electrodes would be ideal, but this isn't really an option for the DIY'er. A few suggestions though are:
in the middle, USB to Serial next, and finally, a CR2032 coin cell battery.
- Use shielded wire. I have used RCA cables and clipped off the ends with decent results.
- Make your cables as short as possible. The longer the wire, the more noise that it can pick up.
- Make your contact pads as large as possible. The more contact with skin, the greater the signal voltage picked up.
The software for the PIC is rather straight forward. After initializing all the peripherals, it loops through waiting for the UART to be empty, then it reads a sample and checks the comparator. If the comparator is high, it lights the LED. It also sends the AD result over the UART. Since the AD converter is 10 bits, the PIC right shifts the result 2 bits to send the data as 8 bit.
The UART has its baud rate set to 600 which is 60 bytes per second. Since the software waits for the UART buffer to be empty before sampling, it has the effect of setting the sample rate to 60. This is a great way to reduce and possible eliminate the 60Hz noise. This won't get you a perfect looking ECG waveform, but for heart rate calculation, it is perfect.
I hope that this will help you in your design of a simple low cost heart rate monitor, and with the addition of an external EEPROM, this could easily be setup to record heart rate over time (eg. exercise monitor).
Copyright © 2013 by 100RandomTasks. All rights reserved.