Printer Friendly

A laboratory graphic data acquisition system.

OVER THE LAST 15 years, programs for gathering data in real time have evolved from simple programs, written in assembly language or BASIC, to slick new products, marketed by a number of companies, that feature eye-pleasing graphic interfaces. Graphic User Interfaces (GUIs, pronounced GOO-eys) are implemented in different ways on many systems, but probably none so popularly as featured in the Windows (Microsoft Corp., Redmond, Wash.) operating environment for PCs. GUIs are characterized by windows with on-screen "buttons," "check boxes," "scroll bars," and other types of controls.

Usually these controls are manipulated by a mouse. The keyboard can also be used, although with a lesser degree of control. The mouse is used to "click" on selected items, turn options on and off, and "drag" items around the screen. (To click on a control, the user moves the mouse pointer to the item, then presses the left mouse button and releases it quickly. Dragging involves pointing with the mouse, holding the left button down, dragging an object to another location on the screen, and releasing the button.)

More than visually attractive, these new data acquisition systems are generally powerful, easy to use . . . and expensive. Many cost well over $1,000. Faced with a price tag similar to that of a good low-end PC, one may find the prospect of writing one's own data acquisition system more appealing. The program described here is such a tool.

The Laboratory Data Acquisition & Analysis program (LDAA) runs under Windows, may be configured for virtually any data acquisition hardware (analog-to-digital converter, or ADC), and has the following features:

* Graphic user interface;

* User-specified acquisition rate;

* Digital smoothing;

* Graphic plotting and printing;

* Unit transformation; and

* Data export to file.

In most programming environments (Assembly Language, BASIC, C, and others), writing a program that gathers, manipulates, and stores data is fairly straightforward and relatively simple. A graphic interface, on the other hand, can become a major project. Considerable planning of control layout, appearance, and function must be completed before a single line of code is written. Voluminous amounts of programming are typically required to execute such an interface; mouse control adds a dimension of complexity. The last thing one hopes to do at this point is to make changes in the newly designed GUI, which would require editing the computer program.

A new class of programming tools has turned GUI-based programs completely around. Now the graphic interface is the easiest part of the project, so that developing the graphics becomes almost trivial. Instead of writing code for each control, one selects the desired function from a "toolbox," drags it over to the application screen, and sizes it dynamically by dragging the sides (frame) with the mouse. Controls may be placed anywhere on the screen and moved around at any time without editing a single line of programming code. An entire application's layout, size, color, and other features may be entirely altered within a few minutes until satisfactory. While a number of similar products are available, the project described here uses a package from Microsoft called Visual Basic (VB). Its list price is $195; the careful shopper can find it for around $125.

* Visual Basic programming. Although Visual Basic has its roots in the BASIC programming language, there are two significant differences. First, Visual Basic makes Windows application programming far easier than assembly language or C programming, the classic Windows programming languages that put such projects out of reach for millions of BASIC programmers. (Microsoft recently announced a non-Windows, DOS-based version of Visual Basic.) Second, Visual Basic is an event-driven programming language, in contrast to the linear programming techniques of BASIC, C, and spreadsheet macros.

In linear programming, a series of steps defines a program; when they are executed, the computer performs each task, one after the other. Event-driven programming requires the programmer to define what needs to be done when various specified events occur. Events refer primarily to user interactions: clicking on a control or window, typing in a text box, selecting items from a menu, and many others. Writing an event-driven program takes a bit of getting used to, but in the long run it is easier than linear programming.

The hierarchy and terminology used to describe the structure of a Visual Basic program will be new to most programmers. A Visual Basic application program is referred to as a Project. A project is composed of one or more Forms, which are displayed as windows on a user's screen. Each form may contain any number of Controls, such as command buttons, picture boxes, text boxes, and scroll bars.

Visual Basic v1.0 has 15 different controls. Each has its own set of properties, such as color, initial settings, captions, and font attributes (size, typeface, underline, italic, and so on). Controls are generally created and properties set at design time (when the program is being written), but these may also be implemented at run time (when the program is executed), under program control.

The first step in writing a Visual Basic program is to design the user interface. This involves determining the number of necessary forms, deciding what controls are needed for each, placing the controls on each form, and setting attributes for each control. This primary step entails no traditional computer programming; it consists solely of dragging, clicking, and selecting from menus.

The next step is to decide what events need a response from the program. What should happen when the user clicks on the Cancel button or enters text in a text box? Each event for each control requires a separate subprogram. Although each control can detect roughly a dozen events, not all need to be programmed; if no code is written for a given event, no action is taken if that event should occur.

With the code complete, the program may be run while still in the Visual Basic environment. The logic of the program may be checked and debugged at this point by setting breakpoints in the program and single-stepping through instructions. The debugging facility of Visual Basic is similar to that of QuickBasic (also from Microsoft) but somewhat less extensive.

The final step is to have Visual Basic produce an executable (that is, an .EXE) file of the project that may be used on any system running Windows without requiring a copy of Visual Basic. One point to remember when running a VB application on another computer is that a file called a Dynamic Link Library (.DLL) file must also be present on the system, which for VB v1.0 is called VBRUN100.DLL. This .DLL file may be freely distributed with a VB application, within the bounds of the Microsoft Visual Basic license agreement.

* LDAA program operation. Once LDAA has been installed and run (see installation details later in this article), the main program form, containing various command buttons and text boxes, is displayed. Clicking on the Start button will begin data acquisition at the rate shown in the associated text box for a period of time indicated by the value just below the rate. The total number of points is calculated by the program (from rate and time) and displayed in the bottom text box. As data are collected, the current number of points is shown in the "n =" text box. Data acquisition will end when the Stop button is clicked or when the calculated total points have been reached.

Clicking on the Plot button will plot the data in a separate window; a typical plot is shown in Figure 3. Double-clicking anywhere in this window will send the plot to the printer. Various plot options may be specified by clicking on Plot Options from the menu bar, which displays another window. By checking the desired boxes, the user can plot raw and/or smoothed data, with or without grid lines.

The Smooth button will perform a digital smoothing on the collected data. By default, the smoothing technique is a simple, non-weighted sliding window, with a window size of 10. This means that a new array of data is built where each raw data point is replaced by the mean of the data within a window of 10 surrounding it. The original data are not lost in this process. Clicking on Smooth options from the menu bar will bring up another options window, where the type of smoothing and the window size are selectable. The window size may be directly typed into the text box, or the "slide" control may be used to adjust the value up or down.

Clicking on the Transform button allows the user to set a slope and offset value to be used in transforming the raw data. This feature would be used, for example, when collecting data from a spectrophotometer where the on-screen readout should be in absorbance units instead of voltage values. When the slope=1.00 and the offset=0.00 (the default values), the readout represents the raw output of the ADC.

The Clear command button erases the values in both the raw data and smoothed arrays, and resets n back to zero. The system is then ready for acquiring new data.

The last form is the Save As submenu, accessed from File on the menu bar. A file name is chosen by typing the desired name or by selecting an existing one from the file list box (another VB control). Alternate drives or directories may also be selected from the appropriate areas in this window. Clicking on the Save button of this form will save the data to a flat ascii file, which is appropriate for import to other applications such as spreadsheets, databases, and word processors. Attempting to save data to an existing file will display a prompt requesting confirmation of the action, which will overwrite the previous data.

* Technical aspects. The file LDAA.EXE will run on any IBM PC clone that is running Microsoft Windows v3.0 or above. The PC also requires some sort of ADC board that digitizes analog voltages from instruments or other sources. Virtually any type of board may be used, such as a "homebrew" system for under $100 (to be described in full in a future column of this department) or the popular, low-cost ($425) DAS-8 from MetraByte (Keithley Data Acquisitions, Taunton, Mass.). The DAS-8 is an 8-channel, 12-bit system that gives resolutions of one part in 4096, adequate for most clinical laboratory applications. The same company also makes the less-expensive DAS-4 ($199). Because it is an 8-bit system with a resolution of only one part in 256, however, it is unsuitable for most laboratory applications.

