Journal of Microcomputer Applications (1984) 7, 3 19-327
The microcomputer-controlled sensor
electrochemical
Elizabeth A. H. Hall Nufield Department of Anaesthetics. University of Oxford, Radcl@e Infirmary, Oxford OX2 6HE Operation of an electrochemical sensor involves the application of a voltage source to the electrode, and sampling of the current from the electrode. These requirements can be achieved by the use of digital-to-analogue and analogue-to-digital converters, interfaced to and controlled by a microcomputer. A ‘non-steady state’ measurement technique has been developed, requiring a pulsemode voltage source, where the reduction voltage is applied to the cathode as a rectangular wave for time periods ranging between 20ms and SOOms, and requiring sampling rates as fast as 8/ms. In order to achieve such fast execution requirements, software was developed in relocatable Z80 machine code, emminently suitable for further development to microprocessor ‘stand-alone’ systems. Accurate timing was provided by the use of a counter-timer circuit, programmed in the counter mode. to provide interrupts.
1.
Introduction
It would be desirable to be able to monitor blood and anaesthetic gases by a simple, reliable and inexpensive means. Electrochemistry could provide this means, since not only oxygen and carbon dioxide, but also nitrous oxide and halothane have been found to be electrochemically active. By providing sufficient energy, in the form of an electrode potential, the gas to be measured may be electrochemically reduced, giving rise to a current which is proportional to the concentration of the gas present. Traditionally, the monitoring of gases using membrane-covered electrochemical sensors has involved steady-state measurements at a polarizing voltage chosen within the diffusion-controlled region of the reduction wave for the gas concerned, such that the probe is gas selective, providing the reduction potential is exclusive to the one gas. Each gas, therefore, has required a separate electrode, polarized constantly at the reduction potential of that gas. The method requiring a constant voltage source involves consumption of the species undergoing measurement, which may lead to a significant depletion in the total gas concentration in measurements where low concentrations are involved. In this steady-state operation, the diffusion field of the electrode will spread into the sample phase, and since diffusion is different for gaseous and liquid samples, a ‘liquid-gas difference’ is observed between the two sample phases. For the 20~1 Pt Radiometer Oxygen electrode, this has been found to be of the order of 5%. This difference can be reduced by making non-steady state measurements at times when the diffusion field has not penetrated the sample phase, so that a discrete rather than continuous measurement system might be preferred, when the reduction voltage is
319 0745-7 138/84/0303 19 + 09 $03.00/O
0 1984 Academic Press Inc. (London) Limited
320
E. A. H. Hall
applied for a sufficiently short time to encourage a minimum in the liquid-gas difference. Since the reduction potential is a characteristic of the individual gases and the electrode material, a single multigas measurement probe could therefore be envisaged, where the electrode potential is switched between the various reduction potentials, selectively assaying the gases of the mixture. Realization of such an electrode system requires a pulsed potential source, stepped between the desired potentials. On applying a step change in the polarizing voltage to the electrode, a transient current-time response is recorded. Integration of the transient between given time limits gives an integral with a suitable time response. Examination of the current-time transient from the electrode, also indicates that the high current response at short times would have the advantage of increased sensitivity. In order to establish the ideal pulsing regime and integration time-limits, such that reproducable accurate measurements can be achieved, a control system is required where the parameters can be varied easily and quickly without involving circuit redesign or hardware reconstruction. These requirements can be achieved, by the use of digital-toanalogue (DAC) and analogue-to-digital (ADC) converters, interfaced to and controlled by a microcomputer.
2.
Hardware
The following microcomputer:
development parameters
(a) Polarizing voltages (b) Reaction times (c) Integration times (d) Sampling rate (e) Current sampling
must
be able to be regulated
or handled
by the
reduction potential . . . pulses rest potential . . _ spaces pulse lengths space lengths delay before integration integration length store of the current from the electrode as a voltage.
In early work (Hahn, Hall, Maynard & Albery 1982) (a) and (e) were provided via the ‘on-board’ parallel input/output controller (PIO) with external digital-to-analogue and analogue-to-digital conversion. This gave an g-bit resolution which proved to be insufficient for most applications. (b), (c) and (d) were achieved by a crude system of experimentally calibrated nested ‘time-wasting’ loops. Unfortunately, this timing system did not allow for deviations in execution time for the rest of the program, depending on sample data size, and was shown to be insufficiently accurate. The Nascom2 64k Z80-based microcomputer &as therefore extended in an intradepartmental development (Maynard, 1982/3) to provide bus-compatible input/output and timing devices. Input and output for the electrode were available using address decoded 12-bit ADC and DAC devices respectively, enabled by ‘IORQ’ (available on Nascom bus) initiated on execution of an ‘OUT’ instruction provided in the software. Accurate timing was achieved by the use of a counter-timer, in the counter mode, also enabled by ‘TORQ’, to provide programmed interrupts.
/tC-controUed electrochemical sensor
32 1
In later work VDU output and printer copy were replaced by LCD meters and ,W plots accessed via an eight-channel 8-bit DAC board (Maynard, 1983).
3.
Software
3.1
Input/output
requirements
The polarizing voltage should be applied to the electrode in a rectangular wave, where all parameters of that wave can be varied. The polarizing voltage may be a single repeating rectangular wave (one gas), or the alternate repetition of two rectangular waves (two gases) (Figure 1).
Time
c
Figure 1. Output and input from and to the electrode. (a) Electrode current-time transients. (b)
Electrode polarizing voltages. The current from the electrode should be sampled from the current transient, after current to voltage conversion, and at intervals which may be varied. Sampling rate and thus programming of the counter-timer must be compatible with the application. Typical sampling rates range from eight times per millisecond for a 20 ms pulse, to once per millisecond for a 500 ms pulse.
3.2
Calibration and arithmetic procedures
3.2.1 Single gas. A two-point calibration, with one point 0% GAS provides the most simple calibration: e.g. for oxygen, after introduction of the electrode to 0% oxygen, the ‘raw data integral’ (RDI) can be stored (ZERO) to give the base line. Subsequent introduction of the electrode to a known concentration of oxygen, say 20%, and storage of the RDI (02HIGH) completes the calibration. The calibration factor, CAL02, may then be calculated: CAL02 = “‘;p”.
322
E. A. H. Hall
This then allows other concentrations according to the equation: %UNKNOWN
of oxygen to be monitored
= (RDI,,,,,,,
and calculated
- ZERO)/(CAL02).
It is, however, usually more convenient and more accurate to use a concentration of gas other than 0% for the calibration, so that an arbitary zero is taken - 02LOW (say 20%), and the second point is taken at a higher concentration (say SO%), so that 02HIGH represents 50-20%. %UNKNOWN then becomes: 02LOW% + (RDI,,,,,,,
- ZERO,,,,,,)/(O2HIGH/30).
This modification requires that the software can deal with both positive and negative results before 02LOW% is added. 3.2.2 Two gases. Calibration must take into account the fact that at the higher pulse reduction of both gases occurs (Figure 2), while at the lower pulse only one gas is reduced.
-750
-15oOmV
mV
Polorizmg
voltage
Figure 2. Voltammogram for oxygen and nitrous oxide, showing expected current response for various gas concentrations at the chosen pulse polarizing voltages, - 750 mV and - 1500 mV (vs Ag/AgCl). A: base line, 0% 0,; 0% N,O. B: 20% 0,; 0% N,O. (a) 0, current at - 750 mV; (d) 0,current at - 1500 mV. C: 40% 0,; 0% N,O; (c) 0, current at - 750 mV; (f) 0, current at - 1.500mV. D: 30% 0,; 20%N,O. (b) 0,current at - 750 mV; (e) 0,current at - 1500 mV. (g) N,O current at - 1500 mV.
Calibration of the lower pulse is as in 3.2.1. The higher pulse must first be calibrated in the absence of the second gas (say nitrous oxide). This calibration can occur consecutively on both pulses, to give calibration factors: CAL02/1,
CAL02/2.
pC-controUed electrochemical sensor
323
Unknown concentrations of oxygen are then calculated as in 3.2.1 from the lower pulse, and the calculated value used to find the RDI due to oxygen on the higher pulse. RDI,, = 02%,,,,*CAL02/2. This may then be subtracted from the total RDI for the higher pulse, subsequently allowing a single concentration calibration for the second gas (say 20% nitrous oxide). The nitrous oxide calibration factor then becomes: CALN20 = (RDI,,,,, - RDI,,)/20 and unknown concentrations %UNKNOWN,,,
4.
Software
of nitrous oxide can be calculated: = (RDI,,,,, - RDIo,-
ZERO)/CALN20.
development
Application of the microcomputer to the control of electrodes is limited by the speed of execution of the output, input, and data processing routines. In BASIC output to the electrode via the 12-bit DAC requires a simple four-line program of ‘OUT’ instructions, where the number is loaded as three separate nybbles and output activated by a further ‘OUT’ instruction. Similarly, sampling of the electrode current via the ADC is activated on an ‘OUT’ instruction and requires two ‘INP’ commands to read the high byte and low nibble of the sample. Together with a ‘PRINT’ statement of the sample, this complete cycle requires 64 ms in Nascom Microsoft 8k BASIC, running at 4 MHz, so that the monitored reading could be updated every 64 ms. However, if a printer recording of the output is also required. the repeat time is increased to a minimum of 127 ms (depending on the baud rate and printer type). An improved sample/noise ratio is achieved if this ‘single sample’ technique is substituted by an integration, summing consecutive sample at intervals of At. For a lo-sample integral in Nascom BASIC, using a ‘FOR/NEXT’ loop for the sampling routine a repeat time of 380 ms is obtained and At of the order of 30 ms. It would, however, be desirable to have a greater number of samples in the integral, but this would further decrease the update time. Nascom BASIC therefore, even where running at 4 MHz, has an execution time which is outside the limits of the requirement. However, if the BASIC output, input, and integration routines are replaced by machine code routines, the BASIC program can retrieve the sample already in its integral form, from an area of memory allocated in the machine code: Collect input data from machine code program W2 = PEEK(20748):REM High byte of integration Wl = PEEK(20747):REM Low byte of integration w = (w2*256) + w 1 PRINT W
The sample rate can now be chosen, and the repeat time, for a lo-sample integration at 2/ms is considerably reduced. The BASIC program requires 64ms. the machine code 5 ms.
324
E. A. H. Hall
So far these programs are not calibrated and the output appears as values between 0 and 20480. To convert this to a percentage, the extra line that is required increases the update time to 86 ms (BASIC-81 ms; machine code-5 ms). At this point it was necessary to substitute the calibration arithmetic in BASIC with rather more complicated but nevertheless faster machine code routines to allow interaction with the keyboard, and automation of the calibration values, and a faster sampling rate, within the time limits desirable for a pulsed electrode. The programs would only be required to return to BASIC after each cycle to display the percentage on the screen, the repeat time becomes 37 ms (BASIC) + 7 ms (machine code). So, at this stage the software was sufficiently developed to allow electrode control and data processing, with a calibrated integral of the electrode current displayed as a percentage on the screen, or where a greater time-error allowed, on a printer. If however, the output is not to a VDU, but to a y-t chart recorder or a LCD-meter, then this is easily controlled with a machine code subroutine and the return to BASIC is no longer required and the repeat time becomes 7 ms. Thus the two extremes of pulse length and sampling rate can be achieved by a single variation in the programming of the CTC to adjust the timing interval and sampling rate. The construction of the program to control and monitor the pulsed electrode is described in the flow diagram in Figure 3.
5.
Operation
5.1
Polarization voltages
The pulse potential(s) should be chosen to be in the diffusion controlled region of the current/potential reduction plateau. Fine tuning can be provided easily by keyboard control, after concentration linearity tests. The space potential(s) should be at a voltage where no reduction of the gas/vapour to be measured is taking place.
5.2
Integration
In order that the electrode gives a linear concentration response, integration must be performed while the electrode reaction is entirely electrochemical and there is no contribution from electrical charging. This non-electrochemical current error is greatest at the beginning of the pulse, while the electrode is being charged, so that measurements made during the first milliseconds must compute this and eliminate it. The time focus on the current transient will depend on the particular application of the electrode. If breath by breath analysis or a minimum liquid-gas difference is desired, a sampling rate of about 7-10/s should be required, and the pulse length restricted to around 20 ms. Here integration must be performed early in the current transient (Figure 4).
@controlled
electrochemical sensor
325
c Collect new p&ruing
t
voltage
t
Output
poloriring
and pulse length voltage
Collect CTC parameters
Collect CTC porometers
I
IWolt for interrupt
I
contribution
Collect present subtotal current
from
+ Zero next subtotal
oxide col~brot~on .
Colculote nitrous concentrotlon ICorrect Scale Output
arbdrary
numbers to LEDs
Figure 3. Software
for 8-bit &/ory-f
oxide
base-lme output plot
flow diagram,
326
E. A. H. Hall
(b) Slow pulsing
ms
Figure 4. Electrode current-time
ms
transients for (a) ‘short’ and (b) ‘long’ pulses, demonstrating probable integration periods.
For other applications a slower sampling rate is possible and the first part of the transient (typically > 100 ms) can be totally eliminated from the integration.
5.3
Limitations
In practice, identification of the non-electrochemical current component is difficult, and is related to electrode size and geometry. The pulse must therefore be of sufficient duration to ensure that decay of this current is complete, and a linear concentration response can be expected. Reliable achievement of this brief demands that ‘long’ pulses must unfortunately be employed. In order to realize the ‘short’ 20 ms pulse, therefore, further modification in the electrode control technique would be required (Hall, 1984).
6.
Further
development
Final development of the software was independent of BASIC and was written in relocatable 280 assembly code. It was therefore emminently suitable for use in a microprocessor stand-alone system, with very little further development. A prototype microprocessor unit (Maynard, 1983) designed for use with an anaesthetic machine to measure oxygen and nitrous oxide, was able to be further expanded to accept the more accurate timing achieved with a counter-timer. The approximate two-point calibration of the prototype was superseded by the three-point calibration described here. Keyboard handling and interaction was replaced with single function switches and LEDs. The Mark II unit was dedicated to long pulses of 400 ms, suitable for a Radiometer type 0.125 mm silver bench electrode. Integration was performed for 160ms after 240 ms, with a sampling interval of 0.5 ms.
pC-controlled electrochemical sensor
327
Future development will include a faster sampling rate and shorter pulses, leading to a vastly reduced liquid-gas difference. In order to realize such a pulse regime the nonelectrochemical current at the beginning of the pulse must be eliminated. Work in this area is currently in progress (Hall, 1984). Sampling rates faster than the 8-10 times per millisecond already achieved on the Nascom2 are likely to require faster and considerably more expensive ADCs and microprocessors.
References Hahn, C. E. W., Hall, E. A. H., Maynard, P. & Albery, W. J. 1982. A sandwich electrode for multi-gas analysis: A prototype. British Journal of Anuesthesia, 54, 68 1. Hall, E. A. H. 1984. The pulsed membrane gas electrode. Proceedings from 2nd International Conference on Fetal and Neonatal Physiological Measurements. London: Butterworths. Maynard, P. 1982/3. Extended I/O facilities: Part I. Nuffield Department of Anesthetics Internal Report, Oxford. Maynard, P. 1983. Extended I/O facilities: Part II. Nuffield Department of Anaesthetics Internal Report, Oxford. Maynard, P. 1983. A microprocessor controlled instrument for the measurement of oxygen and nitrous oxide in a hospital environment. MSc Thesis in Digital Systems, Polytechnic of Central London. Elizabeth A. H. Hull is a research fellow of the Nuffield Department
of Anaesthetics. She graduated from Queen Mary College, University of London, in chemistry, in 1974, and was awarded a PhD in 1977. She was elected to membership of the Royal Society of Chemistry in 1982, having completed a Research Programme in Electrochemistry in France and Germany.