Jump to content

A Blast From The Past


Recommended Posts

post-2-1097202332.gif?width=400


And this little lab tool is beta, beta good.

BYTE editors were excited about a beta version of a program that combined a data-flow programming model with an iconic language for scientists. The program was for scientists and engineers who didn't want to become computer whizzes in order to exploit the personal computer's capabilities. The program, called LabView, turned a regular Mac into a general-purpose laboratory tool.

LabView made a splash in the September 1986 issue:

PRODUCT PREVIEW:
LabVIEW:
Laboratory Virtual Instrument Engineering Workbench


An executable block-diagram environment exploiting Macintosh graphics

by G. Michael Vose and Gregg Williams

Editor's note: The following is a BYTE product preview It is not a review. We provide an advance look at this product because we feel that it is significant. A complete review will follow in a subsequent issue.

Scientists and engineers do not deny that computers are important tools in the laboratory. However, they often wish they didn't have to become computer wizards to exploit the potential of the computer. Extending the graphics power of the Macintosh, National Instruments' Laboratory Virtual Instrument Engineering Workbench (LabVIEW) offers a computer programming environment that closely resembles the way scientists and engineers work. Using graphic front panels controlled by executable block diagrams, LabVIEW gives laboratory users a way to create virtual instruments that turn the Macintosh into a general-purpose laboratory tool.

LabVIEW requires a 512K-byte Macintosh and costs $1995. It works with stand-alone instru ments connected to the Macintosh's serial port. and it supports National Instruments' $595 GPIB-MAC interface box and the $1495 MacBus box (see the text box "Using LabVIEW in the Real World" on page 92).

The intended user base for LabVIEW includes engineers and scientists with no programming experience or limited experience with a simple language like BASIC. The components of LabVIEW are the front panel and block-diagram panes for the creation of virtual instruments; a graphic programming language for building front panels and block diagrams; mechanisms for connecting virtual instruments to one another and for linking them to existing C, assembly language, or FORTRAN code modules; built-in I/O functions for reading and writing data to disks or communication ports; and built-in functions for statistical and matrix operations.

Virtual Instruments

