A potentiometric analyser based on the ZX81 microcomputer

Automation can remove much of the tedium and labour from titration, and the availability of personal computers permits efficient control and the opportunity for fast data-processing at a low cost. In addition, the versatility of the computer allows almost any type of potentiometric determination, including Gran’s plot. This paper describes a titration unit controlled by a ZX81 microcomputer through a parallel bus interface system, which can also be used for calibrating electrodes with respect to ion concentration; this is illustrated for a precipitation titration of silver nitrate with bromide using a silver wire indicator electrode and glass reference electrode (Corning Model No. 33 1070 030).


Introduction
Automation can remove much of the tedium and labour from titration, and the availability of personal computers permits efficient control and the opportunity for fast data-processing at a low cost. In addition, the versatility of the computer allows almost any type of potentiometric determination, including Gran's plot. This paper describes a titration unit controlled by a ZX81 microcomputer through a parallel bus interface system, which can also be used for calibrating electrodes with respect to ion concentration; this is illustrated for a precipitation titration of silver nitrate with bromide using a silver wire indicator electrode and glass reference electrode (Corning Model No. 33 1070 030).

Instrumentation
The instrumentation layout is shown in figure 1. The titrator employs a Mettler DV11 digital burette, which is driven by a stepper motor, and which, when fitted with a 10cm cylinder assembly (Mettler DV210), can deliver titrant in mm (#1)

Auto-titrator system
The Sinclair ZX81 microcomputer, with television, cassetterecorder and ZX printer, provides the necessary control and processing facilities. Besides being easily obtainable it has the advantages of a powerful Z80 microprocessor, a corrosionresistant membrane keyboard, and full access to all system lines at the rear-edge connector. It is programmed in BASIC and machine code. Various potentiometric electrode systems have been used, and their potentials monitored by an Intersil-Datel 42X-digit millivoltmeter (Type 4101L) fitted with a differential highimpedance input buffer.
A Bryans (J-J Instruments type PL3) X-Y recorder is used to make high-resolution plots of titration and derivative curves.
With the standard program (obtainable from the authors) three plots (titration curve, second derivative, and calibration curve for direct potentiometry) are drawn on to A3 paper.   These units are connected via the interface system (figure l)---the interface is a parallel bus-oriented system and comparable to the IEEE 488 bus [1]. However, the complexity ofthe full IEEE standard was considered inappropriate, since this system was conceived as a highly cost-effective addition to the existing data/address bus structure of a Z80-based microcomputer. The design and development of the interface is discussed below.

The ZXS1 interface system
The design used was a memory-mapped interface: it is accessed by the CPU in the same way as any normal memory location. The chief advantage of this method is that the circuitry can be operated from BASIC via simple PEEK and POKE commands (PEEK and POKE being BASIC commands to examine or alter, respectively, the contents of specified memory locations). It operates by redefining 16 memory-locations from 15552 to 15567 as interface addresses. The block diagram (figure 2) clarifies this. The circuit diagram is given in figure 3. When the correct combination appears on the address lines (i.e. A 4,5,8,9,14,15 LOW;A 6,7,10,11,12,13 HIGH) the decoder (ICI, IC2) activates the 'SELECT' lines (figure 3). These then operate the routing circuit (IC3) and divert the RD and WR signals away from the memory and into the interface. (Note [a] the bars in RD and WR indicate that these lines go LOW when active, a common feature of control lines, and [hi RD and WR signals always appear shortly after the address is established.) This will occur regardless of the state of the lowest four address lines A0-A3, i.e. for 24 or 16 addresses.  addresses from 15552 to 15567 are used. These addresses have been shared between four distinct circuit functions, as follows" 15552-15555: analogue-to-digital converter (ADC) 15556-15559: digital-to-analogue converter (DAC1) 15560-15563: digital-to-analogue converter (DAC2) 15564-15567: digitally controlled switch (SW).
These are selected by decoding A2 and A3 into four lines (IC5, figure 3). This leaves A0 and A1 to control the circuit blocks.
Tri-state logic and buffering So that data lines may be shared by all sections of a computer, 'tri-state' logic is used. Here, any part of the circuit which can send a signal to the bus has three possible outputs: low, high, and high-impedance (isolated). Only one device is enabled at a time, thereby avoiding the possibility of two outputs conflicting. Devices are generally enabled under CPU control, via the address and RD or WR lines etc. In this design, a bidirectional tri-state buffer (IC4, figure 3) is used to isolate the external circuitry from the ZX81. Since the rest of the interface design consists either of inputs driven by the ZX81 or of tri-state outputs this may seem unnecessary; but since in practice there is a limit to the number of device inputs (and, due to capacitance effects, the length of wire) a Z80 CPU can drive [2], this buffer was found essential. (Most microcomputer systems are fully buffered as standard; the ZX81, for reasons of cost, is not.) The buffer normally isolates in both directions; when the millivoltmeter circuit is addressed it is switched to receive data (by IC5) and when any other part is addressed, it sends data. The remaining circuit blocks are now described in order of complexity.  Reset D-A converters to zero 6 7 addressed, i.e. when WR and SW go low. Data is then passed to IC7, a 4-to-16-1ine decoder. Addressing the circuit from BASIC by the instruction POKE 15567, n (n 0-15), causes output n of IC7 to go low, the others remaining high. The seven functions required in this application, together with values for n and output pin numbers for IC7, are given in table 1. The Mettler burette uses 18 V switching levels, which are driven from 5 V logic by the level-shifting circuits shown on IC7 pins 2, 3 and 4. Pin numbers for the Mettler multi-way connector are also shown. IC8(b) is added to invert IC7 pin 5 output since the chartrecorder pen is lowered by a high logic level.

Digital-to-analogue converters
The two digital-to-analogue converters (DACs) are identical and share a common voltage reference and power-supply. They are based on the Radiospares Components 12-bit converter, type 7542 ( figure 5).
This device is quite easy to use, but because of the eight-bit limitation of the data bus, it must be loaded with data in three sets of four bits each [3]. A fourth operation then combines the bits and generates the analogue output.
Thus, when the first DAC address is selected (DAC1 low, A0, A1 low) the first converter will expect the four least significant bits to be present on the data bus when the WR (Write) line goes low; when the second address is selected (A0 high, rest as before) the device will expect the middle four bits; similarly for the third address and the four most significant bits.
When the fourth address (A0, A1 high) is selected, the data lines are ignored and the data previously collected is transferred to the 12-bit output register of IC9, from which the appropriate analogue voltage is derived.
The CLEAR input (figure 5) can be used to reset the 12-bit register to zero, and is operated by the SW function described earlier. In the circuit offigure 5, the output voltage ranges from 0 to (-4095/4096)xVref, so the reference voltage must be negative for a positive output range. The negative supply for the reference and output amplifiers is taken from the analogue-todigital converter (see below) which has an on-board supply inverter.
Analogue-to-digital converter (ADC) The connection of the Intersil-Datel 4Xz-digit millivoltmeter to the ZX81 data bus involves dual use of data lines and machinecode programming. This meter gives access to its digital outputs via four data lines and five digit 'strobes' (figure 6).
The display is internally multiplexed [4], i.e. the digits are illuminated sequentially (the most significant first) but with such a high repetition rate (500 Hz) that they appear continuously lit.
Thus, at any time, the data lines carry a binary coded numbe?
representing just one of the digits, the digit strobe lines indicating which. The computer is required to wait for the first digit line to go high, then read the data lines, store the number, and go back to wait for the next digit, in less than 0.4 ms. This must be done with a short piece of machine code rather than BASIC. The data lines are used alternately for examining the digit and data outputs, which are accessed as required through the tristate buffers IC 11, 12 (figure 6). The required buffer is selected by ADC, A0 and A1 as shown. The program address of each buffer is chosen so that when selected, its address line will go low, while the address line of the other buffer remains high. The polarity signal from the meter, which goes low when negative, is inverted and fed in with the data lines.

ADC input machine-code subroutine
The Z80 code subroutine I-5] reads the five digits in turn, placing them in five reserved memory locations from 16514 to 16518. The most significant digit is 0 or when positive, 16 or 17 when negative. The BASIC program combines the digits, multiplying them by the appropriate power of 10 to recreate.the original meter reading. When a number higher than 16000 is registered, the program subtracts 16000 and makes the result negative. S. W. Bateson et al. A potentiometric analyser based on the ZX81 pendent on the solubility product for an insoluble product or the formation constant for a complex.
(2) Knowing the stoichiometry of the reaction, the titrand concentration can be found at all stages of the titration (figure 9).
For instance, at Va (figure 9), the amount oftitrand in solution equals (Vep-Va) times the titrant concentration; so the titrand concentration can be found by allowing for solvent volume, dilution by titrant, solubility product, and stoichiometry.
Knowing the titrand concentration at each point, plotting log (conc) versus electrode EMF will result in a conventional calibration curve. This is illustrated in figure 10 for a silver ion calibration of a silver wire electrode used in conjunction with a glass electrode as reference. This is generally applicable to various potentiometric indicating electrodes, including ionselective electrodes, and is far less tedious that the conventional static procedure based on serially diluted standard solutions.

Program and illustrative results
The titration program is constructed in sections, based on subroutines for operating the interface system. The structure is shown in the block diagram (figure 7).
On running the program, the user chooses from a 'menu' of available options.

Titration options
The first main option is the titration, which then prodeeds without further attention. It calls on the burette control and ADC input subroutines. Various titration parameters are set up in advance but can be changed by the user. When titrating, the system adds a quantity of titrant, waits a pre-set time then starts taking EMF readings. When these are stable within a pre-set limit, the EMF, together with titrant volume and derivative values, is stored in an array.
As the endpoint approaches, the addition volume is reduced in response to the increasing slope of the titration curve. The volume of each aliquot is decided as follows: New VOL-previus VOL x target emf change previous emf change When the titration is complete, the endpoints are calculated from the second derivative values. The first and second derivatives are 'averages' over several titration points to reduce the effect of random errors. Maximum and minimum values are recorded for automatic scaling ofgraphs. The main menu is then re-presented.

Results options
The second menu option is a display and print-out of titration results, while titration curve plotting is the third option. Typical results for a precipitation titration of silver nitrate with potassium bromide are shown in figure 8.
Besides titration and derivative curves, electrode calibration curves may be drawn, based on the following principles: (1) At the endpoint of a titration, there is a known small concentration of detectable species in solution, de- Log [Ag + Figure 10. Calibration of silver wire with respect to silver ion concentration from titration curve of figure 8. -2

Conclusions
The ZX81 is a versatile and economically priced microcomputer which can be conveniently interfaced to a high-precision potentiometric titration assembly. This can be programmed for a variety of options including the facility of setting up electrode calibrations for direct potentiometry.
members will be 40.00 (70"00 for non-members), whilst the daily fee will be 15.00 (30"00 for nonmembers). The fee for accompanying persons will be 10.00. A concessionary fee of 8.00 will also be available for students, schoolteachers, retired members, and unemployed members, and there will be a fee of 50.00 for those attending only the workshop. The charge for accommodation for the three-day period of the Congress (dinner, bed and breakfast) will be about 50.00.
Further information, includin9 applicationforms, should be available early in 1984from Dr John F. Gibson, The Royal Society of Chemistry, Burlington House, London W1 V OBN.