Interfacing a Cary 210 spectrophotometer to a Commodore PET 2001 microcomputer

The use of microcomputers for instrument control and data acquisition has become an important aspect of the chemical laboratory. The availability of inexpensive microcomputers, the ease of interfacing with existing chemical instrumentation, and the availability of such high-level languages as BASIC, all make such applications attractive and feasible to implement. A considerable amount of well-built instrumentation without microprocessor control exists and will be with us for some time. Interfacing brings this instrumentation into the current age at a cost far below that of purchasing a new instrument.


Introduction
The use of microcomputers for instrument control and data acquisition has become an important aspect of the chemical laboratory. The availability of inexpensive microcomputers, the ease of interfacing with existing chemical instrumentation, and the availability of such high-level languages as BASIC, all make such applications attractive and feasible to implement. A considerable amount of well-built instrumentation without microprocessor control exists and will be with us for some time. Interfacing brings this instrumentation into the current age at a cost far below that of purchasing a new instrument.
The authors have been acquiring UV scans by means of a simple microcomputer interface for some time. Benefits include a greater precision than is possible by hand digitizing, more facile data handling of larger data-bases, and, consequently, the acquisition ofa much higher point density in each scan. High point density is an important consideration in such statistical procedures as factor analysis. Once the data is acquired by the microcomputer it can be processed by the same processor or passed along by a modem or RS232 interface to another more powerful computer. This paper reports a method of interfacing a Cary 210 spectrophotometer (Varian Associates, Inc., 611

Method
The MCS-6522 Versatile Interface Adapter is a very powerful interface chip and is well suited for this application. It consists of two eight-bit bidirectional 32 ports, Ports A and Port B, as well as four control lines. One port is used to input data from the Cary and the other to output data to the Cary. Two control lines are used to manage the handshaking commands, as well as two lines of Port B. It also has on board a 16-bit timer which counts TTL pulses incoming on line 6 of Port B, as well as an interrupt flag register. Other features of this chip are not used in this application.
The 6522 is mounted on a single Vector 3677-2 circuit board (Vector Electronic Company, 12460 Gladstone Avenue, Sylmar, California 91342, USA), and is powered by an auxiliary + 5 V power supply. Also mounted on the circuit board is a DM-7404 hex inverter (National Semiconductor Corporation, 2900 Semiconductor Drive, Santa Clara, California 95051, USA).
The connections between the PET and the 6522 are simple and straightforward (figure 1). The data bus'is connected directly, as well as the reset, clock and read/write. IRQ is not connected in this application. The PET contains a 16-bit address bus. To operate the interface chip only five of the address lines are utilized. Turning on the chip is accomplished by utilizing only SEL6 of the PET. SEL6 selects the 4K byte page of memory with a base address of 24576. In our PET, an early 8K model which is equipped with a 16K expansion board (Skyles Electric Works, 231 E. South Whisman Road, Mountain View, California 94041, USA), nothing is located in this page except this interface chip. SEL6 is connected directly to CS2 and through the inverter to CS1. When a location in the 4K page is addressed CS1 is driven high and CS2 driven low, simultaneously activating the chip.  To conduct a scan, the Cary is first manually base-lined.
Then it is set to the initial wavelength. The initial wavelength, as well as the interval between readings and number of readings, are programmed into the PET. The PET issues the commands to the Cary to scan down, stop and take absorbance readings at the wavelengths desired. When the end of the scan is reached, the scan direction is reversed and the Cary reset to the initial wavelength.
Data is presented on the screen, on the printer and optionally stored on disk with user-developed routines written in BASIC.
Two aspects of the system control deserve special discussion: first, the issuing of commands by the PET to control the scanning of the Cary from one wavelength to the next; and, second, the transfer of absorbance information from the Cary to the PET. First, to scan across any given wavelength region, the following occurs: the number of pulses to be counted for the scan is calculated, divided into two eight-bit bytes and 'poked' into the two registers of Timer 2. The timer is then programmed to count incoming pulses and to set a flag in the interrupt flag register (IFR) on the 6522 when the required number of pulses has been counted. The PET polls this IFR to watch for the setting of the appropriate flag, which indicates that the predetermined number of pulses has been counted. Lines 2-5 and 7 of Port B are programmed by the Port B data direction register as output. Command control data is output on these five lines of the Port B.
A command is issued to the Cary by the following series of events" I/O is held low, CNTL is driven high, and the data placed on PB2-5, 7 of the 6522. After a 20 ms delay, CNTL is driven low initiating the data transfer to the Cary. When the CARY accepts the control data, it responds by driving CNTL high again and the process is complete. The input and output timing diagrams are schematically shown in the Digital Interface Port Operator's Manual [2]. Initial operating conditions of the Cary are issued in BASIC. However, the scan down command, and the polling for the flag set in the IFR when the predetermined number of pulses are counted, are both done in an assembly language subroutine in order that no pulses are missed and the scan interval is accurately accomplished.
The second aspect of system control to be discussed is acquiring an absorbance reading. When the Cary is stopped, the PET inputs the absorbance data from the Cary. The data consists of 18 four-bit nybbles of BCD information, which are output by the Cary in less than 54 ms, a timing constraint imposed by the Cary. Because of this constraint this subroutine is also written in assembly language. The subroutine stores these 18 nybbles for later conversion in BASIC to decimal values.
To accomplish a data transfer from the Cary, Port A is programmed as an input and Port B as an output. I/O and CNTL are held high for a minimum of 20 ms, whereupon CNTL is driven low. The Cary responds by driving FLAG low, indicating data is valid, and the PET latches the data and drives CNTL high. The Cary indicates data is no longer valid by driving FLAG high. This process is repeated 18 times to complete a data transfer.

Results
To demonstrate the use of this interface the vapor, phase spectra of benzene was taken. The Cary was base-lined using two matched cm quartz cells and two drops of reagent grade benzene were put in the bottom of the sample cell. After a sufficient period of time to allow for the benzene vapor to equilibrate, the scan was conducted with a 0 to absorbance range and a bandwidth of 0.25 nm. A total of 601 data points were taken over the wavelength range of 280-220 nm and output to a floppy disk. The absorbance-wavelength data pairs were read by a second program and output to a Data General Eclipse S/130 minicomputer. The data file was converted into a program file in the word-processor and the data was submitted by remote job entry to the University ofRhode Island mainframe computer, a National Advanced Systems 7000 for graphic display (figure 2), by means of SAS Graphics Routines (SAS Institute, Inc. [3]). Typically, graphs are available .15 min after the scan is conducted.
Documented versions of the machine code are available from the authors, as well as copies ofthe BASIC programs which include this machine code.