A photoplethysmograph experiment for microcontroller labs

Similar documents
i S1 V IN i C1 i N i C2 i S2

Sinusoidal Steady State Analysis

A Novel Control Method for Input Output Harmonic Elimination of the PWM Boost Type Rectifier Under Unbalanced Operating Conditions

Pre-distortion Linearization for 64-QAM Modulation in Ka-Band Satellite Link

Web-based Remote Human Pulse Monitoring System with Intelligent Data Analysis for Home Healthcare

Superposition, Thevenin and Norton. Superposition

Simplified Algorithm and Hardware Implementation for the (24, 12, 8) Extended Golay Soft Decoder Up to 4 Errors

Synchronous Machine Parameter Measurement

A High-Sensitivity Oversampling Digital Signal Detection Technique for CMOS Image Sensors Using Non-destructive Intermediate High-Speed Readout Mode

Synchronous Machine Parameter Measurement

Unit 1. Current and Voltage U 1 VOLTAGE AND CURRENT. Circuit Basics KVL, KCL, Ohm's Law LED Outputs Buttons/Switch Inputs. Current / Voltage Analogy

Exercise 1-1. The Sine Wave EXERCISE OBJECTIVE DISCUSSION OUTLINE. Relationship between a rotating phasor and a sine wave DISCUSSION

VI.C CIRCUIT BREAKERS

ABB STOTZ-KONTAKT. ABB i-bus EIB Current Module SM/S Intelligent Installation Systems. User Manual SM/S In = 16 A AC Un = 230 V AC

Design and Construction of Automatic Voltage Regulator for Diesel Engine Type Stand-alone Synchronous Generator

IEE Electronics Letters, vol 34, no 17, August 1998, pp ESTIMATING STARTING POINT OF CONDUCTION OF CMOS GATES

Figure 1. DC-DC Boost Converter

High Speed ADC Sampling Transients

Design of solar insolation power logging system with ADC error testing and correction

antenna antenna (4.139)

Application Note. Differential Amplifier

RC Filters TEP Related Topics Principle Equipment

Protection of insulated gate bipolar tr. t.

5 October 2015 Stereo Cross-feed Network for Headphones 1 of 12 Copyright 2015 Peter H. Lehmann. All Rights Reserved.

EFFECTIVE CURRENT CONTROL DESIGN AND ANALYSIS OF SINGLE PHASE INVERTER FOR POWER QUALITY IMPROVEMENT

Reinforcement Learning for Fuzzy Control with Linguistic States

EE Controls Lab #2: Implementing State-Transition Logic on a PLC

Math Circles Finite Automata Question Sheet 3 (Solutions)

VRT014 User s guide V0.8. Address: Saltoniškių g. 10c, Vilnius LT-08105, Phone: (370-5) , Fax: (370-5) ,

An Optimal Method for Using Multiple Gateways in Cellular IP Networks

POLYTECHNIC UNIVERSITY Electrical Engineering Department. EE SOPHOMORE LABORATORY Experiment 1 Laboratory Energy Sources

The Performance Improvement of BASK System for Giga-Bit MODEM Using the Fuzzy System

Passive Filters. References: Barbow (pp ), Hayes & Horowitz (pp 32-60), Rizzoni (Chap. 6)

Figure 1. DC-DC Boost Converter

Content Based Color Image Retrieval via Wavelet Transforms

IMPROVEMENT OF THE QUALITY OF ELECTRICAL POWER BY A PHOTOVOLTAIC GENERATOR CONNECTED TO THE GRID

MAXIMUM FLOWS IN FUZZY NETWORKS WITH FUNNEL-SHAPED NODES

Student Book SERIES. Fractions. Name

Digital Transmission

TECHNICAL NOTE TERMINATION FOR POINT- TO-POINT SYSTEMS TN TERMINATON FOR POINT-TO-POINT SYSTEMS. Zo = L C. ω - angular frequency = 2πf

CHAPTER 2 LITERATURE STUDY

ECE 274 Digital Logic

ECE 274 Digital Logic. Digital Design. Datapath Components Shifters, Comparators, Counters, Multipliers Digital Design

Research on error compensation and measurement technology in robot flexible measurement

Algorithms for Memory Hierarchies Lecture 14

Synchronous Generator Line Synchronization

Module 9. DC Machines. Version 2 EE IIT, Kharagpur

Misty. Sudnow Dot Songs

100 mm. 200 mm. 300 mm. 500 mm. Wood (rough) Cardboard Black DBT DBT DBT DBT DBT - 1 K DBT K CONNECTION DIAGRAMS.

Sequential Logic (2) Synchronous vs Asynchronous Sequential Circuit. Clock Signal. Synchronous Sequential Circuits. FSM Overview 9/10/12

MEASURE THE CHARACTERISTIC CURVES RELEVANT TO AN NPN TRANSISTOR

LOW SENSITIVITY DESIGN OF MULTIPLIERLESS ELLIPTIC IIR DIGITAL FILTERS

Experiment 3: Non-Ideal Operational Amplifiers

High Speed, Low Power And Area Efficient Carry-Select Adder

-.. ANALOG DEVICES. HighSpeed,LowDrift FEYOperationalAmplifieṛ !'

Semi-quantum private comparison protocol under an. almost-dishonest third party

