The first step in interfacing serial instruments to computers

instruments: The First Step in interfacing Serial instruments to Computers. Kenneth E. Hvde. Smts Unlvsrsny of New Yo*. College at Oswego. Oswsgo, NY ...
1 downloads 0 Views 2MB Size
Connecting Dumb Terminals to instruments: The First Step in interfacing Serial instruments to Computers Kenneth E. Hvde Smts Unlvsrsny of New Yo*

College at Oswego Oswsgo, NY 13126 A number (1-1 7)of descriptions have appeared that describe the interfacing of laboratory devices to computers for the purpose of data acquisition, but the majority of these articles involve nondigital laboratory instruments and often require the construction of a hardware circuit to connect the device to the bus system of the microcomputer. Few articles (13,18) appear to have taken advantage of the fact that many new generation instruments are supplied with digital interfaces and interfacing these devices with the inputloutput ports of a comouter often involves onlv cable fabrication. The most common difital interface is the serial one, and such interfaces are supplied as low-cost optiuna on simple inslrumenta such as balances and pH meters that are used in high school and undergraduate chemistry laboratories. It is probably the more difficult digital interface to implement hecause the RS-232 standard that is assaciated with it defmes electrical and mechanical specifications but not device or dataflow control. When a serial interface appears on a major instrument such as a gas chromatograph or a spectrophotometer, the manufacturer usually supplies the appropriate cables and software necessary for computer data acquisition. Establishing and testing the interface between the instrument and a PC is routinely part of the installation procedure for these major instruments, but it has been our experience that little help is provided for the task of interfacing minor serial instruments to a computer. We believe that the confusion associated with the connector systems wmmonly used with serial interfaces and the lack of knowledne " of the RS-232 standard. and asynchronous data communication has discouraged the development of laboratory experiments and associated software that deal with computerized serial data acquisition. The descriptions below represent a strategy that we have found useful in establishing interfaces between serial instnunenta and computers. The process is independent of the nature of the instrument (balance, pH

meter, spectrophotometer, etc.) and the of an interconnecting cable; setting serial computer (PC, AT, Apple 11, Macintosh, communication parameters; tasting for data etc.) and does not require knowledge of the communication. RS-232 standard. The nremises are that a Cable Selection terminal is a versatile L o l for teatins the - ~ ~ serial interface of an instrument and that We have constructed our own set of cathe terminal/mstrument c o ~ e e t i u nshould bles, adapters andgender changers, but simbe the first step in establishing the computilar versions are commercially available at erlinstrument interface. It has been our ercosts that are usually $20 or less per item. perience that terminals are widely available The two cables are three-condudor (pinbeenuse of their use in multiuse; computer ning: 2,3,7) with DB25 connectors of differsystems. We have used both ZenitbZ-29and ent genders a t each end. The difference beDEC VT-100terminals and believe that anv tween the two cables is that one has conducother asynchronous ASCII terminal wouli tow 2 and 3 wired straight through, while he auitahle. the other has these two wires cross over. The goal of the procedure is to establish P h y s i d problems that result when one atbidirectional data transferred between an tempts to connect the serial instrument instrument and a terminal. This may be achieved by a thrw-step process: sele&on (Continued on page A1161 ~

~

~

~~~~~~~~~

~~~~

~~~

-

~~

.~~~~~ ~

~

Volume 66

Number 4

April 1989

A115

the comnuter bulletinb o d with the terminal or instrument are usually obvious and may be overcome with gender changers and/or adapters. C a l h selection may be by a trial and error approach, but we prefer to identify a negative voltage (more negative than -4 V) on pins 2 or 3 relative to nin 7 of each device. The crossover cable is ;sed if the negative voltage is found on pins with the same number at both the instrument and the terminal.

Communication Parameters The parameters are determined or selected at the instrument first. The usual parameters (and some suggested values if that parameter is selectable) are: baud rate (select 300). number of data bits (select 81, nature of parity (select none), number of stop bits (select 2) and nature of flow control (select XONIOFF or DClIDC3 or "software", which usually are identical). Select similar parameters a t the terminal, but realize that data communication may well occur if an exact match does not occur for eachparame,tar.

~

~

~

.~

Attempt to send data from the instrument to the terminal. This is usually accom-

4. The terminallinstrument interface may be used as an aid in identifying a problem in an existing but malfunctioning computerlinstrument serial interface.

If connecting a dumb terminal to a serial instrument is the first step in interfacing a computer to this same instrument, what are the remaining steps? We advocate two additional steps. The first of these involves replacing the terminal with a computer that is running terminal emulator software. Now the computer ads as a terminal and the same tests as described above can be nerformed. The lasc step involves the replacement of the terminal emulator software by user written or commercial application roftware designed to perform the desired data acquisition and instrument control functions via the computer's serial port.

~~

1. Remote operation of the instrument is possible. If the instrument is to be located at a hazardous or inaccessible location, then it can be controlled and used for minimal data collection without the renuirement of a dedicated comnuter. ~. 2. Nerther prograrnmin~skills nor applicationsuftware isrequ~redtolest the interface. One can establish by direct ohservation that data flow has occurred. 3. The cable that is produced may ade~

Testing for Data Communlcatlon

quately serve for the computer to instrument interface.

plished by evoking a "print" or "transmit data" function at the instrument's keypad or keyboard. Terminals are somewhat forgiving with respect to communication parameter mismatch. They will often respond with gibberish if the baud rate is incorrect, and they usually ignore any parity associated with an incoming character. A failure to observe data a t the terminal suggests that the wrong three-conductor cable has been used or that a cable with device control is required. In the former case, switching cables will resolve the problem, but in the later ease a knowledge (19, 20) of the RS-232 standard and any device control implemented by the instrument manufacturer will be required. Mast terminals and simple instruments do not evoke this control and simply changing the cable should result in data flow. The final testing of the interface involves entering commands a t the terminal's keyboard and witnessing the appropriate resnonse a t the instrument. We lirt what we haw found u, be some oi the advantages of establishing a ttrminall instrument interface.

George R. Brubaker illinois instiMe of Technology Chicago. IL 60616

~

Larry L. Alber USFDA-DRiS at the USFDA Chicago District Labwatwy Chicago. IL 60616

As electronic balances replace mechanical balances in teaching institutions, balance instruction must change from applied classical mechanics to principles of calibration. Few students will ever need to know how the electronic balance works, but most will need to know that it is working. The purpose of this note is to describe an application of an electronic digital balance, equipped with an RS232C serial interface, in which the apparent masses of a series of standard weights are digitally recorded and subseouentlv subieeted to linear reeression " analyms t ~ calibrate , the balance. We haw also described an application of the digital electronic 1,alanue to Compendia weight variation unifurmicy tests, which involve calculation of active ingredients baaed upon tablet/capsule weight (21). Our methuds may u,a variety irf uwka, inrlud. be amlied -. ing counting, s very common application of dieitallv interfaced electronic balances. ireo over, data captured from the electronic balance may he integrated with subsequent computations.

.

1

Journal of Chemical Education

- .

Materials and Methods At the Chicago District Laboratory of the USFDA, we use a Mettler model AE 163 digital display balance with RS232ClCurrent Loop data output option 011 (unidirectional).' Similar analytical balances (0.1 mg),include the Fisher Scientific XA-250,

the Ohaus G-160, Mettler AM-lMI, and the Sartorious A-ZOOS, among others, which are available from major laboratory supply houses in the V25W 3OlX) (1987-19RR ram. log) rice ranre includine the RS232C mterface: ~ a l a n c e with i 1 - i g sensitivity available from the same sources in the $1,3002,024 price range include the Fisher Scientific XT-400D, t h e Ohaus G-410, the Mettler PM-400, and the Sartorious L4205. The cost of an electronic halanee is generally comparable with the cost of a mechanical balance with the same rated sensitivity. We have used a number of "Industry Standard" MS-DOS 8088 or 80286 based PC's, such as the KayPro, Leading Edge, DEC-VaxMate, and inexpensive "clones". An RS232C serial port is required; a high clock speed and large RAM are useful for other applications hut are not necessary for this application. Neither a hard disk nor a hieh-resolution disulav is reouired. Nothine " precludes the use of a similarly equipped Apple computer. The balance is connected to the computer using a standard RS-232 25-conductor cable connected to the PC serial communication port. For the calibration study that is the suhject of this article, we used Denver Instruments NBS Class S weights. An appropriate weight was placed on the halanee pan, and data collection was started immediately. Single weights were used to minimize additive errors.

..

-

Results The Mettler serial interface transmits data continuously a t a rate of about 5 readings/~.If successive readings meet the stability criteria of the internal program of the Mettler halanee, the output takes the form: S 3.09485 g. The S and g are part of the output, which is followed by a carriage return and line feed. Should the reading not satisfy the internal stability criteria, the output takes the form: SD 3.09485 g. The format of the output will vary from manufacturer to manufacturer. Consult the manual for details concerning your balance. The BASIC program we have written to capture data from the Mettler balance excludes any values that contain "D" and averages a user-defined number of stable ("S")readings. When the system has collected and averaged these data, it "heeps"to signal the user to load another sample, displays the average value on the CRT, and writes that value to a disk file. Interested readers may obtain a copy of the program listing from LLA a t the address above. Data collection requires about 20 min including setup time. We performed data analyses with Borland's Quattroz; similar analyses are possible with most popular spreadsheet programs. Regression analyses show that our Mettler AE 163 is linear lr2 = 1, to within the preriaion 131 Class S weights in the range 2 lIMW mg. Collecting digital data from an electronic balance followed by a detailed spreadsheet analysis is a useful introductory exercise for any analytical Laboratory course, affording an introduction to the balance. an introduc-

tion to computer interfacing, and an introduction to "spreadsheet data analysis". The instructor may, of course, vary the emphasis on each component to suit the level and needs of the class.

' Reference to any commercial materials, equipment, or processes does not in any way constitute approval, endarsement, or recommendation by Me Fwd and Drug Administration. (hrsdro. Me hfesslonsl Spreadsheet Borland international: Scotts Valley. CA 95066.

Llterature Cited Waldo, 0. S.;Sehulze, C. A,; Battino, R. J. Chem. Edue. 1984.61.530. Blanck. H.F.J. Chem.Edur. 1984.61.533. Rlanck. H. F.J. Chem Edue. 1985,62,62. Hardy, J. K. J. Chem. Educ. 1985.62.62. Hughes, E.; Cox, A. J. J. Chom. Educ. 1385.62.63. 6. Miller, 8.: Van Oort, M.: White, M. A. J. Chrm. Edue. 1.

2. 3. 4. 5.

1985.62.64.

7. Greempan. P. D.;Burchfield. D. E.; Veening, H.J. Chem. Edue. 1385.62.687.

8. Mattpon,B.M.;Shephed,T.R.;Solaky, J.F,ilChm,.

Educ. 1985.62.630 9. Ruaso. T.J. Cham. Educ. 1385.62.692. 10. Barry,P.J.;Brothera,A.D.Am. J.Phya. 1988.52.186. 11. Swisrtz, J. C.: C m d . J. T. J. Chrm. Edue. 1986, 63, 1071

12. Pearron, M. S.; Tuzeo, S. J. J. Chom. Edur. 1986, 63, 1074. 13. Jeneen, D.A,: Hsrdy, J. K. J. Chrm. Educ. 1986.63,

-232 Mode Eoay; Prenfim-Hall: En-

Volume 66

Number 4

April 1989

A117