Real-Time Embedded Programming Project: Heart Rate Measurement

Team 4: Marc Andreas Kleser, Nathalie Majcherczyk

Project Overview

The aim of the project is to determine heart rate by measuring the varying opacity of tissue containing small blood vessels. The opacity changes with the blood pressure, which changes accordingly during a heart beat cycle. Using the light of a LED and a photo transistor, light is sent through the tissue and detected on the other side. The varying light intensity as a signal contains all information to calculate the heart rate.

Hardware

The project can be realised by making use of the Raspberry Pi. An AD converter needs to be interfaced between the light-sensing circuit and the RPi as it does not have analogue inputs. The AD7705 can be used for this purpose, it is a differential Sigma-Delta AD converter. The PCB design for adding this piece of hardware can be found here.

The light-sensing circuit comprises a red LED and a phototransistor to perform the measurements. The phototransistor selected has a viewing angle of 15° which is narrow enough to exclude external noise. It is necessary to provide a differential voltage to the AD converter. Therefore, a voltage divider with a variable resistor is used to produce the lower voltage input. It is set to the output value of the transistor when not receiving any light. The higher voltage input is connected to the phototransistor. The circuit layout can be found here. The following components are used : passive components, op-amp TL071, photo-transistor BPV11 and led SPC22343.

Software

The device for data acquisition, i.e. the AD converter is accessed via SPI. In linux, the corresponding device is called /dev/spidev0.0. To set up the SPI communication, the function, setADC() is called once.

Fetching the data is realized by using a timer of 40ms intervals. Inside the timer event, the function read_data() returns the current read value. The data is then saved in a buffer, shifting the old data via the memmove() command. Displaying the data is done by using QT libraries.

The whole project is accessible via github here: http://github.com/NathalieMajcherczyk/RTEPteam4.git

Test Set-up and Results

The test set-up is shown on the next picture.


It is important to position the light source as exactly as possible over the photo transistor, since it has a small sensitivity angle. Also, when measuring, a shielding against stray light is beneficial.


This picture shows the difference between the output when the diode light hits the photo transistor directly vs. no light from the diode hits the transistor. The smaller peak is an effect of stray light.


The reaction to changing the illumination of the photo transistor rapidly using the LED is shown in this picture.


A measuring attempt for the heart activity resulted in this data. When looking at the largest peaks, a pattern can be identified, that has a plausible frequency. This pattern, although noisy, is clearly distinct from noise only. Further data processing can help to improve the signal quality, as stated further down.


Prospective improvements

a) Hardware

In order to enhance the usability of the device, some further changes have to be applied. Most importantly, the sensor construction should be changed so that the LED and the photo transistor are both held in place on the finger. This can be realized by using some sort of clamp, the simplest way would be to use a peg for this purpose.

Another constructive measure to improve reliability and safety is to insulate the electrical connections. For example, if the connections of the photo transistor are in touch with the skin while measuring heart rate, the resulting data is biased. Furthermore, the insulation is necessary regarding safety reasons. Since there is no electrical decoupling between the sensor circuit and the power supply, there is always a risk of electric shock with open current carrying parts.


b) Software

Regarding the software part, the data processing can be enhanced. By applying real time filtering routines to the received data, the unwanted parts of the signal can be suppressed. This is for example the DC drift, which can be removed by a simple DC filter. Since the environment in which the device is designed to be used is indoors, 50Hz noise has to be taken into account. A bandstop filter should be applied here to get rid of the unwanted frequency, depending on the choice of the data acquisition rate. Since in this case, a sampling frequency of f = 1 / 40ms = 25Hz = 50Hz / 2 is used, the 50 Hz noise counts towards the DC component because of the sampling theorem and is already taken care of by the DC filter.

In order to output the actual heart rate, a matched filter can be used in combination with a peak detector. To realise this, a FIR filter is designed such that its coefficients are the temporally inverted samples that contain one heart beat. The resulting signal contains peaks, which can be detected by an appropriate routine, for example using a threshold and measuring the time between peaks.


References

http://www.picotech.com/experiments/calculating_heart_rate/