Single-Phase SOGI-PLL Based Reference Current Extraction for Three-Phase Four-Wire DSTATCOM

Experiment 3: Non-Ideal Operational Amplifiers

Arduino for Model Railroaders

Design of Neuro-Fuzzy System Controller for DC Servomotor- Based Satellite Tracking System

Walsh Function Based Synthesis Method of PWM Pattern for Full-Bridge Inverter

The Discussion of this exercise covers the following points:

A Development of Earthing-Resistance-Estimation Instrument

Mitigation of Harmonics by Shunt Active Power Filter using Synchronous Detection Method

Polar Coordinates. July 30, 2014

Lecture 20. Intro to line integrals. Dan Nichols MATH 233, Spring 2018 University of Massachusetts.

Compared to generators DC MOTORS. Back e.m.f. Back e.m.f. Example. Example. The construction of a d.c. motor is the same as a d.c. generator.

A Novel Back EMF Zero Crossing Detection of Brushless DC Motor Based on PWM

Engineer-to-Engineer Note

Digital Design. Chapter 1: Introduction

A Substractive Clustering Based Fuzzy Hybrid Reference Control Design for Transient Response Improvement of PID Controller

FFT Spectrum Analyzer

EET 438a Automatic Control Systems Technology Laboratory 5 Control of a Separately Excited DC Machine

CAL. NX15 DUO-DISPLAY QUARTZ

ECE 274 Digital Logic Fall 2009 Digital Design

CONTENTS. 2 Mastering Ukulele

Figure.1. Basic model of an impedance source converter JCHPS Special Issue 12: August Page 13

Performance Evaluation of Survivable Multifiber WDM Networks

29. Network Functions for Circuits Containing Op Amps

Research on Peak-detection Algorithm for High-precision Demodulation System of Fiber Bragg Grating

Chapter 13. Filters Introduction Ideal Filter

Uncertainty in measurements of power and energy on power networks

How to Get Started with Virtual Goalie

Triferential Subtraction in Strain Gage Signal Conditioning. Introduction

Software Pipelining for the Pegasus IR

NATIONAL RADIO ASTRONOMY OBSERVATORY Green Bank, West Virginia SPECTRAL PROCESSOR MEMO NO. 25. MEMORANDUM February 13, 1985

Energy Efficient Session Key Establishment in Wireless Sensor Networks

Abacaba-Dabacaba! by Michael Naylor Western Washington University

Time-frequency Analysis Based State Diagnosis of Transformers Windings under the Short-Circuit Shock

Strain Gauge Measuring Amplifier BA 660

Engineer-to-Engineer Note

Data Attribute Reduction using Binary Conversion

Section 16.3 Double Integrals over General Regions

MASTER TIMING AND TOF MODULE-

EE 201 Lab Lab 9. AC analysis. This week we look at some (relatively) simple AC circuits.

... -J to send radio signals through the air, how modulation , IJ."~ UNITED STATES~~ FREQUENCY ALLOCATIONS

Efficient Large Integers Arithmetic by Adopting Squaring and Complement Recoding Techniques

International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 INTERNATIONAL JOURNAL OF ADVANCED RESEARCH IN

Experiment 3: The research of Thevenin theorem

Microelectronic Circuits

Transcription:

A photoplethysmogrph experment for mcrocontroller lbs Z- Gngl, A photoplethysmogrph experment for mcrocontroller lbs INTERNATIONAL JOURNAL OF ELECTRICAL ENGINEERING EDUCATION 49:() pp. 4-60. (0) http://dx.do.org/0.77/ijeee.49..4 Fnl mnuscrpt A photoplethysmogrph experment for mcrocontroller lbs Zoltn Gngl Deprtment of Techncl Informtcs Unversty of Szeged, H-670 Árpád tér, Szeged, Hungry e-ml: gngl@nf.u-szeged.hu. Abstrct An esy-to-buld photoplethysmogrph experment for mcrocontroller lbs s presented. Students lern bout drect sensor nterfcng to modern mxed-sgnl mcrocontrollers nd sgnl processng durng n exctng bomedcl mesurement whch s generl nd mportnt enough to be ncluded n vrous engneerng courses. The full development s open source nd the low-cost hrdwre s vlble worldwde. The experment s hghly trnsprent nd sclble, ccessble to begnners whle provdng mny chllenges to even the most qulfed students. It cn lso be used s demonstrton tool n orl lecturng. Keywords: photoplethysmogrph, sensor, mxed-sgnl mcrocontroller, lbortory experment, open source Introducton The brod rnge of mcrocontroller (MCU) pplcton felds ncludes consumer electroncs, household mchnes, bttery-powered portble nd werble helthcre products, utomotve ndustry, ndustrl sensng nd embedded control, smrt nd wreless sensors nd mny more. Tody's mxedsgnl MCUs offer hgh ntegrton of both dgtl nd nlogue perpherls lke tmers, communcton ports, supervsory crcuts, comprtors, dt converters, voltge references nd temperture sensors. In ddton, low power requrement, ese of use nd hgh effcency mke MCUs very populr n solvng mny multdscplnry engneerng problems. It s obvous tht trnng n MCU softwre nd hrdwre, nterfcng nd embeddng plys key role n engneerng educton. Courses of dfferent levels exst to d undergrdute nd grdute students of mechncl, bomedcl or electrcl engneerng n lernng bout MCUs nd ther pplctons. It s mportnt to note tht besdes the revew of the theoretcl bckground lbortory prctces re needed to enhnce the students' blty to successfully use MCUs to solve rel world problems. In the current pper sclble MCU-bsed LED-trnsstor photoplethysmogrph lbortory prctce experment s presented mng to demonstrte nd tech how n nlogue-ntensve modern MCU cn be ppled to effectvely provde nformton bout the crdovsculr system of the humn body. In typcl cse such lecture ncludes buldng nlogue sgnl condtonng crcutry bsed on opertonl mplfers, pplcton of dt converters nd dgtl processng unts nd cn lso requre the use of wreless networks -5. These solutons ether rely on pressembled prts of the development or need qute long tme nd comprehensve knowledge vlble lkely only n lmted envronment. Here n lterntve pproch s shown s n ddton to the bove mentoned methods. A hghly ntegrted mcrocontroller ncorportng hgh-resoluton dt converter reduces the complexty of nlogue preprocessng crcutry drmtclly. At the sme tme the code cn lso be kept very smple wthout ny loss of ccurcy. Although the bsc pplcton requres smll effort, mny ddtons re possble; therefore wde rnge of educton levels cn be covered. The whole experment s open source, the tested demonstrton code s shred on dedcted web

