A portable battery-powered flow injection monitor for the in situ analysis of nitrate in natural waters

The design and performance of a portable, automated flow injection (FI)-based photometric monitor are described. The system is controlled by an in-house microcomputer system that enables the monitor (including a solid state detector) to operate from a 12 V battery supply. The monitor uses the cadmium reduction/diazotization method to analyse for nitrate with a linear range of 0 to 12 mg l-1 and a limit of detection of 0.05 mg l-1 (NO3-N). The hardware and software design, monitor performance and results obtained during unattended operation are presented.


Introduction
Physical water quality parameters, such as pH, temperature, flow rate and conductivity, can be routinely determined in situ using the appropriate sensor and a data logging device. A limited number of chemical parameters (for example ammonia and nitrate) can also be measured, using ion selective electrodes, but such devices can often suffer from electrode fouling and require frequent recalibration to maintain accuracy.
The conventional method of measuring chemical parameters, however, involves batch sampling in the field with subsequent laboratory analysis. Potentially, this procedure can introduce errors into the process due to contamination and degradation of the sample between taking the sample and analysis [1] and becomes very time consuming and labour intensive, particularly when large numbers of samples are involved.
'Fhere is a growing need to conduct on-line chemical analyses in the field to provide a pseudo-continuous profile of water quality parameters. This is particularly important for those species (for example, nitrate) which are covered by EC legislation [2], because the conventional (manual) monitoring scheme may not detect short-term changes (for instance storm events, or point discharges) between sampling events.
Flow injection (FI) is ideally suited to automating standard laboratory methods and has been successfully applied to process control [3] and environmental monitoring [4, 5-]. In the latter context field monitors have been developed for such parameters as nitrate [6], phosphate [7], ammonia [8] and aluminium [9] using solid state photometric detection ]-10]. These designs were based on commercial mains-powered microcomputer systems, and are thus unsuitable for use in a portable (i.e. batterypowered) monitor.
Recent developments in microchip technology have led to the production of specialized microcontroller devices for control and automation applications. Such devices have many of the necessary I/O functions built onto the chip and consequently many of the peripheral devices associated with microcomputer-based systems are no longer required, allowing miniaturization of system hardware. The advantages of microcontroller-based systems are particularly clear for battery-powered equipment which can be constructed from a relatively small number of low power CMOS components. Thus, microcontroller-based systems have been used in applications such as data logging [11-], laboratory automation ]-12] and in situ monitoring [13]. This paper describes the construction of a batterypowered automated FI monitor, comprising an in-house designed microcomputer and solid state detection system. The microchip used is a member of the industry standard Intel 8051 series of microcontrollers which are widely employed in industrial control applications, such as anti-skid braking systems and engine management systems. The computer system described has been designed to automate all of the functions required for field-based operation, i.e. control of peristaltic pumps, injection valve and switching valve and data acquisition, processing and logging. An FI manifold for nitrate has been installed in the monitor and data are reported from laboratory stability trials and nitrate fluctuations in tapwater.

