Sei sulla pagina 1di 2

Chapter 5 Building the Block Diagram LabVIEW User Manual 5-24 ni.

com Figure 5-5 shows wiring objects


with compatible units. In this figure, LabVIEW automatically scales the distance indicator to display
kilometers instead of meters because kilometers is the unit for the indicator. Figure 5-5. Wiring Objects
with Compatible Units An error occurs in Figure 5-6 because distance has a unit type of seconds. To
correct the error, change seconds to a unit of distance, such as kilometers, as shown in Figure 5-5. Figure
5-6. Wiring Objects with Incompatible Units Results in Broken Wires Some VIs and functions are
ambiguous with respect to units. You cannot use these VIs and functions with other terminals that have
units. For example, the Increment function is ambiguous with respect to units. If you Chapter 5 Building
the Block Diagram National Instruments Corporation 5-25 LabVIEW User Manual use distance units,
the Increment function cannot tell whether to add one meter, one kilometer, or one foot. Because of
this ambiguity, you cannot use the Increment function and other functions that increment or decrement
values with data that have associated units. To avoid ambiguity in this example, use a numeric constant
with the proper unit and the Add function to create your own increment unit function, as shown in
Figure 5-7. Figure 5-7. Creating an Increment Function with Units Block Diagram Data Flow LabVIEW
follows a dataflow model for running VIs. A block diagram node executes when all its inputs are
available. When a node completes execution, it supplies data to its output terminals and passes the
output data to the next node in the dataflow path. Visual Basic, C++, JAVA, and most other text-based
programming languages follow a control flow model of program execution. In control flow, the
sequential order of program elements determines the execution order of a program. In LabVIEW,
because the flow of data rather than the sequential order of commands determines the execution order
of block diagram elements, you can create block diagrams that have simultaneous operations. For
example, you can run two While Loops simultaneously and display the results on the front panel.
Chapter 5 Building the Block Diagram LabVIEW User Manual 5-26 ni.com LabVIEW is a multitasking and
multithreaded system, running multiple execution threads and multiple VIs simultaneously. Refer to the
Using LabVIEW to Create Multithreaded VIs for Maximum Performance and Reliability Application Note
for more information about performing tasks simultaneously in LabVIEW. Data Dependency and
Artificial Data Dependency The control flow model of execution is instruction driven. Dataflow execution
is data driven, or data dependent. A node that receives data from another node always executes after
the other node completes execution. Block diagram nodes not connected by wires can execute in any
order. Although the LabVIEW Development Guidelines manual recommends using a left-to-right and
top-to-bottom layout, nodes do not necessarily execute in left-to-right, top-to-bottom order. You can
use a sequence structure to control execution order when natural data dependency does not exist.
Refer to the Sequence Structures section of Chapter 8, Loops and Structures, for more information
about sequence structures. You also can use flow-through parameters to control execution order. Refer
to the Flow-Through Parameters section of Chapter 14, File I/O, for more information about flow-
through parameters. Chapter 5 Building the Block Diagram National Instruments Corporation 5-27
LabVIEW User Manual You also can create an artificial data dependency, in which the receiving node
does not actually use the data received. Instead, the receiving node uses the arrival of data to trigger its
execution. Refer to the Timing Template (data dep) VI in the examples\general\structs.llb for an
example of using artificial data dependency. Missing Data Dependencies Do not assume left-to-right or
top-to-bottom execution when no data dependency exists. Make sure you explicitly define the sequence
of events when necessary by wiring the dataflow. In the following example, no dependency exists
between the Read File function and the Close File function because the Read File function is not wired to
the Close File function. This example might not work as expected because there is no way to determine
which function runs first. If the Close File function runs first, the Read File function does not work.

Potrebbero piacerti anche