Files required to run LDAA:

* LDAA.EXE, the main executable program;

* LDAA.CFG, the configuration file (adapts LDAA to virtually any ADC);

* VBRUN100.DLL, the Runtime Dynamic Link Library for VB programs;

* INPOUT.DLL, the Runtime Dynamic Link Library for INP/OUT functions; and

* SPECT*.DAT, optional demo data files.

The file INPOUT.DLL is required because VB v1.0 lacks built-in functions to access hardware ports, which is necessary in obtaining information from the ADC. The optional demo data files contain spectral data: SPECT1.DAT is a smooth curve, while SPECT2.DAT through SPECT8.DAT have the same data with varying amounts of random noise added. The latter demo files allow a user to investigate the effects of digital smoothing and graphically see how larger window sizes increase smoothing while decreasing resolution.

All of these files must be copied to a new directory onto the hard disk, preferably called C:\LDAA.LDAA.CFG should be edited (with any text editor, such MS-DOS 5.0's EDIT.COM) to match the installed ADC. Windows may now be started. From Window's Program Manager, the file LDAA.EXE may be added to a program group or executed directly by typing <Alt F> <Alt R> to access the run window. In the Command Line: box, the program name, with full path, is typed:


To use one of the demo files, append the name of the desired file to the command line, preceded by a space. For example, to use the file SPECT1.DAT, type:


If a demo file name is specified, hardware calls to the ADC are disabled; data are generated when the program reads the named file at the specified rate.

* Obtaining the program. You can download LDAA.EXE v1.0 and all support files 24 hours a day, at no charge, from Med TechNet, the on-line information system operated by Western New York Microcomputer, Inc. The phone number for modem users is (716) 688-1552 (8 data bits, 1 stop bit, no parity, 300 to 16800 baud). You'll have to download two files from File Area #10 (Med Tech-Ware): LDAA.ZIP (18,000 bytes), which contains LDAA.EXE and support files, and VBRUN100.ZIP (170,000 bytes), the required Dynamic Link Library. At 2400 baud, this download will take about 15 minutes. Other VB demonstration files are also available for download on Med TechNet. Since they all require the same VBRUN100.DLL, there is no need to download additional copies of that file.

Alternatively, to receive these files on disk, specify the required disk size (360K, 720K, 1.2M, or 1.4M) and send a check for $10.00 postpaid (in U.S. funds; outside the U.S., add $5.00) to: WNY Micro, Inc., MLO/LDAA Disk, P.O. Box 84, East Amherst, NY 14051.

LDAA.EXE v1.0 will be distributed with fully commented source code and is intended as a learning tool for Visual Basic. This and future versions will be user supported via the Med TechWare Conference Area (#10) on Med TechNet. Users are encouraged to leave questions, comments, and suggestions for enhancement on the bulletin board or to send them to the author by E-mail at bill

The author is president of Western New York Microcomputer, Inc., East Amherst, N.Y., and clinical assistant professor, department of medical technology, State University of New York at Buffalo.
COPYRIGHT 1992 Nelson Publishing
No portion of this article can be reproduced without the express written permission from the copyright holder.
Copyright 1992 Gale, Cengage Learning. All rights reserved.

Article Details
Printer friendly Cite/link Email Feedback
Author:Hliwa, William R., Jr.
Publication:Medical Laboratory Observer
Date:Oct 1, 1992
Previous Article:Part-time curricula can promote student recruitment.
Next Article:How to build supervisors' management skills.

Related Articles
Tips on buying microcomputer hardware and software.
Integrated software: a quick way to audit turnaround time or paid hours.
Personal computers in the lab: what will the future bring?
Getting the most out of your old LIS.
CIM systems.
A PC buyer's primer.
Material testing software.
Fully integrated modular software package introduced.

Terms of use | Copyright © 2017 Farlex, Inc. | Feedback | For webmasters