Reagents
All solutions were prepared using Milli-Q water (Millipore  [6].
colour reagent was prepared by mixing equal volumes of the N1NED and sulphanilamide reagents. The reagents were stored in plastic-ware containers, except the mixed colour reagent which was stored in a brown glass bottle.
Cadmium reductor columns were prepared by adding 5 g of cadmium power (100 mesh) to .50 ml of a copper (II) sulphate solution (0"2.5 g) and stirring for 2 minutes. The resulting copperized cadmium was washed with 2 M hydrochloric acid (2 x .50 ml) and ammonium chloride solution (10 g l-a). The slurry was then packed into glass tubes (.50 mm x 3 mm i.d.) and plugged with glass wool. The columns were connected to the PTFE tubing by 20 mm lengths of orange/orange pump tubing (Anachem).
A concentrated diazo dye solution was prepared by mixing 5 ml of a 50 mg 1-1 NO2_N solution (itself prepared by serial dilution of the 1000 mg 1-1 stock solution) and 20 ml each of the mixed colour reagent and ammonium chloride solutions. The absorbance standards used [br the calibration of the solid state detector were prepared by serial dilution of this intensely coloured solution. Absorbance data for this comparison were measured at 565 nm using an LKB Ultrospec II UV/visible spectrophotometer fitted with an 18 btl glass flow cell with a 10 mm path length (Hellma).
Chemical melhod and FI manijbld The analytical procedure used for the chemical determination of nitrate is an adaptation of a standard water industry method [ 14]. I involves the reduction of nitrate to nitrite by a copperized cadmium mini-column followed by derivatization with sulphanilamide and coupling with N-(1-naphthyl)ethylenediamine dihydrochloride. The diazo product can be detected spectrophotometrically (s542 4-6 x 104 dm 3 molcm-1).
The manilbld design (see figure 1) is based on that reported previously [-6] and is constructed from 0"8 mm i.d. PTFE tubing (Anachem) and in-house PTFE Tpieces.

Compuler syslem
The hardware and software were developed and debugged on a platlbrm based around the 8-bit Intel 8052AH BASIC microcontroller [15]. Some  (3) Auto boot facility.
The system has been designed with 32 k of battery backed RAM and 24k EPROM space. The EPROM allows permanent storage of BASIC control and utility software and in addition, can store the baud rate, an auto boot flag and moveable system pointer (MTOP). The boundary between the program/system and data sections of RAM is controlled by MTOP which allows a very flexible (software configurable) memory map. On initialization (power-up) the processor clears all memory locations up to the MTOP leaving locations above this suitable for storing logged data. Generally, once programs are running from EPROM, less than 4k of RAM is required for the stack and variable storage. The system can therefore be configured with between 0 and 28 k non-volatile data storage space. For this application the MTOP is set at 16384 (16 k).
Integrated into the CPU board design is a real time clock which is battery backed against external power failure and provides the system with access to the time, date, day of week, month and year. In addition, the clock has 50 bytes of RAM which are used by the control software to store the system configuration. The memory map of the computer system is illustrated in figure 2.  The second port (B) of the PIA supplies TTL triggers to the injection valve (to toggle between fill and inject positions), the 14 bit AD converter and the analogue switch. The final port (C) supplies the input to the 8 bit DA converter.
In addition to the detector output, the eight channel analogue switch enables the AD converter to monitor a series of sensors. These enable the computer to monitor the reagent levels and battery capacity and close the system down if either fall too low. A schematic representation of the I/O board is given in figure 3. External communication is achieved by a three line RS232 connection to a PC. This can be either locally by direct connection or remotely using a pair of modems and a cellular phone link. The microcontroller communicates using an 8 bit data word, stop bit and no parity and is capable of all commonly used baud rates up to 19 200. The serial link operates without hardware handshaking, so a baud rate of 9600 was selected as the most convenient rate without data loss.
An IJCD screen (two lines of 20 characters) is connected to the system and displays simple messages describing the monitor status.
Once the system had been fhlly tested and the control software debugged and programmed into EPROM, the 8052 AH BASIC chip was replaced with a CMOS 80C32 microcontroller and the MCS BASIC vl.1 interpreter programmed into an external 8 k EPROM. Functionally, this configuration is identical to the initial set-up but the power consumption is reduced from about 400 to 40 mA.
Solid state detector Solid state photometric detectors incorporate light emitting diodes (LEDs) as the light source and either photodiodes or phototransistors as the light detecting component. They offer several advantages over conventional spectrophotometers, most notably they are considerably smaller and consume less power.
The detector developed is a single channel device (consisting of a single LED and photodiode) which allows the power consumption to be reduced even further in comparison to a dual beam system. The photodiode (Radio Spares 308-067) has a spectral range of 200 to 1100 nm and includes an integral logarithmic amplifier. The voltage output of the device is linearly related to a function of the absorbance of the solution. A variety of LEDs are commercially available covering the majority of the visible and near infrared (NIR) regions of the spectrum (400-1100 nm) [10]. The most commonly encountered types include NIR (2ma 950rim), red (/max 635 nm), yellow (/max 583 nm), green (/max 565 nm) and blue (/]'max 470 rim) devices, which enable a range of analytes to be measured by choosing the appropriate LED [16]. The green LED used in this study is a 5 mm high intensity (200 mcd) type with an output wavelength close enough to the analyte absorption band ('max 562 rim) to allow detection without a significant loss in sensitivity.
The output from the photodiode is amplified by a precision operational amplifier (IC2), processed and passed through the analogue switch into the 14 bit AD converter. The AD converter includes an internal 3V reference giving the device a resolution of 0"2 inV. The The detector includes an automatic baseline correction thcility that enables the computer to adjust the detector baseline to within a software defined window at the beginning of each injection cycle. This is particularly important for a single channel design, which, unlike a dual channel detector, does not include internal compensation tbr instrumental drift during periods of inactivity.

Flow cell
The flow cell is of in-house design and construction and is a single channel derivative of that described previously [7]. The flow cell block, machined from aluminium (20 mm cube) consists of a length of PTFE tubing (2 mm i.d.) running orthogonal to the light path, which is held in position by 10 mm lengths of silicon tubing either side of the block. The detector is extremely sensitive to external light, so black heatshrink tubing is used to shield 10 cm lengths of the PTFE tubing on either side of the flow cell block. The flow cell block is securely mounted inside an aluminium box.

Power supply
The monitor is powered by 6 x 2 V (25 Ah) Cyclon cells (Radio Spares 591-629) connected in series. The batteries are sealed lead acid cells and were selected as they offered the best compromise between robustness and their storage capacity/size ratio.

Control software
The monitor is controlled by a BASIC program written in-house using the embedded Intel MCS BASIC interpreter (vl.1). The software is stored in EPROM and is configured to execute automatically on power-up. The monitor operation is configured by a series of system variables which define the injection cycle, for example, .e fill and delay times, the self-diagnostic routines and e data logging pointer. These data are stored in battery cked RAM and assigned to the relevant system triables on execution of the centrM control software. This :tends the flexibility of the system by allowing the system be reconfigured (for instance to alter delay times, AD tegrations), without needing to reprogram an EPROM. esults and discussion fonitor operation addition to the standard laboratory requirements of :curacy and precision, long-term stability and some form "automatic recalibration are desirable features for ld-based instrumentation. The monitor described here flects these needs and is configured so that each aalytical result is validated by the software and cali-"ated against an on-board standard. A schematic .presentation of the monitor design, is shown in figure 5.
he analytical cycle involves duplicate injections of both le sample and on-board standard. Each set of duplicate jections is validated before the concentration of the .mple is calculated by a single point calibration. This tlibration method reduces the hardware and software )mplexity and power and reagent consumption in )mparison with a multipoint calibration. For an accurate :sult, however, the calibration must be linear over the tire concentration range and the intercept must pass trough (or close to) the origin, it is therefore important tat the blank signal is zero (or very close to zero), :herwise the divergence between the observed and cedicted calibration slopes will introduce an increasingly rge error into the calculated value for the unknown as te actual concentrations of the sample and standard ove apart. A flow diagram of the analytical cycle is town in figure 6.
'ata acquisition and processing he detector output is sampled at the maximum (software :stricted) rate of 15 Hz. The signal is averaged over a )ftware defined number of integrations, which ensures at the best compromise between reducing the noise of e detected signal and the rate of the reading required )adequately cover the FI peak is achieved. After each  Figure 6. Flow diagram of the control software.
integrated value has been calculated it is stored as a segment in a 250 element array. Typically, for a 60 injection window, each of the stored values represents the average of six conversions.
After data acquisition is complete the array containing the FI peak is digitally filtered using a moving median algorithm. Statistically, this filter is robust and nonparametric and is ideal for removing impulse noise from digital signals [17]. It is used widely in image processing [ 18-] and has also been proposed as a method for correcting baseline drift in liquid chromatography [19]. The filter design preferentially removes sharper peaks and passes broader features; its discrimination between sharp and broad features is controlled by the filter window width, with peaks that span less than half of the window effectively removed from the output array. A seven segment window was found to be the optimum value for  Figure 7. Screen dump illustrating the effect of the data processing software on the detector signal.
suppressing impulse noise caused by air bubbles in the FI stream. Larger filter ranks were tbund to degrade the sharper features of the FI peak and increase the processing time without any significant increase in the effectiveness of the filter operation.
Implementation of the algorithm involved sampling a moving window within the main data array. The data within the window are sorted into increasing numerical order and the median (middle) value identified. The central element is then,reset to the median value and the window position incremented by one.
The second Stage of data processing involves digitally smoothing the updated data array using a least squares polynomial regression with a five point window [20-]. This non-recursive filter, originally developed by Savitzky and Golay [21], was found to be more suitable than a moving average design, which tended to degrade the resolution of smaller signals. Like the filtering routine this algorithm involves the recalculation of the central value within a moving window. The formulae and coefficients used in the algorithm are given below: where R is the central element of the moving window and R' is the updated element.
The effectiveness of the data processing algorithms is illustrated in figure 7 which shows the detector response for an FI peak which has had air bubbles deliberately introduced into the carrier stream. Figure 7 isa screen dump taken from a program written in-house that displays a real time graphical,representation of the detector output via a serial communications link. The lower window in 164 figure 7 also shows the peak heights of the previous injections in the analytical cycle. After filtering and smoothing the array the peak maximum is identified and the. peak height calculated by subtracting the baseline (calculated as the average of the first 10 elements of the array) from the peak maximum. After each series of injections the mean and RSD for the replicates are calculated.