A photoplethysmogrph experment for mcrocontroller lbs pge 6, the development tools re vlble for free, nd the requred hrdwre s lso very esy nd chep to purchse worldwde, so ny lecturer cn strghtforwrdly dd t to n exstng course. The experment cn lso be ported to lterntve hrdwre pltforms. The prncple of fnger photoplethysmogrphy The photoplethysmogrph mesures blood volume chnges n n orgn, most commonly n the fnger. In crdc cycle the hert contrcts nd relxes, mkng chnge n the blood pressure nd consequently chnge n the momentry blood volume n the fnger. Snce hemoglobn bsorbs the nfrred lght, ths chnge cn be esly montored by usng n nfrred LED nd photodode or phototrnsstor n ether trnsmsson or reflecton mode s shown n Fg.. The sme prncple s ppled n pulseoxmetry, when red lght s used ddtonlly due to ts senstvty of oxygen content n the hemoglobn, whch llows the estmton of ths vlue compred to the sturton level 3. Note tht the plethysmogrph sgnl contns nformton bout the hert rte nd blood pressure chnges, blood vessel pulstons, brethng nd even more. The ese of use nd nstllton, nonnvsve nture nd rch nformton content mke photoplethysmogrphy very useful tool of montorng the processes of the humn body. Fg.. Prncple of the reflectve fnger photoplethysmogrph. The ntensty of the reflected lght depends on the momentry volume of blood n the fnger. Hrdwre pltform nd expermentl setup The sensor nd ctutor In one of the smplest experments seprte nfrred LED (SFH487) nd phototrnsstor (SFH309FA) re used n trnsmsson mesurement rrngement 7. However, t s sgnfcntly smpler to pply the reflectve method especlly f the photodetector s ntegrted wth the ctutor. In ths work the TCRT000 sensor-ctutor pr ws ppled, therefore no ddtonl mechncl work s needed to prepre the mesurement hed. The TCRT000 hs hgh senstvty, whle ts housng style nd bult-n nfrred flter provde esy nstllton, protecton gnst nterferng lght sources nd relble operton durng the experment. The MCU development kt There re severl hgh performnce mxed sgnl MCUs on the mrket wth ntegrted nlog components. The mesurement of photoplethysmogrph sgnls requres hndlng smll AC component n the presence of lrge DC component. In most cses, the DC component s removed by n nlogue hgh-pss flter, then the AC sgnl s mplfed by opertonl mplfers to mtch the rnge nd nput mpednce of the nlogue-to-dgtl converter (ADC) ntegrted nto the MCU. However, f the MCU hs wde dynmc rnge nd low nose ADC (resoluton rnge from 6 to 4

A photoplethysmogrph experment for mcrocontroller lbs 3 bts), the requred sgnl processng cn be done n the dgtl domn nd the externl nlogue sgnl condtonng cn be omtted, so the sensor cn be drectly nterfced. Ths pproch hs sgnfcnt dvntge n educton, snce the processng ppers much less s blck box; students cn smply mplement the needed opertons n the MCU nd cn esly explore the mpct of prmeter chnges on the results. Ths experment s bsed on C805F350DK development kt from Slcon Lbortores 8. The 805 s one of the most populr, successful nd longest lvng 8-bt MCU rchtectures well suted for sensors, ctutors nd most embedded control. Modern 805 MCUs hve fst core nd extensve ntegrton of nlogue nd dgtl perpherls. One exmple s the C805F350, whose sngle-cycle core cn be operted up to 50MIPS nd ntegrtes hghly confgurble 4-bt sgm-delt ADC. The low cost development kt contns the trget bord wth prototypng re, USB debug dpter nd emultor, code sze lmted compler nd ntegrted development envronment everythng needed for the work. Note tht the ntegrted development envronment (IDE) nd confgurton wzrd softwre supportng esy setup of the MCUs regsters re free s well s n unlmted nd open source lterntve compler, the populr Smll Devce C Compler (SDCC) 9. Expermentl setup The block dgrm of the system setup s shown on Fg.. The sensor-ctutor devce s connected to the MCU wthout ny nlogue sgnl condtonng hrdwre only two resstors re needed. One sets the current flowng through the LED nd the other serves s current-to-voltge converter of the photocurrent of the lght detector. A recommended front-end nput flter n for the ADC s prenstlled on the trget bord. Fg.. The nfrred LED nd phototrnsstor cn be connected to the MCU bord usng only two ddtonl resstors, no further nlogue sgnl condtonng s needed. The LED s powered from the VDDA supply lne (nomnlly 3,3V) usng seres resstor to set the current flowng through the LED. The block dgrm of the whole system setup s shown on Fg.3. The MCU code s developed on the host personl computer nd the USB debug dpter llows downlodng the code nto the trget, supports non-ntrusve debuggng, sngle-steppng nd t even powers the bord. Serl communcton s provded between the MCU nd the computer, therefore rel-tme processng nd dsply of mesured dt re possble. The conventonl RS3 port my be mssng n newer computers, however relble USB-RS3 converters re vlble. Note, tht newer trget bords hve USB-UART nterfce rther thn the conventonl RS3 serl port. The communcton protocol remns the sme usng the vrtul serl port feture of the opertng system.