A virtual instrument (abbreviated as "instrument" for the rest of the article) in the LabVIEW system consists of two items: a front pa nel and a block diagram. The front panel contains the input and output controls (e.g., dials. switches, and output screens) that represent the data coming into and going out of the instrument (a control's appearance changes when the user manipulates it). The block diagram contains the program that the instrument executes. Each control is represented by an icon in the block-diagram window, and the program appears as a collection of "black box" icons connected in logicdiagram fashion (see the right half of figure 1). If an instrument is to be used inside another instrument, it must also have an instrument icon, which allows the smaller instrument to be used as a black box in the block diagram of the larger instrument.

A Simple Example

We will demonstrate the LabVIEW system with a simple example. Let's say we want to generate, graph, and store sets of random data points in the range of (0, s). (We can store multiple runs of data with the instrument and recall them later, perhaps for use as test data for another instrument.)

Before we start planning the example itself, remember that the randomnumber function supplied with LabVIEW generates numbers in the range (-1, 1). We need a separate virtual instrument that scales a number from the range (-1, 1) to (0, s ), where s is an arbitrary positive scaling factor. Our first task, then, is to create a scaling virtual instrument.

To create a virtual instrument that scales a number from the range (-1, 1) to (0, s ), we first have to understand how we are going to calculate this transformation. If we think of the number as a signal to be processed, we might come up with a block diagram for our virtual instrument like the one in figure 2.

First we must add the appropriate controls to the front-panel window (see the left half of figure 1). In standard Macintosh fashion, we call these items up from menu selections in the Controls menu and the dialog boxes that subsequently appear. By clicking on the open-hand ic on in the tool palette at the top of the display, the cursor changes to the hand shape, called the Grabber, while it is in the front-panel window. We can then move (and in some cases resize) these controls by using the Grabber. In this example, we use a slider switch to represent the input number to be scaled, an input-only digital readout for the scaling factor 5, and an output-only digital readout for the scaled result. When we add controls to the frontpanel window the block-diagram window (which appears when you execute Open Diagram from the File menu) gains corresponding icons. We create the instrument's design in the block-diagram window in figure 1, using icons called by the Functions menu. Again, we use the Grabber to move icons, and the wiring tool (the spool-of-wire icon in the top row) to draw the connections between icons. The scaling instrument is now complete. We can test it by using the operate tool (pointing finger) to move the slider switch (thus changing its value) and edit the scale value. W hen we click on the Go icon on the menu bar, LabVIEW executes the program defined by the block-diagram window and puts the result in the front-panel window. Note that the input value 0, which is in the middle of the interval (-1, 1), translates to 5 on a scale of (0, 10).

The two remaining tools in the tool palette are the labeling tool, which is an I-beam cursor acquired by clicking on the large A icon, and the magnifying-glass-shaped help tool, which displays tutorial information on whatever feature of LabVIEW it is used to click on.

This instrument can be saved, recalled, and run as is. However, we must do one more thing to use it inside other instruments: create a distinctive icon for it. Through selections in the Format menu, you can draw an arbitrary icon, divide its area into rectangular regions, and associate each region with an input or output control. Then within a larger instrument, wires that connect to these regions will be taken as sending or receiving values consistent with the corr esponding controls.

The screen dump of figure 1 was taken while the connection points on the scaling instrument's icon were being defined. The icon is represented here by the dark square in the upper left corner of the front-panel window. At this particular moment, the upper left corner of the icon (blackened) is associated with the slider switch (outlined with dashes). The finished icon for the scaling instrument, visible in figure 3, has two inputs, labeled IN and SCA (scale), and an output labeled OUT.

Building the Graphing Instrument

The construction of the final instrument, which generates the random numbers and scales and graphs them, proceeds similarly to that of the scaling instrument. (The data can be saved in a step unrelated to the instrument definition.) We begin by creating an input control for the number of points to be generated (e.g., a different kind of slider switch), an inputonly numeric window for the scaling factor. and a graphic-output window (see the lef t half of figure 3).

The block-diagram window contains several new items. The icon marked IN/OUT/SCA represents the scaling instrument we just designed. The icon with the graphed points is another predefined instrument that takes a list of numbers, pairs the entries with the numbers 0, 1, 2 and outputs them as a composite structure of data (note the thick striped line) suitable for use by the graphic control. The triangle with the two dice in it is the random-number-generating function.

The most important item in the block-diagram window is the large box that looks like a stack of stationery; in the LabVIEW system. this represents a FOR loop. The contents of the box will be executed a set number of times. The box labeled N determines the number of iterations (here it receives its input from the Number of Points slider switch on the front panel).

As before, to run this instrument, we set the number of data points and the scaling factor using the operator tool, then hit Go. When LabVIEW is finished, it displays the new data in the graphic control, automatically scaling both axes to fit the data.

Controls

Now that we've seen an example, let's look at the LabVIEW controls in detail. Controls are the components of the front-panel window that define the inputs to and the outputs from the instrument. Controls are input-only or output-only, meaning that they will receive values from the front panel or display them.

We have seen numeric controls as both input and output controls. At any time, the user can change the control's appearance, the range of valid values, and other characteristics. (LabVIEW also offers a strip-chart numeric control that displays a running history of the variable's values as they scroll off to the left.) String controls differ from numeric controls in that they hold character strings as values; they usually appear as boxes within which text can appear. Binary controls contain a simple 1-bit value; they can appear as a variety of toggle switche s, buttons, and indicator lamps whose appearances change when their states change.

Numeric, string, and binary controls all share the ability to be multidimensional; that is, a single control can represent more than one value. For example, an indicator lamp can be declared as a 2 by 4 by 3 array of binary values. Such a control appears on the front panel as an indicator lamp with three boxes beside it that contain the indexes of the value currently being displayed. By changing the values inside the boxes, you can look at the values of individual elements in the array. LabVIEW supports controls that have up to eight dimensions.

