Академический Документы
Профессиональный Документы
Культура Документы
Virtual Instrument
LabVIEW works on a data flow model in which information within a LabVIEW program, called a virtual instrument (VI), flows from data sources to data sinks connected by wires. LabVIEW supports two types of VIs--internal VIs and user created VIs. Internal VIs are packaged with LabVIEW and perform simple functions like adding numbers or opening files. User created VIs consist of both a graphical user interface called the front panel and a code pipeline called the block diagram.
FRONT PANEL
Every user created VI has a front panel that contains the graphical interface with which a user interacts. The front panel can house various graphical objects ranging from simple buttons to complex graphs. It also includes nonfunctioning items such as free labels and decorations.
Block diagram
AutomaticToolSelection AutomaticallyselectsbetweentheOperate Value,Position/Size/Select,EditTextandConnectWireTools.Itisthe mostcommonlySelecteditemontheToolsPalette. OperateValue ManipulatesthevaluesofFrontPanelControlsand Indicators.GenerallyselectedwhilerunningaVI. Position/Size/Select SelectsobjectsinaVI,movesthemandresizes them. EditText CreatesFreeLabelsontheFrontPanelandeditstheirtext. AlsoeditstextinOwnedLabels. ConnectWire WiresBlockDiagramnodesandobjectstogether. ObjectShortcutMenu Displaysanobject'spopupmenuwiththeleft mousebutton. ScrollWindow PansthecontentonaVIwindowwithoutusingthe window'sscrollbars.
Set/ClearBreakpoint CreatebreakpointsinaVIBlock Diagramfordebuggingpurposes.BreakpointscausetheVI tosuspendexecutionataparticularpoint. ProbeData PlacesProbesonwiresintheBlockDiagramfor debuggingpurposes.AProbedisplaysthedataonawire whereitisplaced. GetColor CopiescolorsfromVIobjectstopastingwiththe SetColorTool. SetColor ColorsobjectsinaVIanddisplaystheforeground andbackgroundcolorsoftheobject.
DATA TYPES
There are three possible data types in a VI Number- This data type contains numbers that can be either floating point or integer. Boolean - This data type contains logical combinations of TRUE/FALSE, AND, OR, NOT, Etc. String - Contains alpha-numeric characters only All of these data types can be in either Scalar, 1D Array or 2D Array form.
Wire Types
There are different wire colors and types that depict what kind of data is flowing through a particular wire and if it is in Scalar, 1D Array or 2D Array form:
ABBREVATION
Abbreviation I8 U8 I16 U16 I32 U32 SGL DBL EXT
TERMINAL
Terminal
SIZE(BYTES)
Size (bytes) 1 1 2 2 4 4 4 8 16
8 16 32
CHANGING REPRESENTATIONS
WIRING
Wires are data flow paths between Block Diagram components. Block Diagram nodes are wired together for logical functioning of the VI. Deleting wires: Creatingwires:selecttheConnectWiretoolonthetoolspalette
Selecting wires:
RUNNING VI
DEBUGGING VIs
ExecutionHighlight
when pressed, turns bright and allows you to view the data flow through the Block Diagram slowly as it goes from one Block Diagram component to the next. activates the single-step mode which steps the execution of the VI from node to node. Each node blinks then it executes one at a time. activates the single-step mode and is used to step into a loop or Sub VI so you can single step inside them. used to step out of a loop or Sub VI and to end the execution of a VI. used to set breakpoints or stopping points in a VI, especially in a Sub VIs, functions, structures and wires. creates probes on wires in the Block Diagram. It shows the data at that point in a wire at a particular time. It is used for checking intermediate data inside a VI.
SUB VIs
The Sub VI is considered as a lower-level VI inside of an upper-level VI. This reduces the number of Block Diagram icons, which simplifies and modularizes the VI. Sub VIs are much like functions or subroutines in conventional text-based programming languages. Steps in creating sub vi: create sub vi icon Assign sub vi connectors
STRUCTURES
In addition to controls, indicators, and VIs, the block diagram can also contain a number of programming structures that modify the sequence of data flow on the block diagram. LabVIEW currently supports six different structures, -whileloops, case structures, event structures, for-loops, sequence structures, and formula nodes.
WHILE LOOP
A While Loop executes all or a portion of your Block Diagram code multiple times
pseudo-code: Do Execute diagram Inside the loop While the condition is TRUE/FALSE Create a While Loop Block Diagram > Functions > Structures > While Loop Drag a rectangle area around the portion of Block Diagram code that is to be included in the while loop
The conditional terminal is wired to a Boolean Terminal. This terminal represents a Boolean Control (switch) on the Front Panel for the user to control the operation of the while loop.
FOR LOOP
The For Loop repeats Block Diagram code a predetermined number of counted times. When the number of iterations equals the predetermined count, the loop stops. pseudo-code: For i = 0 to N-1 Execute diagram inside the loop Create a For Loop Block Diagram > Functions > Structures > For Loop: then drag a rectangle area around the portion of Block Diagram code that is to be included in the for loop
The Count Terminal The Count Terminal is where the predetermined count is placed. to control the number of iterations. The Iteration Terminal The Iteration Terminal in a for loop It is a terminal that outputs the number of times the loop has been executed. The count starts at zero (the first iteration of the loop is Iteration Zero)
Case structures
The Case Structure is a method of executing conditional statements. The Case Structure is similar to if ... then ... else statements in conventional programming languages. pseudo code: If (Condition = Something) Then Do This Else Do That Endif
Case Structure is configured like a deck of cards. Labview only executes one at a time. case executed is determined by the value wired to the selector terminal
Creating a Case Structure is much like creating While Loops and For Loops. To create a Case Structure, Pop-up in the Block Diagram > Structures > Case Structure. Drag an area for the Case Structure to encompass. Managing case structure
This function: Returns the value wired to the t terminal if the value at the s terminal is TRUE Returns the value wired to the f terminal if the value at the s terminal is FALSE.
SEQUENCE STRUCTURES
used to control the order of execution of nodes that are not data dependent on each other. The nodes within each frame are data dependent The output tunnels of Sequence Structures can only have one data source which, unlike Case Structures, has outputs that must have one data source per case. The output can come from any frame, but the data will not leave the structure until the last frame in the structure has completed it's execution. Data input is available to all frames
CREATING SEQUENCE STRUCTURE:Pop-up in the Block Diagram > Structures > Sequence Structure. Toaddmoreframes,popuponthesequenceboundary>AddFrameAfter SEQUENCE LOCAL: variablesthatallowyoutopassdatabetweenframesofaSequence Structure
FORMULAE NODE
Below is an example of how you would implement y = x^2 + x + 1 with regular block diagram nodes
CreatingaFormulaNode
Pop-up in the Block Diagram > Structures > Formula Node. Add an Input and an Output on the left and right vertical sides of the Formula Node's boundary. The nodes must also be named to match the variables used in the equation. Add them by popping-up on a vertical boundary > Add Input or Add Output. Label them correctly and wire them to the appropriate nodes. Thentypeequationusingthecorrectoperatorsandfunctions.Asemicolonalways followseachformulastatement.
ARRAYS
ARRAY FUNCTIONS
Arrays can also be created and controlled by Array Functions. They are all found by popping-up in the Block Diagram > Functions > Array:
ARRAYSIZE
INITIALIZE ARRAY
BUILD ARRAY
ARRAYSUBSET
ARRAY SEARCHING
Creating One-Dimensional Arrays With a Loop Manually creating and adding data to arrays can be tedious work. So loops are often used to create onedimensional and twodimensional arrays. Both For Loops and While Loops can create arrays and their boundaries automatically with auto indexing.
The outer loop creates the row elements and the inner loop creates the column elements.
To clear an array of data, pop-up on any Index Display > Empty Array:
INDEXING
Indexing is a feature that can be enabled for input and output tunnels of both whileloops and for-loop When an array wire passes into a loop through a tunnel that does not have indexing enabled, the entire array is placed on the wire and can be accessed during each loop iteration. When indexing is enabled, only the array element at the index corresponding to the current loop iteration is available from that tunnel.s by right clicking on a tunnel.
INPUT INDEXING
OUTPUT INDEXING
Polymorphism
Labview arithmetic functions like Add, Multiply, Divide. Etc. are polymorphic. This means that the data structures on their inputs can be either scalar or array. If any inputs are of the array data structure, the output will be an array data structure. If the inputs have array structures of different sizes, the output will be an array that is the same size as the smallest input array.
BooleanControls usually operate like switches. Most of them are in the off position by default (Normally Open). You can control the mechanical action of the Boolean Control by popping-up on it > Mechanical Action
SwitchWhenPressed TheControl'svalueischangedeachtimethe controlispressed.Thisworksmuchlikeastandardlightswitch. SwitchWhenReleased TheControl'svalueischangedwhenthemouse buttonisreleased. SwitchUntilReleased TheControl'svalueischangedwhenthecontrol isclickedandretainsthatvalueuntilthemousebuttonisreleased. LatchWhenPressed TheControl'svaluechangeswhenitisclicked, retainsthatvalueuntiltheVIreadsitonceandthenreverts backtoit's originalvalue.
THANK YOU