A photoplethysmogrph experment for mcrocontroller lbs 4 Fg.3. The block dgrm of the experment ncludng the host computer connecton. Techng the sgnl processng by sclble experments In ths secton experment exmples re reported tht help students to understnd nd prctce the sgnl processng typclly requred for the nlyss of the photoplethysmogrphc nd other smlr sgnls. Fg. 4 shows photo of the expermentl setup. The sensor cn be drectly connected to the bord usng three wres, only two externl resstors re needed. Fg. 4. The reflectve optcl sensor (TCRT000) s connected to the mcrocontroller trget bord v three wres, only two ddtonl resstors re needed.

A photoplethysmogrph experment for mcrocontroller lbs 5 Wtchng the rw output sgnl of the sensor After nstllng the hrdwre, the students my try to check the output wveform of the sensor usng n osclloscope by touchng AIN7 (see Fg..) wth the probe. A typcl result mesured by Tektronx DPO04 osclloscope s llustrted on Fg. 5. Fg. 5. Typcl rw output sgnl of the sensor mesured n DC coupled mode. The mpltude of the AC component of the sgnl s only few percent compred to the DC mgntude. Students cn clerly see tht the AC component s rther smll, only few percent of the DC component. Although the blood pressure cn vry bout 40% n crdc cycle, the blood volume chnge n the fnger s smller nd sgnfcnt prt of the lght s reflected from the bone, from the tssue, therefore the chnges n the reflected lght ntensty flls n the rnge of few percents. The typcl wy to mesure smll AC sgnls n the presence of lrge DC component s to use the AC couplng mode of the osclloscope. However, the AC couplng n osclloscopes mens hgh pss flterng wth corner frequency well bove Hz, therefore most of the slowly chngng AC component cused by the crdc ctvty wll be ttenuted nd bured completely n the hgh frequency nose, s shown on Fg. 6. Fg. 6. If the student uses AC couplng mode, most of the photoplethysmogrph sgnl wll be ttenuted by the hgh pss flterng nd the sgnl wll be bured n the hgh frequency nose. After performng these tests the propertes of the sgnl wll be cler to the students nd they wll lso see tht n osclloscope cn t be used to effectvely extrct nformton from the mesured sgnl, further sgnl processng wll be certnly needed:

A photoplethysmogrph experment for mcrocontroller lbs 6 hgh pss flterng wth sub-hz corner frequency to remove the DC component, but keep the slowly vryng AC component, low pss flterng wth corner frequency of bout 0-30 Hz to remove hgh frequency nose, mplfcton to get lrge enough sgnl, gn of 00 s suffcent ccordng to the osclloscope mesurement presented on Fg.5. Possble nlogue sgnl processng Students of electrcl or bomedcl engneerng wll probbly suggest smple nlogue ctve flter to fulfll the bove mentoned requrements. An often used smple two stge crcut exmple 7 cn be further smplfed usng sngle opertonl mplfer nd some pssve components s shown on Fg. 7. Fg. 7. Ths smple crcut removes the DC nd hgh frequency nose components nd provdes sgnl mplfcton. Generl purpose opertonl mplfers lke the LM358, TL07 cn be used. Ths crcut cn be bult on smple prototypng bord nd t s good chnce for students to lern tht cre must be tken to put 00nF supply decouplng cpctors close to the supply pns nd seres resstor t the output of the opertonl mplfer to solte the cpctve lod cused by the osclloscope probe to prevent possble osclltons. Ths ctve bndpss flter provdes n overll gn of 00 n the pssbnd rnge of bout Hz to 30Hz, whle both the DC nd hgh frequency components re removed. Students cn check the output sgnl gn wth n osclloscope, lso my vry the component vlues to see the effect of chngng the flter corner frequences both for the low nd hgh pss prt. Fg. 8. shows typcl wveform recorded by n osclloscope.