Data validation and self diagnostics
The validation of each pair of injections is controlled on-line by a series of simple statistical and logical tests using the system configuration variables. The routines compare the precision of the replicate injections with a minimum acceptable precision and the calculated mean peak heights with a maximum and minimum expected signal. The score given to each test is unique to that test and reflects its relative importance. Thus, poor precision is considered to be more important than either a higher or lower than expected signal. The total for all tests is assigned to an error code variable which is used to selectively trigger repeat injections by setting the re-inject flag at the appropriate value. The time (hour and minutes), date, means of the sample and standard duplicates, calculated concentration, overall RSD and the combined error code variable are stored in the battery-backed memory at the end of each analysis. When the monitor is idle and awaiting the next analysis, the current time, time of the next analysis and the concentration of the last measured sample are displayed on the LCD screen.

Detector and manifold calibration
The performance of the solid state detector was determined by connecting a UV/visible spectrophotometer in series and running a set of absorbance standard solutions through the combined system as described above. The responses for the spectrophotometer and the solid state detector (table 1) are illustrated in figure 8. Figure 8 shows that the solid state detector (SSD) has a good correlation with the commercial spectrophotometer with a sensitivity described by the equation: SSD Response (counts) 1463, Absorbance + 9 where absorbance is the reading from the commercial spectrophotometer.
The manifold was calibrated with a series of nitrate standards covering the range 0 to 12 mg 1-1 NO3. N using the optimized conditions reported previously [6].

