Journal of Microcomputer Applications (1983) 6,47-57
COMMUNICATION
The potential of personal computers laboratory control applications
in
D. W. Pritty Department of Computer Science, University of Strathclyde, Livingstone Tower, Glasgow GI IXH
Personal microcomputers, having already made a very significant impact on business and data processing applications of computing, are now showing considerable potential in the automation of simple laboratory tests. Such tests require a combination of data-processing capability for sample identitication and user-friendly interface for display of results and test limits coupled with realtime control of the measurement process. These are just the combination of characteristics available in the personal microcomputer and the relatively clean environment of the laboratory means that they provide an ideal vehicle on which to base the design of laboratory automation systems. This communication describes the use of a PET microcomputer as the controlling element in two typical laboratory applications, namely tensile testing of ahuninium and additional control facilities for an air pollution monitor based on spectograph techniques. Each application is described briefly with emphasis on the assembly-code software techniques necessary to overcome the lack of computing speed in the interpreted BASIC which was used for the rest of the software. The benefits of using a common approach to the hardware interfacing are also discussed.
1.
Introduction
The low cost of microprocessors and associated memory components has lead to a wealth of new control and automation applications in a wide variety of fields. Unfortunately the difficulties in developing such systems from the chip level up reduce the overall effectiveness of this approach for low-quantity applications. Board-level systems, where complete processor, memory and I/O cards are purchased from a supplier, solve many of the problems but the standardization required to produce a compatible set of boards leads to extra hardware, particularly in the I/O area, and hence higher hardware costs. These modular systems, like the chip-level approach, run fixed task programs committed to EPROM. This can be adequate in the control area but when data handling tasks are involved software modification becomes a much more important criterion. Here the self-contained facilities for program preparation and editing of the older minicomputer systems are particularly valuable. The advent of the personal microcomputer in the late 1970s provided these facilities 47 0745-7138/83/010@47+11
$03.W/O
0
1983 Academic
Press Inc. (London)
Limited
48 D. W. Pritty for program development and modiication for little more than the cost of a VDU. One area specifically suited to the use of a personal computer as the controlling element is the automation of laboratory measurement tasks, which generally involve measurements on test samples. The measurement part involves the normal dedicated real-time control tasks plus the data processing tasks associated with entry of sample identification data and the display of results in a suitable format. This communication describes the application of the PET personal computer in two laboratory systems-one for the control of a tensile tester and the other an air pollution measurement system. A description of each application is given with emphasis on the assembly-code software necessary to overcome the limited processing speed of the interpreted BASIC. As both applications use the same hardware interface to the PET a brief description of this is given first.
2.
PET hardware
interfaces
The advantages and disadvantages of the various hardware interfaces available on the PET, namely, memory expansion bus, user port and IEEE interface, have been fully discussed previously (Pritty & Barrie, 1981). Discussions here will therefore be limited to a brief description of the special version of the IEEE interface which has been used on both applications. 2.1 IEEE-488 bus--a simpl$ed version The IEEE bus is an industry-standard 8-bit data bus with control and timing handshaking signals which is widely used in the instrumentation field. Although it should perhaps be noted that there are some timing restrictions which make the PET implementation of IEEE bus non-standard. In particular, when the PET is a listener it expects DAV to go low within 64 ms of it setting NFRD high. A similar constraint is applied when the PET is a talker in that it expects NDAC to high within 64 ms of it setting NRFD high. Used with all control signals the bus is extremely versatile but the control logic is somewhat complex (IEEE, 1975; Fisher & Jenson, 1980). Fortunately in the implementation on the PET the control signals are derived through two I/O chips-a PIA and a VIA with suitable bipolar buffer chips to provide reasonable signal current capacities for the interface. Given that intelligence is not required in most input/output devices associated with microprocessor control systems, a much simplified version of the PET IEEE bus can be used. This involves the eight data lines and only two control lines, namely ATN (which distinguishes between I/O addresses and data) and DAV which is used as a clock signal to strobe data into registers. This simplification is possible because of the particular way in which the control signals of the IEEE bus are generated on the PET. ATN is bit PB2 on the VIA and can be set as required by addressing that output register of the VIA. The key factor is, however, DAV (OUT), derived from the CB2 line of a PIA. This line can be arranged to pulse after the output data for the interface register has been loaded into the PIA output register by setting up the control register of the PIA appropriately. (The pulse occurs approximately 1 ps after the data is loaded and lasts O-5 ps.) In both the series 30 and newer series 40 PETS the PIA for the IEEE interface is located at addresses E820 to E823. The register located at E820 provides the input register for the IEEE data bus and
Personal computers in laboratory control
49
PIA Port B (IEEE
r-7 Set ATN line low (PB2 of VIA)
WI-data
-
This strobes &to into address register
This returns interface to transfer state
CB2 pulse occurs autamatically al next cbcli pub after write to Part B
Figure 1. Flowchart showing operation of simplified IEEE interface.
E822 the output register. E823 is the control register for Port B. CB2, the DAV line, can be set high by loading this register with 3C and CB2 can be pulsed by loading it with 2C. The only signal involved from the VIA in this adaption of the interface is ATN. This is bit PB2 located at EM. ATN can be set high by ‘ORing’ 04 into E480 and set low by ‘ANDing’ FB into the same location when required. These operations all have to be carried out in assembly code unless a tremendous loss in speed can be tolerated. A flowchart showing the necessary operations on the PIA and VIA is shown in Figure 1. This should be examined in conjunction with the block diagram of the bus interface logic showing the principles of handling input and output data which is given in Figure 2. The I/O address is strobed into the address register using the ATN line. The address register contains the I/O addresses together with a R/W control bit to distinguish between inputs and outputs. On input R/W is a ‘1’ and this enables the LS138 address decoder driving the tristate buffers permanently so that the data can be read when
50
D. W. Pritty I
_
T
I
A6
01
Figure 2.
A
ATN IEE
simplifiedIE!EE
488 interface.
required by the PET. On output R/W is low and data on the IEEE-488 bus is strobed into the relevant output register using the DAV pulse which now drives the address decoder. The input data bus from the tristate buffers is passed through open collector NAND gates which are disabled by either the ATN line or the write condition (R/W = ‘0’). This ensures that the input bus is disabled either when the I/O address register is being loaded or whenever a write operation is taking place.
3.
Tensile tester
This application is concerned with the control of a tensile testing machine and measurement of the proof stress, ultimate stress and elongation at fracture of a sample of aluminium. Load is applied to the specimen (Figure 3) at two speeds, a slow speed up to proof-stress point and then a faster speed until the specimen breaks. The faster speed is necessary because with aluminium, considerable extension is required to break the specimen after proof load. [Approximately 10 thou (O-25 mm) of extension is required to reach proof-stress point and 200 thou (5 mm) to break the specimen.] Control of the tensile-tester machine is via three solenoids which operate hydraulic valves on the machine. These are slow up, fast up and dump. Dump releases hydraulic pressure in the system once the specimen has broken and returns the machine to its starting position. Load is measured using a hydraulic pressure sensor which outputs a d.c. voltage corresponding to the applied load (stress is calculated by dividing the load by previously entered data giving cross-sectional area). Extension of the sample is measured using an
Personal computersin laboratorycontrol 51 Hydraulically applied upward load WI specimen
t
Testpiece
specimen exiension Fixed end Figure
3.
Tensile testing.
extensometer. An extensometer is a device with two knife edges which grip the sample. Movement of the knife edges is sensed using a Linear Voltage Differential Transducer (LVDT). The LVDT is essentially a differential transformer; the primary of the transformer is driven with a 5 kHz a.c. signal. The amplitude of the output voltage is proportional to the movement of the extensometer (the scale factor is 10 mvjthou). A commercial unit is used to drive the LVDT and to convert the a.c. voltage accurately into a d.c. voltage. The d.c. voltages from the load and extension signals are then amplified to suitable levels and fed to two O-1% charge integrating A/D converters. Control of the machine merely involves three digital signals to the three solenoids. Another interesting feature which is extremely useful in operation is automatic measurement of the aluminium sample diameter or rectangular cross-section. This measurement is taken by a modified Moore and Wright digital micrometer which measures to 1 pm. Up/down pulses are taken from the input to the micrometer’s custom-designed counting and display chip and passes through line-driver amplifiers incorporated at the end of the micrometer casing. A short length of screened cable connects the micrometer to a six-decade CMOS up/down counter chip which is then interfaced to the PET. The system hardware, which has been partly described previously (Pritty & Barrie, 1980), consists of an interface unit, a PET personal microcomputer, and a data concentrator unit for communicating results to a remote minicomputer. The foregoing describes the measurement aspects of the tensile-tester application. A user interface and some data processing is also required. The operator has to be able to enter, display (and edit) about ten quantities associated with each test, such as operator identification no., plate no., batch no., etc. In addition, results for each sample in a test batch have to be displayed on the PET screen for checking prior to print-out or transmission to the remote minicomputer. These aspects of the test are typical of a laboratory situation where data on the sample has to be entered and associated with the results and the results have to be displayed on a screen and then committed to a permanent storage media either via print-out, tape, floppy disc or onward transmission to a central archiving system. A detailed description
52 D. W. Pritty of the way in which these facilities are implemented in the tensile tester will not be given here. 3.1
Control software
The BASIC software to provide the user interface and entry of sample identication data is straightforward and discussion is therefore limited to the assembly code control software segments. The diameter of the specimen is read automatically by the modified Moore and Wright digital micrometer as part of the sequence of entering data on the sample on to the table on the PET screen. No time criticality arises in reading this input as the time for this reading is related to human response times associated with the user dialogue with the PET. During the actual test only two quantities had to be measured, namely load and strain. (See Figure 4.) These were read together in one section of machine code which was
Figure 4.
Tensile testing-load
strain graph.
invoked from the BASIC by inserting a software patch which recognizes unassigned character sequences and then jumps to the starting address of an appropriate machinecode routine to recognize the new command (Hampshire, 1980). This technique reduces the evaluation time required by the interpreter to process a SYS command and its associated address parameters. In fact although it represents a useful reduction in access time to read the input values the technique is of limited significance unless the associated BASIC processing loop consists of only one or two BASIC statements. As the load and strain signals were both being measured using integrating converters circuitry had to be added to synchronize the converters. Synchronization was achieved by interrupting the clock pulses to one converter until the end of conversion signals from the two came into synchronism. Once in synchronism the converters were fed with a common clock signal and therefore remained synchronized. This eliminated any errors that could arise in calculation of the slope of the load/strain curve due to reading load and strain values at different times. During the initial linear slope the speed of the BASIC loop was adequate for calculation of the gradient. However, the speed of the BASIC was inadequate for solution of the proof-stress equation. Fortunately the proofstress equation could be recast so that approach to the proof-stress point could be
Personal computers in laboratory control
53
detected in BASIC and sufhcient values to cover the actual proof-stress point stored in a buffer, loaded under assembly code control. Processing of these values in the proofstress equation was then carried out in BASIC.
4.
Air pollution
monitor
This equipment is known as Beryl 80 and was largely developed by the Department of Pure and Applied Chemistry at the University of Strathclyde. It is based on the use of commercially available spectograph analysis units manufactured by Pye Unicam and some special equipment designed and manufactured by the Chemistry Department. An outline block diagram of the equipment is shown in Figure 5. The equipment operates by sucking a sample of air, whose pollution level is to be measured into a furnace.
Vacuum plmP
Air (lomple inlet -
Analytical signal output \
Savkd
inlet
Figure5. Air pollution monitor equipment. The carbon tube in the furnace is heated to 3000 “C whereupon any particles of impurities in the air fall out as ash. The ash is then subjected to normal spectographic techniques to measure the concentration of any given element. The wavelength to which the Pye Unicam Spectograph is sensitive can be adjusted thus allowing the instrument to detect the pollution levels of various elements in the air. In order to calibrate the readings of the instrument a solution containing a standard amount of the pollution element is drawn into the furnace and measured as a reference between readings of the air sample. Control of the operation of the spectograph and associated furnace is carried out by a Pye Unicam microprocessor-based controller with additional control being provided by a hardwired logic control unit built in the Department of Chemistry. Fairly late in the development programme of the prototype instrument it was decided that a number of additional measurement, control, and equipment and operator monitoring features were required. These have been provided by a PET with an associated interface unit for processing the signal outputs and inputs to and from the spectograph units and the hardwired control unit. The measurement facilities included measurement of the analytical signal output from the spectograph. Measurement of both peak signal height and area were required to an accuracy of l-2%. As will be discussed below, this involved some time-critical computation. The status of the instrument also had to be monitored throughout the test to
54 D. W. Pritty advise on equipment malfunction or operator misadjustment. Control of a timed period had also to be carried out by the PET. Outputs to the operator were an audible warning and a flashing PET screen with an appropriate error message to show the operator the source of the malfunction. The above describes briefly the measurement and control facilities provided by the PET. In this particular application, entry of sample identity data was not required. The PET screen facilities had however to be used to enter acceptable upper and lower limits for the various test parameters involved in the equipment. Once any quantity being monitored went outside these limits the warning outputs would be initiated. Facilities for editing these limits and their storage on tape were required. In this case, facilities for printing out the test results had already been provided by the Pye equipment and were therefore not required from the PET. Naturally, the mixture of a hardwired control unit with additional facilities provided under software control by the PET is undesirable. It has been decided that in future models the hardwired control unit would be replaced by extending the control undertaken by the PET. Further developments are likely to include better graphical presentation of the results using a printer or graph plotter interfaced to the PET. 4.1
Control software
Much of the BASIC software used for user interface which had been developed for the tensile tester was incorporated in the spectograph application after suitable modification. As this was again relatively straightforward BASIC, discussion will be limited to the assembly-code routines. In the case of the spectograph there were two time critical operations. The major one concerned determination of the peak analytical signal height and its area. Less accuracy was required in this application-l-;!% as against the O-3-0*5% of the tensile tester (which had necessitated the use of 0.1% integrating A/D converters) and it was therefore possible to use an &bit high speed A/D converter with a conversion time of 15 t~s and an analogue multiplexer for the several analogue channels involved. Figure 6 is an outline block diagram of the hardware. The analytical signal output from the spectograph quickly rises from zero to a fairly sharp peak and then falls back to zero again over a period of l-2 s and it seemed appropriate to determine its area using Simpson’s rule. This requires a fixed time between the ordinates which led to the decision to use the interrupt routine which runs 60 times/s in the PET to scan the keyboard, etc., rather than to use a separate external clock to interrupt the PET. It was fortunate that ordinate readings every 15 ms were sufficiently close together to provide adequate accuracy for the integration given the l-2 s signal duration. Using Simpson’s rule the area under the curve can be expressed as tr [Z Y-a YF+ Yd] in terms of three variables ( YF, the tist ordinate; CUSUM, the cumulative sum of all the ordinates, i.e. Z Y, and Y, the last ordinate; multiplied of course by the time tr between ordiates which is a constant). This eliminates the need to store all the ordinates for later processing, a fact which could be of considerable importance if the integration time was lengthy and there were a large number of ordinates to be stored. During the measurement YpEAK,the peak value of the signal, also had to be stored.
Personal computers in laboratory control
55
Other
WWe
inputs from
instrutment
Diiitol
LS
*MOOUQNltS fmn imtrument
_i
; ”
-c
I Figure 6.
ATN DAV
Outline diagram of spectographinterface.
Segments of assembly code were inserted at the start of the keyboard scan interrupt routine by modifying the jump vector held in RAM. An assembly code segment was therefore written which scanned all inputs and updated all outputs in the interface. When the analyse flag was set (i.e. when the analytical signal was present) the assembly code routine to compute and store the values of Yp, CUSUM, YL and YpEAKwas invoked. These values were later scaled using the floating-point facilities of BASIC for subsequent display. Fortunately the other time critical aspect namely the PET time could be handled to the accuracy required by reading the PET jiffy timer and outputting the timer-end signal using BASIC.
5.
Common design philosophies
The vast majority of tasks carried out on a laboratory are associated with measurements of test results on a sample. In computing terms this involves real-time process control type of tasks (for the measurement part) and data processing tasks in terms of entry of sample identification data, test limits, display of results and other aspects of user interface. A further factor is that the amount of time-critical computing required is likely to be limited to data capture problems as the actual processing of results is only required at speeds acceptable to the human operator.
56 D. W.Pritty These factors allowed the vast majority of the software for both applications to be written in BASIC which can be easily modified and extended throughout the life of the instrument if required. Assembly-code segments were only employed for handling the I/O interface and for data capture routines. For historical reasons two different approaches were used to handle the I/O in the two applications. In the case of the tensile tester individual sections of assembly code were called from the BASIC which dealt with only those inputs of interest at that particular phase in the test. Whereas in the case of the spectograph the opportunity of using the fixed timing of the interrupt routine to implement the Simpson’s rule integration of the analytical signal was extended to scanning all inputs and outputs every &r s. With the use of flags to invoke particular computation routines at specific times during the test. In fact it would also have been possible to scan all inputs and outputs in the tensiletester application. Although here the use of the interrupt routine would have been too slow to collect the values at the required rate to solve the proof stress equation. It would therefore have been possible to standardize further on the assembly-code software driving the interface but any assembly-code software required for processing has to remain unique to the application. Considerable standardization was possible in terms of the hardware interface. As well as avoiding the possibility of actual program corruption through noise on the memory expansion bus, use of the IEEE bus provides a neat mechanical connection to the interface unit through the moulded cabling supplied by Commodore for connection of their peripherals.
6.
Conclusions
The use of a personal microcomputer such as the PET in a control application makes available minicomputer characteristics and capabilities at almost zero cost (given that VDU data entry and screen display facilities are required). The self-contained facilities for program preparation, storage and editing, the graphics software and the simple fact of a proven working processor system around which to hang the interface circuitry are all extremely valuable and go a long way to making at least the computing associated with the analysis and display of the results a non-specialist task certainly as regards small in-service modifications and amendments. The screen graphics for user-friendly interfaces are simple to program using the BASIC PRINT and PORE statements with the graphics characters, the cursor control commands and the memory-mapped screen (CBM, 1978). The data processing tasks can be performed efficiently if somewhat slowly. Unfortunately the need for specific assemblycode segments still requires the involvement of microprocessor specialists who have to spend a considerable time familiarizing themselves with the details of the application. One of the main aims of the microprocessor control industry must be to deskill the design processes required to implement control systems. In terms of attempting to deskill the use of the techniques described here it is possible to envisage modular construction of the hardware together with appropriate driving software already programmed in PROM for insertion into free sockets in the PET. This would undertake scanning of all inputs and outputs. It is less obvious how to cater for any manipulation of these values in assembly code without skilled personnel. A first step would, of course, be a compiIed high-level language for instance of the PL/M type that
Personal computers in laboratory control 57 executes efficiently on the 6502 processor and which could be run on the PET with floppy discs. Further work obviously remains to be done in this area but the validity of the various design techniques described here is demonstrated by the success of both applications. The tensile-tester system has been in full production use since the end of 1980 and the spectograph system was delivered to the final customer in October 1981.
Acknowledgements The author wishes to thank Mr J. Callender and Mr P. Barrie for their valued assistance in writing the software for the two applications. Thanks are also due to Mr R. Watson who undertook the constructional work on both projects to his usual high standard.
References CBM 1978. PET User Manual. Commodore Business Machines. Fisher, E. & Jenson, C. W. 1980. PET and the IEEE 488 Bus, pp. 28-35. McGraw-Hill. Hampshire, M. 1980. The PET Revealed Computability, pp. 78-80. Computabits. IEEE 1975. IEEE Standard 488. Pritty, D. W. & Barrie, P. M. 1980. The use of a personal computer in a typical automation system. Journal of Microcomputer Applications 4 (2), 116-127. Pritty, D. W. & Barrie, P. M. 1981. Personal computers in automation systems. Microprocessors and Microcomputers, 5 (4), 139-147. David Pritty graduated from Glasgow University, in 1958, with a BSc in electrical engineering. After some 15 years of involvement in research and development in industry he joined the Department of Computer Science at Strathclyde, in 1973. Here he has continued his research interests in process control, robotics and numerical control systems.