mt2278 - paper - pobox

55
P O Box Utilizing a Microchip dSPIC30F2012 Digital Signal Controller Product: Pulse Oximeter For: Design Contest 2007

Upload: musab-umair

Post on 29-Dec-2015

77 views

Category:

Documents


0 download

DESCRIPTION

How to design a pulse oximeter

TRANSCRIPT

Page 1: MT2278 - Paper - POBox

P O Box

Utilizing a Microchip dSPIC30F2012

Digital Signal Controller

Product: Pulse OximeterFor: Design Contest 2007Sponsors: Microchip/Circuit CellarDate: October 16, 2007

Page 2: MT2278 - Paper - POBox

By: MT2278INTRODUCTION

MOTIVATIONA BREIF HISTORY

THEORY

HARDWAREDIGITAL SIGNAL CONTROLLER

dsPIC30F2012SYSTEM CLOCKTIMER T1TIMER T2INPUT CAPTURE 1 SPI MODULEUART MODULEDIGITAL I/ODIGITAL OUTPUTSDIGITAL INPUT

LED DRIVER CIRCUITLED MODULEH-BRIDGEBUFFER AMPLIFIERSSPI-DACDIGITAL CONTROL BITS

LIQUID CRYSTAL DISPLAYR/*W INPUTRS INPUTENABLE

COMMUNICATIONS PORTSWITCH INPUTLTF SENSOR LED EMITTERSMOUSE CABLEVELCRO CONSTRUCTION

SOFTWAREMEASUREMENT STRATEGYLOWPASS FILTERDIFFERENTIATOR (HIGH PASS FILTER)DC TRACKING FILTERPEAK FOLLOWER

Page 3: MT2278 - Paper - POBox

HEARTBEAT/SpO2 CALCULATIONSIMPLE MOVING AVERAGE FILTER

ASSEMBLY16-bit 28-pin DEVELOPMENT BOARDMEZZAINIE BOARDLCD ASSEMBLYFINAL ASSEMBLY

OPERATIONS

APPENDIX 1TRANSMITTANCEABSORBANCE

APPENDIX 2BEER-LAMBERT LAW

APPENDIX 3OXYGEN SATURATION

APPENDIX 4OUTPUT DATA

GROUP 1GROUP 2GROUP 3

APPENDIX 5BLOCK DIAGRAM

APPENDIX 6SCHEMATIC DIAGRAM

APPENDIX 7MEZZAINIE BOARD LAYOUT

APPENDIX 8BILL OF MATERIAL

MEZZANINE BOARDSENSOR

Page 4: MT2278 - Paper - POBox

INTRODUCTIONThe purpose of this paper is twofold; to demonstrate the concept of Pulse Oximetry using a Microchip dsPIC30F Digital Signal Processor and as an entrant into the 2007 Microchip 16-Bit Embedded Control Design Contest sponsored by Microchip and Circuit Cellar.

The Pulse Oximeter is an instrument that is widely used in today’s medical field. There are many different models available by different companies. Some units such as those utilized in hospitals are integrated into larger systems used to monitor other vital signs. Other smaller more portable units can be found in doctor’s offices, clinics, and nursing homes and are also used by home health-care professionals. In the Oct/Nov 2000 issue of RT – The Journal for Respiratory Care Practitioners, an article titled “Recent Developments in Pulse Oximetry” is quoted as “Pulse Oximetry is often considered the fifth vital sign, after heart rate, blood pressure, temperature and respiratory rate.” Pulse Oximetry has served as an important tool for the clinician by providing continuous monitoring of the critically ill patient’s arterial oxygen saturation (SaO2), by calculating an estimate of the SaO2 (know as the SPO2) via and algorithm, and displaying a readout of this estimation.”

MOTIVATIONOver the past number of years I have had experience with the nursing home setting since my uncle had spent two years there. It is very common for bed-ridden patients to contract pneumonia during the flu season. A pulse oximeter is normally used to determine if the patient is having difficult time breathing. A particular nursing home my uncle was at had one such instrument. During the winter, he had contracted pneumonia; I asked the nurse if he could be examined. They had to wait for the oximeter because it was being used in another part of the building. Because of the instruments high cost, the nursing home couldn’t afford a second or perhaps a third.

Some time earlier, when my mother was hospitalized with what the doctors though was pulmonary fibrosis, my wife and I looked for a pulse oximeter that we could purchase that she could use when she came home from the hospital. They were all very expensive. During our search, we read an interesting article of an individual who was on the same quest. With his level of the fibrosis disease, he was able to exercise. He wanted to monitor his oxygen level during his workout. He couldn’t find a unit that he could afford. His question was - does anybody make one? With the low cost and availability of microchips, I can’t understand why these

Page 5: MT2278 - Paper - POBox

instruments are so expensive and why they are not available at your local drugstores like glucose meters. A BREIF HISTORYThe concept of Pulse Oximetry started back in 1935 when Carl Matthes built a device which used two light sources of different wavelength to monitor blood oxygen saturation in living tissue. The device had certain limitations, was difficult to calibrate and absolute values were not obtainable.

In 1940 a method of calibration by compressing tissue to eliminate blood was developed by J.R. Squire.

From 1939 to 1942, Glen Millikan concepted and designed a lightweight and practical earpiece used to detect oxygen saturation in aviators during high altitude testing. By 1948 a similar device was used to control anoxemia during surgical anesthesia. During this time Glen Millikan coined the term “oximeter”. Millikans probe was not calibrated and had to be adjusted for each use. The thickness of the subjects ear was also a variable that had to be compensated for.

During the 1950’s at the Mayo clinic, Earl Wood utilized J.R. Squires concept by added a pneumatic cuff to measure the light increase when the ear was squeezed.

During 1966, the Walters Company developed the X-350 oximeter based on Earl Woods work. This oximeter was the first to provide absolute readings of oxygen saturation without adjustments to a know concentration.

Starting around the year 1971, a Japanese engineer named Takuo Aayogi in his work identified detectible pulsatile flow. While attempting to eliminate these variations, he discovered that the absorbency ratios of these pulsations at different wavelengths varied with the oxygen saturation. With the subsequent development of light emitting diodes, photo detectors and microprocessors the pulse oximeter was gradually introduced into clinical practice.

It was this detection of the pulsitile signal that heralded the development of the modern pulse oximeter. The pulsitile changes in light transmission through living tissue are due to changes in the blood volume in the arteries. Measurement and analysis of these pulsitile signals can then be used to detect the oxygen saturation of blood.

Page 6: MT2278 - Paper - POBox

THEORYThe fundamental basis for Oximetry is that blood has different optical properties at different levels of oxygen saturation. This means that if multiple sources of light at different wavelengths are used to examine the blood, they can be compared algorithmically by a computer to determine the level of oxygen saturation in the blood. The beauty of the concept is that the examination can be made invasively by passing light through an extremity such as a finger, ear lobe, etc. The light is collected by a light sensitive solid-state device such as a photo-detector, phototransistor or more recently a LTF (Light to Frequency) converter. Oximeter probes are designed to have multiple light sources (LEDs) that are switched on/off during the measurement phase of the instrument. The oxygen carrying component of blood is called Hemoglobin. It is also the colored substance in your blood. The amount of absorption of visible light changes with the level of oxygenation. On a molecular scale, there are two forms of the hemoglobin molecule. One is called oxidized hemoglobin (HbO2) and the other is called reduced hemoglobin (Hb). Both of these molecular forms have different optical characteristics. The absorption of both forms of hemoglobin can be seen

below.

Page 7: MT2278 - Paper - POBox

FIGURE 1: The graph shows the absorption spectra of both HbO2 and Hb. Hb has a higher absorption than HbO2 at 660nm (Red light). In the infrared region, HbO2 has a higher absorption. The point were the absorption of the HbO2 and the Hb are equal is called the isobestic point.

R IR

` FIGURE 2: Basic Oximeter Sensor Components LTF

Above, illustrates two LED sources (RED and INFRARED) that transmit light through a finger. The light is received by the LTF (Light to Frequency sensor). The output of this sensor has a frequency that is proportional to the intensity of the light for each source. The sources are time multiplexed. Each source is switched on for a brief instant and the frequency is measured. Light is absorbed from each source by the tissue as well as the blood. The absorption is different in the tissue for each source. As blood flows through the finger a pulsitile component is present. The pulsatile component represents the arterial flow of the blood which contains 97% of the oxygen in the body. The constant or DC component that is picked up by the

Page 8: MT2278 - Paper - POBox

LTF represents the tissue, venous and capillary absorption. Below shows the pulsitile and DC components for each of the signals. The RED trace represents the RED source and the BLUE trace represents the IR trace. The Black line represents the DC value for each of the sources.

FIGURE 3: Blue Trace– IR Light / Red Trace – RED LightThe appendix of this paper goes into more detail on the theory behind the equations that govern how with a few simple measurements the blood oxygen saturation can be obtained from the signals above. The system measures both the AC and DC levels obtained from both sources and computes the SPO2 based on the following equation:

The above equation is a 3rd order polynomial fit to the SpO2 graph given in reference [4]. The graph is shown below and also in appendix 3.

Page 9: MT2278 - Paper - POBox

FIGURE 4: Calibration curve for oximeter

The Heart Rate is determined by measuring the elapsed time between peaks of the IR signal. The heart rate is then calculated using the equation:

HARDWAREThe heart of the pulse oximeter is a Microchip dsPIC30F2012 Digital Signal Controller. Since Microchip has some very nice tools, it was very practical to develop this concept utilizing one of the may available development kits. The Microchip CPU (16-bit 28-pin Development Board) was chosen for this task. Minimal changes were required to get this board to work with the system. A small mezzanine board was constructed to interface to the sensor and serial port. The board also contained the necessary circuitry for this interface along with an inexpensive liquid crystal display.

DIGITAL SIGNAL CONTROLLERdsPIC30F2012The Microchip dsPIC30F2012 digital signal controller was a nice choice for this project because of its excellent computational abilities, available hardware, its low cost and its ease of field programmability.

SYSTEM CLOCKThe 16-bit 28-pin development board comes with an external 7.3728M Hz crystal. This worked out perfect for the application. The on-chip PLL was used to boost the operating frequency 16x. With the instruction clock set at ¼ input clock frequency, the operating frequency of the clock for the system is: Tcy = 29.4912 MHz.

Page 10: MT2278 - Paper - POBox

TIMER T1T1 is a 16-bit timer that acts as a time-base generator with interrupt to implement a simple state machine used to control the sequencing of events. Timer T1 also sets the sample rate for all signal processing. T1 is a type-A timer which uses the 29.4192 MHz internal clock as its input. A prescaler is used to divide the frequency by 256 to drop the TMR1 module input to 115200 Hz. The Period Register PR1 is set to 576 so the timer provides an interrupt period of 5ms.

TIMER T2T2 is also a 16-bit timer that is setup to be free-running with a 29.4192MHz input to the TMR2 module. Timer T2 is a type-B timer but does not utilize an interrupt in its operation. It is used to measure the period of the output from the Taos TSL235R LTF device. The LTF output period is inversely proportional to the intensity of the light striking its surface.

INPUT CAPTURE 1 is connected to the output of the TAOS LTF device. It is setup to trigger on each rising edge of its input. When the IC1 event occurs, an interrupt is produce and the value of timer T2 is copied. An interrupt handler saves this value. On the secondinput capture event, the period of the LTF can be determined by taking the difference between this value and the saved value. The period is used to compute a frequency which is proportional to the intensity of the light measured.

SPI MODULEThe SPI module is enabled for use in communicating with the Microchip MCP4822 serial digital to Analog converter IC. The SPI is setup in master mode to have a 16 bit serial output at a clock rate of 7.3728MHz. Since the SPIDAC device has 12 bit resolution, the other 4 bits are used for control. The SPI module sends LED intensity commands from the digital controller to the DAC IC.

UART MODULEA serial output from the system sends data at a rate of 115,200 bits per second to the development computer with an 8 bit data size, 1 stop bit, no-parity and no flow control. Since the data comes out of the system in serial form, a special scope program was written and used to analyze system operation during development. Using the SW1 input on the development board, one of three diagnostic screens can be selected.

DIGITAL I/OTen pins were used as digital output and a single pin for a digital input. They are identified below:

Page 11: MT2278 - Paper - POBox

DIGITAL OUTPUTSRB0 VIRon Signal to the H-Bridge to control the IR light source. A High

state turns IR LED on, a low state turns the IR LED off.RB1 VRon Signal to the H-Bridge to control the RED light source. A High

state turns the RED LED on while a low state turns the RED LED off.RB3 R/*W Controls Read/Write input on the LCD display. A high state

sets display into READ mode while a low state sets display to WRITE.RB4 D4 LCD Data input line Bit 4RB5 D5 LCD Data input line Bit 5RB6 D6 LCD Data input line Bit 6RB7 D7 LCD Data input line Bit 7RB9 PULSE Diagnostic Bit used during developmentRF4 E Enable Line input for the LCD display.RF5 RS Register Select line for the LCD display. High state selects the

internal data register while a low state selects the command register.DIGITAL INPUTRD8 SW1 Input connected to a momentary switch with pull-up resistor on

the development board. This switch is used to toggle one of thee data outputs from the serial port. This was used during development and may be used for diagnostics.

LED DRIVER CIRCUIT

LED MODULEThe sensor is built using an Advanced Photonix Inc. (API) PDI-E832 GaALAs High Power Dual LED emitter. The module has two parallel connected emitters that can conduct in both directions. One direction produces photonic energy at 660nm (RED) and the other produces photonic energy at 905nm. This module is available from Digikey for about 10 dollars. In order to drive this module, a bridge circuit was used. With the bridge circuit, the intensity of each emitters as well as when to switch are controlled independently.

Page 12: MT2278 - Paper - POBox

FIGURE 5: Emitter assembly schematic and dimensions

H-BRIDGEIn reference to the schematic located in Appendix 6, the LED module is driven by (U2) an H-Bridge module consisting of a 14 pin DIP silicon complementary-pair transistor package available from Central Semiconductor Inc., P/N: MPQ6002. This circuit uses a 9V decoupled supply to deliver pulsed power to the LED's at variable drive currents.

BUFFER AMPLIFIERSA Microchip MCP607 dual op-amp package is used to drive the bottom half of the H-Bridge circuit and isolate it from the SPIDAC. These amplifiers along with the current feedback resistors R1 and R2 are used to set the current in each branch of the H-Bridge circuit thus setting the LED intensities. Element U4B controls the IR LED and U4A controls the RED element.

SPI-DACA Microchip MCP4822, Digital to Analog Converter with SPI interface and internal reference connects the dsPIC30F controller to the buffer amplifiers.This device takes a 12 bit command over the SPI link. The SPI is setup for a 16 bit word transfer using a 7.3728MHz clock. The bottom 12 bits of the word are data and the upper nibble are control bits. One of these control bits is used to select one

Page 13: MT2278 - Paper - POBox

of the two DAC circuits in the device. DAC output A (pin 8) controls the intensity of the IR Led while DAC output B controls (pin 6), the RED emitter.

DIGITAL CONTROL BITSTwo bits from the dsPIC30F device are used to switch the LED's on and off. The upper half of the H-Bridge is controlled by output pins RBO and RB1. These pins control transistor drivers Q2 and Q1 which drive the PNP transistors in U2. Pin RB0 will turn on the IR Led while pin RB1 will turn on the RED Led. The software will switch only one light source on at a time. Below are the code segments for SPI initialization and DAC Output.

/*Routine to setup SPI hardware*/void SPIInit(void)