Power consumption
During normal operation the computer board consumes about 40 mA, which is reduced to about 20 mA during periods of monitor inactivity by placing the processor into an interrupt driven idle mode. The basic components of the FI system have the largest power consumption while the monitor is active. These data are summarized in table 3.

Monitor trials
The stability of the monitor and the chemistry were investigated by ratioing duplicate injections of an 8 mg 1-1 sample and a 5 mg1-1 standard (NO3-N) every 50 minutes (figure 9). The statistical data from this trial are summarized in table 4. The overall performance characteristics and reagent consumption over this seven-day trial are given in  Figure 9. Repeatability of nitrate determination over a seven-day period.
Nitrate levels in Plymouth tapwater were measured over the period from 17 April 1993 to 21 April 1993. An unfiltered sample was fed into the system via a constant head device (200 ml capacity)and analysed every 50 minutes. No significant fluctuations above the underlying variability were observed over this period (see figure 10).

Conclusions
The feasibility of using an FI approach for measuring water quality parameters in situ has been demonstrated. The FI monitor and solid state detector described perform well and are capable of measuring nitrate levels over the range commonly encountered in freshwaters. The power supply and reagent consumption allow the monitor to operate unattended, for one week. Over this period the monitor provided accurate and precise results at 50 minute intervals. The flexibility of the hardware and software design in combination with the versatility of the FI technique enable the monitor to operate in a variety of monitoring situations such as nutrient budget studies, supply intake protection and industrial process control.