Graphic controls are simpler; as output, they display an ordered set of x,y pairs as a line graph. National Instruments plans for the graphic controls to have additional options in the finished product.

The last type of control is a cluster control, which allows you to group an arbitrary collection of data items together so that they can be represented as a si ngle line in the blockdiagram window instead of as multiple lines. For example, the X(i)-versus-i instrument in figure 3 contains a single cluster that transforms the list of X(i) data and an internally generated list of i values into the data structure that the graphic-output control requires.

Compiled Instruments

The designers of LabVIEW realize that you may need functions that cannot be accomplished with high-level userdefined instruments. They also realize that you may already have data acquisition routines written in a highlevel compiled language that you do not want to give up. To meet this situation, LabVIEW has the ability to link the parameters of a compiled subroutine (called, in Macintosh terminology a code resource file) to front-panel controls. In this way you can tie your routine to an instrument icon and use it anywhere in the LabVIEW system. National Instruments plans to offer Macintosh users the ability to link to routines written in C, as sembly language. and FORTRAN, with links to other compiled languages possible in the future.

G-The Graphics Programming Language

LabVIEW's programming language, called G, uses icons in place of keywords but tosses in a few textural compromises to overcome the intrinsic limitations of a pictographic lexicon. The LabVIEW programmer uses the icons to build the block diagrams that define the function of a virtual instrument.

The language offers a special set of flow-of-control structures and a wiring mechanism to connect them. These wired structures define the flow of data among the parts of a block diagram. In addition, the language provides standard and special arithmetic functions plus a broad array of special functions for input/output, string manipulation, and scientific and engineering tasks (see table 1 for a list of specific functions available). The compromises to the iconic scheme of the language include a calculator that permits the use of formulas within virtual instru ments and a provision for linking traditional program code to existing instruments.

Building Blocks

Computer science theorists have shown that any algorithm can be built successfully with three structures: an iterative loop, an IF...THEN...ELSE structure, and a DO...WHILE loop. Any system with these structures can be called a programming language. Using these criteria, LabVIEW's iconic underpinnings can be called a language.

G provides five flow-of-control structures: a sequence structure; an iterative, or FOR, loop; a case selection structure; an indefinite, or WHILE, loop; and a set of shift registers that permit the recursive use of the iterative and indefinite loops. These graphic structures permit structured programming in a data-flow environment.

The sequence structure of G allows the LabVIEW programmer to specify the order of execution of any set of operations. Icons that look like frames of film (see figure 4) represent the separate ordered steps in a series of seq uential operations. A number in the upper middle area of each frame displays the sequence number of the frame currently selected.

An instrument's sequence frames execute in strict order; that is, frame one must finish execution before frame two can begin. Interestingly. structures within a frame, such as a FOR structure, can execute in parallel with other such structures. Sequences, however, like nodes in a traditional data-flow model, cannot execute until a prior condition is satisfied, namely, the arrival of dependent data. Sequences help, in fact, to defeat LabVIEW's inherent parallelism. For example, in a three-sequence instrument, you cannot specify that execution begins with the second frame in the sequence; execution always begins with the first frame. The execution signal for the start of the second frame in the sequence is the availability of all outgoing data at the border of the first frame.

Variables within a sequence frame are local to that frame, but local variable data can pass from a lowernumbered frame to a higher one.

The G control structure for iterative operations is a FOR loop (see figure 4). A pair of special variables local to the loop hold the total number of iterations and the value of the current iteration, or index. It is possible to pass arrays of data into an iterative loop or to perform operations on indivdual elements using the value of the index to extract values. All the operations placed inside the icon representing the loop execute for every iteration of the loop.

