Instant Interfacing Raymond E. Dessy and Jonathan Titus Virginia Polytechnic Institute and State
University Blacksburg, Va. 24061 Although laboratory automation is becoming more and more of a necessity, the special knowledge and time required to design and fabricate specific interfaces for analytical equipment in the modern laboratory often are too formidable a task for the nonelectronically oriented chemist. The purpose of this article is to acquaint the reader with design considerations involving some of the new mediumand large-scale integrated circuits (IC's),modules, and devices described in the article which will allow him to interface his equipment easily, inexpensively, and without extensive electronic knowledge-almost instant interfacing. It is often best to analyze any interfacing problem in the following terms: imagine an octahedron made up of eight identical faces, each representing a three-dimensional variable in the interfacing problem. These decision domains are to he handled in much the way a chemist develops phase diagrams. Each boundary represents 0-100% contribution by the variable associated with it, and all variables in the domain must be correlated to one another. In each domain, local conditions will indicate that a certain area within the domain will be the most practical solution for that phase of the complex multidimensional probIem. Although each domain is somewhat related to the others, if a careful order of attach is made on each domain in succession. and the nrocess is iterzired until rhi.srn;illcit poisihlc area is d( r i n d ils il rmtcntial iolurion in each domain, theresult will be a 294A
-
'
~~~~
~~
~
, ,
No control over existing equipment
ANALYTICAL CHEMISTRY, VOL. 46, NO. 3, MARCH 1974
,
Data Flow
The long distances (1000ft) between the clusters of control instruments and their distance from the lab containing the spectrometer system preclude parallel digital transmission* from the control equipment to a processor situated near the highspeed unit because of high cable costs. Noisy environmental conditions make analog transmission from the control facilities potentially difficult. Serial digital transmission* appears an attractive alternative.
'
Data Processing Mode Quick report generation is important, as well as correlation with old data base material. Local handling of the data along with other user needs as a "Batch" in a nearby computer is very poor. A computer "dedicated" to the system will solve current needs. However. a hierarchical* svstem is envisaged as the medium-speed devices are added to accommodate their need for calculations, storage, and retrieval of large reference data bases for report generation. The original computer will serve as a host machine.* and intelligent controllers* will assume responsibility for the slower units as their needs are more fully comprehended by studies under~
Data Acquisition Mode
,
1s necessary, and either off-line data logging or real-time open-loop* (items with asterisks are defined in the Glossary) acquisition would suffice. The new instruments will require closedloop* control.
satisfactory one for implementation, Ifa domain remains undefined, it suggests that the problem is not completely understood, and the user, far from being discouraged, should revel in the fact that he a t least knows his difficulty. To demonstrate the concept of multiphasic design and demonstrate the powers of the new electronic components, let us set up a rather common laboratory situation: Alaboratory has two groups of quality control instruments, with three instruments per group (GC, GPC, LC, TGA, DTA) and one rapid scanning spectrometer. Two X-ray diffractometers will be installed in one year. and analyze each domain as follows,. Data Rate/Type The quality control units are lowspeed devices, and sampling rates of 10 points/sec will retrieve all meaningful data. The high-speed rapid scanning spectrometer will need sampling rates of 50,000 pointslsec, but the data are acquired in bursts, separated by a l-msec waiting period, each burst consisting of 512 words of data. The other instruments will require dataflow of 100 points/sec and are considered medium-speed devices. (Groups of instruments of the same type are easy to handle. It is addition of many different types that can cause difficulties.)
.
- *
i
Data Acquisition Mode .... .“..“I_ .. .. .,..
,~.,“~..._I__ ”___“,__l__. I__x__ .___,,_I.”
I
I
,
I
Asseml !
Interface Accomplishad by
Computer Langu
taken during the first year of automation.
sign considerations are related to the last, unmentioned, design phase. Any interfacine task renresents an investment-the expenditure of a given amount of human resources. This energy must be provided in the form of the product of Time expended, Talent available, or Lucre spent (the TTL principle). Casual inspection of the relationships suggest that if any two of the variables are zero, the function is distressingly discontinuous, and that implementation of interfacing under such conditions is to be avoided. Even turnkey systems purchased without user understanding can lead to dissatisfaction when changes are required or original specifications were in error. With these concepts in mind, let us return to the ability of the “new” peripherals or modules to lighten this interfacing task. The first device is a unit which makes telecommunication interfacing extremely easy. The first step in understanding this device is to analyze the method by which most scientists already communicate with the computer-the teletype (TTY).The standard TTY was designed long before digital computers were conceived of; although they therefore have many peculiarities that would not be Dresent if one were designing from scratch, we must not only live with these eccentricities, hut can utilize them to our benefit. Being designed to transmit information along twisted pairs of wires, the ‘ITY is a serially oriented machine. In other words, a code representing each alphanumeric character made up of 8 bits of information is ~~~
Computer Languages Involved The available software capability in both FORTRAN (compiler*) and real time BASIC (interpreter*) is good, hut experience a t the assembler* level is nil. A FORTRAN compiler system will be used to develop file manipulation and report output. Real time BASIC appears to be too slow for input/output; therefore, assembler coding of the I JO programs will be utilized. Interface Functions Accomplished by Hardware capability is not well developed. System operation of the control instruments involves a large number of technicians with rapid turnover, and calibration and standardization procedures change frequently from fixed-set to fixed-set. Read-only-memory*instructions would “firm” up potential system volatility, since power failure or program failure cannot destroy the control instructions. Interface Level The lack of electronic talent suggests that interfacing directly on the computer’s 1/0 bus* is unwise. The lack of capital equipment money to he invested a t one time precludes the purchase of a turnkey system, where the vendor provides all the software and hardware. It is obvious that many of these de-
~~
sent along the wires, one hit after another. Each letter, number, and control character required for human communication is represented by a unique code sequence of 8 bits. This code sequence of binary* ones (marks) and zeros (spaces) is often written in shorthand fashion. utilizing octal* notation, thus:
uuuuui start 1 0 1 0 1 0 1 0 2 (binary) bit 2 5 2 8 (octal) ~
Table I shows the code for decimal numbers in the international code used most widely, the American Standard Code for Information Interchange (ASCII). When we press a key on a TTY, a code bar places 1 and 0 signal levels simultaneously (in parallel) on a series of strips located radially on a circle which is swept by a commutator. The correspondihg bit string is thus sent down a pair of wires serially. This step involves a parallel-to-serial conversion of the code sequence, and the unit is called a transmitter. An interface at the computer, called a receiver, accepts the serial string, converts it into a single word by serial/parallel conversion, and signals the computer that the complete %bit character is ready to he read by the processor. To echo the character back to the TTY, the interface a t the computer also contains a transmitter, which sends a sei rial code along another pair of twisted wires back to the printer mechanism of the TTY. where the code word ac-
ANALYTICAL CHEMIST1?Y, VOL. 46, NO. 3. MARCH 1974
-
295A
tivates electromagnets to position a printer head in the proper position. Communication between a TTY and a CPU requires two pairs of wires and a transmitter/receiver interface at each end to accomplish the series/ parallel conversions required. With only four wires connecting the two units, there is no direct synchronization or common clocking between the two units. For this reason, the method of transmission is referred to as binary asynchronous transmission. It works effectively solely because both the speed of transmission from a transmitter and the rate at which the incoming hit string is sampled a t the receiver are controlled hy two separate clocks set to approximately the same frequency (&l%). The start and stop hits transmitted with each word indicate to the receiver that a new set of bits is coming, or transmission of a hit string is complete. All that we have to do to have instant interfacing is to make all of our slower analytical equipment look like a TTY to the computer's TTY interface. Several years ago this would have been a task for a well set-up electronics shop, but a new integrated circuit called a Universal Asynchronous Receiver-Transmitter (see photo) (UART) emulates a complete TTY interface. It takes a parallel word of data, converts it to a serial bit string, adds start and stop hits, and sends it down a twisted pair like a transmitter. The unit will also accept a serial bit string, strip out the start and stop hits, and provide a parallel data word, thus functioning as a receiver. It contains flag or signal lines that indicate when it is ready to transmit a new word or has received a word. These flag conditions are referred to as INPUT BUFFER FULL or OUTPUT BUFFER EMPTY. These signals can be used by simple peripheral circuitry to synchronize data flow to and from the unit. Both the input and output buffers (or storage register) are double-meaning that there are two buffers in parallel, and that if two words are sent, or two are received in rapid succession, the first word is not lost by being written over by the second. Most TTY interfaces are now double buffered. It is obvious that if we have 8 or 16 hits of data that need to be sent to a computer, i t is a simple matter to do so using a UART integrated circuit. In many cases, i t is desirahle for the CPU to activate data acquisition a t a unit based on a scheduling algorithm. This is easily accomplished by having the CPU issue a unique code word to the T T Y transmitter unit; this is received and decoded by the UART unit and associated decoder circuitry, and if the word sent matches the preset code word a t the receiver. the 296A
* ANALYTICAL CHEMISTRY. VOL.
UART begins to transmit the digital information back to the CPU (Figure 1). Most chemists live in an analog domain, where voltages are continuously variable and are not available in digital form. This problem can be solved easily by employing as a front end to a UART, an inexpensive digital panel meter containing its own analog/digital convertor (ADC). These units are available for around $100 and provide not only a decimal display of the data for easy viewing, but also have four digital signal lines providing binary coded decimal infor mation (BCD) for each digit. As the code chart indicates, 4 hits of information are needed to encode the decimal number 0-9. Although the code is inefficient in terms of data transmission, since 6 of the possible code combinations are not used, it is human oriented, and easily available in prewired modules. Such units having a four-digit display (resolution of l/lO,OOO) could easily he attached to the UART assembly and send 16 hits of BCD encoded data to the CPU. Software is readily available to convert this BCD to straight binary for manipulation by the processor. New autoranging panel meters make it even unnecessary to use operational amplifiers to condition instrument output signals to meet the voltage input needs of the meter's ADC (see photo). The serial signals from the UART can he sent along the twisted pair either as current (20 mA) or voltage (A6 V). In classic telegraphy no current flow meant a 0, and current flow, a 1. This constant current loop is immune to all sorts of changing line re-
46, NO. 3, MARCH 1974
sistances (within the limits of the power supply) and is also insensitive to transient voltage spikes induced on the signal lines, both important factors in today's data transmission. Most TTY's and their interfaces operate a t transmission speeds of 110 bits/sec. It would be desirahle to speed this up for data communication. If the mechanical limitations of the TTY are removed from the picture, 20-mA current loops may easily operate a t speeds of 2400-4800 hits/ sec over distances of several thousand feet without difficulty, and UART IC's may operate at speeds up to 20,000 bits/sec. Although many vendors will not support such operation with their standard TTY interfaces on the slight chance that peculiar local conditions might interfere, many chemists have rewired their standard TTY interface hoard to do just this with no difficulties. The wiring changes necessary are even specified in most vendors' instruction manuals and are easy to accomplish. All that usually is involved is there-
Figure 1. Modes of instant interfacing
moval of one or two components and rewiring two to four jumper wires. These two modules, the UART and digital voltmeter, obviously solve the interfacing problem posed by the control equipment in our model problem. As the medium speed devices come on line, modifications of this solution may he necessary for reasons that will be discussed later. One possibility is to modify the above circuitry so that data can he continuously collected at each instrument and stored temporarily in a small memory hank. When the CPU is free to accept a new record from the instrument, i t can query it and cause a dump of the memory. Since it is desirable that the first word in is the first out, the memory is called a FIFO memory. These are now available in IC packages (e&, 64 x 8-hit words) with almost all interfacing control signals built in. Addition to the circuitry suggested is simple (Figure 1). With this concept in mind, let us return to the problem posed by the high-speed spectrometer. In such applications, high-speed data are produced in bursts, and designing an on-line computer to meet these needs is inefficient and costly. A number of extremely high-speed and moderate-speed ADC’s are currently available, which have their 298A
own particular type of FIFO memory. The concept is to digitize the data at the rate required by the experiment [rates from 100 MHz to 0.1 Hz (sic) are available] and store the data file in a very fast memory. When the recording period (25 psec to 20,000 sec) is finished, the memory can be dumped into CPU core memory. These devices, therefore, resemble the familiar storage oscilloscope, hut instead of a trace-that can be photographed, they provide a file of digital information that can be read hy the computer after the event is completed. For this reason, they are called transient recorders. There is no reason why the available digital data could not he transmitted in an asynchronous manner to the computer by means of the UART techniques, as was done with the digital voltmeter data. In this way, experiments operating in a real time of 200psec could generate 256 data words to be transmitted to a computer at a later time in a period of 1sec. An interesting alternative to building auxiliary FIFO memories to convertors is logging the digital information either on to paper tape or on to magnetic tape if slow to medium speeds are involved. Since many off-line logging users would like a hard-copy output for rec-
ANALYTICAL CHEMISTRY, VOL. 46,
NO. 3, MARCH 1974
ord keeping, conversion of the BCD or straight binary code to ASCII is often necessary (Table I). This allows the commonly available TTY to both punch an ASCII paper tape as well as print out a useful report. Several “convertors” to accomplish this are commercially available. On the other hand, if no copy is required, or magnetic tape loggers are involved, the natural binary data may he recorded. Increasingly, low-priced digital cassette loggers will he employed. Frequency modulation techniques* are usual in such recording devices. These units commonly have the ability to multiplex a number of analog signals into a common ADC and record both the channel number and the datum point on magnetic tape for retrieval a t a later time. Normal speeds in the lower price units are about 100 16-bit data words/sec, thus accommodating one medium speed device or 10 slow devices. 120,000 data words can he stored per cassette, thus allowing continuous data from 10 GC‘s to he stored for 20 min. Continuous data from our two groups of three instruments could he stored for over an hour. The low cost of these units suggests that for even slow equipment existing in nodes of 3-4 a t distant locations, a logging unit would be stationed at each node, with an asynchronous communications link at each node caDable of communicating to a host computer for data reduction. Since the UART units look like teletypes, these connections can involve extremely long distances (miles) if modem* connections to standard telephone circuits are involved. In many cases, vendors provide the option of straight hinary, BCD, or ASCII output format. We have, by using standard modules, achieved interfacing to the existing instruments in our problem with facility. Now, let us look into the expansion problem and the subject of speed which i t introduces. Although speed of data acquisition and manipulation is the usual reason for employing a computer, it is surprising that few analyses hothe? to evaluate the system overhead times in the early states of development. It is obvious that two time constraints must he carefully met if the computer is to operate effectively. First, the available real time for data acquisition must not be exceeded. A computer acquiring data via register transfer (accumulator I/O)* from a single instrument is normally limited to a total data acquisition rate of 30,000 data samples/sec. This takes into account not only the data acquisition time, hut the software overhead* necessarily associated with data storage. (Table IIshows typical
data acquisition speeds for various types of computer configuration and peripherals as a guide. A 16-bit data word is assumed). However, even this rate cannot be achieved under circumstances in which a large number of slow instruments (2400 bits/sec, for example) are communicating with the CPU. This is due to the fact that even more complicated executive software is necessary to handle the scheduling (when to sample) as well as the proper filing. As each instrument interrupts normal CPU operation, expensive time (in excess of 100 psec) is utilized in identifying the interrupting device, saving important CPU status registers, servicing the interrupting device (acquiring the data), and restoring the system to its original state. These processes could easily halve or quarter data acquisition speeds if an interrupt/data word interfacing scheme was employed. This is the reason for suggesting FIFO buffer memories as our system was expanded. Second, if data processing and reporting are involved, sufficient time must be alloted for these operations, or the unit will become calculation bound. Since TTY 1/0 is very slow, output to these devices will not normally consume more than 1 msec of processor time per second of TTY output printing. Simple high-speed line printers employ buffers and use about the same amount of processor time. Of more serious consequence are the long periods required for mathematical operations, particularly using software containing floating point* instructions. These require from 35 to 1200 pseclmath operation, depending upon its nature and the quality of vendor software. An 11point least-squares fit through 16 points can easily involve 0.5 sec of CPU time. Hardware math packages are available which will reduce these times by a factor of ten a t prices comparable to the CPU itself! However, this time squeeze in a dedicated system will increasingly be 300A
solved by employing a hierarchical system-a system in which one host computer handles the data reduction and reporting for a number of satellited computers which only handle the data acquisition problem. This is due to the advent of microprocessors or microcomputers (see photo). These are inexpensive large-scale integrated circuit devices which are essentially central processors on a chip. They are completely software programmable, with instruction sets approaching those of the more sophisticated minicomputers (like the PDP-11, for example). A typical system configuration is shown that would cost about $1000, complete with power supplies, memory, rack, and UART transceiver unit. Bootstrap loaders and commonly used programs are stored in programmable read-only-memory. Their low cost and their ability to control the data acquisition process for a number of similar, slow-data-rate instruments indicate that they are the ideal solution to the type of problem outlined above, in which increasing utilization of the main processor required installation of satellited control and acquisition devices for slower instruments. Most of the microprocessor systems have a number of input and output ports* wired to the processor itself, thus relieving the interfacer of understanding 1/0 electronics. One merely plugs the output of a convertor into a n input port. The program interrupt structure on most systems is as well developed as that of state-of-the-art minicomputers. The unit thus provides control and scratch pad (temporary) memory capability at low cost. BCD/binary conversion can be done under software control, and the unit can handle all telecommunications to a host computer. Software for these systems is still somewhat of a problem, but increasingly cross assemblers* are being made available which will allow program preparation on the host and transmission of the binary-coded program to the micro-
ANALYTICAL CHEMISTRY, VOL. 46, NO. 3, MARCH 1974
processor via asynchronous binary communication. After the data base has been acquired by the microprocessor, and manipulated, it can be sent back to the host computer in a similar manner. At present, such units cannot handle floating-point arithmetic with ease. However, this task can be taken over by a minicomputer with hardwire capability. In a few years the use of calculator chips in microprocessors may even alter this situation. At present even this route could be employed if the long division times (100 msec) of such units could be tolerated. In brief, it appears that vendors are finally realizing that interfacing to a variety of analytical instruments is a fast-growing field. Most main frame manufacturers do not wish to make specific interfaces for each instrument, nor could the chemist afford them if available. The increasing number of do-it-yourself modules is solving the problem neatly. Glossary Assembler: a computer program which can change a program written in special code words, called mnemonics, to machine-executable binary code Binary/octal: binary is a means of representing numbers by a scheme in which each number position has the following weight 2O, Z1,2*, 23, etc.: in octal each Ei3, etc. weight is go, 8l, Closed loop: control by a C P L where real time decisions affect the sequence or nature of the controlled operation; involves feedback from the experiment to the CPU Compiler: a program to translate user commands in almost algebraic/English format into a code that is machine executable when another program called the “operating system ’ is also present Cross assemblers: assemblers which run on one machine, but produce code executable on another machine Direct memory access: data flow to or from a computer which bypasses the accumulator or input register. It appears to flow directly into memory. Used for fast transfer of blocks of data Firmware: programmable read-onlymemories, involving storage of programs in units that cannot be written on by the program. Some units can be field reprogrammed with special devices; others are “fixed” Floating-point math: mathematical operations in which a number is represented by a characteristic and mantissa Frequency modulated recording: where a binary 1 is represented by one frequency, a binary 0 by another Hierarchical (net): interconnection between several CPU’s, in which one serves as a central body to satellited CPU’S Host machine: see hierarchical I / O bus: the 50-100electrical lines that represent the input, output lines of a computer, as well a s decoding and timing signals. Each computer model has a slightly different 1/0 bus structure Input/output ports: collections of 8-16 electrical points which can be electrically connected to a digital device, providing a channel for data flow to or from the CPU
Intelligent controllers: devices t h a t can control equipment operation and make moderately complek decisions. These may involve all hardware or a combination of hardwarelsoftware Interpreter: B program t h a t accepts user commands in almost algebraic/English format. Stores it, and executes when commanded Modem: modulator-demodulator devices used t o translate 1's or 0's t o tones (frequencies) t h a t can be sent over eommon carrier lines On-line: d a t a collection and control achieved by direct connection between the device and a central processor unit ~~~~
(CPU) Open loop: computer activation of experimental sequence; no feed-back from experiment (cf closed loop) Parallel and serial transmission: in parallel transmission all of the elements of a word are transmitted simultaneously, similar t o the output of an adding machine's printer. Serial transmission involves output of the elements of a word, one element a t a time, the way a typewriter presents data Read-only-memory: memory which can be read from, b u t not written into. Some ROM's are reprogrammable (can be altered with special equipment)
tic reiisters of thecomputer, often called the accumulate; Software overhead time: the execution time of software necessary to accomplish a task
302A
"Microprocessors a r e going to change your future. Are you ready?" ask Jonathan Titus and Raymond Dessy
Raymond E. Dessy and Jonathan A. Titus wrote a report for Analytical Chemistry in February 1973 on 'Tomputer Interfacing."Technological progress in microComputers has taken place a t such a rapid pace that a new iook a t interfacing is imperative. Dr. Dessy, with David Larsen, h a s over the iast three years. given an ACS sponsored course on minicomputer interfacing. Beginning in June 1974, Dr. Dessy and Jonathan Titus will be presenting a new ACS sponsored course on microcomputer interfacing. Raymond E. Dessy. professor of chemistry at Virginia Polytechnic Institute and State University. received his BS and PhD degrees in 1953 and 1956. After fellowships a t UCLA and the University of iilinois and a faculty appointment a t the University of Cincinnati, h e c a m e to VPi in 1966. Jonathan A. Titus is a research assistant at VPI a n d is completing his PhD requirements under R. E. Dessy. He received h i s BS degree in 1967from Worchester Polytechnic institute and h i s M S degree in 1969 from RenSselaer Polvtechnic institute.
* ANALYTICAL CHEMISTRY, VOL. 46,
NO. 3, MARCH 1974