Heart-Rate and EKG Monitor Using the MSP430FG439 - Murugavel Raju, TI, 2007sep25
http://www.ti.com/lit/an/slaa280a/slaa280a.pdf
https://www.olimex.com/Products/Modules/Biofeedback/MOD-EKG/
ABSTRACT
This application report describes how to build a digital heart-rate monitor using a MSP430FG439 microcontroller (MCU). The heartbeat rate per minute is displayed on an LCD. In addition, the application outputs a digital data stream via an RS232 serial port to allow EKG waveform display on a PC. The entire application runs using a CR2032 3-V lithium battery.
1 Introduction
...
An actual voltage potential of approximately 1 mV develops between various body points. This can be measured by placing electrode contacts on the body.
...
In this application report, the EKG waveform is used by the MCU to measure the heartbeat rate. Because heartbeat calculation is the major focus the electrodes are simplified to two connections, one to a right arm and the other to the left arm. This type of setup can be frequently seen in exercise machiness such as treadmills.
2.1 Front-End Amplifier
The electrical signal derived from the electrodes is typically 1 mV peak-peak. An amplification of about 1000× is necessary to render this signal usable for heart-rate detection. Realizing clean amplification of the EKG signal with such high gain is no easy task given that the human body acts as a huge antenna that picks up a lot of noise, including a dominant 50-Hz/60-Hz line-frequency noise. This has to be filtered by a strong post filter after amplification. Unfortunately, any amplification amplifies the noise voltages in addition to the desired EKG signal. In certain situations, the noise can completely override the EKG and render the amplified signal useless.
A better approach is to use a differential amplifier. Thanks to the identical common mode signals from the EKG pick up electrodes, the common mode noise is automatically cancelled out using an ideally matched differential amplifier.
The differential amplifier used in the front end of this application is an INA321 instrumentation amplifier that has perfectly matched and balanced integrated gain resistors. ... The INA321 provides a fixed amplification of 5× for the EKG signal. With its CMRR specification of 94 dB extended up to 3 kHz, the INA321 rejects the common-mode noise signals including the line frequency and its harmonics.
2.2 EKG Amplifier
The EKG signal at the output of INA321 is further amplified by OA0, one of the three integrated operational amplifiers in the MSP430FG439. ...
...
Together with the OA0 amplification, the EKG signal is amplified to a total of 500×. Slight imbalances in electrode lengths and contacts cause the common-mode signal to offset, resulting in noise at the OA0O output. The line frequency content can be seen as a broad trace of the EKG signal as shown in Figure 3. The broadening is caused by the additive line frequency content over the EKG signal.
Because of the large amplification factor, the output is sensitive to the variations in electrode to skin contact resistance. This results in a variation of the dc content of the amplified differential signal and manifests itself as a drift in the baseline of the EKG. This is popularly called baseline wandering and often causes wavy traces of the EKG. This issue is managed by using an analog integrator scheme designed with OA1. The integrator integrates the dc content of the 5× amplified EKG and feeds it back to the INA321. The feedback allows the INA321 to maintain a constant DC level at the output, regardless of the change in skin contact resistance.
If this application is primarily used for EKG display and monitoring, the third operational amplifier, OA2, can be used as a unity gain buffer between the DAC1 output and the third electrode, which is often connected to the right leg (RL) or right side of the thorax of the individual whose EKG is monitored.
The DAC1 is one of the two integrated DAC12 12-bit digital-to-analog converters in the MSP430FG439. Using DAC1 allows the user to implement a digital baseline wandering scheme by appropriate software algorithm. This function is not implemented in this application report. Instead, DAC1 provides a constant midsupply voltage level as the bias for the amplifier chain.
3 Signal Processing and Heartbeat Detection
3.1 EKG Sampling
The amplified EKG signal is internally fed to the on-chip analog-to-digital converter ADC12 input channel A1. The ADC12 samples the EKG signal with a sampling frequency, fsample, of 512 Hz. Precise sampling period is achieved by triggering the ADC12 conversions with the Timer_A pulses. Timer_A is clocked by ACLK, which is generated from the 32.768-kHz low-frequency crystal oscillator.
The fastest deflection in the EKG is in the 20-ms range and happens at the QRS complex. It is important to capture the QRS complex in its entirety for useful medical evaluation of the EKG waveform. Having a sampling frequency of 512 Hz, or sampling period of approximately 2 ms, captures at least 10 samples at the QRS complex and ensures that the QRS complex is fully digitized. The QRS complex also serves as a definite indicator for every heart beat, hence, it is necessary to have it captured for heartbeat rate calculation. The heartbeat rate itself is typically in the 60 to 200 beats per minute, or about 1 Hz to 4 Hz.
3.2 Filtering Line-Frequency Noise
The sampled EKG waveform contains some amount of superimposed line-frequency content. This line requency noise is removed by digitally filtering the samples. A 17-tap low-pass FIR filter with pass-band upper frequency of 6 Hz and stop-band lower frequency of 30 Hz is implemented in this application. The filter coefficients are scaled to compensate the filter attenuation and provide additional gain for the EKG signal at the filter output. This adds up to a total amplification factor of greater than 1000× for the EKG signal. ...
The filtered samples can be output using the DAC0 in the MSP430 for analog reconstruction of the EKG waveform or can be streamed using the UART of the MSP430 at 115.2 kbps to be displayed on a PC screen.
3.3 Detecting QRS Complexes
In order to calculate the heartbeat accurately, the QRS complex must be detected for every beat. The QRS complex is the fast-rising portion of the EKG waveform. If the low-pass filtered samples of the EKG are differentiated or high-pass filtered, the QRS complex can be isolated for every beat. A 17-tap highpass FIR filter with a corner frequency of 2 Hz is used in this application report. The filtered output is further rocessed by subtracting a fixed threshold from the filtered output. This cuts off the unwanted disturbances caused by the P and T waves and other movement-related artifacts. Using this method, the QRS complexes are is dcriminated from the complete EKG waveform. Figure 5 shows the signal that is output from the QRS discriminator to the input of the heartbeat detection and heart-rate calculation algorithm.
3.4 FIR Filters
...
3.5 Calculating Heartbeat Rate
The number of heart beats per minute is calculated using a three beat average. Two variables in the C main function, counter and pulseperiod, accurately track the time scale. Each output sample from the QRS discriminator is compared against a set threshold to detect the presence of a beat. Pulse period is incremented by one during every sample period. Because each sample occurs every 1/512 second, it is easy to track the time scale based on the number of counts in the pulseperiod variable. A 128-sample time window is used as a debounce time using counter. ...
4 Software
The software for this application is written in C using IAR Embedded Workbench Kickstart edition, available for free download from the MSP430 web page.
5 Testing the Application
...
5.1 PC Scope EKG Display
For displaying EKG, the PC must run scope.exe using command line option of Windows. The scope.exe is an open source PC application program.
NOTE: This application design is published for reference purpose only and not intended for any lifesaving or medical monitoring use.
Reference: MSP430FG43x MIXED SIGNAL MICROCONTROLLER
http://www.ti.com/lit/ds/slas380c/slas380c.pdf
The Texas Instruments MSP430 family of ultralow power microcontrollers ... features a powerful 16-bit RISC CPU, ... with
two 16-bit timers,
a high performance 12-bit A/D converter,
dual 12-bit D/A converters,
three configurable operational amplifiers,
one universal synchronous/asynchronous communication interface (USART),
DMA,
48 I/O pins, and a
liquid crystal display (LCD) driver.
...
.END
No comments:
Post a Comment