You are on page 1of 13

what Is Data Acquisition?

Data acquisition, or DAQ for short, is simply the process of measuring a real-world
signal, such as a voltage, and bringing that information into the computer for
processing, analysis, storage, or other data manipulation. LabVIEW can command
DAQ devices to read analog input signals (A/D conversion), generate analog
output signals (D/A conversion), read and write digital signals, and manipulate the
on-board counters for frequency measurement, pulse generation, quadrature
encoder measurements, and so on, to interface with the transducers. In the case of
analog input, the voltage data from the sensor goes into the plug-in DAQ devices
in the computer, which sends the data into computer memory for storage,
processing, or other manipulation.
Shift Registers
Shift registers, available for While Loops and For Loops, are a special type of
variable used to transfer values from one iteration of a loop to the next. They are
unique to and necessary for LabVIEW's graphical structure; we'll talk more about
their uses in a little while. You create a shift register by popping up on the left or
right loop border and selecting Add Shift Register from the pop-up menu.
The Feedback Node
Generally, LabVIEW does not allow you to create a "cycle," where the output of
block of code is used as the input for the same block of codeand attempting to do
so will cause wires to become broken. You can see an example of a "cycle" in
Figure 6.22. The cycle is broken due to the data flow rules, which state that (1) a
node cannot execute until data flows into all of its input terminals and that (2) data
does not flow out of a node's output terminals until the node finishes executing.
Because a "cycle" uses the output terminals as a source for the input terminals, data
can never flow into the input terminals because data will never flow out of the
output terminals, because the node will not run until data flows into the input
terminalsquite a paradox.

However, if we are inside a While Loop or For Loop, we can place a Feedback
Node in between the output terminal and the input terminal, and our code will now
work. You can see an example of this in Figure 6.23. In fact, by default, LabVIEW
will automatically place a Feedback Node in your cycle, when it is created, if you
are inside a While Loop or For Loop. This setting is controlled by the Auto-insert
Feedback Nodes in cycles checkbox in the Block Diagram section of the
LabVIEW options dialog.
The Case Structure :If a Boolean value is wired to the selector terminal, the
structure has two cases: FALSE and TRUE. If a numeric or string data type is
wired to the selector, the structure can have from one to almost unlimited cases.
Initially only two cases are available, but you can easily add more. You can specify
more than one value for a case, separated by commas, as shown in the previous
diagram. In addition, you typically must select a "Default" case that will execute if
the value wired to the selector terminal doesn't match any of the other cases; this is
very handy when you can't think of every possible case but want to specify a
"catch-all" case.
Wiring Inputs and Outputs:The data at all Case Structure input terminals
(tunnels and selector terminal) is available to all cases. Cases are not required to
use input data or to supply output data, but if any one case outputs a value to a
tunnel, all must output a value (unless Use Default If Unwired, which we will
discuss in a moment, is enabled from the pop-up menu of the output tunnel). When
you wire an output from one case, a little white tunnel appears in the same location
on all cases. The run arrow will be broken until you wire data to this output tunnel
from every case, at which time the tunnel will turn black and the run arrow will be
whole again (provided you have no other errors). Make sure you wire directly to
the existing output tunnel, or you might accidentally create more tunnels.
The Sequence StructureFlat or Stacked: Determining the execution order of a
program by arranging its elements in a certain sequence is called control flow.
Visual Basic, C, and most other procedural programming languages have inherent
control flow because statements execute in the order in which they appear in the
program. LabVIEW uses the Sequence Structure to obtain control flow within a
dataflow framework. A Sequence Structure is an ordered set of frames that execute
sequentially. A Sequence Structure executes frame 0, followed by frame 1, then
frame 2, until the last frame executes. Only when the last frame completes does
data leave the structure.

Timing
It's "time" for another digression. Timing functions are very important in
LabVIEW and help you measure time, synchronize tasks, and allow enough idle
processor time so that loops in your VI don't race too fast and hog the CPU.

Wait Until Next ms Multiple causes LabVIEW to wait until the internal clock
equals or has passed a multiple of the millisecond multiple input number before
continuing VI execution; it is useful for causing loops to execute at specified
intervals and synchronizing activities (see Figure 6.53). These two functions are
similar, but not identical. For example, Wait Until Next ms Multiple will probably
wait less than the specified number of milliseconds in the first loop iteration,
depending on the value of the clock when it starts (that is, how long it takes until
the clock is at the next multiple and the VI proceeds).
What Are Arrays?
Array elements are accessed by their indices; each element's index is in the range 0
to N-1, where N is the total number of elements in the array. The one-dimensional
(1D) array shown here illustrates this structure. Notice that the first element has
index 0, the second element has index 1, and so on.

Index 0 1 2 3 4 5 6 7 8 9

10-Element Array 1 3 8 8. 4. 5. 6. 1. 2. 1.
2 2 2 0 8 1 0 0 5 7

Using Auto-Indexing
The For Loop and the While Loop can index and accumulate arrays at their
boundaries automaticallyone new element for each loop iteration. This capability is
called auto-indexing. One important thing to remember is that auto-indexing is
enabled by default on For Loops but disabled by default on While loops.

TWO DIMENSIONAL ARRAYS


Functions for Manipulating Arrays
Initialize Array will create and initialize an n-dimensional array with the value of
your choice. You can configure it for larger dimensions by "growing" it with the
Positioning tool to provide more dimension size inputs. This function is useful for
allocating memory for arrays of a certain size or for initializing shift registers with
array-type data

Initialize Array shows how to initialize a ten-element, one-dimensional array of


DBL numerics, with each element of the array containing a zero.
Array Subset returns a portion of an array starting at index and containing
length elements (see Figure 7.24). Notice that the third element's index is two
because the index starts at zero; that is, the first element has an index of zero
(see Figure 7.25).

Delete From Array deletes a portion of an array starting at index and


containing length elements (see Figure 7.29). Similar to the Array Subset
function, Delete From Array returns subset of an array, but it also returns the
original array minus the deleted subset (see Figure 7.30).
Polymorphism
polymorphism of the LabVIEW arithmetic functions, Add, Multiply, Divide, and
so on. Polymorphism is just a big word for a simple principle: the inputs to these
functions can be of different size and representation. For example, you can add a
scalar to an array or add two arrays together using the same function. Figure 7.33
shows some of the polymorphic combinations of the Add function.

In Figure 7.34, each iteration of the For Loop generates one random number
(valued between 0 and 1) that is stored in the array created at the border of the
loop. After the loop finishes execution, the Multiply function multiplies each
element in the array by the scaling factor you set. The front panel array indicator
then displays the scaled array
String:
You should know that some commonly used non-printable characters, such as
space (0x20), tab (0x09), carriage return (0x0D), new line (0x0A), and so on are
not shown in "\" codes display with a hexadecimal value following the backslash
(\). Instead these common non-printable characters have a single lowercase letter
that represents the non-printable character. For example, you will never see "\20"
(0x20 is the hexadecimal value of the space character), only "\s" (the "\" code of
the space character). In fact, if you type "\20" into a string that is configured for "\"
codes display, the "\20" will immediately be converted to "\s."

Choose Your Own Display Type


String Functions

File Input/Output

From the Write To Measurement File Express VI configuration dialog , you can
specify how a file will be formatted, and what data to store in the file.
From the Read From Measurement File Express VI configuration dialog , you can
specify the format of the file to be read. If you press the Read File Now button,
LabVIEW will read the file once and populate the Sample Data table to show you
whether the read operation worked successfully.

You might also like