A photoplethysmogrph experment for mcrocontroller lbs 7 Fg. 8. Amplfed nd bnd-pss fltered photoplethysmogrph sgnl. The crcut depcted on Fg. 7. ws used for the experment. Dgtsng wth the mcrocontroller s bult-n hgh-resoluton delt-sgm ADC The output sgnl of the nlogue crcut presented on Fg. 7 could be dgtsed wth commonly used -bt ADC, wht could be the reson to use hgher resoluton ADCs? Wht could be the dvntges nd dsdvntges? Tody s medum speed (up to bout 0 6 smples per second) -bt ADCs typclly hve bult-n smple nd hold crcut followed by successve pproxmton ADC rchtecture (.k.. smplng ADC). Accordng to the smplng theorem, the sgnl must not contn sgnfcnt components bove the hlf of the smplng frequency. Snce the crcut of Fg. 7 forms only frst order low-pss flter, ether hgh smple rte or more complex nlogue flterng wll be needed. On the other hnd, the DC removl lso cuses sgnl dstorton dependng on the corner frequency of the hgh-pss flter, tht cn t be esly optmsed nd chngng the corner frequency of the hgh-pss flter needs component replcement. All of these problems cn be solved by pplyng hgh-resoluton delt-sgm ADC, sometmes clled sngle-bt ADC,3. Ths revolutonry ADC rchtecture s very common (they re used n sound crds, moble phones), becuse t hs severl dvntges ncludng: the nternl smple rte f much hgher thn the dt rte, therefore the nt-lsng flter cn be much smpler (n severl cses frst order wll be suffcent); very hgh resolutons cn be relsed (6-4 bts) wth nherently hgh lnerty nd precson, therefore the dynmc rnge s very hgh nd the nose s lso very low; most of the crcut s dgtl, therefore t s esy to ntegrte wth dgtl crcutry lke processors nd the prce s lso low (for exmple the C805F350 mcrocontroller wth bult-n 4-bt delt-sgm ADC hs lmost the sme prce s the C805F40 mcrocontroller wth bultn -bt successve pproxmton ADC, close to 6; see t www.frnell.com). In summry, the delt-sgm ADC llows the use of very smple externl nlogue crcutry, most of the sgnl processng cn be done n the dgtl domn, therefore flexblty, complexty ccurcy re drmtclly mproved whle the prce s kept low. Snce the delt-sgm ADC llows drect dgtston of the sensor s output sgnl wthout the need for DC removl, students cn del wth the rw sensor dt, therefore: they cn mplement the requred processng, therefore they lern nd understnd more bout such processng; they cn tune the processng prmeters very esly nd see the effect n rel tme; they lern lso bout tody s pproch of hghly ntegrted mxed sgnl (both nlogue nd dgtl) hrdwre nd embedded progrmmng. In the followng chpter sgnl processng softwre exmples wll be presented usng the expermentl rrngement shown by Fg. Confgurng the MCU nd ts perpherls Snce the C805Fxxx seres MCUs re mong the most dvnced 805 fmly MCUs, cre should be tken durng ntlzton of the regsters. A useful tool, the Confg Wzrd cn help to generte the source code; however the students must understnd frst the bscs of the C805Fxxx fetures. The setup process should nclude the confgurton of the wtchdog tmer, the port nput/output, the on-chp osclltor, the unversl synchronous communcton port (UART) nd relted tmers, the voltge reference nd the ADC.

A photoplethysmogrph experment for mcrocontroller lbs 8 The MCU code After settng up the regsters the MCU s redy to cqure the sgnl comng from the sensor. Three typcl opertng modes re recommended to be mplemented by the students. The tested nd nnotted C source code ws developed usng the free nd open-source SDCC compler nd cn be found n the Appendx. Contnuous dt trnsfer to the host computer Ths s the smplest opertng mode, where the ADC does the conversons contnuously nd t the end of the converson the mcrocontroller sends the 4-bt rw dt to the host computer n ether pollng or nterrupt mode. The dt smples cn be represented s text ncludng termnton chrcter or cn remn n ther bnry representton. In the frst cse the dt cn be retreved nd vewed usng smple termnl softwre lke Hypertermnl, cn be logged nto text fle or the dt cn even be coped nto the students fvourte spredsheet softwre. Fg. 9 shows typcl rw dt wveform. For n exmple code, see the RwSensorDt() functon n the Appendx. Fg. 9. Typcl rw sensor sgnl. The dt hs been receved from the mcrocontroller usng the Hypertermnl softwre nd coped nto spredsheet progrm to mke the plot of dt. A slowly vryng component cn be esly seen. Gven tht only one byte t tme cn be sent over the serl port, students hve to mke ther decson bout usng lttle endn or bg endn formt f they decde to use bnry dt representton. They should lso tke cre of usng sgned or unsgned nteger numbers. Consequently t s very useful wy to help the students to properly use dt representton, where sometmes even prctced developers my mke relted mstkes. However, n ths cse termnl softwre s not enough, the students must develop ther own softwre to receve nd process the dt strem. Hgh-pss dgtl flterng Ths mode s lso bsed on contnuous dt converson, but the rw dt s frst pssed through dgtl hgh-pss flter before the strem s forwrded to the host computer. Snce the sgnl contns lrge DC nd slowly vryng components 0, these should be removed frst to ese hert bet detecton t s the sme job s n the cse of nlogue sgnl processng s ws dscussed bove. At ths pont students re fcng the problem how to mplement hgh-pss flter n the dgtl domn. In generl, the recursve (.k.. nfnte mpulse response or IIR) dgtl equvlent of n nlogue flter cn be found by usng the blner trnsform 3. If A(s) s the nlogue flter s trnsfer functon, the

A photoplethysmogrph experment for mcrocontroller lbs 9 correspondng dgtl flter s A(z) trnsfer functon cn be obtned by substtutng s s follows:, ) z ( ) z ( f s s () where f s s the smplng frequency nd z=exp(s/f s ). Ths wy A(z) wll be polnom of z - :... z b z b... z z (z) A 0, () nd the correspondng recursve flter wll hve the form:... y b y b... x x x y 0, () where x nd y represent the nput nd the fltered smpled dt, respectvely. However, for sngle pole (frst order) flters students cn use smple method to esly mplement frst order nfnte mpulse response hgh-pss dgtl flter usng the followng expressons 3 :, e b, e, e, y b x x y s c s c s c f f f f f f 0 0 () where f s s the smplng frequency nd the corner frequency of the hgh-pss flter s f c. Fg. 0 shows typcl wveform obtned wth Hz corner frequency. For n exmple code, see the FlteredSensorDt() functon n the Appendx. Fg. 0. Typcl dgtl hgh-pss fltered sensor sgnl wth Hz corner frequency. The DC component s removed, however the wveform s somewht chnged compred to the sgnl shown on Fg. 9. Hert bet detecton, hert rte clculton After hgh-pss flterng the men vlue of the sgnl becomes zero, therefore smple wy to vsulze the hert bets cn be relzed by turnng on n LED on the C805F350 trget bord f the

A photoplethysmogrph experment for mcrocontroller lbs 0 sgnl s postve. However, f students wnt to mesure the tme between successve hertbets, smple zerocrossng detecton won t be suffcent, snce some nose on the dt cn cuse flse hert bet detectons. A common technque cn be exercsed by the students here: dd some hysteress to the level-crossng detecton to prevent flse pulse countng. Ths cn be esly mplemented by usng two thresholds: f the sgnl goes bove the hgher level, the pulse s detected nd subsequent detecton s blocked untl the sgnl goes below the lower level. The lecturer cn drw the students ttenton to the nlogue equvlent, comprtor wth dded hysteress clled Schmtt-trgger. Mesurng the tme between successve pulse detectons llows the students to clculte the betto-bet nstntneous hert rte nd send these vlues to the host computer t every hert bet. Ths cn be esly mplemented by just countng of the number of conversons between successve hert bet detectons, snce the conversons re performed t gven nd known rte, 00Hz. In ths mode the students cn record the bet-to-bet hert rte nd cn observe tht the hert rte s fluctutng round ts men (t s often referred nd mesured s hert rte vrblty), snce the helthy nervous system controls the rte ccordng to the fluctutng externl nd nternl stmul. A typcl result s shown on Fg.. For n exmple code, see the HertBetDetecton() functon n the Appendx. Fg.. The mcrocontroller performs the dgtl hgh-pss flterng, hert bet detecton nd sends the clculted hert rte vlues for ech bet. The dt cn be receved from the mcrocontroller usng Hypertermnl (see the screenshot on the left hnd sde) softwre nd cn be coped nto spredsheet progrm to mke the plot of dt. The host computer softwre The host computer should be ble to red nd dsply dt contnuously to cpture the sgnl comng from the sensor. As t ws ponted out, the smplest wy s to use termnl softwre lke Hypertermnl to control the system nd retreve nd dsply dt. After settng up the communcton port (the provded code n the Appendx ssumes 500 bt/s, 8 dt bts, no prty, no hndshkng), the students cn esly check f the system s workng, snce pressng ny key wll cuse the correspondng chrcter to be sent to the system, nd t wll respond wth sendng the sme chrcter bck to the personl computer (see the whle loop n the mn() functon of the source code n the Appendx). The rw dt, fltered dt nd hert bet detecton modes cn be strted by pressng r, f nd b, respectvely. In ll modes the mcrocontroller wll send the numbers representng the selected dt: the dgtsed sensor dt, the dgtlly fltered sensor dt or the

A photoplethysmogrph experment for mcrocontroller lbs nstntneous hert rte (bets per mnute). The dt cn be logged nto text fle or cn be coped nto the clpbord to llow dsplyng or further processng usng the students fvourte spredsheet softwre. Dependng on the level of educton the lecturer my sk the students to wrte ther own progrms to receve nd plot the dt even n rel tme. Experence n serl communcton bscs nd rel-tme grphcl dt plottng wth utomtc sclng, zoomng mght be requred; therefore, such code my hve too hgh degree of complexty f t s to be wrtten n Jv, C++ or C#. However powerful vrtul nstrumentton envronment lke LbVIEW cn be esly used to do the job nd Mtlb lso hs esly ccessble serl communcton nd dt dsplyng cpbltes, therefore these tools re recommended to develop more dvnced pplctons. Concluson In ths pper mxed-sgnl MCU bsed fnger photoplethysmogrph lbortory experment hs been presented. Ths gretly trnsprent experment helps students to see n exmple how modern nlogue-ntensve MCU llows drect sensor nterfcng, elmntes the need for extensve nlogue sgnl condtonng nd mproves flexblty, ntegrton nd relblty. The key ponts re lsted below. Students hve ther MCU trnng by mkng n nsprng nd exctng crdovsculr experment; they mesure ther own blood volume pulstons. The experment helps students to understnd the bsc prncples of operton of modern helthcre devces, sgnl condtonng nd embedded processng. Besdes lbortory prctce, rel tme demonstrtons n lectures re supported s well. Most prt of the processng tkes plce n the dgtl domn, students mke most of the whole system themselves, ths wy they cn understnd the job better. They lern bout smplng, delt-sgm ADC bscs, dgtl sgnl processng, embedded nd host computer progrmmng. The low prce llows students to hve seprte kt, therefore every student do the sme experment n the lb. The lecturer cn ntroduce the bscs, cn esly help students, drw ther ttenton to the specfc problems whle more sklled students re free to go fster, to do nd lern more. The experment s sclble: t s sutble for begnners, whle llowng more experenced students to explot ther cretvty n developng more dvnced code, plyng wth the processng prmeters. It s lso esy to dd new tsks ncludng hert rte verge nd vrblty clcultons, bet-to-bet sttstcl nlyss, frequency domn nlyss, estmtng brethng frequency nd mny more. Addng hrdwre lke n lphnumerc LCD dsply s lso esy. The low cost hrdwre nd free development tools re vlble worldwde, students cn esly nstll one t home nd cn use t for mny other problems. Addtonlly, unversty educton s supported by the mnufcturer of the hrdwre. The experment hs been tested nd demonstrted. By shrng the ssocted code nd nformton on dedcted web pge, we mde t fully open source nd esly reproducble 6. The experment cn be esly ported to other MCU pltforms. The mn requrement s the presence of wde dynmc rnge low nose ADC. Cnddtes wth hgh resoluton ntegrted nlogue components nclude the PIC8F87J7 8-bt MCU, the MSP430FG47x 6-bt MCU nd the ADuC7060 3-bt ARM core MCU. Smlr experments cn be crred out wth other smll output sgnl sensors whch cn lso be nterfced drectly to precson nlogue MCUs. Thermocouples, pressure sensors, lod cells, mgnetc feld sensors, strn guges re good exmples. These broden the educton pplctons even further 4.

A photoplethysmogrph experment for mcrocontroller lbs Acknowledgment The uthor thnks Peter Mkr for helpful dscussons. References A. L. Lee, Albert J. Thmoush nd J. R. Jennngs, An LED-Trnsstor Photoplethysmogrph, IEEE Trns. Bomedcl Engneerng, BME- (3) (975) 48-50 K. A. Reddy, J. Rezun B, B. George, N. M. Mohn nd V. J. Kumr, Vrtul Instrument for the Mesurement of Hemo-dynmc Prmeters Usng Photoplethysmogrph, n Proc. IEEE Instrumentton nd Mesurement Technology Conference, (006) 67-7 3 K. Ashok Reddy, Boby George, N. Mdhu Mohn, Student Member nd V. Jgdeesh Kumr, A Novel Clbrton-Free Method of Mesurement of Oxygen Sturton n Arterl Blood, IEEE Trns. Instrumentton And Mesurement, 58 (5) (009) 699-705 4 K-I. Wong, N. Brsoum nd C. Z. Mynt, Techng the Electronc Desgn nd Embedded System Course wth Body Sensor Nodes, Proc. nd Interntonl Conference on Educton Technology nd Computer (ICETC), (00) 58-6 5 S. Rhee, B.-H. Yng nd H. H. Asd, Artfct-Resstnt Power-Effcent Desgn of Fnger-Rng Plethysmogrphc Sensors, IEEE Trns. Bomedcl Engneerng, 48 (7) (00) 795-805 6 http:// www.nf.u-szeged.hu/nose/edudev/ppgonf350 7 Applcton note AN944, Plethysmogrph bsed on the TS507, STMcroelectroncs, http://www.st.com 8 http://www.slbs.com 9 http://sdcc.sourceforge.net 0 J. Allen nd A. Murry, Effects of flterng on mult-ste photoplethysmogrphy pulse wveform chrcterstcs, Computers n Crdology, 3 (004) 485-488, K. H. Shelley, Photoplethysmogrphy: Beyond the Clculton of Arterl Oxygen Sturton nd Hert Rte, Anesthes & Anlges, 05 (6) (007) S3-S36 Wlt Kester, ed. Dt Converson Hndbook, Newnes, (004), ISBN-3: 978-075067844, http://www.nlog.com/lbrry/nlogdlogue/rchves/39-06/dt_converson_hndbook.html 3 Steven W. Smth, The Scentst & Engneer's Gude to Dgtl Sgnl Processng, Clforn Techncl Pub.; st edton (997), ISBN-3: 978-09660763, http://www.dspgude.com/ 4 Z. Gngl, Fbrcte hgh-resoluton sensor-to-usb nterfce, EDN, 56 (0) 54-57, http://www.nf.uszeged.hu/~gngl/edq4/ Appendx SDCC comptble smple source code for the C805F350 mcrocontroller used to demonstrte the experment. #nclude <stdo.h> #nclude <stdlb.h> #nclude "c805f350.h" // Perpherl specfc ntlzton functons, // Clled from the Int_Devce() functon vod PCA_Int() PCA0MD &= ~0x40; // dsble wtchdog tmer PCA0MD = 0x00; vod Tmer_Int()

A photoplethysmogrph experment for mcrocontroller lbs 3 TCON = 0x40; TMOD = 0x0; CKCON = 0x08; // Tmer bse = system clock for hgh resoluton TH = 0xCB; // 500 bt/s (closest mtch) vod UART_Int() SCON0 = 0x0; // 8-bt, vrble bud mode // Confgure the ADC: // 00Hz smple rte, unpolr mode // gn=, externl voltge reference // nlog nput buffers re bypssed // ADC nput s AIN7 nd GND vod ADC_Int() ADC0CN = 0x00; // dsble ADC, wll be enbled lter ADC0CF = 0x04; ADC0MD = 0x80; ADC0CLK = 0x04; ADC0DECH = 0x00; ADC0DECL = 0xBE; ADC0MUX = 0x78; vod Port_IO_Int() PMDIN = 0xBF; // P. s nlog P0MDOUT = 0x90; // P0.4 (UART TX) nd P0.7 (LED) push-pull PSKIP = 0x40; XBR0 = 0x0; XBR = 0x40; vod Osclltor_Int() OSCICN = 0x8; // nternl osclltor,.5mhz vod Int_Devce(vod) PCA_Int(); Tmer_Int(); UART_Int(); ADC_Int(); Port_IO_Int(); Osclltor_Int(); unsgned chr SIn(vod) whle (!RI); RI=0; return SBUF; // Intlzton functon for the devce // serl nput functon // wt for byte // return the byte

A photoplethysmogrph experment for mcrocontroller lbs 4 // serl output functon vod SOut(chr ) TI=0; SBUF=; whle (!TI); // trnsmt byte // wt for end of trnsmsson vod putchr(chr c) SOut(c); vod ClbrteADC(vod) ADC0MD = 0x8; whle(ad0cbsy); whle(adc0md & 0x07); AD0INT=0; // full nternl clbrton // end of cl step // wt return to IDLE!!! // Do contnuous smplng // every smple wll be sent to the host vod RwSensorDt(vod) unsgned chr c; unsgned nt x; ClbrteADC(); // ADC clbrton s requred c=0; // ntlze UART nput vrble ADC0MD = 0x83; // enble ADC do whle(!ad0int); // wt for end of converson AD0INT=0; // cler flg x=(adc0h<<8) ADC0M; // most sgnfcnt 6-bts re enough prntf("%u\r",x); // send to PC f (RI) c=sin(); // check f chrcter receved whle (P_0 && c!=7); // stop f button s pressed or ESC receved ADC0MD = 0x80; // dsble the ADC // Do contnuous smplng, pply dgtl hgh-pss flterng // every smple wll be sent to the host vod FlteredSensorDt(vod) unsgned chr c; nt x,xprev; nt y; ClbrteADC(); xprev=0; y=0; c=0; ADC0MD = 0x83; do whle(!ad0int); AD0INT=0; // ADC clbrton s requred // ntl vlue of dt // ntl vlue of fltered dt // ntlze UART nput vrble // enble ADC // wt for end of converson // cler flg

A photoplethysmogrph experment for mcrocontroller lbs 5 x=(adc0h<<8) ADC0M; // most sgnfcnt 6-bts re enough y=((x-xprev)*48l+y*40l)>>8; // do dgtl hgh-pss flterng xprev=x; // shft dt for dgtl flterng prntf("%d\r",y); // send to the PC f (RI) c=sin(); // check f chrcter receved whle (P_0 && c!=7); // stop f button s pressed or ESC receved ADC0MD = 0x80; // dsble the ADC // Do contnuous smplng, hgh-pss flterng // detect hert bets nd flsh the LED ccordngly // send clculted hert rte t the host vod HertBetDetecton(vod) unsgned chr c; nt x,x; nt y,threshold,threshold; unsgned chr b,t; threshold=0; threshold=0; // lower threshold // upper threshold ClbrteADC(); // ADC clbrton s requred x=0; // ntl vlue of dt y=0; // ntl vlue of fltered dt c=0; // ntlze UART nput vrble b=0; // bt detecton flg, used to mplement hysteress t=0; // mesures tme (number of smples) between bets ADC0MD = 0x83; // enble ADC do whle(!ad0int); // wt for end of converson AD0INT=0; // cler flg x=(adc0h<<8) ADC0M; // most sgnfcnt 6-bts enough y=x-x; // do dgtl hgh-pss flterng f (y>threshold &&!b) b=; prntf("%d\r", 6000/t); // send hert rte (t s n 0ms unts) t=0; f (y<threshold && b) b=0; P0_7=b; // drve LED to vsulze hert bets x=x; // shft dt for dgtl flterng t++; // ncrement tme f (RI) c=sin(); // check f chrcter receved whle (P_0 && c!=7); // stop f button s pressed or ESC receved ADC0MD = 0x80; // dsble the ADC vod mn(vod) unsgned chr ; Int_Devce(); whle () =SIn(); SOut(); // loop forever // wt for byte // return to the host for "softwre hndshkng"

A photoplethysmogrph experment for mcrocontroller lbs 6 f (=='r') RwSensorDt(); f (=='f') FlteredSensorDt(); f (=='b') HertBetDetecton(); // f 'm' s receved, strt mesurement // detect her bets, strem dt to host // f 'm' s receved, strt mesurement // detect her bets, strem dt to host // f 'm' s receved, strt mesurement // detect her bets, strem dt to host