The case selection structure in G permits you to the execute several operations within the structure by using a selector value to determine the operation to be performed. The selector value must be an integer between 0 and n. You must use the case structure to perform the equivalent of IF.. .THEN...ELSE comparisons in G. The indefinite, or WHILE, loop is similar to the FOR loop with one major difference. Loop execution depends on a test of a specified condition, usually a Boolean conditional. As with FOR loops, you can pass data arrays into the loop. You can also pass individual array elements into an indefinite loop. Even though the LabVIEW manuals call this a WHILE loop, it is actually an UNTIL loop that always executes at least once, even when the conditional is set at zero. The shift registers of G allow an iterative or indefinite loop to execute recursively. A shift-register set includes a leaf node and two or more root nodes. You can use multiple sets of shift registers. Since many programming situations demand the use of past, or existing, data, G's shift registers offer a method for accumulating this data, The data shifts from register to register. with the initial value of the leaf node passing to the first root node and that node's value passing to the second root node.

Connecting the Parts

Since the underlying programming model for G is data flow, the connections between control structures, constants. variables, and input/output controls are extremely important. The iconic representation of the paths on which data flows among the G components is wire. The wiring tool is used to connect block-diagram parts. The appearance of a wire reveals details of the type of the data that travels that path. For example, a thin wire represents a flow of single numbers, while a medium-size wire with a hatched border represents a multidimensional array of strings (see figure 5). A dashed wire denotes a bad connection, which is a data path that is not possible.

When G programmers connect two G program structures together with the wiring tool, they do not have to know what kind of wire to use. G chooses the appropriate data type for the data path based on the kind of structures that are being connected. G knows, for example, that plotting values on a graph means that the data flowing to the graph will be at least a two-dimensional array of numbers.

The appearance of the wires often changes at the border of a control structure due to data transformations taking place at the border. The values that a FOR loop's operations generate. for example, accumulate into an array at the loop border. and this array of values travels along a data path to another component. In this way the change in the appearance of the wire from a thin line to a thicker line signals that a data transformation has occurred.

LabVIEW programmers have four basic data types at their disposal: real numbers and arrays of reals, Booleans and arrays of Booleans, strings and arrays of strings, and structures that are analogous to structures in C.

Constants, Variables, and Arithmetic Functions

You load G program variable values into controls on an instrument's front panel. The controls represent variables on the underlying block diagram, and these values are then used when the program, the virtual instrument. runs. Constants function similarly except that you load their values at the block-diagram level.

Arithmetic functions in G are as rich as in any other imperative language. A ddition, subtraction, multiplication, and division are supplemented by complex functions such as exponentiation, binary and logical functions, transcendentals, and special functions like square root and random-number generation. Table 1 lists the full set of available functions.

A calculator solves the problem of screen clutter for implementing complicated formulas or equations in G. One of the calculator's inputs takes a string containing one or more formulas and uses this formula string to process up to five numeric inputs to produce up to four numeric outputs. The calculator is itself a virtual instrument. and its underlying block diagram can be displayed to aid in the debugging of entered formulas.

Input/Output, String, and Other Functions

The LabVIEW system's design targets scientists and engineers as primary users. The system's designers have incorporated within the G language a number of specialized functions aimed specifically at these users.

In addition to s tandard file input/ output functions, LabVIEW provides built-in functions to manage GPIB communications between a Macintosh and stand-alone instruments or board-level devices. These functions go beyond merely passing ASCII strings containing GPIB commands, providing functions to reset the bus, triggering instrument events, and giving GPIB status information.

A variety of signal-processing functions. like fast Fourier transform, convolution, correlation, power spectrum, integration, and differentiation are planned in the release version of LabVIEW although they were not in the software we worked with. National Instruments also promises statistical functions, matrix manipulation functions, and curve-fitting routines in the initial release of LabVIEW.

Caveats

When we wrote this article, there were a number of claimed features for LabVIEW that were not yet complete so we cannot describe exactly how they will work. We worked with at least three pre-beta versions of LabVIEW over a p eriod of three months in compiling this preview, the last of which was version 0.35. We found that the mechanism for programmable data retrieval of past instrument runs was unreliable. The Options function for choosing certain features of input/ output controls wasn't working, and several of the planned built-in functions were not yet available. Some of the alternate graph styles were not yet added. These alternate graphs will include polar plots and scattergrams as well as the ability to plot multiple sets of data on one graph.

Conclusions

Many of LabVIEW's features show great promise. Its pop-up menus are context-sensitive; the menu you get depends on the icon you are touching when you call for it. These contextual menus make creating front panels and block diagrams easier and less prone to error. Pop-up menus are consistent with the Macintosh user interface and are usually better than the dialog boxes that they replace.

The amount of housekeeping that LabVIEW performs-letti ng the programmer forget about data types, for example-makes the system easy to use by not requiring you to be a programmer. LabVIEW does type-checking automatically, and there is essentially no such thing as a syntax error (dashed lines representing improper wiring connections excepted) when using icons for programming. LabVIEW initializes and maintains loops automatically, and its block diagrams make programs self-documenting.

The metaphor of the front panel and its underlying block diagram is intuitive and creates a comfortable user interface. The different versions of LabVIEW that we've seen show a good design sense with the addition of new features when necessary, Logical debugging of block diagrams can be tedious, however. The program's multiple cursors (tools) can be confusing, such as deciding whether to use the Grabber tool or the Pointer. The system is also constrained by its application being limited to engineering uses and by its existence on a Macintosh in a world dominated by IBM PCs.

There are some intrinsic contradictions in LabVIEW. What LabVIEW calls a WHILE loop is actually an UNTIL statement. The case icon must be used for an IF...THEN...ELSE construct.

The screen space within a block diagram may be a limiting factor in LabVIEW's practical application. A single virtual instrument can't be very complex since there's room for only a finite number of operations within a single screen. You can nest virtual intruments without limit, but this doesn't guarantee that you can build complex structures with 10 or 20 branches versus the 2 to 3 branches that can easily fit on a screen.

LabVIEW uses the Macintosh's SANE math library, providing full IEEE-7 54 floating-point compatibility, SANE yields 80-bit precision for floating-point operations and gives a dynamic range of -1.7E-4932 to 1.IE+4932. Loop counters are always cast to integers and are currently limited to the range 0 to 2*32.

National Instruments claims that LabVIEW's performance is equal to BASIC's, but many labor atory applications may require better performance than that. However, the capability to link code resources to virtual instruments may negate this performance limitation.

Overall, using LabVIEW is an exciting experience that may give us a peek into the future. Will the data-flow programming model and objectoriented programming techniques merge into an iconic language of the future? Maybe LabVIEW is a step in that direction.
Table 1: Built-in functions in LabVIEW

Arithmetic:
+, -, *, /, **(exponentiation), min, max, neg, abs, inv,
AND, OR, XOR


Comparative:
=, not =, >, > -,
<
,
<
=, = 0, not = 0, >0, > = 0,
<
0,
<
=0


Transcendental:
sin, cos, tan, asin, acos, atan, sinh, cosh, tanh,
log, exp, sqrt, In


String:
string concatenation, substring, parse string, string to
numeric, numeric to string, string compare, string length,
null-string detection, ASCII-string detection


Statist
ical:
mean, variance, standard deviation, histogram, mode,
median, moments, residues


Matrix:
transposition of dimension, lesser-dimension subsets,
subarrays, individual element manipulation, dot product, cross
product, matrix multiply, inversion


Curve fitting:
linear, polynomial, exponential


Signal processing:
FFT, inverse FFT, convolution, correlation, power
spectrum, integration, differentiation

Biography:

G. Michael Vose and Gregg Williams are senior technical editors for
BYTE. They can be contacted at BYTE, One Phoenix Mill Lane,
Peterborough, NH 03458. Copyright
  • Like 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.