{ //Set *SS1=1; (*CS = 1)LATB |= 0x0004; //Enable SPI module - SCK1, SDO1, SDI1, *SS1SPI1STATbits.SPIEN = 1; //Disable Framed, Enable 16 bit data width, ActiveSPI1CON = 0x053E; //clock to Idle clock,active state hi,Master Mode.} //enabled,Secondary Prescaler /1,

/*Routine to Write data out SPI port*/void SPIOut(unsigned int data)

{LATB &= 0xFFFB; //Set Chip Select LOW (*CS = 0)SPI1BUF = data; //Send data out SPI PortT10us(); //Wait for 10 usLATB |= 0x0004; //Set Chip Select HIGH (*CS = 1);

}/*Routine to write data to selected channel A or B *//*channel = 1: RED DAC Command in <data> *//* = 0: IR DAC Command in <data> */void DACOut(char channel,unsigned int data)

{if(channel) //If channel = 1,

SPIOut(data | 0x9000); //Write RED DAC command,Output Enabled,2x gain.else

//If channel = 0,SPIOut(data | 0x1000); //Write IRED DAC command,Output Enabled,2X gain

}

LIQUID CRYSTAL DISPLAYThe system uses a 2 line by 8 character display to provide the SPO2 data as well as the heartbeat information to the user. A Hantronix Liquid Crystal display was chosen to do the job because it is inexpensive, robust and easy to work with. To reduce the number of I/O pins required by the microcontroller, a 4 bit data bus was chosen. There are three additional control lines that the micro has to supply to communicate with the display. The 8 bit data is multiplexed into the display from the micro using the upper nibble of the lower byte of PORTB. One nibble is loaded at a time on the upper four pins of the display bus (the display bus is an 8 bit bus but has both modes of operation). See the attached code segment on the next page for details on how the display is initialized and how data is written to the display.

R/*W INPUT

Page 14: MT2278 - Paper - POBox

This is an input to the display that allows the software to select either a read or a write operation. This application uses only writes to the display and does not necessitate the use of the read function.

RS INPUTThis input to the display allows writing to either the DATA register or the CONTROL register. When the input is low, Instructions can be written to the control register. When the input is high, ASCII data can be written to the display.

ENABLEBy applying a pulse on this input of about 50us, the data and control bytes can be written to either the data or control registers respectively.

SOFTWAREThe following are some code segments that show how the display is initialized, and written to. There are more routines that can be referenced by examining the code listings for this project.

/*Initialize Display for 4 bit interface.*/void Initdisp(void)

{LATF &= 0xFFEF; //Drop Enable Pin low (E = 0) LATF &= 0xFFDF; //Reset RS line low (RS = 0)LATB &= 0xFFF7; //Reset R/*W line LOW (write) (R/*W = 0)T15ms(); //Wait for 15msLATB |= 0x30; //Set function for 8 bittoggleE(); //Toggle E bitT5ms(); //Wait for more than 4.1mstoggleE(); //Repeat, then T100us(); //Wait an additional 100ustoggleE(); //Repeat.LATB = (LATB & 0xFF0F) | 0x20; //Set function for 4 bit interfacetoggleE(); //Toggle E bittoggleE(); //Repeat function for 4 bit interface HI NibbleLATB = (LATB & 0xFF0F) | 0x80; //Second Nibble (2 lines)toggleE(); //Toggle E bitLATB &= 0x0F; //Turn OFF displaytoggleE(); //Toggle E bitLATB = (LATB & 0xFF0F) | 0xE0;toggleE(); //Toggle E bitLATB &= 0x0F; //Clear DisplaytoggleE(); //Toggle E bitLATB = (LATB & 0xFF0F) | 0x10;toggleE(); //Toggle E bitLATB &= 0xFF0F; //Set Entry Mode (Increment)toggleE(); //Toggle E bitLATB = (LATB & 0xFF0F) | 0x60;toggleE(); //Toggle E bitLATB |= 0x8; //Set R/*W line HI (write) (R/*W = 1)}

/*Routine to apply a 100us pulse to the E input of the display.*/

Page 15: MT2278 - Paper - POBox

void toggleE(void){LATF |= 0x0010; //Set E pin (E = 1)T100us(); //100 us DelayLATF &= 0xFFEF; //Reset E pin (E = 0)}

/*Routine to load CONTROL character into the display (4 bit bus).*/void DispCmd(unsigned char data)

{LATB &= 0xFFF7; //Reset R/*W line LOW (write) (R/*W = 0)LATF &= 0xFFDF; //Reset RS line low (RS = 0)LATB = (LATB & 0xFF0F) | (data & 0xF0); //Load Upper Nibble of datatoggleE(); //Toggle E-LineLATB = (LATB & 0xFF0F) | ((data << 4) & 0xF0); //Load Lower Nibble of datatoggleE(); //Toggle E-LineLATB |= 0x0008; //Set R/*W line HI (write) (R/*W = 1)T5ms();//Wait 5ms}

/*Routine to load DATA characters into the display (4 bit bus).*/void DispDat(unsigned char data)

{LATB &= 0xFFF7; //Reset R/*W line LOW (write) (R/*W = 0)LATF |= 0x0020; //Set RS line high (RS = 1)LATB = (LATB & 0xFF0F) | (data & 0xF0); //Load Upper Nibble of datatoggleE(); //Toggle E-LineLATB = (LATB & 0xFF0F) | ((data << 4) & 0xF0); //Load Lower Nibble of datatoggleE(); //Toggle E-LineLATB |= 0x0008; //Set R/*W line HI (write) (R/*W = 1)}

COMMUNICATION PORTThe communications port uses only a single direction of the UART MODULE. It was used to collect data during the development of the software and can also be used to monitor the heartbeat waveform from both the IR and RED sensors if one wishes. Input RD9 which is connected to SW1 on the demo board is used to toggle between three different data output modes. More will be explained on this later.

The UART pin of the controller is connected to IC-U1, a MAX232 (EIA-232 Driver/Receiver) manufactured by Texas Instrument. U1 converts the output voltage level of the controller UART to those necessary to connect to an RS-232 device. The output of U1 goes to the 3-pin connector (JCom) which may be wired to the RS-232 port of a computer.

The software sets up the UART MODULE to have the following parameters:Baud Rate: 115200Data Size: 8 bitsParity: NoneStop Bits: OneFlow Control: None

The code segments used to initialize and implement the UART are shown below:

Page 16: MT2278 - Paper - POBox

/*Sets up the Serial Port UART hardware with the following characteristics *//*BAUDRATE: 115200 *//*DATASIZE: 8 *//*PARITY: N *//*STOPBIT: 1 *//*FLOW: NONE */void UARTinit(int BRGWord)

{ TRISF = 0xC; //Make pins U1RX and U1TX inputs

U1BRG = BRGWord; //Calculate word for Baud Rate RegisterU1MODE = 0x8400; //Enable UART, Set 8-n-1, Use U1ARX/U1ATX U1STA = 0x0440; //Reset status register and enable TX & RX_U1RXIF=0; //Clear UART RX Interrupt Flag}

/*Send a single character out the UART*/void SendChar(char data)

{ int i = 0;U1TXREG = data; //Place data in transmit register.while ( !U1STAbits.TRMT && (i<10000) ) //Wait for byte to be sent or timeout.

i++;}

/*Send a string out the UART*/void SendString(char s[])

{int i = 0;while(i < BigString) //Send each character to trasmitter. Stop at NUL or largest string.

{if( s[i] == '\0' ) // quit on string terminator

break; SendChar(s[i++]);}

}

SWITCH INPUTInput RD9 which is connected to SW1 on the demo board can be used to toggle between three different data output modes. The data that comes out the serial port will be ASCII and utilizes a space character as a separator. There are three different groups of software-variables that may be selected. They are as follows:

GROUP 1:RFilt - LP Filtered RED Led Measured Intensity R_DC - DC Level for RED Led Measured IntensityIRFilt - LP Filtered IR Led Measured IntensityIR_DC - DC Level for IR Led Measured Intensity

GROUP 2:IRDiff - LP Filtered, IR AC signaldIRFilt - Differentiated LP Filtered IR dataPeak - Output of the Peak Follower Algorithm

GROUP 3:BPM - Heart Rate in beats-per-minuteSPO2 - Oxygen Saturation in Percent

Page 17: MT2278 - Paper - POBox

Hyper-Terminal can be setup to collect the data that is sent out the serial port. Hyper Terminal is a program that is bundled with all Microsoft Windows O.S.

LTF SENSORThe sensor chosen to measure the light intensity of both emitters is a digital Light to Frequency (LTF) device manufactured by Texas Advanced Optoelectronic Solutions (TAOS). It has a digital TTL output instead of a low level analog output that is used in most oximetry equipment. The advantages of such a device are better noise immunity and no analog signal conditioning required. All digital techniques may be applied with one processor. The LTF chosen is the TDL235R because of its small size and excellent sensitivity. Its internal workings consist of a silicon photodiode and a current-to-frequency converter on a single monolithic CMOS integrated circuit. This means, there is a high-level signal out of the sensor that can travel a distance over the cable and still maintain its signal integrity. The output is a square wave with a 50% duty cycle. The device allows direct interface to a microcontroller such as the Microchip dspPIC30F family. The small size fits the device into the oximeter probe very easily with three wires connecting back to the instrument.LED EMITTERSThe RED and IR sources used in the oximetry probe have been described in the section on the LED driver circuit. The small size of these emitters along with the TAOS device make an excellent home-made probe.

MOUSE CABLEThe emitter and sensor connections back to the instrument were made with an old left over serial mouse. The DB9 connector was already attached and the cable was perfect with its flexibility. The mouse portion was discarded. There were enough wires in the cable to accomplish this connection (only 5 needed). Don't have to worry about shielding with the LTF sensor, so it worked great.

VELCRO CONSTRUCTIONThe emitter assembly and the LTF sensor were both soldered to a small section of perf-board (left over from another project). This perf-board has solder pads to allow soldering the devices and wires. Both boards need to be about ½" square.

The boards are soldered to the mouse cable wires. About 2" of cable were stripped back to expose the individual wires. Wires need to be dressed as short as possible.

FIGURE 6:

Page 18: MT2278 - Paper - POBox

Two holes were punched into the Velcro so that they would be on opposite sides of the index finger. This is the soft side of the Velcro (top strip).

The boards were placed on the sticky side of the Velcro (soft side) in such a way that the light would go through one hole pass through the finger and get detected on the opposite hole. The soft strip of the Velcro will make contact the finger.

The mating side of the Velcro (hard side) is attached to the side containing the sensors (soft side). Be very careful with the alignment. Sticky side to Sticky side.

SOFTSTRIP

HARDSTRIP

Photograph 1: Holes are punched into the soft Velcro strip. The locationof the holes correspond to the top and bottom of the index finger.

Photograph 2: The two sensors are placed into position after being soldered to the wires of the cable. The two Velcro strips are adhered together to form one flexible piece.

Page 19: MT2278 - Paper - POBox

Photograph 3:Sensor assembly is complete. A smaller section of transition cable was built toconnect the DB9 serial connector into the mezzanine board.

SOFTWAREMEASUREMENT STRATEGYAs discussed in the HARDWARE section of this paper, Timer T1 sets up a 5ms interrupt. The interrupt handler sets up a state machine with two states and an initialization state that takes place in the main program. The state machine has the following flow diagram:

STATE = -1Executed in Main Program

STATE = 0The system waits for the next T1interrupt 5ms later. During thistime, the IC1 interrupt gets centerstage. MEASURE is the state counter for the IC1 interrupt.

Turn OFF both LEDsSet DAC valuesInitialize Timer T1

Set PULSE = 0 (Diagnostic)Set MEASURE = 0Initialize Timer T2Initialized IC1STATE = 1

Interrupt T1 occurs

Page 20: MT2278 - Paper - POBox

STATE = 1After 5ms, the second T1 eventOccurs. The measurements haveBeen taken and it is time to processThe data. This occurs during thisSTATE

In the main program, at a presetable number of samples, the program runs the auto_adj() procedure which tunes the IR LED to match the intensity of the RED LED. After this routine is executed, the STATE counter is set to –1,

AND THE BEAT GOES ON…

During STATE = 0, the T1 handler sets up the entry point for the IC1 interrupt. The state counter MEASURE = 0. The RED DAC is loaded and the RED LED is turned on. The IC1 interrupt will occur on the rising edge of each and every TAOS output pulse until the IC1 interrupt is disabled. The interrupt occurs twice for each emitter measuring the PERIOD from the TAOS device and calculating the subsequent INTENSITY.

MEASURE=0

MEASURE=1

Set PULSE = 0 (Diagnostic)Perform LP filteringPerform HP filteringPerform DC trackingSet PULSE = 1 (Diagnostic)Calculate AC signal ValuesSTATE = 0

Interrupt T1 occurs

IC1 Interrupt Handler

Read IC1 buffer and save T0 = IC1BUFMEASURE = 1

Read IC1 bufferCalculate RED periodCompute Intensity for RED (K/RPeriod)Turn OFF RED LedTurn ON IR LedMEASAURE = 2

IC1 Interrupt Handler

Page 21: MT2278 - Paper - POBox

MEASURE=2

MEASURE=3

The STATE=1 of the T1 interrupt handler process the Low Pass Filter, High Pass Filter and DC Tracking filter algorithms for both the RED and IR sources. These algorithms are briefly described next.

LOW PASS FILTERINGThe 4th order LP algorithm in Z-domain is:

Fc = Low Pass Cutoff FrequencyTs = Sample Rate

IC1 Interrupt Handler

Read IC1 buffer and save T0 = IC1BUF MEASURE = 3

IC1 Interrupt Handler

Read IC1 bufferCalculate IR periodCompute Intensity for IR (K/IRPeriod)Turn OFF IR LedMEASURE = 0Disable IC1Disable T2

Page 22: MT2278 - Paper - POBox

The coefficients of the above function are determined in the main program while the algorithm is executed after each set of Red and IR samples are acquired in the interrupt handler for the T1 timer. This occurs every 10ms.

DIFFERENTIATOR (HIGH PASS FILTER)The differentiator is used by the peak follower algorithm to detect an edge for timing of the heart wave.

Fh = High Pass Cutoff FrequencyTs = Sample Rate

DC TRACKING FILTERAverages the Low Pass output and removes the AC signal.

The output of this algorithm is the DC level for each color LED.

PEAK FOLLOWERThe Peak Follower algorithm can be found in the main program. Referencing the code listing, you can see the segment of code listed below is the main structure for the peak follower.

if(dIRFilt < = Peak)Peak = dIRFilt;MeasureFlag = -1;

else{..

Page 23: MT2278 - Paper - POBox

.}

The peak follower algorithm uses the differentiated Lowpass output sequence from the IR sensor as its input. The idea is to allow the Peak variable to follow these differentiated peaks and decay at a very slow rate. It works much like a filter capacitor in a power supply. It attempts to follow the peaks and decays very slowly producing an envelope that can be used to time the heartwave that is produce by the IR signal. This IR signal was chosen because its amplitude is greater that that of the RED source and it doesn’t vary as much as the RED sensor does.

HEARTBEAT/SpO2 CALCULATIONThe peak follower is used to time the period of the heart wave and also set up a period for the RMS calculation of the AC portion of the signal. In the T1 handler, the AC signal is calculated by taking the difference between the Filtered Sensor output and the DC level (from the DC tracking algorithm). For example, the AC signal from the RED sensor is:

Rdiff = Rfilt – R_DC;

The RMS value is calculated for each sample of the Rdiff and accumulated using the statement:

Rsum = RDiff*RDiff + Rsum;

After the period is detected, the RMS value is calculated and Rsum set back to 0:

Rms = sqrt(Rsum/period);Rsum = 0;

Once the RMS value is calculated, the SPO2 is calculated by finding the ratio R;

R = Rrms/RDC / Irrms/IRDC

Then,

SIMPLE MOVING AVERAGE FILTERA simple moving average filter is used to smooth the heartrate and the oxygen calculations over 10 samples. It follows the general form:

Where,

Page 24: MT2278 - Paper - POBox

N = 10

FIGURE 7: Above shows the results of the differentiator (black) and the peak follower envelope (blue) on the IR waveform (Red)

ASSEMBLY

16-bit 28-pin DEVELOPMENT BOARDThe only modification that needs to be done to the development board is the removal of the zero ohm jumpers R14 – R17. These are not needed in this application.

MEZZANINE BOARDThe mezzanine board is mounted atop the 16-bit 28-pin development board using the exiting header and a connector. Use appendix 8 to order parts for the board. Use appendix 7 to cut, drill and layout the connectors for the board. Refer to the schematic for wiring of the board. Below is a photograph of the board after it has been wired.

Photograph 4: Mezzanine board after assembly

Page 25: MT2278 - Paper - POBox

LCD ASSEMBLYThe Liquid Crystal Display assembly is assembled by adding the 16 pin connector to the Hantronix component. Refer to Appendix 6 for connector part numbers and Appendix 7 for location of the mating connector on the mezzanine board. Below shows a photograph of the display assembly with the connector added.

Page 26: MT2278 - Paper - POBox

Photograph 5: The display is complete after the connector is soldered in place.

.

Photograph 6: Above is a photograph of the completed mezzanine assembly with the display removed. Notice that there are two battery clips connected together. This gives the option of using a 9V wall-wart power supply or a 9VDC battery to power the unit.FINAL ASSEMBLYThe Mezzanine board is carefully positioned above the Microchip 16-bit 28-pin Development Board, then the two are plugged together using the connector/header installed. The Display board is now plugged into the mezzanine board matching the connector/headers installed. Standoff posts were used on both sides of the mezzanine board to space the boards from each other as well as providing support when the boards are pressed together. Two of the standoffs can be seen in Photograph 6 atop the mezzanine board and the mounting screws for the other two can be seen at the top of the mezzainine. These are mounted at the bottom of the board. Of course, these need to be installed before the board is wired. The approximated location for the holes for these standoffs can be found in appendix 7 - Mezzanine Board Layout.

Page 27: MT2278 - Paper - POBox

Photograph 7: Above is a photograph of the completed system. The mezzanine board has been connected to the Microchip board. The Display has been connected to the mezzanine board. Both the RS-232 cable (left side of mezzanine board) and the sensor cable (top side of mezzanine board) have been connected. Note the sensor located to the left of the system. Power to the unit is through the wall-wart power adapter supplied with the Microchip ICD-2 tool.

OPERATIONSWhen the system is powered up, there will be a brief prompt on the display as that

shown below in photograph 8.

Photograph 8: Shows unit at power-up. Notice display prompt. This will last for a few seconds.

Page 28: MT2278 - Paper - POBox

After the unit has gone through its initial power up, it will display the prompt "WAITING" as show in photograph 7. Place one of your index fingers into the sensor. The first time you use the unit, you will have to wrap the sensor around the finger. Photo 7 shows the sensor that has already been fitted to my finger. Once the controller detects the placement of the finger, it will begin taking measurements. After about 10 seconds, you will have a stable reading of both your heart-rate (BPM) and your blood oxygen saturation (SP2). Below is a photograph of the system measuring my heart-rate at 77 beats-per-minute and my SPO2 at 99%. The heart-rate was up slightly because of the success of the project.

Photograph 9: Stable measurements after about ten seconds. BPM = 77 and SPO2 = 99%.

APPENDIX 1

TRANSMITTANCE

Materials can absorb electromagnetic radiation such as light. The definition of transmittance through a material with concentration C is:

Io IConcentrationC

Page 29: MT2278 - Paper - POBox

where: I = Output IntensityIo = Input Intensity

ABSORBANCE

The absorbance by the material is defined as the log of the inverse of transmittance:

APPENDIX 2

BEER-LAMBERT LAW

AIo IiIizIz I I IIz Iz-dI

Page 30: MT2278 - Paper - POBox

Z dZ, dI

B

The Beer-Lambert model can be derived for a material of absorbing species. First consider the absorption dI, of an infinitesimal cross-sectional slab of material of thickness dZ. The total length of the path of the material is B with a total cross-section of A. The intensity is Io at Z=0 and I at the full length of the material. The intensity at Z is Iz. The intensity after the absorption dI is (Iz – dI). Consider a molecular cross section of (cm2). If there is a concentration of N (mol/cm2) absorbers in this molecular cross section. Then the total absorbed light on this infinite cross-sectional slab would be:

* N * A * dZ (cm2) * (# mol/cm3) * (cm2) * (cm) = #mol*cm2

The fraction of photons absorbed across this surface area A is:

* N * A * dZ / A = * N * dZ (#mol)

The fraction of the photons absorbed across dz becomes,

- * N * dZ = dI/Iz

Integrating both sides,

Remember that absorbance is equal to the left side of the equation, and then the equation becomes:

A = NB

Page 31: MT2278 - Paper - POBox

Since N (molecules/cm3) *(1 mol/6.023x1023 molecules) * 1000 cm3/liter = c (mol/liter)

and 2.303 * log(x) = ln(x)

then,

or,

where, = * (6.023 x 1020/2.303) = * (2.61 * 1020)

So,

Beer-Lambert Law

APPENDIX 3

OXYGEN SATURATION

Hemoglobin is the primary component that carries oxygen from the lungs to the rest of the body via passages called arteries, veins and capillaries. It is a protein that is bound to the red blood cells. Oxygen is chemically combined with the hemoglobin inside of the red blood cells and makes up nearly all the oxygen present in the blood.

The absorption of visible light at different frequencies by hemoglobin varies with oxygenation as can be seen in Figure 1 (THEORY section). Two forms of the hemoglobin molecule are oxidized (HbO2) and reduced hemoglobin (Hb).

The oxygen saturation is defined, as SaO2 (SPO2) and s a function of the concentration of the two forms of hemoglobin in the blood:

Where,

Page 32: MT2278 - Paper - POBox

Ko = Concentration of HbO2Kr = Concentration of Hb

Arterial SpO2 is a parameter measured with Oximetry and is normally expressed as a percentage. Under normal conditions, arterial blood is 97% saturated while venous blood is 75% saturated.

The wavelength range 600nm – 1000nm is the range for which there occurs the least amount of attenuation of light by body tissue because tissue and pigmentation absorb blue, green and yellow light and water absorbs the longer infrared wavelength.

The Oxygen Saturation (SPO2) of the arterial blood may be determined by measuring the transmitted light through the fingertip or earlobe at two different wavelengths and then compared ratiometrically. The two wavelengths that best suit this type of measurement are RED (660nm) and INFRARED (940nm).

According to the Beer-Lambert law there is a linear relationship between the absorbance and concentration of each component of the blood at that particular frequency of light. Also, the intensity of the light will decrease logarithmically with the path length.

Io I

Z

Suppose we had a source of length Z with incident light intensity Io and transmitted intensity of I. If there were two species of absorbers called HbO2(RED) and Hb (Blue) with the concentrations Ko and Kr respectively. These are analogous to oxygenated hemoglobin and reduced hemoglobin. Now supposed we examine the specimen using two light sources 1 and 2.

Using Beer-Lambert law, at each wavelength, we get:

Page 33: MT2278 - Paper - POBox

At (1)

At (2 )

Where:K0 = concentration of hemoglobinK1 = concentration of reduced hemoglobino1 = absorption coefficient of HbO2 at 1

r1 = absorption coefficient of Hb at 1

o2 = absorption coefficient of HbO2 at 2

r2 = absorption coefficient of Hb at 2

Writing both equations in log form:We can express both functions as the ratio (R).

Then solving for Kr,

Substituting this into the equation for SaO2 yields:

Where:

Page 34: MT2278 - Paper - POBox

Below is a graph of the above equation showing the theoretical values. The second trace shows an actual calibration using arterial blood samples. This is the curve for the HP M1190A probe. The difference has been found to be caused mainly by scattering effects and non-ideal light sources.

Using Matlab, analyzing the graphical data above, data from the real calibration curve shown above was extracted into vector form. The data was input into Microsoft excel and fit to a 3rd order equation. It is this equation which expresses SpO2 = f (R) that was used in this project. The graph of this data and the fit equation are shown below.

Page 35: MT2278 - Paper - POBox

APPENDIX 4

OUTPUT DATAThe thee photographs below show graphs of the data that was collected from the COM port. In reference to SW1 on the demo board, each time it is pressed, a different group of data is sent out the port. The data consists of program variables.

GROUP 1:RFilt - LP Filtered RED Led Measured Intensity (red)R_DC - DC Level for RED Led Measured Intensity (black)IRFilt - LP Filtered IR Led Measured Intensity (blue)

Page 36: MT2278 - Paper - POBox

IR_DC - DC Level for IR Led Measured Intensity (red)

GROUP 2:IRDiff - LP Filtered, IR AC signal (red)dIRFilt - Differentiated LP Filtered IR data (black)

Page 37: MT2278 - Paper - POBox

Peak - Output of the Peak Follower Algorithm (blue)

GROUP 3:BPM - Heart Rate in beats-per-minute (red)SPO2 - Oxygen Saturation in Percent (black)

APPENDIX 5

Page 38: MT2278 - Paper - POBox

BLOCK DIAGRAM

\APPENDIX 6SCHEMATIC DIAGRAM

VDD

VB

VOLTAGE REGULATOR

LM7805 1

2

3

ON/OFFPOWER

9V

LONGLIFEBATTERY

MICOCHIP 16-Bit 28-Pin Starter Board

XTFREQ = 7.3728MHzPLLMODE = 16Fcy = XTFREQ*PLLMODE/4 =29.4912MHZ CLOCK

R/*W

E

RS

P/N: HDM08216H-3-S00SMFG: HANTRONIX INC.

DISPLAY2 LINE x 8 ASCII CHARACTER

D7

D6

D5

OUTPUTS

RB5

RB6

RB7

RB3

DIGITAL I/O

OUTPUTS

RF4

RF5

RB4 D4

115.2KHz

Interrupt

TIMER T216 BIT

SERIAL PERIPHERAL

RED

IRED

PDI-E835DUAL LED EMITTERS

API

RF3/SDO1

RB2/*SS1

RF6/SCK1

DUALOP-AMPDRIVERS

MCP607MICRCHP

VOLTAGEDUAL 8BITMCP4822

OUTPUT DAC

MICROCHIP

MPQ6002

XISTORQUAD PACK

CENTRAL-SEMI.

INTERFACE (SPI)

RD9

RC14

TIMER T116 BIT

/256 PRESCALER

RD8/IC1CAPTUREINPUT

IC1

29.4912MHZ

SW1

PR1 = 576

INTERRUPTROUTINEREADSTIMER

5ms

SERIAL/UART0

INPUT

LIGHT SOURCES. ITALSO SETS UP TIMERT2 AND INPUT CAPTURE

ARE PROPORTIONAL TO

LED INTENSITY.

IC1 TO MEASURE THETAOS LTF OUTPUT INTHE FORM OF A PERIOD.THESE PERIODS ARECONVERTED TO FREQUENCIES WHICH

THEIR CORRESPONDING

THE PROGRAM USES THE INTENSITY SAMPLES TO

AND OXYGEN SATURATION.DETERMINE HEART-RATETAOS

TSL235R

SENSOR

FINGER

L/F

SAMPLECLOCK(100 Hz)

TRIGGERS INTERRRUPTROUTINE WHICH IS SETUP AS A STATE MACH.

THIS STATE MACHINE

SEQUENCES THE LEDMULTIPLEXES AND

PE1RC13

RB1

RB0 VIRon

VRon

TO PCDATA

SERIALRS-23257.6K,N,8,1

U1ATx 2

U1ARx

5 9 4 8 3 7

P1

6 1

Page 39: MT2278 - Paper - POBox

BT19V234KKEYSTONE

OFF

1

2

3SW1EG2477ESwitch

ON

C11

C20.1

C31

VIGND

VOU1LM7805FAIRCHILD

VDD

VB

C40.1

FRONT

LM7805

RB6

1234567891011121314

2827262524232221201918171615

P2

FEMALE: PPTC142LFBN-RCMALE: PEC14DAAN

SULLINS

MEZZANINE BOARD

*MCLRRB0RB1

MICROCHIP INTERFACE

GND

RB3RB4RB5

VDD

RB2/*SS1

RC13/U1ATXRC14/U1ARX

RD9/IC2

RB7

RF4RF5VDDGND

RD8/IC1RF6/SCK1RF3/SDO1RF2

RB9/OC2RB8/OC1

Vi G Vo C EB

2N3904BOTTOM

R81.2K Q2

2N3904

R41.1K

RD8

R65K

R55K

VB

VDD +5V

0V

Fo

JSen

1

5

2 TOSENSOR

LEDI

LEDR

3

4

HEADER:103361.3AMP

8910

11

12

13

14

U2MPQ6002CENTRAL SEMI

VDD

Q12N3904

R71.2K

R31.1K

C50.1

VIRon

VRonRB1

RB0

VDDRF5RF4

RB5

RSE

D5

DISPLAYP110KX262R103CTS

1 23 45 67 89 1011 1213 1415 16

DISP

MALE: PEC08DAAN

GNDVL

D4

R/*W

RB4

RB3

D6RB6 D7 RB7

RxD

TxD

GND

o Remove 0-ohm resistor jumpers R14-R17 from microprocessor board. o Display used is Hantronix P/N: HDM08216H-3-S00S. o An Enclosure has not yet been chosen for this prototype.

BLOCK:102241.1TERM:876672

NOTES:

123

JComm

AMP

12345

BLOCK:102241.3TERM:876672AMP

Jsen

RS-232 CABLE

RxDTxD

GND

SENSOR CABLE

+5V

0V

LEDR

LEDI

Fo

FEMALE: PPTC082LFBN-RC

VDD

0.1

RB2/*SS1RF6/SCK1RF3/SDO1

SULLINS

1 8VDD*CS 2

SCK 3

SDI 4 *LDAC 5VOB 6GND 7VOA

C6

U3MCP4822MICROCHIP

6

5

1

2

17SDE09SAMPHENOL

5 9 4 8 3 7 2 6 1

RS232

RxD

TxD

GND

VELCRO

I

PDI-E832Rd 660nm 1.8V 20maIR 905nm 1.2V 20ma

R

GND

TSL235RTAOS

EMT1

API

SENSOR

VDD

FOUT 3

U1

ENCLOSURE: TBD

RC13/U1ATX

T2OUTR2IN

MAX232

V- 6 7 8

TI

C81

C101

VDD

C1+ 1

V+ 2

C1- 3

C2+ 4

C2- 5

U1

C71

C91

T1IN 11

R2OUT 9T2IN 10

R1OUT 12R1IN 13T1OUT 14GND 15VCC 16

MICROCHIP

2

3 1

4

U4AMCP607

RC14/U1ARX

7

U4BMCP607MICROCHIP

8

R120

R220

1 2 3 4 5 6 7

COMMRS232

HEADER:103361.1

PORTGND 3

AMP

TxD

RxD 2

JComm

1

APPENDIX 7MEZZAINIE BOARD LAYOUT

Page 40: MT2278 - Paper - POBox

APPENDIX 8BILL OF MATERIAL

- DENOTES DRILL HOLE

0.2

1

3

3.4

12

0.2

2.720.6

1.9

0.2

Page 41: MT2278 - Paper - POBox

MEZZANINE BOARD

Qty REF P/N MFG---------------------------------------------------------------------------------------1 BT1 234K KEYSTONE 1 C1 1 GENERIC 1 C2 .1 GENERIC 1 C3 1 GENERIC 1 C4 .1 GENERIC 1 C5 .1 GENERIC 1 C6 .1 GENERIC 1 C7 1 GENERIC 1 C8 1 GENERIC 1 C9 1 GENERIC 1 C10 1 GENERIC 1 DISP MALE: PEC08DAAN SULLINS

FEMALE: PPTC082LFBN-RC SULLINS 1 JComm HEADER:103361.1 AMP 1 JSen HEADER:103361.3 AMP 1 P1 10K X262R103 CTS 1 P2 FEMALE: PPTC142LFBN-RC SULLINS

MALE: PEC14DAAN SULLINS 1 Q1 2N3904 GENERIC 1 Q2 2N3904 GENERIC 1 R1 20 GENERIC 1 R2 20 GENERIC 1 R3 1.1K GENERIC 1 R4 1.1K GENERIC 1 R5 5K GENERIC 1 R6 5K GENERIC 1 R7 1.2K GENERIC 1 R8 1.2K GENERIC 1 RS232 17SDE09S AMPHENOL 1 SW1 EG2477 ESwitch 1 U1 MAX232 TI 1 U1 LM7805 FAIRCHILD 1 U2 MPQ6002 CENTRAL SEMI 1 U3 MCP4822 MICROCHIP 1 U4 MCP607 MICROCHIP APPENDIX 7BILL OF MATERIAL - Continued

Page 42: MT2278 - Paper - POBox

SENSOR

Qty REF P/N MFG---------------------------------------------------------------------------------------1 U1 TSL235R TAOS 1 EMT1 PDI-E832 API