Products > Programming

Pulse Oximiter project


Hi all,

I'm currently working on a Pulse Oximiter project. As a part of this project. I'm using a red LED and a photo diode as a sensor and feeding that into a ADC on a microcontroller after some LC Low Pass filtering to remove noise from the environment. This all works great and I can easily see my heartbeat when I display the readings from the sensor.

I'm also implementing an algorithm to determine when a heartbeat occurs and count it to determine heart rate. To do this, I take a moving average of the current sensor reading and store the resulting value, I then determine when the value of the sensor reading exceeds the average, The filter is set up to depend mostly on the previous value, meaning that the sensor reading will exceed whatever value the filter has stored on a heartbeat.

The issue I'm having with this I believe is mostly to do with hysteresis, I think there is enough noise on the incoming signal that it crosses the average value multiple times before going to the maximum value and again as it crosses the average value.Is there a way to fix this issue in code or do I need to come up with a different method for heartbeat detection?

for(some values to determine frame lengths){
 if(inByte > avg){
     beatCount = beatCount+ 1;
     avg = tempavg * 0.995  + inByte * 0.005 ;
     tempavg= avg;
    beatCount = 0;
Note, beatCount gets reset later in the code. this is actually Java on a processing sketch as it was the fastest way for me to get started. Once I have the algorithm down I'm going to port the code to Python or C/C++ with graphics libraries to give me greater flexibility with this code


Ti has quite some information on pulse-oxymeters available:

With a relatively noisy signal the show code may not work very reliable. The amplitude of the pulse signal can depend on the actual position, so chance are one should have thinks relative to the measured amplitude of the "AC part".  The kind of brute force way would be to take enough data an run an FFT.  Some kind of hysteresis check is probably a good idea.

To suppress environmental background, especially light flickering, the normal method for such optical measurements is to modulate the light and do a synchronous detection. Depending on the environment this could help with the SNR.

You will need to use both a red LED of the correct wavelength, and an IR LED of the correct wavelength, and pulse them alternately, to do the oxygen measurement. As Kleinstein indicated, you really ought to start working with that pulsed approach now. Pump all your transmit energy into a brief pulse, and detect at the right moment. This will improve your SNR a lot, and reduce things like the 100Hz/120Hz pulsing of most room lighting. When you get to measure the oxygen, analogue filtering of the signal will be a problem, unless you have two analogue chains, and switch between them as you switch between the LEDs. Its really better to sample the raw transimpedance amp signal with an ADC, and do all the processing with two chains of digital filtering. You are looking for a small signal with a huge DC offset, which requires some careful handling to keep the signal within range. The TI app note which Kleinstein linked to, and the earlier versions of that for older MSP430 parts, gives some information about the issues that need to be addressed, and one set of solutions.

Maxim makes a range of pulse oximeter sensors:

Firstly, I owe a big thank you to everyone who has responded, your feedback taught me a lot about these sorts of systems. I assumed, incorrectly, that a single red LED was responsible for the SpO2 measurements. I jumped into it without doing enough research to know that I was incorrect.

It is true that I can capture heart rate data with just the Red LED, however, I can't extract the SpO2 reading from that alone. As for the maxim sensor, I'm going to order a PCB and build up a system based around that as it eliminates a great deal of my problems, but at a potentially higher cost than a pair of LED's and photodiodes. from what I've gathered, my best bet at getting something more "traditional" to work is to pulse the LED's and use a transimpedance amp on the photodiodes. For right now I'm going to try and pulse the red LED that I have and see if I can get my SNR levels down with out the need for an LC filter and if that works, (it should) ill move on to other methods of sensing.
Thanks again!


[0] Message Index

There was an error while thanking
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod