Copyright is owned by the Author of the thesis. Permission is given for a copy to be downloaded by an individual for the purpose of research and private study only. The thesis may not be reproduced elsewhere without the permission of the Author. Design of Instrumentation for Metabolic Monitoring of the Adelie Penguin thesis presented in partial fulfillment of the requirements for the degree of Master of Science in Physics at Massev Universitv , , by Paul Stephen Ryland December 2000 ii Abstract The motivating question for the work described in this thesis was "How does the Adelie penguin cope with cold'?" It was reasoned that the time-scale of temperature changes in Antarctica precluded all but metabolic and physiological responses. To determine these, a system capable of measuring and recording these biological variables in the penguins natural environment, was designed. A device. based on the principles of near infrared spectroscopy, was developed that could measure the relative oxygen saturation of haemoglobin and the reduction state of cytochrome oxidase as well as heart rate and blood volume. The completed device was housed in a black, waterproof. plastic container. measuring 65mm x 92mm x 15mm and weighing 132.7g. Co-ordination of measurements \Yas achieved with operating system-like control soihvare implemented in Motorola HC 11 assembly code. Synchronous detection was used for signal acquisition and a pulse algorithm, implemented in assembly code, allov,ed real time pulse measurement from the input signals. Programs were written in Matlab and to investigate the characteristics and limits of these techniques. Preliminary testing of the device on human subjects successfully showed changes in metabolic state as a result of physical activity. The results of field testing on Ade lie penguins ,vere unable to ansv,er the original question due to a number of physical factors. However, the success of human trials suggests that, modification and improvement, the device has potential as a valuable research instrument, applicable to a variety of other species. 111 Acknowledgements I would like to express my sincere gratitude to the following people whose contribution and assistance were invaluable to me and to the completion of this thesis. I have gained an enormous amount from their skills and expertise and know that the knowledge and experience gained will continue to be valuable in the future. Particular thanks go to my supervisor, Dr. Simon Brown, for his considerable contribution and guidance throughout the many aspects of the project. In areas ranging from remedial biology, lab work. field work, presentations, CV writing, grant applications and thesis proofing, his enthusiasm for the project and encouragement have been exceptional. I also wish to thank my co-supervisor, Associate Professor Robert O ' Driscoll for the introduction to this project and whose extensive electronics expertise guided me in solving some of my most taxing hardware and software problems. I gratefull y thank the electronics guru, Robin Dykstra, for directing my circuit design efforts. providing development equipment and manuals, component advise, his stringent. NASA approved circuit-board-layout quality control and good friendship. Thanks also to Peter Lewis who helped select and order numerous electronic components, made an exceptional contribution during the time critical construction phase allowing deadlines to be met and even provided reading material for the quiet times in Antarctica. Also from the electronics workshop, I wish to thank Udo von Mulert for allowing the extensive use of the workshop facilities after hours and on weekends, and Keith Whitehead for his advise and ideas on numerous aspects of the project. For her help in Antarctica, expert penguin handling skills and easy going personality I would like to thank Yvette Cottam. I also wish to express my gratitude to Antarctica ew Zealand for their approval of the work in Antarctica with the Adelie penguin and to Massey University for the opportunity to work on this project. I thank Massey University for the approval of my Institute of Fundamental Sciences Graduate Research Fund application amounting in $1731 towards purchase of equipment and related expenses. Particular thanks to John Pedley for his help with the use of the ECG to test the second prototype and for the loan of the exer-cycle used to test the third prototype. I would also like to recognize the many test subjects who exerted themselves in the name of science, in particular, to Jane Shierlaw whose high quality data made it to print. I would also like to thank Jane for her veterinary advice as well as thesis writing comments and ideas. Finally, I would especially like to thank Mark Hunter for the very many coffees, countless ridiculously late nights and for being someone available to discuss the more subtle points of thesis writing (some of which were relevant). Contents Abstract Acknowledgements Contents II 111 IV Vil List of Figures Chapter 1 1.1 Introduction The Problem 1.2 Measurement 1.3 Background - The Adelie Environment 1.4 Technology 1.5 Measurement Principles 1.5.1 Near Infrared Spectroscopy 1.5.2 Triple Wavelength Oxygen Saturation Measurement 1.5.3 Near Infrared Spectrometry 1.6 Thesis Overview 1 1 ..., .) 5 5 5 8 9 10 Chapter 2 Instrumentation 12 2.1 Design Specifications 12 2 .2 Design Overview 13 2.3 Analogue Circuitry 15 2.3 .1 The Sensor Head 15 2.3.2 The Synchronous Detector 16 2.3.3 Synchronous Detection 17 2.3.4 The Analogue Stage 21 2.4 Digital Circuitry 22 2.4. 1 Sampling and Digi tisation 23 2.4.2 The Microcontroller 24 2.4.2. l Output Compare 24 2.4.2.2 Interrupts 25 2.4.2.3 Real Time Clock 25 2.4.2.4 Additional Features of the Microcontroller 25 2.4 .3 Memory 26 2.4.4 Communication 26 2.4 .5 Power Considerations 27 2.4.5. 1 Power Supply Sources 27 2.4.5 .2 Power Considerations on the Device 28 2.4.5.3 Power Saving 28 2.5 Construction 29 Chapter 3 Control Software and Algorithms 3 .1 The Logical Model of the Device 3.1 .1 Setting Write Through Mode and the Result Memory Pointer 3.1.2 Setting the System Clock 3 .1.3 Communication Rate 3 .1.4 Help Command 3.1 .5 Debug Mode 31 32 34 34 34 34 34 IV 3.2 The Microcontroller Operating System 3.2.1 Control Modules 3 .2.1.1 Operating System 3 .2.1.2 System Initialisation 3.2.1.3 Command 3 .2.1.4 Interrupts 3.2.1.5 Sequence Execution 3.2.2 Hardware Modules 3 .2.2. l Serial Communication 3.2.2.2 Memory 3 .2.2.3 Real Time Clock 3.2.2.4 Sampling 3 .2.2.5 Utilities 3.2.3 Measurement Sequence Instructions 3.3 N1easurement Scripting Language 3.4 Pulse Rate Calculation Algorithm 3.4. l The Algorithm 3.4.2 Analysis of the Pulse Measurement Algorithm 36 36 36 36 36 38 38 39 39 39 40 41 41 43 45 48 49 51 Chapter 4 Prototyping and Application 57 4.1 Developmental Testing 57 4.1.1 Early Prototypes 57 4.1.2 Signal Verification using an Electrocardiogram 58 (ECG) 4.1.3 Software Development System 4.1.4 Blood Oxygen Saturation 4.1.5 Pulse Rate Measurement 4.1.6 The Stand-alone Prototype 4.1.7 Testing of the Final Device 4.2 Field Testing 4.2.1 Capture Technique and Attachment 4.2.2 Physical Results and Observations 4.2.3 Biological Responses Chapter 5 5 .1 5.2 Appendix A A.1 A.2 A.3 Conclusion Evaluation Future Development Derivations Oxygen Saturation Derived from Double Wavelength Measurements Oxygen Saturation Derived from Triple Wavelength Measurements Relative Blood Volume Derived from Double Wavelength Measurements 59 60 61 62 62 67 68 69 70 74 74 76 77 77 79 80 V vi Appendix B MatLab Programs 82 B.1 Synchronous Detector Numerical Solution 82 B.2 Pulse Algorithm Simulation 83 B.3 Input-Signal Drift Limitations for the Pulse Algorithm 86 B.4 Period Measurement Limitation due to the Digital 89 Filter B.5 Input-Signal Noise Limitations for the Pulse 89 Algorithm B.6 Utility Routines 91 Appendix C Circuit Diagrams 96 C.l Overview 96 C.2 Sensor Head 97 C.3 Analogue Stage 98 C.4 Digital Stage 99 C.5 Memory 100 C.6 Power Supply 101 C.7 RS-232 Interface Unit 102 Appendix D Printed Circuit Board Layouts 103 Appendix E Assembly Code 106 1 Pengos.a CD E.2 !nit.a CD E.3 Equates.a CD E.4 Global.a CD E.5 Vectors.a CD E.6 Commands.a CD E.7 Exec.a CD E.8 Pulse.a CD E.9 LED.a CD 10 Temp.a CD E.11 Delay.a CD E.12 Loop.a CD E.13 Intr.a CD E.14 Sample.a CD E.15 Mem.a CD E.16 RTC.a CD E.17 Serial.a CD 18 Utils.a CD E.19 EEPROM.a CD References 107 Figure 1.1 1.2 1.3 1.4 1.5 1.6 2 .1 2.2 ? -, __ .) 2.4 2.5 2.6 2.7 2.8 2.9 2. 10 2. 11 2. 12 2.13 2. 14 2 .15 2. 16 2.17 2.18 List of Figures Figure caption The metabolism of sugar with the cell. Ross Isl and and breeding colonies of the Ade lie penguin. An Ade lie penguin upon its nest of pebbles . Abso rption spectra of oxy- and deoxy- haemoglobin and oxidised and reduced cytochrome oxidase. Interpolating to find an estimate of the background absorbance at wavelength, /42 . The two main configurations for near infrared spectroscopic systems, transmission mode and reflectance mode. Ade lie penguin with a control unit and sensor head fitted. vii The connectivity and packaging of the sensor head and control unit. The fi nal realisation of the device. The sensor head layout. The senso r head circuit. A graphical representation of the implemented synchronous detector. Demodulation of an in-phase, input sine wave . The Fourier components of the fu ll-wave rectified sine wave . The phase se lectivity of the detector. The freq uency and phase response of the synchronous detector. The amplification and filtering stage of the device. The digital circuit components. Serial communication between digital devices using the Motorola serial peripheral interface. Block diagram of the 68HC11E9 microprocessor. The power-supply schematic. Connectivity of a computer, the serial interface unit and the device. The functional regions of the PCB layout for the control unit. Photographs of the completed device. Page 2 '"' .) 4 6 8 10 13 14 14 15 16 17 18 19 19 21 22 22 23 25 27 28 29 30 3.1 System overview. 3 .2 The logical model of the device. 3 .3 Branch vector use in operating system debugging. 3.4 Hierarchical arrangement of modules within the microcontroller operating system. 3.5 The algorithm used to make light scattering measurements. 3.6 A graphical representation of the pulse rate calculation process . 3. 7 The beginning of calculation of the maximum, minimum and median values from the waveform stored in the median buffer. 3.8 Example waveforms that posed a problem to pulse algorithm without the use of the upper and lower quartile in generating the square wave. 3.9 Transition points used to obtain period estimates. VIII 3.10 The boundaries for which each input signal ceases to cross the calculated median value and therefore ceases to generate the square wave. 3 .11 3.12 3.13 3.14 3. 15 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 Transfer function of the digital low-pass filter used in the pulse measurement algorithm. The performance of the pulse measurement algorithm as the pulse frequency increased beyond the corner frequency of the digital low­ pass filter The limiting signal to noise ratio for a sinusoidal input signal. The limiting signal to noise ratio for an asymmetric square wave input signal of similar shape to acquired human data. A pulse measurement example using real data collected during testing on a human subject. The second prototype. The correlation between ECG data and the signal obtained from the second prototype. ECG absorbance signal comparison for a subject with increased heart rate. Blood oxygen saturation measurement for a subject undergoing approximately two minutes of physical exertion on an exer-cycle. Resting pulse signal. Pulse signal after exercise. Intensity data acquired from the device. Relative blood-oxygen saturation. Relative cytochrome oxidase saturation. 31 32 35 37 44 49 so so 51 52 54 54 55 56 56 57 58 59 60 61 61 63 64 64 4.10 4.11 4.12 4.13 4.14 4.15 4.16 4.17 4.18 4.19 Relative blood volume. A pulse waveform used to calculate pulse rate. Pulse rate measurement. Temperature measurement. Attachment of the device using tape. Data collected during two potentially stressful events for an Adelie penguin. Relative blood oxygen saturation calculated from the data in figure 4.15. Relative oxygenation state of cytochrome oxidase calculated from the data in figure 4.15. Relative blood volume calculated from the data in figure 4.15. Pulse rate data acquired during the two potentially stressful events for an Adelie penguin. 5.1 An alternative layout for the sensor head that may give improved signal strength. A.2.1 D. I D.2 D.3 The use of three wavelengths to remove non-uniform drift in oxygen saturation measurements. Printed circuit board layouts with component overlays. Printed circuit board layouts. Serial interface unit PCB layout. ix 65 66 66 67 69 71 72 72 73 73 79 103 104 105 Chapter 1 Introduction 1.1 The problem For the Adelie penguin (Pygoscelis adelie) of Antarctica there exists an intriguing biological paradox. As for any animal living in this environment, adaptation to cold and the regulation of body temperature is of primary importance. During breeding however, the Adelie penguins exhibit behaviour that seems to defy these thermal demands. For periods lasting as long as two weeks [ l] they remain on their nests vigilantly guarding their eggs. During this time they fast , exhibit minimal muscular act ivity and no behavioural activities such as huddling. Fasting results in a reduction of resting metabolic rate thereby conserving energy. Contrary to this, an adaptive response to cold is to increase metabolic rate, producing heat from food or body fat reserves. As the penguins are fasting, this increase in metabolic rate results in the depletion of the bird's insulating body fat layer, further increasing the need for heat generation. As thermogenesis does not occur significantly by other means there seem to be conf1icting metabolic demands and the question arises, 'How does the Adelie penguin cope in this environment?' 1.2 Measurement An increase in metabolic rate implies an increase in the demand for oxygen . Processes that exhibit a response to changes in metabolic rate are the transport of oxygen via haemoglobin and the oxidation of substrates within cells by oxidative phosphorylation. Two proteins involved in these processes, haemoglobin (Hb) and cytochrome oxidase (COX), exhibit changes in their spectral characteristics depending on their oxygenation state . These spectra can be observed in viva using near-infrared (NIR) spectroscopy, a technique that has been employed successfully with the human foetus , neonate and adult [2]. Oxidised and reduced haemoglobin and cytochrome oxidase exist in equilibrium in blood and in the mitochondria of cells respectively (1. 1 and 1.2). The equilibrium concentrations for each of these give information about the supply and demand for oxygen at the beginning and end of the metabolic process. Hb+ 02 ~Hb02 COX+ 02 ~ COX02 (1. 1) ( 1.2) Haemoglobin, oxygen and oxyhaemoglobin are transported throughout the body via blood vessels (figure l. 1). A concentration gradient between the blood and the cell causes oxygen to diffuse through the wall of the blood vessel into the cell. Higher concentrations of oxyhaemoglobin observed in the blood imply that the supply of oxygen is greater than the demand due to decreased respiration or reduced metabolic rate. If oxyhaemoglobin concentrations decrease, then oxygen consumption is greater than the demand as a result of increased respiration or higher metabolic rate. Oxygen is consumed within the cell during the last stage of oxidative phosphorylation. Within the cell , sugar is broken down into a smaller molecule called pyruvate that is oxidised within the mitochondria to produce the waste products; carbon dioxide and water. This final reaction is catalysed by cytochrome oxidase that exists in equilibrium with oxygen in the mitochondrial membrane. If high leve ls of oxidised cytochrome oxidase are observed, this indicates that the rate of sugar metabo lism is slow and, conversely, highly reduced cytochrome oxidase ind icates an increased metabolic rate. Blood Vessel Glucose Cell Glucose\ Pyruvate Mitochondrian Tricarboxylic Acid Cycle Enzymes of the electron transfer chain Figure I. l : The metabolism of sugar with the cell. Oxygen exists in equilibrium with two proteins, haemoglobin and cytochrome oxidase, in blood and in the mitochondria within cells respectively. The spectral characteristics of these two proteins depend on the relative concentrations of their oxidised and reduced forms. Changes in these spectra give information about the rate of oxygen metabolism. By developing a device capable of making oxygen saturation measurements along with pulse and temperature measurements a corre lation may be observed between the environmental temperature and biological responses of the penguin. Such a device must be portable, small and lightweight so as not to inhibit the normal activ ities of the bird or cause stress resulting in unrealistic data. NIR spectroscopy, a non-invas ive technique, is ideally su ited to this problem and the development of such an instrument would allow changes in the relative oxygen saturation to be observed with minimal impact on the penguin. 2 1.3 Background - The Adelle Environment Antarctica, and its surrounding oceans, form one of the most extreme, and yet habitable, environments on earth. All species that live and breed in this southern polar region face the same survival issue: the adaptation to cold and maintenance of body temperature. Each animal that lives in or visits this environment exhibits biological or behavioural adaptations that enable it to combat the extreme cold such as increased body fat, thicker skin/feather layers or group huddling behaviour. Adelie penguins spend eight months of the year living and foraging off the pack ice that forms where the polar ice cap meets the southern ocean. The birds move with the pack ice that advances and recedes seasonally, covering a distance of over 1300km [3]. Starting around mid October, the Adelie penguins make a trek, often travelling 80km or more inland, to their annual breeding sites located on the shores of the Antarctic mainland or on many of the Antarctic islands. Some nesting colonies can number in the tens of thousands and on Ross Island (figure 1.2), where there are six colonies [ 4], a major nesting site of approximately 60,000 Adelie penguins is located at Cape Bird (Barton, K. J., personal communication). Cape Royds Figure 1.2: Ross Island and breeding colonies of the Adelie penguin. The Adelie penguin rookeries are indicated in yellow. At Cape Bird an Adelie colony numbering approximately 60,000 forms every year from early November to mid January. 3 Upon arrival at the nesting site the males, who arrive earlier than the females, begin constructing nests. Open windswept mounds and ridges are the usual location for the nests as these snow-free areas are all that is available when the Adelies arrive in early spring. The Adelies collect stones ranging in size from 1cm to 5cm and place them around the edge of a depression in the ground forming a doughnut shaped wall on which the penguin sits (figure 1.3). Figure 1.3: An Adelie penguin upon its nest of pebbles. The nest consists of pebbles between !cm and 5cm in diameter arranged around a depression in the ground. Nests are constructed on snow-free mounds to avoid streams and puddles when surrounding snow and ice melts. Unfortunately these regions are also exposed to harsh weather conditions. This choice of nest location has both advantages and disadvantages. As spring turns to summer the surrounding snow and ice melts forming streams and puddles that these raised regions avoid. Unfortunately, these raised areas are also exposed to wind and during the early stages of brooding the Adelies have to contend with harsh spring weather conditions. In the early weeks of November the male Adelies may endure temperature fluctuations of approximately 20°C brought on by increased wind chill due to blowing snow. More surprisingly, on still days the Adelie is faced with a heat dissipation problem due to the zero humidity of Antarctic air. Under constant sunlight, local air temperatures can rise well above zero and on these 'hot' days nesting Adelies will lie with flippers and feet outstretched in an attempt to dissipate heat. For birds without eggs to protect, the overheating problem is solved by lying in or eating snow. The total incubation period for Adelie eggs is between 33 and 39 days and, in 88% of cases, the male incubates the eggs for the first 14 days. During this time he fasts (1]. Since there are few other options, thermo-regulation must occur on a systemic level through variation in heart rate, metabolic rate, respiratory rate and vasoconstriction. The goal of this thesis was to develop a system capable of measuring these responses and provide an insight into the homeostatic mechanisms of the Adelie penguin. 4 1.4 Technology The basic requirements of NIR spectroscopy are a monochromatic light source in the red and infrared region of the electromagnetic spectrum and a photo-detector sensitive enough to respond to the subtle changes in scattered light intensity. The options considered for light sources were either laser diodes or LEDs as other sources were impracticably large. An attractive aspect of using laser diodes includes increased incident illumination and temporal coherence. However, temperature instability, cost, power consumption and the lack of availability over a range of frequencies prohibited their use. Recent development in LED technology has seen a dramatic increase in the intensity and range of available frequencies. Combined with their cost, weight, power consumption and acceptable coherence (typical linewidth of 20nm), they were selected as the most suitable light sources for the device. The options available as detectors included photodiodes of varying areas and construction or a photo-multiplier. The later was eliminated for cost and size reasons and of the photodiodes, a large area (7 .5mm2 ) silicon detector was selected as its cost, sensitive range and temperature stability made it favourable . Other possibilities were hybrid photo-detector/preamplifier devices, however their expense precluded their use. Basic improvement to a NIR spectroscopic system is achieved by either increasing the intensity of the incident light or increasing the effective sensitivity of the detector. The factors considered when designing the device also included cost, weight, size, temperature stability and power consumption. 1.5 Measurement Principles 1.5.1 NEAR INFRARED SPECTROSCOPY The biological and medical value of near infrared spectroscopy arises from the relative transparency of tissue to light in the red and near infrared regions of the electromagnetic spectrum and the presence of two natural chromophores that exhibit oxygenation dependent absorption at these wavelengths (figure 1 .4). These chromophores are haemoglobin, which is present in red blood cells and is therefore an indicator of blood oxygenation, and cytochrome oxidase, which is the terminal enzyme in the mitochondrial electron transfer chain and therefore an indicator of tissue oxygenation [5]. The goal of NIR spectroscopy is to obtain absolute quantitative absorption spectra through observed changes in detected scattered light. However, differences from subject to subject in physical attributes such as skin opacity, skin thickness, blood circulation and temperature preclude single wavelength measurements due to an inability to calibrate the system. Using double wavelength techniques similar to that used by Shiga [6] and Mendelson [7], qualitative oxygen saturation data are obtained through normalisation of the absorbance data. 5 ~ ro u (/) Ol g C ,Q a. 0 (/) .0 ro (I) -~ ro ai a::: lsobestic Point 805 (I) ro u (/) Ol g C ,Q 0.. Reduced 0 (/) .0 ro (I) £ ro ai a::: Oxidised 400 500 00 700 8 0 900 1 OOO 900 590 660 880 950 Wavelength /nm (a) 625 Wavelength /nm (b) Figure 1.4: (a) Absorption spectra of oxy- and deoxy- haemoglobin and (b) oxidised and reduced cytochrome oxidase 181, 805nm is the isobestic wavelength for oxy- and deoxy- haemoglobin, other specified wavelengths indicate the frequencies of the available light sources (LEDs). 1000 In radiation transport, light is comprised of discrete photons that are either elastically scattered or totally absorbed according to the coefficients E (absorption coefficient) and cr (scattering coefficient) for constituents within the tissue [8]. The Beer-Lambert law ( 1.3) describes the total absorbance as the sum of the absorption coefficients multiplied by the concentration of each absorber [9]. The total absorbance is related to the detected light intensity by the logarithm of the incident and transmitted light ( 1.4) A= L:~:.."· [X,]L A= log 10 (!0 / 1) ( 1.3) ( 1.4) where I O and I are the intensity of the incident and transmitted light respectfully, c}· are the absorption coefficients (at wavelengths A ) for the various absorbers ( X ;) in the tissue, [ X;] are the concentration of the absorbers and L is the optical path length. The following result that relates blood oxygen saturation to the measured light intensity is calculated from absorbance data measured at the two wavelengths, 660nm and 880nm. At 660nm, reduced haemoglobin absorbs considerably more than oxyhaemoglobin and at 880nm the absorbance due to oxy- and deoxy- haemoglobin is comparable. The tissue oxygenation result is derived in the same manner using the same assumptions but shorter wavelengths of 605nm and 626nm. The general oxygen saturation derivation using double wavelength measurements is given in appendix A. l . At 660nm and 880nm it can be assumed that the contribution to the absorption by chromophores other than haemoglobin is small and, on the time scale of an observation, their contribution remains constant [ 6]. These terms along with optical loss and the sensitivity of the detector can be incorporated into an attenuation constant such that ( 1.3) may be rewritten as (1.5) 6 Equations ( 1.4) and ( 1.5) can be combined resulting in an equation that describes the observed intensity, I , as a function of the optical path length, the oxy- and deoxy­ haemoglobin absorption coefficients, and concentrations which vary m a complementary fashion. In ( 1.5) the absorbance, A, depends on the optical path length, which is unknown. Work using time-resolved or frequency-domain reflectance spectrometry has been carried out by a number of researchers (Wilson et al. [8], Liu et al. [ l OJ) to obtain absolute, quantitative absorption data. These techniques however, have large computational and hardware requirements that are unsuitable for this application. Given the relative transparency of tissue to red and near infrared light it can be assumed that the concentration of scatterers is much greater than the concentration of absorbers and that the degree of scattering varies insignificantly between 660nm and 880nm. That is, (S >> A) and (S 66onrn ""'Sssonm) where S LO",, [X 1 ] ( 1.6) Under these conditions, the average optical path length for both wavelengths is approximately equal (i.e. (L 66011m}"" (L88011,,,)) and, by taking the ratio of absorbances, the optical path length tenn may be eliminated [8]. E/,~~ [Hb] + £:~1 ~ 02 [HbO:] /-fh[Hb]+ HW[Hb02] ( 1.7) Using the complementary relationship between the oxy- and deoxy- haemoglobin concentration and recalling that the absorbance is proportional to the intensity signal, A= log(f 0/ I), an equation that describes the relationship between measured light intensity and oxygen saturation is found ( appendix 1 ). (£Hb -£Hbo,)log(io,66o/166o) +£Hbo, -£fib 880 880 l (1 j f ) 660 660 og o.sso / 880 ( 1.8) The reduction state of cytochrome oxidase and measured light intensity is calculated using the same analytical method, however in this case, the difference in absorption is observed for light of wavelength, 605nm (figure 1.4). From the absorbance relationship ( 1.5) an equation describing relative blood volume can also be derived by considering the absorbance at two different wavelengths A660 = cZt [Hb ]L + sZt0 ' [Hb02 ]L Asso oc £:St [Hb ]L + E~t0 ' [Hb02 ]L ( 1.9) ( 1.10) 7 Obtaining either ( 1.9) or ( l.l 0) in terms of [Hb] and [Hb02 ] then combining the results gives an equation re lating the total haemoglobin concentration to the absorbance ( 1. 11 ). Assuming that the total haemoglobin concentration in the blood remains approximately constant, the relationship between blood vo lume and measured light intensity is found by substituting the absorbance relationship, A oc log(/0 / !) , into ( 1. 11 ). The general derivation of relative blood volume is given in appendix A.3. ( A ( HbO, Hb ) A ( lfb HhO, )J [Hb ] oc _!_ 660 c'sso · - Esso + sso £ 660 - £660 · Iota/ [ Hb Hb01 Hb llhO: £ 660c'sso - c'sso£66o ( 1.11) 1.5.2 TRIPLE \VA VE LENGT H OXYGEN SATURATION MEASUREMENT [n general, the opacity of tissue reduces for light of increasing wavelength. Within an absorption band ( e.g. 590nm to 880nm for oxyhaemoglobin) the background absorbance can be estimated by interpolating between two wavelengths at which the absorbances of the oxidised and reduced stares are comparable (figure 1.5). Normalising the acquired absorbance with this predicted reference point reduces the error due to non-uniform base line drift and improves the validity of assumptions made for the constant attenuation assumed in equation ( 1.5) . ......... (1) CU u (J) CJ) 0 -C 0 Hb02 ·.;:; a. ,._ 0 . - Hb (J) .D ro (1) > A, A~ AJ _, ro (1) 0:::: 00 700 900 805 Wavelength /nm Figure 1.5: In te rpolating to find an estimate of th e background absor bance a t wavelength, Ai . Comparing the measured absorbance with the background es timate helps to remove the no n-uniform baseline drift present in double wavelength measurements. The equation describing oxygen saturation from triple wavelength measurements is given for the oxygenation state of haemoglobin using the wavelengths A,= 590nm, Ai= 660nm and ~ = 880nm. A similar result is obtained for cytochrome oxidase 8 using the wavelengths Ai= 590nm, Ai= 605nm and A,= 625nm. The general derivation of triple-wavelength oxygen saturation measurement is given in appendix A.2. Linearly interpolating between 590nm and 880nm gives an express ion for the background absorbance, A;60 , at 660nm, r1' = Asso - As90 + rl 600 J\ 590 880-590 where J\=--- -=4.143 660-590 (1. 12) Defining, /J, as the ratio of the measured absorbance to the background absorbance and assuming again that the mean optical path lengths are approximately equal at all three wavelengths gives the following expression (1.13) As before, the complementary relationship between the oxy- and deoxy- haemoglobin concentration is used allowing equation (1.13) to be solved for the oxygen saturation giving, [Hb02 ] _ f](E;~~ + (J\- 1)£~~ )-Ac~~ [Hb ] - HbO, Hb /J ( I) Hb HbO, Hb HbO, /Ota/ i\ £660 . - £660 + J\ - C590 - C590 . + Cggo - Cggo . (1.14) To obtain the direct relationship between measured intensity and oxygen saturation, the absorbance relationship, A ex log(f 0/ !) , is substituted into /J /J= M 66o = J\log(Io_66o / f66o) Asso + A59o (J\ - 1) log(Io.sso / fs8o)+ log(ro,s90 / l 590XJ\- 1) (1. 15) In both the double and triple wavelength calculations, relative blood volume, blood oxygenation and tissue oxygenation are found to be functions of the intensity signal and absorption coefficients only. Using data acquired from the device and absorption information from the literature allowed the metabolic state of the subject to be described. 1.5.3 NEAR JNFRARED SPECTROMETRY Near-infrared spectroscopic systems are usually arranged in one of two configurations, transmission mode or reflectance mode (figure l.6). Established clinical and research devices such as the Wood-Geraci ear-oximeter and the Hewlett-Packard eight­ wavelength oximeter are all transmission mode devices [ 11]. The use of reflectance mode spectrometry was introduced by Brinkman and Zijlystra in 1949 who showed that changes in oxyhaemoglobin saturation could be recorded non-invasively from an 9 I I I I I I I optical sensor attached to the forehead [7]. Reflectance mode oximeters however, have not achieved widespread commercial use due to limited accuracy and difficulties in absolute calibration. For the intended application, absolute calibration of the device was not required, as the main objective was to demonstrate a correlation between environmental conditions and the relative changes in the metabolic response of the Adelie penguin. In this device limitations in accuracy were reduced by the greater intensity of modem LED technology and calculation techniques such as the triple wavelength measurement (section 1.5.2). Aside from the differences in construction and calibration, the physical basis for both transmission and reflectance mode spectroscopy is the same for measurements of completely diffuse light ( i.e. the photon distribution within the medium retains no information about initial direction). Photon diffusion analysis by Kumar and Schmitt [12] has shown that, with a source and detector spacing of greater than 2mm, a collimated incident light source is equivalent to a diffuse source located below the surface in an optically turbid medium such as tissue. Since the Beer-Lambert law describes a measured intensity in terms of the photon path length and the incident light source may be considered diffuse, the detected signal for both transmission and reflectance mode spectroscopy is equivalent. Tissue Tissue Sou;ce "n, D'itector , ~n~ (a) (b) Figure 1.6: The two main configurations for near infrared spectroscopic systems, (a) transmission mode and (b) reflectance mode. For distances greater than 2mm from the incident light source the scattered light may be considered a diffuse light source below the surface. As diffuse light is independent of direction both transmission and reflectance mode spectroscopy are equivalent. 1.6 Thesis Overview The work undertaken in this thesis involves the design and development of a NIR spectroscopic device. Using the principles and techniques described above, a system was developed that not only collected the necessary physiological data but also addressed some of the difficulties of working in Antarctica and with the Adelie penguin. In the instrumentation chapter that follows, the hardware is assembled along with justification for the components selected. A logical division between measurement and control exists that divides the hardware into analogue and digital stages respectively. The acquired signal is followed through the various analogue processes to the point of digitisation where focus is then moved to the control of the device by the digital components. 10 The third chapter examines the control of the device from a software perspective. It gives a description of the operating system and the interaction between measurement sequence files, the terminal emulation software and the embedded processor. The final section of this chapter describes the algorithm used to determine pulse rate from the fluctuating scattered light signal and gives analysis of the signal processing techniques used to overcome noise. Chapter four begins by describing the incremental development of the device and the results of the validation steps taken at each stage. Reasons for each new prototype and the increased functionality that each system allowed are described in the logical order in which they were developed and the conclusion to this section gives the test results of the final prototype version of the device. The second part of chapter four describes the results obtained during field-testing. Included are the physical aspects of the experiments, such as capture, attachment and behavioural response, through to the biological results obtained m response to stress and temperah1re changes; oxyhaemogJobin saturation, cytochrome oxidase saturation, blood volume and pulse rate. A discussion of the acquired data follows in the conclusion chapter that then lead to an evaluation of the device, its limitations and various suggested improvements. Long-term enhancements conclude chapter five with an outlook toward the potential fr1ture of the device in environments as equally diverse as that of the Ade lie penguin. I l Chapter 2 Instrumentation An optical device was designed and constructed to provide an insight into the metabolic responses of the Adelie penguin. This necessitated a compromise between the constraints arising from working with penguins and the requ irements of the hardware. 2.1 Design Specifications The biological information to be measured included pulse rate, blood oxygenation, the reduction state of cytochrome oxidase and relative blood volume. As these variables are calculated from changes in the absorption of light at different wavelengths (section 1.5.1) , a system to record this absorption data was needed. Experiments designed to measure these variables could last only a few hours with continuous sampling or for several days using less frequent sampling. The device had to be equipped with timing facilities and have the ability to store the acquired data for retrieval after the measurement period. As the device was to be fitted to an Adelie penguin , there were a number of physical restrictions that also had to be considered. The average weight of an adult Adelie penguin is approximately 3.5 - 4.5 kg [13] and the device had to weigh only 2 - 3% of this ( :S l 50g) to minimise restriction of the birds normal activities such as walking, jumping, stone collecting or egg incubating. For the same reasons , minimising the package dimensions and careful consideration of shape were necessary. Research into the swimming energetics of instrumented penguins shows an increased level of energy expenditure with even relatively small instruments attached (<2% of body cross­ sectional area) [14]. The added complexity of waterproofing and streamlining the device packaging was avoided by conducting experiments during the penguins breeding period, where they spend the majority of their time on land. On the occasions that the penguin intended to go to sea, the bird was recaptured and the device removed. Waterproofing of the device, however, was still necessary to prevent problems from melted snow or ice. Minimising awareness of the device, by either the individual bird or its neighbours, was important for reducing stress. Research into the most suitab le package co lour has shown that colours similar to that of the bird's plumage are interfered with significantly less than other colours [ 15] and so all exterior surfaces of the device were coloured black. 12 2.2 Design Overview Measurements were made from the ulnar artery and deep ulnar vein located at the proximal end of the penguin flipper's medial side [16]. Attaching a device with the necessary functionality outlined in the design specifications to this location was not possible so a sensor head and control unit arrangement was employed ( figure 2.1 ). Sensor head fitted under the ----­ flipper Interconnecting Cable Tape Figure 2.1: Adelie penguin with a control unit and sensor head fitted. The control unit, tape and interconnecting cable were coloured black to be less obvious to the penguins. A plastic case, measuring 65mm x 92mm x 25mm and sealed by a plug fitted with an 0-ring, enclosed the control unit protecting it from water and interference by the penguin (figure 2.2). The sensor head was connected to the main unit by an interconnecting cable soldered to a row of header pins and mounted into the plug using epoxy glue. The connecting cable linked the control unit, located on the lower back of the penguin, to the sensor head that was taped to the underside of the penguin flipper. At the sensor head, LEDs of various wavelengths transmitted light into the tissue. Some of the scattered light was received by a photodiode (also mounted on the sensor head) that converted the light signal into an electrical signal. This was then amplified and filtered before being digitised by an analogue to digital converter and processed by a microcontroller in the control unit. Co-ordination of this process, measurement sequence interpretation, serial communication and power management were all done by the microcontroller. Finally, the acquired data were stored to static memory for later retrieval. 13 Microprocessor Analogue to Digital converter Figure 2.2: The connectivity and packaging of the sensor head and control unit. Information was transferred between the device and a computer via an RS-232 serial port. Using this communication, measurement instructions could be downloaded into the microcontroller's memory where they were interpreted and executed (section 3.2.3). As measurement periods could last anywhere from a few hours to several days, two important features of the device were the timing and power management capabilities. A microcontroller feature was used in conjunction with a real time clock to allow the processor to switch in and out of its power saving state at particular times. The final realisation of the device is shown in figure 2.3. The total weight of the control unit and sensor head (including the case and interconnecting cable) was 132.7g and the control unit had a frontal cross sectional area of approximately 1600 mm2 • 200 250 Figure 2.3: The final realisation of the device. 14 2.3 Analogue Circuitry 2.3.1 THE SENSOR HEAD Optical measurements were made by the sensor head located over the ulnar artery under the penguin flipper. The sensor head was 28mm in diameter and 12mm thick. It carried LEDs of six different wave lengths and a temperature sensor arranged equidistantly around a photodiode (figure 2.4). As suggested by Kumar and Schmitt [ 12] a source - detector spacing of 5mm was used. This spacing is suitable for shallow tissue absorption measurements and provides adequate signal intensity given the power limitations of the device. Also, the feasibility of this LED-photodiode arrangement was verified by preliminary experiments. In a similar device constructed by Shiga et al. [6] dual wavelength LEDs were mounted 30mm from the optical detector. Shiga states that thi s distance is su itable for making musc le tissue measurements but requires greater power to achieve measurable signal strength. Connec ting Cable rn \ Below Figure 2.4: The sensor head layout. The sensor head was 28 mm in diameter and 12mm thick. The view labelled 'Above' is the side that contacted the penguin flipper. Selection of LEDs for the sensor head was based on the availabili ty of wave lengths as close as possible to the peak differences and isobestic points of the haemoglobin and cytochrome oxidase absorption spectra (figure 1 .4). The LEDs chosen had peak outputs centred at 950nm, 880nm, 660nm, 625nm, 605nm and 590nm of which the 880nm, 660nm and 590nm were used for blood oxygenation experiments and the 625nm, 605nm and 590nm were used for tissue oxygenation experiments. The 950nm LED was included as an extra wavelength for the blood oxygenation measurements since many similar systems use 660nm and 950nm for their double wavelength measurements [7]. Individual contro l of each LED by the microcontro ller was achieved using three data lines and an eight channel surface mount multiplexer. The major advantage of this was to reduce the number of connections between the sensor head and the contro l unit. Using a three-bit address the microcontroller is able to select each of the six LEDs . Each LED was modulated when in use (section 2.3.2) so to achieve this, one of the eight multiplexer channels was left unconnected and by switching between the required LED channel and the unconnected channel the LED was modulated. 15 Light, emitted from the LEDs and scattered by the tissue, was collected by a large area photodiodc. The BPW34 photodiode was chosen for its large radiant sensitive area (7.5mm') and high photosensitivity rn the visible and infrarcd regions. Exposure of the detected signals to interference was minimised bv mounting a current to voltaae '- ., ._, b converter with gain as close as possible to the photodiode. This converter also acted as a preamplificr and was constructed using an OP07, low offset voltage and low bias current, operational amplifier. The benefit of this amplifier was its low noise characteristics making it ideal as the preamplifier. An estimate of the local skin temperature was obtamed from a temperan1re sensor located on the sensor head. The sensor was directly calibrated and had a linear response to changes in temperature of I Orn V/K. The sensor head is summarised 111 figure 2.5 and a complete circuit diagram is given in appendix C.2. ,-: 1, Temperaturen_i ----------1 Sensor LJ I c-------------~J -9 ! ' u' 590nm•; · \. 605nm v"1 ~ I ' I 625nm •1• ·~ MUX ·--------~ (j) ! 660n m v ,f----~---- __j c : \. ~-:------------- 18 !,; 880nm v+1---1)>M-/-~ 1 -,, ---iAMP LEDs : I ~ ,7: Figure 2.5: The semor head circuit. An t:ight-channd multiplexer was used to f('.dui..:c the number of connections between the LEDs on the sensor hezid and the s:untrol unit. A complete circuit di::rgram of the sensor head is given tn appendix C.2. 2.3.2THESYNCHRO~OUSDETECTOR One of the most useful experimental techniques for increasmg the signal to noise ratio of a noisy signal is synchronous or phase-sensitive detection. The underlying principle of this technique is to sbili the frequency of the signal of interest (usually near de) into a ·quiet' band of frequencies. A high pass or band pass filter is then used to remove the noise components outside of this frequency range so that, after demodulation, the original signal 1s reconstructed without the original noise [17]. The explanation that follows describes the synchronous detector implemented for the device (figure 2.6) while a more general analysis of synchronous detection is given in section 2.3.3. Consider the signal resulting from the photodiode on the sensor head if it were under constant illumination. The major factors contributing to noise and interference in this signal would be changes in background light levels, thermal drift and electrical interference (e.g. the switching of the LED address lines). Separating this noise from the true signal resulting from changes in scattered light would be a near impossible task. 16 Suppose now that the light source is modulated by a reference square wave. The resulting current through the photodiode detector will now also contain a square wave in phase with the light source (reference point 1 in figure 2.6). The magnitude of this square wave is proportional to the scattered light signal only and is synchronous with the reference Since this ac signal is the only signal of interest the offset voltage (background de interference signal) can be simply removed using a coupling capacitor such that the wavcfom1 becomes centred about zero (reference point 2 in figure 2.6). This ac signal tends to be small ( of the order I O - I OOm \") so it is amplified before it 1s passed through the phase sensitive detector which uses the modulation wave to toggle an electrical switch between the signal and its inverse. As the modulation wave and signal are in phase the effect of this switching is to full-wave rectify the signal (reference point 3 in figure 2 6) By passing this signal through a simple low pass filter a smooth de waveform proportional to the scattered light detected by the photodiode is obtained (reference point 4 in figure :.6) 3ack:;rouncr :.gr~t _, ,_ED ,:11..,,r,rna'.,Jr; ,;.!". . ' 't,1CJ·j1~:a;1on -:-r,e,rr,,Ji dr1 '! Photo::J1ode '/oi'.age -- =wi ,~..... ,--.• ,.w,, ~ \-1. ]--=~-: ........ ·'-.,2_.' ; i ~ AC Couo:1o ___ J '"'Elec'.r:'.:al wter'.erence •I ,,l,l,"l"""'I,¥t,~i.'iN ·3 ----,,.., Lo•:1 ::,ass "'Liter Figure 2.6: A graphical representation of the implemented synchronous detector. l) The raw volt:igc proportional to the current through the photodiode \Vith a background off\ct. 2) The rJ\V signal with thl'. background offstt removed. 3) Full w;ivc rcct1ficat1on of the rrmp!itlec! signal. -1-) • .i. \V3.veforrn directly proportional to the illumination of ihc pholudio t5 (j) ai (j) -10 -20 -30 -40 -50 -60 -70 >. 0 C 0 0.2 I ;;, 1------1----,+---i.----l © > Si ~ -0.2 -0.4 -0.6 -rr~ -----0.8~0 ____ _, Phase difference ,.__ Data acquired • / by physical measurement -80 ~--~---~---~--~---~--~ 500 1000 1500 2000 2500 Input Signal Frequency /Hz (Amplitude= 1V) 3000 3500 Figure 2.10: The frequency and phase response of the synchronous detector. These data were calculated for a synchronous detector using l kHz modulation ( 0,1 = ]kHz) and a low pass filter with a comer frequency at !Hz. The bandwidth of the dominant peak is 2Hz equal to twice the low pass filter comer frequency. The peak at 3u:i0 is predicted in equation 2.11 when w = 3WQ and n 3. The C+-c- program written to generate the data for the synchronous detector is given in appendix B.1 2.3.4 THE ANALOGUE STAGE On the device, the synchronous detector was implemented using a modulation frequency of-1 kHz and a low pass filter comer frequency of 3.4Hz. The demodulator was a DG419 analogue switch connected to a passive first order low pass filter. Since the function of the synchronous detector does not depend critically on the selectivity of the low pass filter a simple filter design was chosen to minimise weight and the circuit board area required. The remainder of the analogue circuitry (figure 2.11) is concerned with adjusting the signal levels so that they lie within the range of the analogue to digital converter (OV to 5V). The two input signals from the sensor head were converted into four outputs, signal-out, high-gain signal, pulse signal and the temperature signal. The first two of these were for LED measurements. The signal-out output was calibrated for the 950nm, 880nm, 660nm and 625nm LEDs and the high-gain output was for the shorter wavelength LEDs (605nm and 590nm) from which the signal strengths were much weaker. The pulse signal output was designed to amplify the signal oscillations to improve the computation of the pulse period (section 3.4). Most of the de offset was removed by level shifting the signal to approximately 0.1 V and then amplifying by a factor of 19. This increased the ac component of the waveform while keeping the 21 signal within the digitisation range. Finally, the temperature signal output was designed to increase the sensitivity of the temperature sensor by subtracting a de offset and increasing the sensitivity from 1 Orn V/K to 40m V/K. This meant that the temperature sensor was no longer directly calibrated in Kelvin but temperature measurements became four times more sensitive. Temperature Signal In Photodiode' ac x11 Signal In ""1Couplingr-· Amp --- Level Shift! Temperature + x4 ·- Signal Out ,---------·- Signal Out Low Pass ' X11 ac Level shift . , Demodulator, Filter ·-· Amp ·-,-:coupling·· +x19 Amp·-Pulse Signal -' ·1 ________ .. __ X11 Amp ... High Gain Signal Modulation Signal~-.... _____ .. _____ _ Figure 2.11: The amplification and filtering stage of the device. This analogue section of the device converts signals from the sensor head into measurable signal outputs ready for digitisation. A complete circuit diagram is given in appendix C.3. 2.4 Digital Circuitry The control unit's digital circuitry consisted of four functional blocks; the microcontroller, analogue to digital conve11er (ADC), real time clock (RTC) and serial EEPROM (figure 2.12). The latter three (slave devices) were connected to the microcontroller (master device) using the Motorola Serial Peripheral Interface (SPI) [ l 9] [20] which is a three-wire system for communication between digital devices. A complete circuit diagram for the digital circuitry is given in appendix C.4. Power Sense Real Time Clock Modulation LED Signal ,---------... 0,m .. ,c,c Pin Motorola MC68HC11E9 Microcontroller Serial EEPROM 12-Bit Analogue to Digital I---:-:=-::----; Converter -: -Channel 1 2 3 4 Enable Figure 2.12: The digital circuit components. Each of the slave devices (RTC, ADC, memory) were connected to the microeontroller via the serial peripheral interface (indicated by Serial Comms). 22 For the microcontroller to send and receive data from any slave device it first had to deselect all other devices connected to the serial data lines to avoid data collision. Once a single slave device was selected, data were transmitted and received bit by bit, synchronised by the serial clock (figure 2.13). When 8 bits had been shifted, two complete bytes of data were been swapped between the master and slave device. In each case the received byte was transferred to a data buffer which was then internally accessible by each device. Using this form of communication the microcontroller was able tQ sample data using the ADC, at timed intervals controlled by the RTC, process the data and store the results into memory. I Master device I , I I device select i Slave device I I I ~----------~ I r-~, 1 _.____,. ; data out ,-t.,___,___, i b~~=r I ic---+-J --ll,b~a~=ri 'I I.I i data in I I I I • 1 1 J1Jlf_-_----,c-lo-ck------J1Jlf Figure 2.13: Serial communication between digital devices using the '.Wotorola serial peripheral interface. 2.4.1 SAMPLING AND DIGITISATION At the end of the analogue stage there were four outputs, each used depending on the measurement to be made (section 2.3.4; figure 2.11). These were connected to the of LTC 1594 analogue to digital converter [21], the features of which included 12-bit resolution, low supply current and automatic shutdown. A major consideration when selecting components for the device was power consumption (section 2.4.5.3). An attractive feature of this ADC is that it draws only 320µA during conversion and then drops automatically to approximately 1 between conversions. Therefore the ADC could remain constantly connected to the power supply and high­ resolution data could be sampled at any time without concern for power consumption. To collect a sample using the ADC, a byte (with the last 4 bits containing port number information) was sent while the chip-select pin was high (unselected). Before the next SPI clock cycle the ADC chip was selected (pin set low) and two consecutive bytes ( 16 bits) were read by the microcontroller. The 12-bit sample value was retrieved by concatenating the two bytes and reading bits 2 through 13. The bits outside this range could be used for error detection. 23 2.4.2 THE MICROCONTROLLER The microcontroller used to control the device was the Motorola XC68HC7 l l E9Cf­ S2. This device was chosen because there was local knowledge and experience with the 68HC 11 and also because it was readilv available. A block diagram of the C ~ controller is given in figure 2.14 showing the functional blocks and input and output connections. Some of the features that prompted its use include: • 12k by1cs of erasable programmable read-only memory (EPROM) • S 12 byies of electrically erasable programmable read-only memory (EEPRO:VI) • 512 by1es of static RA.iv! • Serial peripheral interface (SP!) • Serial communication interface (SCI) • Eight channel 8-bit analogue to digital converter • 16 bit timer system with output compare timctions • Power saving mode via the STOP instruction In the final implementation of the device the control software ( chapter 3) was stored in the 12K by1cs of EPROM, the 512 b11cs of EEPROM were used to store measurement sequence information and the 512 b11es of RAM were used for system variables. 2.4.2.1 Output-Compare The ·output-compare' functionality of the microcontroller was used to implement the modulation of the LEDs. Each output-compare had an associated register that was used to trigger an interrupt and optionally a pin on port A of the microcontroller. An output-compare was triggered when the value of the internal clock (represented by a 16-bit free running counter) equalled the data held in one of the output-compare registers. LED modulation on the device was achieved using the first output-compare timction (OC l ). A special feature of OC l is the ability to control any of the pins of port A. During initialisation of the controller, OC I was configured to control pins 1 through 4. which were connected to the multiplexer on the sensor head (section 2.3.1) and to the demodulator of the synchronous detector (figure 2.11). LED modulation was initiated by setting the value of the OC 1 register to a time in the future. The state for port A was assigned into the OC 1 data register and the intemipt mask was removed. When the interrupt occurred, the contents of the OC 1 data register were mapped to the pins of port A and program execution entered the OC 1 interrupt routine. Within the interrupt routine, the value of half the modulation period was added to the OC 1 register so that the next interrupt would occur half a period later. The OC 1 data register was assigned a value of either zero or an LED address, depending on its previous state. Periodic sampling was achieved in a slightly different manner using output compare 5 (OCS). In this case OC5 was not configured to control a pin of port A but only to generate an interrupt. A sample was acquired during the interrupt routine and the time period until the next sample was added to the OCS register. 24 MODA MOOB (LIR) (V,...,) a. 0 0 u ;;; :5 E <.> ~ ~ Timer ~ System .. "' ~ OC1 i --- ~ XTAL EXTAL E ,._ 0 co __ co a. ll. IRQXIRQ RESET (Vpp) Interrupt Logic ROM 12K Bytes CPU Core I~ co 0:: I­C/) EEPROM 512 Bytes RAM 512 Bytes j ;:===::.::.-:.,-r----_S-:,.e_n_a_l_-_-,:-.::;"""Tc--' V 00 Senal Peripheral Interface SPI Commun1cat1on Interface SCI I~~ ioo::< ;3 __ 8 O::i.... a.. Q. ,._ 0 w--w ll. ll. t;;C/) Figure 2.14: Block diagram of the 68HC 11 E9 microcontroller. 2.4.2.2 Interrupts Another feature of the microcontroller was the ability to assign the highest priority to a particular user intem1pt. The pulse measurement algorithm (section 3.4), used to calculate the period of a pulse wavefo1m, relied on the sampling frequency being known. This was ensured by assigning the highest priority to the sampl ing output compare intem1pt. Other interrupts used by the device were OC L (for LED modulation) and the external non-maskable interrupt XIRQ (for receiving status from the real time clock). 2.4.2.3 Real Time Clock The Motorola MC68HC68T 1 real time clock (RTC) [22] was used for timing over long time periods, for power supply level sensing, and recovery from power saving mode (section 3.2.2.3). Periodic interrupts, alarm interrupts, and power sense interrupts generated by the RTC were communicated through the microcontroller's non-maskable interrupt pin. When one of these events occurred, the microcontro ller received an XIRQ interrupt. The interrupt service routine read a byte from the RTC containing status information that was saved in a system variable. It was then up to the operating system software to parse the status byte to determine the reason for the interrupt and to respond accordingly. 2.4.2.4 Additional Features of the Microcontroller Five ports were available on the microcontroller (figure 2.14) each with a specific purpose. Port A was used in conjunction with the output compare function as described earlier in section 2.4.2.1. Port B was a general purpose output port used in this application to select between the various SPI devices (ADC and memory), to enable the analogue circuitry (section 2.4.5.2) and to shut down the system after detecting a failing power supply (section 2.4.5). Port C of the microcontroller is for 25 general purpose input and output but was not used in this application. The pins of port D were used for serial communication fo r both the SP1 and the SC[ (section 2.4.4). Through this port instructions were received from a computer, status was read from the real time clock and data were transferred between the ADC and memory. Finally, port E was the input to an 8 chatmel, 8-bit, on-chip analogue to digital converter. This ADC was fo und to have inadequate reso lution for this application and an external 12- bit converter was used in it place. 2.4.3 MEMORY The acquired data were stored in four banks of 32Kbyte EEPROM (AT25256 (23]) totalling 128Kbytes of avai lab le storage space. Each chip was connected to the SPI data lines and selected us ing port B of the microcontro ller. At one sample per second (each sample had 12 bits so two bytes were used to store each sample value) there was enough available storage for 17 hours of data collection. The rate of collection varied depending on the nature of the measurement sequence so by introducing a delay into the measurement sequence, extended collection periods were possible. Data were written to the memory chips using a 64-byte page write technique. Each memory chip had 64 bytes of RAM that could be mapped to any page boundary with in memory. This writing technique began by enabling the appropriate memory chip, sending a write enable command, deselecting the memory chip and then waiting until the chip entered the 'write enabled' state. Once in this state the memory chip was again enabled and a 16-bit address sent in the form of two bytes, most significant byte first. After this, the memory chip was ready co store consecutive bytes of data. When writing a data stream was completed or a page boundary was encountered the memory chip had to be deselected and then reselected in order ro continue writing data . The memory chips automatically returned to the write disabled state when deselected and a write cycle time of 5 to I Oms occurred before the next stream of data could be written. The sequence of sending a write enable command first, reduced the risk of accidental erasure of existing data in the event of a software error or microcontro ller malfunction. The memory chips were also designed to ·fail secure' so that if the power supply failed, data was not lost. The process of reading from memory was much simpler as data vulnerability was much less. The memory chip was selected and three consecutive bytes were sent, the read instruction followed by two address bytes (most significant byte first). Data were then continuously read (the paged implementation did not complicate the reading process) unti l the memory chip was dese lected. 1n the control software an interface to the four memory chips was created to hide the discrete nature of the memory and provide a contiguous memory model. The memory protection features, together with large capacity, small standby current (- 5µA) and surface mount package design made these memory chips ideal fo r this application. 2.4.4 COMMUNICATION Transfer of instructions to the device and retrieval of data by a computer was achieved using the microcontroller's SCI. This feature of the microcontroller implements the RS-232 communication protocol using SV logic levels that were converted to the standard of 12V levels by a serial interface unit (section 2.4.5. 1, circuit diagram given 26 in appendix C. 7). A non-standard baud rate of 78 12 baud was used for nonnal communication between the microcontroller and the computer as this rate was one of the highest achievable fo r the microcontroller when using a 2MHz crystal (section 2.4.5.3). In the special case of writing measurement sequence instructions to the microcontroller's internal EEPROM a communication rate of 300 baud was used to al low time fo r the longer wri te cycle of the EEPROM. Serial port communication software (TEmu) was written that could communicate at the non-standard rate of 78 12 baud as well as switch between the rates of 300 and 7812 baud. This software was designed for sending commands and receiving data, rea l time viewing of data and debugging purposes (section 3.1 ). 2.4.5 PO\VER CONSIDERATIONS The device was used in two states, the configuration state (power suppl ied externall y) and the measuring state (power suppl ied by on-board batteries). The power supply circuitry (figure 2.15) was designed to make a continuous transition from the external supply to the on-board supply as well as provide control over power supplied to regions of the device and feedback on the battery voltage status. These features were des igned to extend battery life by minimis ing power consumption and provide a clean shutdown of the system in the event of a failing power supply. 2. 4. 5.1 Power supply sources Initially, while the device was connected to a computer for configuration, the serial interface un it supplied power (figure 2.16). A 12V lead-acid battery supplied both the serial circuitry and the device, thus making the whole system portable. Once configured, a jumper on the device was used to connect two 3.7V lithium thionyl chloride batteries that supplied power when the device was isolated from the serial interface unit and taken into the field. On-board supply (Two 3.7volt lithium - - - ----­ thionyl chloride batteries) ..----------- Analogue enable Analogue circuitry power supply +5volts -5volts (closed when needed by the microcontroller) .,__ _______________ Voltage level sense External supply (regulated 8volts fr serial interface un om it) Digital enable (held closed by the external supply) ' Digital circuitry power supply I r--I +5volts (used by RTC to detect failing power supply) Digital enable (held closed by the microcontroller) Figure 2.15: The power-supply schematic. Separating the power supplies into a digital and analogue supply had two main advantages: interference from switching digital components through the ground connection was minimised and the analogue region of the circuit could be shutdown as a means of conserving power. A complete circuit diagram of the power supply is given in appendix C.6. 27 2.4.5.2 Power considerations on the device Supply lines that provided power to the digital circuits were generally noisy due to the switching of digital logic levels. For this reason the power supply was separated into two branches immediately after the battery connection. One branch provided power to the digital components using a s ingle 5V regulator and the other provided 5V and - 5V using a CMOS voltage converter (ICL7660CBA) w ith two 5V regulators. An added advantage of thi s was that the analogue suppl y could be controll ed by the microcontroller allowing it to be shut down when the analogue c ircuitry was not required thereby reducing power consumption . This control switch is labe lled analogue enable in figure 2.15 and was connected to port B of the microcontrol ler. [ Computer ]~1-2v_ ....... Rs-~32 Serial Interface Unit Backup Battery The Device Figure 2. I 6: Connectivity of a computer, the serial interface unit and the device. During configuration the device was supplied power by the serial interface unit and then by its on-board batteries during operation. 2.4.5.3 Power saving As w ith any battery-operated system, a goal was to maximise the usefu l operating time through minimising the load on the batteries. The most signifi cant feature of the dev ice to help with this was the microcontro ll er's stop instruction wh ich, in co­ ordination with the real time clock, reduced the m icrocontroller 's load on the batteries to approx imately I OOµ A. When executed, the stop instruction caused all of the microcontroller's internal clocks and main oscillator to freeze placing the processor in a minimum-power standby mode, a state in which it stayed until a s ignal on the non­ maskab le interrupt pin was received. While in standby mode, all VO po1ts and internal registers retained their values and, as the microcontroller is a full y static device, after recovery from stop execution continued with the next CPU instruction. The other components that were continuously connected to the supply were the ADC that had an auto shutdown feature that reduced its load to approx imately l nA, the memory chips that drew 5µA each in standby mode and the real time clock that ran continuously drawing approximately 25µ A (all analogue circuitry was disconnected from the supply by the microcontroller's analogue enable pin). Another means of reducing power consumption was by selection of the microcontroller crystal frequency. During development a crysta l frequency of 8MHz was used but replaced in the final design by a 2MHz crystal thus reducing power consumption to a quarter of that used previously by the microcontroller. An effect of this frequency reduction was that the max imum sampling rate was reduced due to a limit imposed by the minimum number of CPU instructions that needed to be executed between sampling interrupts. 28 2.5 Construction In accordance with the design specifications, minimisation of the size and weight of the device was achieved using double-sided printed circuit boards (PCBs) and surface mount components. Important aspects of the layout for the main control unit and sensor head were separation of noisy digital tracks from analogue signal tracks, separate ground tracks for the analogue and digital components to further reduce electrical interference and minimising necessary PCB area. Figure 2.17 is a block diagram of the functional regions in the final layout (for complete PCB layouts see appendix D) and shown in figure 2.18 are photographs of the completed device. Current to Voltage ( Common edge) (a) Microcontroller (b) (Common edge) Figure 2.17: The functional regions of the PCB layout for the control unit (a) from above and (b) from below. 29 lfTil1 lll I '"'i ,o 20 3o 40 50 50 70 s., , I 00 l~--- ·:w " •· : ;