• No results found

Implementation of the pCO 2 equation

5.5 Implementation of the Colorimetric Equations

5.5.4 Implementation of the pCO 2 equation

The equation for the partial pressure of carbon dioxide is a logarithmic expression and requires the implementation of a logarithm function more specifically the anti-logarithm function to the base 10 for floating point operations.The function can be implemented by using a look up table but the implementation requires a lot of memory. The accuracy of the operation depends on the size of the look up table[102-104]. A different approach was looked at with improved accuracy without the need for big memory. The logarithmic expression can be expressed as an exponential expression which is shown in equations 5.11 and 5.12.

107

5.11

( ) 5.12

To implement the exponential function it was expressed using the Taylor Series and representation is shown in equation 5.13[105, 106].

5.13

Equation 5.14 shows the relation for pCO2 expressed as a Taylor series.

( )

5.14

where A = log N + pK1 –log Ks

The terms pK1 and Ks are constantsin the equation and are stored in the memory. The concentration of the bicarbonate buffer determines the range of the change in pH when the buffer comes in contact with the carbonic acid formed from the carbon dioxide and water vapour in the blood. Previous experiments conducted on this technique have shown that a buffer concentration of 0.035Molar gives a pH change between the range of 6.8 and 7.8[33].This is the range of the blood pH allowing us to use the same colorimetric algorithm to measure the pH without needing it to be recalibrated to measure the change in pH of the bicarbonate buffer.

Colorimetric Algorithm Floating point Multilpier Floating point Adder pH Factorial Values n! n=2 to 20 Stored as inverse values Rmean Value pCO2

Figure 5.47: Block diagram of the pCO2equation implementation

Figure 5.47 shows a block diagram of the implementation of the equation for pCO2.The image of the indicator combined with the bicarbonate buffer is analysed and the mean value of the colour red is passed to the colorimetric algorithm to calculate the pH of the bicarbonate buffer. The pH value obtained from the algorithm along with the constants is

108

substituted in the Taylor series equation. The Taylor series was restricted to the first 20 terms as they gave the necessary resolution needed of two decimal places in the result. Taylor series implementation uses the floating point multiplier and adder design used in the pH measurement block.There is a division operation in the implementation which was eliminated by storing the factorial term values inversed in the memory as they are constant. The inverse values of the factorial terms were multiplied to the power terms thus achieving the division function without needing to implement a floating point division algorithm. The powers of pH from n= 0 to 20 were calculated using the floating point multiplier. The inverse factorial values were multiplied with the powers of pH and then added using the floating point adder. The final result from the adder is the partial pressure of carbon dioxide.Figure 5.48 shows the simulation results for the implementation of the equation for pCO2 in VHDL. The implementation requires 128 clock cycles to calculate the pCO2 value including the 32 clock cycles to generate the pH value needed for the pCO2 equation.

109

5.6 Conclusion

This chapter presents the design and implementation of the Image based Colorimetric pH and pCO2analyser. The analyser has three distinct parts: the camera, the colour analysis block and the colorimetric algorithm blocks.

The colour analysis block implemented can adapt to read an 8 bit, 16 bit and 24 bit format bitmap image. The block analyses the image and reads the value of the red colour components for each pixel in a 200 x200 window from the centre of the image. The colour data from the 40,000 pixels is averaged to find the mean value of the colour red. The mean value is converted to a floating point value by using a leading zero counter and a shift register.

The colorimetric algorithms for pH and pCO2 are mathematical equations with fractional coefficients requiring the need to use floating point architecture to implement the equations in hardware. The equations have two primary operations: addition and multiplication required to implement the mathematical equations.

The leading one predictoralgorithm and the far and close data path algorithmfor floating point addition were compared with the standard algorithm in terms of speed of operation and power consumption. The LOP and far and close algorithm provided an advantage over the standard algorithm in terms of speed of operation but required extra components to enhance the speed thus increasing the area. The standard algorithm was chosen as speed of operation is not the primary criteria rather low power consumption and lower area is. The floating adder based on the standard algorithm is implemented and has a latency of 7 clock cycles.

The floating point multiplier is implemented based on the standard algorithm with a carry save multiplier to multiply the mantissa. The carry save multiplier provides an easy to layout architecture with good performance in low speed operations. The floating point multiplier implementation has a latency of 4 clock cycles.The pH and pCO2 equations are implemented using the floating point multipliers and the implementation have a latency of 32 and 128 clock cycles respectively. The next chapter discusses the implementation of the complete system on a 0.35 µCMOS process and Xilinx Spartan3 FPGA.

110

Chapter Six: Implementation Results and Analysis

6.1 Introduction

The design for the individual blocks in the Image based Colorimetric Analyser was completed in chapter 5. The next step is the integration of all the blocks to form the Image based Colorimetric Analyser. The design of the integrated block and its implementation are presented in this chapter.

This chapter is divided in two parts. Section 6.2 presents the design of the integrated block and the synthesis of the block in a Xilinx Spartan 3 FPGA and in 0.35 µ CMOS. The section also presents the results from the performance analysis of the design and implementation. Section 6.3 evaluates the performance of the Colorimetric analyser against the current analysers.

Related documents