labview small

Upload: himpandey13

Post on 05-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 LabVIEW Small

    1/30

    INTELLIGENT SYTEM

    UNIT 1& 2

    1. What is Intelligent System?

    The Intelligent System may define as thesurroundings are everything else that interacts

    with a system. The system may sometimes be further subdivided intosubsystems which

    also interact with each other. This division into subsystems is not necessarily unique.

    (a)Low intelligence: Typically a simple system, it has to be told" everything and needs

    complete instructions, needs low-level control, the parameters are set, it is usually

    mechanical.

    (b)High intelligence: Typically a complex system, it is autonomous to a certain extent

    and needs few instructions, determines for itself what the goals are, demands high-level

    control, adaptive, makes decisions and choices, it is usually computerized.

    There is thus a continuum between these two extremes and most practical devices fall

    later category. Because of this broad definition, all control systems are intelligent to a

    certain extent and in this respect they are similar. However, the more intelligent systems

    are able to handle more complex situations and make more complex decisions. As

    computer hardware and software improve it becomes possible to engineer systems that

    are more intelligent under this definition.

    Some of the specific areas in which intelligent systems have been applied are the

    following: instrument landing system, automatic pilot, collision-avoidance system, anti-

    lock brake, smart air bag, intelligent road vehicles, planetary rovers, medical diagnoses,image processing, intelligent data analysis, financial risk analysis, temperature and flow

    control, process control, intelligent CAD, smart materials, smart manufacturing,

    intelligent buildings, internet search engines, machine translators.

    An intelligent system is a system that perceives its environment and takes actions that

    maximize its chances of success. John McCarthy, who coined the term in 1956, defines

    it as "the science and engineering of making intelligent machines."

    The field of intelligent research was founded at a conference on the campus of

    Dartmouth College in the summer of 1956. The attendees, including John McCarthy,

    Marvin Minsky, Allen Newell and Herbert Simon, became the leaders of intelligent

    research for many decades. They and their students wrote programs that were, to most

    people, simply astonishing: computers were solving word problems in algebra, proving

    logical theorems and speaking English. By the middle of the 1960s, research in the U.S.

    was heavily funded by the Department of Defense and laboratories had been established

    around the world. Intelligent founders were profoundly optimistic about the future of

    the new field: Herbert Simon predicted that "machines will be capable, within twenty

    years, of doing any work a man can do" and Marvin Minsky agreed, writing that

    "within a generation ... the problem of creating 'artificial intelligence' will substantially

    be solved"

  • 7/31/2019 LabVIEW Small

    2/30

    The latest status of intelligent system may not required general computer to compute

    complex analysis. There will be dedicated systems which can take care all complex

    analysis and decision. Infact it may not in the size of general computer. Example:

    Humanoid Robots, Control in Nuclear power plant, Control in Satellites etc.

    If the intelligent system is used in industry like control and monitoring, then it may bein a form of network. To control the network, we will be require a dedicated software

    like LABVIEW, SCADA, DCS etc..

    In this chapter we will be concentrating on the LABVIEW and it also called Virtual

    Instrumentation Software. For more than 20 years, NI LabVIEW has been used by

    millions of engineers and scientists to develop sophisticated test, measurement, and

    control applications. While LabVIEW provides a variety of features and tools ranging

    from interactive assistants to configurable user-defined interfaces, it is differentiated by

    its graphical, general-purpose programming language (known as G) along with an

    associated integrated compiler, a linker, and debugging tools.

    2. A Brief History of the Pursuit of Higher-Level Programming

    To better understand the major value propositions of LabVIEW graphical

    programming, it is helpful to review some background on the first higher-level

    programming language. At the dawn of the modern computer age in the mid-1950s, a

    small team at IBM decided to create a more practical alternative to programming the

    enormous IBM 704 mainframe (a supercomputer in its day) in low-level assembly

    language, the most modern language available at the time. The result was FORTRAN, a

    more human-readable programming language whose purpose was to speed up the

    development process.

    The engineering community was initially skeptical that this new method could

    outperform programs hand-crafted in assembly, but soon it was shown that FORTRAN-

    generated programs ran nearly as efficiently as those written in assembly. At the same

    time, FORTRAN reduced the number of programming statements necessary in a

    program by a factor of 20, which is why it is often considered the first higher-level

    programming language. Not surprisingly, FORTRAN quickly gained acceptance in the

    scientific community and remains influential.

    Fifty years later, there are still important lessons in this anecdote. First, for more than

    50 years, engineers have sought easier and faster ways to solve problems throughcomputer programming. Second, the programming languages chosen by engineers to

    translate their tasks have trended toward higher levels of abstraction. These lessons help

    explain the immense popularity and widespread adoption of G since its inception in

    1986; G represents an extremely high-level programming language whose purpose is to

    increase the productivity of its users while executing at nearly the same speeds as

    lower-level languages like FORTRAN, C, and C++.

    LabVIEW: Graphical, Dataflow Programming

    LabVIEW is different from most other general-purpose programming languages in two

    major ways. First, G programming is performed by wiring together graphical icons on adiagram, which is then compiled directly to machine code so the computer processors

  • 7/31/2019 LabVIEW Small

    3/30

    can execute it. While represented graphically instead of with text, G contains the same

    programming concepts found in most traditional languages. For example, G includes all

    the standard constructs, such as data types, loops, event handling, variables, recursion,

    and object-oriented programming.

    While Loop in G is intuitively represented by a graphical loop, which executes

    until a stop condition is met.

    The second main differentiator is that G code developed with LabVIEW executes

    according to the rules of data flow instead of the more traditional procedural approach

    (in other words, a sequential series of commands to be carried out) found in most text-

    based programming languages like C and C++. Dataflow languages like G (as well asAgilent VEE, Microsoft Visual Programming Language, and Apple Quartz Composer)

    promote data as the main concept behind any program. Dataflow execution is data-

    driven, or data-dependent. The flow of data between nodes in the program, not

    sequential lines of text, determines the execution order.

    This distinction may seem minor at first, but the impact is extraordinary because it

    renders the data paths between parts of the program to be the developers main focus.

    Nodes in a LabVIEW program (in other words, functions, structures such as loops,

    subroutines, and so on) have inputs, process data, and produce outputs. Once all of a

    given nodes inputs contain valid data, that node executes its logic, produces output

    data, and passes that data to the next node in the dataflow path. A node that receivesdata from another node can execute only after the other node completes execution.

  • 7/31/2019 LabVIEW Small

    4/30

    3. Benefits of G Programming

    Intuitive Graphical Programming, Interactive Debugging Tools, Automatic Parallelism

    and Performance, Combining G with Other Languages

    LabVIEW is a program development application, much like various commercial C or

    BASIC development systems, or National Instruments LabWindows. However,

    LabVIEW is different from those applications in one important respect. Other

    programming systems use text-basedlanguages to create lines of code, while LabVIEW

    uses agraphicalprogramming language, G, to create programs in block diagram form.

    You can use LabVIEW with little programming experience. LabVIEW uses

    terminology, icons, and ideas familiar to scientists and engineers and relies on graphical

    symbols rather than textual language to describe programming actions.

    LabVIEW has extensive libraries of functions and subroutines for most programming

    tasks. For Windows, Macintosh, and Sun, LabVIEW contains application specific

    libraries for data acquisition and VXI instrument control. LabVIEW also contains

    application-specific libraries for GPIB and serial instrument control, data analysis, data

    presentation, and data storage. LabVIEW includes conventional program development

    tools, so you can set breakpoints, animate program execution to see how data passes

    through the program, and single-step through the program to make debugging and

    program development easier.

    LabVIEW includes libraries of functions and development tools designed specifically

    for instrument control. For Windows, Macintosh, and Sun, LabVIEW also containslibraries of functions and development tools for data acquisition. LabVIEW programs

    are called virtual instruments (VIs) because their appearance and operation imitate

    actual instruments. However, they are analogous to functions from conventional

    language programs. VIs have both an interactive user interface and a source code

    equivalent, and accept parameters from higher-level VIs. The following are descriptions

    of these three VI features.

    VIs contain an interactive user interface, which is called thefront panel, because it

    simulates the panel of a physical instrument. The front panel can contain knobs, push

    buttons, graphs, and other controls and indicators. You input data using a keyboard and

    mouse, and then view the results on the computer screen.

    VIs receive instructions from a block diagram, which you construct in G. The block

    diagram supplies a pictorial solution to a programming problem. The block diagram

    contains the source code for the VI.

    VIs use a hierarchical and modular structure. You can use them as top-level programs,

    or as subprograms within other programs or subprograms. A VI within another VI is

    called asubVI. The icon and connector pane of a VI work like a graphical parameter

    list so that other VIs can pass data to it as a subVI.

    With these features, LabVIEW promotes and adheres to the concept ofmodular

    programming. You divide an application into a series of tasks, which you can divide

  • 7/31/2019 LabVIEW Small

    5/30

    again until a complicated application becomes a series of simple subtasks. You build a

    VI to accomplish each subtask and then combine those VIs on another block diagram to

    accomplish the larger task. Finally, your top-level VI contains a collection of

    subVIs that represent application functions.

    Because you can execute each subVI by itself, apart from the rest of the application,debugging is much easier. Furthermore, many low-level subVIs often perform tasks

    common to several applications, so that you can develop a specialized set of subVIs

    suited to applications you can construct.

    Front Panel

    This tutorial explores the Front Panel and its relationship with the Block Diagram.

    Learn about the different types of Front Panel objects as well as how to find them on

    the Controls palette and place them on the Front Panel.

    Learn about the different types of Front Panel objects as well as how to find them on

    the Controls palette and place them on the Front Panel. This explores the Front Panel

    and its relationship with the Block Diagram. Learn about the different types of Front

    Panel objects as well as how to find them on the Controls palette and place them on the

    Front Panel. The front panel window is the user interface for the VI. The front panel has

    controls and indicators, which are the interactive input and output terminals,

    respectively, of the VI. Controls and indicators placed on the front panel are

    automatically placed on the block diagram. Refer to the Block Diagram tutorial for

    more information on block diagram terminals.

    Front Panel Window

    When you open a new or existing VI, the front panel window of the VI appears and

    functions as the graphical user interface or GUI of a VI. You can find the source code

    that runs the front panel on the block diagram. The front panel window contains a

    toolbar across the top and a Controls palette that you can access by right-clicking

    anywhere on the front panel.

    After opening the Controls palette, use it to place controls and indicators on the front

    panel.

    Note: Use the thumb tack to pin the Controls palette to the front panel and then selectViewChange Visible Categories.

    In the Change Visible Categories dialog box, clickSelect All and then OKto make all

    available controls and indicators visible on the front panel.

    Controls and Indicators

    Controls knobs, push buttons, dials, and other input devices are the interactive input

    terminals, while indicators graphs, LEDs, and other displays are the interactive

    output terminals of the VI. Controls simulate instrument input devices and supply data

    to the block diagram of the VI. Indicators simulate instrument output devices anddisplay data the block diagram acquires or generates.

  • 7/31/2019 LabVIEW Small

    6/30

    Every control and indicator has a data type associated with it. For example, the Delay

    (sec) horizontal slide is a numeric data type. Double-click the Delay (sec) control to

    make LabVIEW jump to the terminal location on the block diagram. Notice the color of

    the terminal. Orange terminals signify a data type called double (DBL), which is a type

    of numeric data.

    The most commonly used data types are numeric, Boolean value, and string. Learnmore about data types in the Data Types tutorial.

    Numeric Controls and Indicators

    The numeric data type can represent various types of numbers, such as integer or real.

    The two common numeric objects are the numeric control and the numeric indicator.

    Objects such as meters and dials also represent numeric data. Use the Controls palette

    to place a numeric control on the front panel and then use the increment and decrement

    buttons to adjust its values.

    Follow steps 1-3 to create a numeric control and change its value.

    1. Right-click the front panel to open the Controls palette, and from the Numeric sub-

    palette drag and drop a Numeric Control onto the front panel.

    2. Label the control Input by double-clicking on the label and typing the word Input.

    3. Now change the value of the control by clicking the increment or decrement button.

    Alternatively, you can double-click the number with either the Labeling tool or the

    Operating tool, enter a new number, and press the key.

  • 7/31/2019 LabVIEW Small

    7/30

    Boolean Controls and Indicators

    The Boolean data type represents data that has only two parts, such as TRUE andFALSE or ON and OFF. Use Boolean controls and indicators to enter and display

    Boolean values. Boolean objects simulate switches, push buttons, and LEDs. The

    vertical toggle switch and the round LED Boolean objects are shown below. You can

    find them in the Boolean subpalette in the Controls palette (see below).

    String Controls and Indicators

    The string data type is a sequence of ASCII characters. Use string controls to receive

    text from the user, such as a password or user name, and use string indicators to display

    text to the user. The most common string objects are tables and text entry boxes as

    shown below. You can find string controls and indicators in the String and Path

    subpalette or the Lists and Tables subpalette.

  • 7/31/2019 LabVIEW Small

    8/30

    Shortcut Menus and Property Dialog Boxes

    All LabVIEW objects have associated shortcut menus and property dialog boxes. As

    you create a VI, use the shortcut menu items and/or the properties dialog box to change

    the appearance and/or behavior of front panel and block diagram objects. To access the

    shortcut menu, right-click the object you want to modify. To access the Properties

    dialog box, select Properties from the shortcut menu.

    Follow steps 1 and 2 to create a string control and then use the Properties dialog box to

    add a scroll bar. Start with a blank VI.

    1. From the String & Path subpalette, select a String Control and place it on the front

    panel.

    2. Right-click the string indicator to open the shortcut menu and select Properties.

    3 From the Properties dialog box, put a check in the Show vertical scroll bar

    checkbox and clickOK.

    4. The resulting string control has a scroll bar so the user can scroll up and down to

    view all of the text. This allows the use of a small string control to display a large

    amount of text.

  • 7/31/2019 LabVIEW Small

    9/30

    Front Panel Window Toolbar

    Each window has a toolbar associated with it. Use the front panel window toolbar

    buttons to run and edit the VI. The following toolbar appears on the front panel

    window.

    Click the Run button to run your VI. You do not need to compile your code;

    LabVIEW compiles it automatically. You can run a VI if the Run button appears as a

    solid white arrow, shown at left.

    The Run button appears broken when the VI you are creating or editing

    contains errors. If the Run button still appears broken after you finish wiring the block

    diagram, the VI is broken and cannot run. Click this button to display the Error List

    window, which lists all errors and warnings.

    ClickRun Continuously to run the VI until you abort or pause execution. You

    also can click the button again to disable continuous running.

    While the VI runs, the Abort Execution button appears. Click this button to

    stop the VI immediately if there is no other way to stop the VI. If more than one

    running top-level VI uses the VI, the button is dimmed.

    Caution: The Abort Execution button stops the VI immediately before it finishes the

    current iteration. Aborting a VI that uses external resources, such as external hardware,

    might leave the resources in an unknown state by not resetting or releasing themproperly. Design VIs with a stop button to avoid this problem.

    ClickPause to pause a running VI. When you click the Pause button,

    LabVIEW highlights on the block diagram the location where you paused execution,

    and the Pause button appears red. Click the Pause button again to continue running the

    VI.

    Select the Text Settings pull-down menu to change the font

    settings for the selected portions of your VI, including size, style, and color.

  • 7/31/2019 LabVIEW Small

    10/30

    Tip: The key on the numeric keypad ends a text entry, while the main

    key adds a new line. To modify this behavior, select ToolsOptions, choose

    Environment from the Category list, and place a checkmark in the End text entry

    with Enter key option.

    It is important for a VI to have an intuitive and easy-to-read front panel. The front panelis essentially the gateway for all user input and output of a VI. Therefore it is essential

    that the programmer has good grasp of how to effectively program a front panel.

    ===============================================

    Block Diagram

    In this introduction to the Block Diagram, we examine the concept of this tool as well

    as the Block Diagrams relationship with the Front Panel. We also explore how to open

    the Block Diagram, how to find objects in the Functions palette and put them on the

    Block Diagram, and how to use different toolbar icons. In addition, we learn how to

    build a simple block diagram to illustrate the important concepts of creating graphical

    code in NI LabVIEW software.

    The block diagram contains the graphical source code of a LabVIEW program. The

    concept of the block diagram is to separate the graphical source code from the user

    interface in a logical and simple manner. Front panel objects appear as terminals on the

    block diagram. Terminals on the block diagram reflect the changes made to their

    corresponding front panel objects and vice versa.

    Block Diagram Window

    When you create or open a new VI, the front panel opens automatically. To bring up the

    block diagram, select WindowShow Block Diagram from the menu bar.

    Additionally, you can toggle between the block diagram and the front panel by pressing

    .

    Block Diagram Objects and Environment

  • 7/31/2019 LabVIEW Small

    11/30

    Block diagram objects include terminals, subVIs, functions, constants, structures, and

    wires that transfer data among other block diagram objects. You can use LabVIEW

    tools to create, modify, and debug a VI. A tool is a special operating mode of the mouse

    cursor, so the operating mode of the cursor corresponds to the icon of the tool selected.

    LabVIEW chooses which tool to select based on the current location of the mouse. You

    can manually choose the tool you need by selecting it on the Tools palette (from themenu bar, select ViewTools Palette). Now you can choose your desired tool, which

    remains selected until you choose another tool from the Tools palette.

    To place objects on the block diagram, simply drag and drop them from the Functions

    palette. The Functions palette automatically appears when you right-click anywhere on

    the block diagram workspace. It contains functions, constants, structures, and some

    subVIs.

    Notice the two buttons on the top of the Functions palette.

    The Thumb Tackpins the Functions palette to the block diagram.

  • 7/31/2019 LabVIEW Small

    12/30

    The Search button opens a search dialog box that you can use to search for

    functions by name.

    Click the Search button to launch the functions search engine. It takes a few moments

    to launch.

    You can use this tool to search for a function by name if you are having trouble finding

    it.

    Once you see the function you want, double -click on it and LabVIEW jumps to the

    place on the Functions palette where you can find that function.

    Note: Complete the following steps to change the subpalettes visible on the Functions

    palette:

    1. Use the thumb tack to pin the Functions palette to the block diagram.

    2. Notice the View button appears when you pin the Functions palette to the block

    diagram.

    3. Select View and, from the shortcut menu, select Change Visible Categories.

    4. In the Change Visible Categories dialog box, you can select the Palettes that you

    use the most or clickSelect All to include all Palettes.

    To change the appearance of the block diagram, select ToolsOptions from the menu

    bar. In the Options dialog box, select the Block Diagram category. Here you cancustomize the appearance of your block diagram. To save space on the block diagram,

    deselect Place front panel terminals as icons.

    Terminals

    Terminals create the block diagram appearance of objects on the front panel. In

    addition, they are entry and exit ports that exchange information between the front

  • 7/31/2019 LabVIEW Small

    13/30

  • 7/31/2019 LabVIEW Small

    14/30

    You can create controls and indicators from either the block diagram or the front panel.

    This tutorial demonstrates this in a later section.

    Block Diagram Nodes

    Nodes are objects on the block diagram that have inputs and/or outputs and perform

    operations when a VI runs. They are analogous to statements, operators, functions, and

    subroutines in text-based programming languages. Nodes can be functions, subVIs, orstructures. Structures are process control elements, such as case structures, for loops, or

    while loops, which are covered in a later tutorial. The image below shows some

    examples of block diagram nodes.

    Functions

    Functions are the fundamental operating elements of LabVIEW. Functions do not have

    front panel windows or block diagram windows, but they do have input and output

    terminals for passing data in and out similarly to controls and indicators. You can tell ifa block diagram object is a function by the pale yellow background on its icon. The

  • 7/31/2019 LabVIEW Small

    15/30

    Functions palette has functions arranged in groups based on the type of function they

    perform. Look in the Numeric subpalette for functions that perform numeric

    operations.

    There are many different types of functions. Remember that a function has a pale

    yellow background like the functions shown below.

    Data flow

    LabVIEW follows a dataflow model for running VIs. A block diagram node executes

    when it receives all required inputs. When a node executes, it produces output data andpasses the data to the next node in the dataflow path. The movement of data through the

    nodes determines the execution order of the VIs and functions on the block diagram.

    In text-based programming languages, you store and access data with functions through

    the use of variables. In the NI LabVIEW graphical programming language, wires

    implicitly handle all of the data storage and access that are associated with variables in

    text-based languages. Think of wires as a path for data to flow. Data comes into block

    diagram objects through a wire and can leave only through a wire. In the figure below,

    wires connect the control and indicator terminals to the Add and Subtract functions. As

    you can see, each wire has a single data source or starting point. However, you can

    branch off one wire and wire it to many VIs and functions. By branching off the mainwire, you can send data to multiple destinations. Note that wires are different colors,

    styles, and thicknesses. Color, style, and thickness change depending on the type of data

    the wire is transmitting.

  • 7/31/2019 LabVIEW Small

    16/30

    Broken wires (wires that are not connected properly) prevent your VI from running. A

    broken wire appears as a dashed black line with a red X in the middle, as shown below.

    Broken wires occur for a variety of reasons such as wiring two objects with different or

    incompatible data types. For example, you cannot wire an array output to a numeric

    input. The data in the wire is an array and the input is expecting a single numeric, so the

    data types are not compatible. When connecting block diagram objects with wires, you

    must connect a wire to one input and at least one output. For example, you cannot wiretwo indicators together. The figure below shows the most common wire types. Notice

    the different colors and thicknesses of the wires indicating the different data types.

    Wire Type Scalar 1D Array 2D Array Color

    NumericOrange (floating-

    point),Blue (integer)

    Boolean Green

    String Pink

    6. Sub VI

    One of the keys to creating LabVIEW applications is understanding and using the

    hierarchical nature of the VI. After you create a VI, you can use it as asubVIin the

    block diagram of a higher-level VI. Therefore, a subVI is analogous to a subroutine in

    C. Just as there is no limit to the number of subroutines you can use in a C program,

    there is no limit to the number of subVIs you can use in a LabVIEW program. You can

    also call a subVI inside another subVI. When creating an application, you start at the

    top-level VI and define the inputs and outputs for the application. Then, you constructsubVIs to perform the necessary operations on the data as it flows through the block

  • 7/31/2019 LabVIEW Small

    17/30

    diagram. If a block diagram has a large number of icons, group them into a lower-level

    VI to maintain the simplicity of the block diagram. This modular approach makes

    applications easy to debug, understand, and maintain.

    When you create a subVI and use it, you see an icon within your block diagram that

    represents the subVI. You can customize this icon, which is the same icon in the upperright corner of the subVI front panel and block diagram. You can create a subVI just

    like a VI and then use it as a subVI, or you can create a subVI from code already within

    another VI.

    Creating a SubVI from an Existing VI

    You can simplify the block diagram of a VI by converting sections of the block diagram

    into subVIs.

    1. Create a new VI and construct the following block diagram.

    2. Select the section of the block diagram you want to convert.

    3. From the Tools menu, select EditCreate SubVI.

  • 7/31/2019 LabVIEW Small

    18/30

  • 7/31/2019 LabVIEW Small

    19/30

    2. If the Functions palette is not visible, right-click any blank space on the block

    diagram to display a temporary version of the palette. Click the thumbtack in the upper

    left corner of the Functions palette to pin the palette so it is no longer temporary.

    3. Select the while loop from the Structures palette under the Functions palette.

    4. Use the cursor to drag a selection rectangle around the section of the block diagram

    you want to repeat.

    5. When you release the mouse button, a while loop boundary encloses the section you

    have selected.

    6. Place a Stop button on the front panel. You can find this under Controls

    PaletteBooleanStop.

    7. Add the Stop button from the block diagram to the while loop by dragging and

    dropping it inside the while loop.

    8. The conditional terminal, shown below, defines when the loop stops. There are two

    settings for the conditional terminal: Continue if True and Stop if True. When set to

    Continue if True, the while loop runs only if a Boolean value of true is sent to the

    terminal. If the conditional terminal is set to Stop if True, and a Boolean value of true is

    sent to the conditional terminal, the loop halts execution.

    Stop if True

  • 7/31/2019 LabVIEW Small

    20/30

    Continue if True

    9. To switch the conditional terminal between Continue if True and Stop if True, right-click on the conditional terminal and check the corresponding setting.

    10. Wire the Stop button to the conditional terminal so that you can control the

    execution of the while loop. When the Stop button is pressed, a true value is passed to

    the conditional terminal causing the while loop to stop execution. You can wire any

    Boolean data to the conditional terminal to control the execution of a while loop.

    11. The iteration terminal is an output terminal that contains the number of completed

    iterations. The iteration count always starts at zero. During the first iteration, the

    iteration terminal returns 0.

    12. You have just created a simple while loop that generates random numbers and

    displays them until the Stop button is pressed.

    Building a For Loop

    1. Open a new VI. You can open a blank VI by selecting FileNew VI.

    2. If the Functions palette is not visible, right-click any blank space on the block

    diagram to display a temporary version of the Functions palette. Click the thumbtack in

    the upper left corner of the Functions palette to pin the palette so it is no longer

    temporary.

    3. Select the for loop from the Structures palette under the Functions palette.

  • 7/31/2019 LabVIEW Small

    21/30

    4. You also can place a while loop on the block diagram. Right-click the border of the

    while loop and select Replace with For Loop from the shortcut menu to change a while

    loop to a for loop.

    5. A for loop contains a count terminal. The count terminal dictates how many times the

    subdiagram is executed.

    6. Right-click on the count terminal and Create Constant to link the count terminal with

    a numeric value.

    7. By inserting 100 into the numeric constant, the for loop executes 100 times before

    stopping.

    8. The iteration terminal, shown as follows, is an output terminal that contains the

    number of completed iterations. The example below would update an indicator on the

    front panel with the current iteration number.

  • 7/31/2019 LabVIEW Small

    22/30

    5. Arrays and Clusters

    An array, which consists of elements and dimensions, is either a control or an indicator

    it cannot contain a mixture of controls and indicators. Elements are the data or values

    contained in the array. A dimension is the length, height, or depth of an array. Arrays

    are very helpful when you are working with a collection of similar data and when youwant to store a history of repetitive computations.

    Array elements are ordered. Each element in an array has a corresponding index value,

    and you can use the array index to access a specific element in that array. In NI

    LabVIEW software, the array index is zero-based. This means that if a one-dimensional

    (1D) array contains n elements, the index range is from 0 to n 1, where index 0 points

    to the first element in the array and index n 1 points to the last element in the array.

    Clusters group data elements of mixed types. An example of a cluster is the LabVIEW

    error cluster, which combines a Boolean value, a numeric value, and a string. A cluster

    is similar to a record or a struct in text-based programming languages.

    Similar to arrays, a cluster is either a control or an indicator and cannot contain a

    mixture of controls and indicators. The difference between clusters and arrays is that a

    particular cluster has a fixed size, where a particular array can vary in size. Also, a

    cluster can contain mixed data types, but an array can contain only one data type.

    Creating Array Controls and Indicators

    To create an array in LabVIEW, you must place an array shell on the front panel and

    then place an element, such as a numeric, Boolean, or waveform control or indicator,inside the array shell.

    1. Create a new VI.

    2. Right-click on the front panel to display the Controls palette.

    3. On the Controls palette, navigate to ModernArray, Matrix, & Cluster and

    drag the Array shell onto the front panel.

    4. On the Controls palette, navigate to ModernNumeric and drag and drop a

    numeric indicator inside the Array shell.

    5. Place your mouse over the array and drag the right side of the array to expand it

    and display multiple elements.

  • 7/31/2019 LabVIEW Small

    23/30

    The previous steps walked you through creating a 1D array. A 2D array stores elements

    in a grid or matrix. Each element in a 2D array has two corresponding index values, a

    row index and a column index. Again, as with a 1D array, the row and column indices

    of a 2D array are zero-based.

    To create a 2D array, you must first create a 1D array and then add a dimension to it.

    Return to the 1D array you created earlier.

    1. On the front panel, right-click the index display and select Add Dimension from

    the shortcut menu.

    2. Place your mouse over the array and drag the corner of the array to expand it and

    display multiple rows and columns.

    Up to this point, the numeric elements of the arrays you have created have beendimmed zeros. A dimmed array element indicates that the element is uninitialized. To

  • 7/31/2019 LabVIEW Small

    24/30

  • 7/31/2019 LabVIEW Small

    25/30

    4. Resize the Cluster shell so that it is big enough to contain multiple elements.

    5. On the Controls palette, navigate to ModernNumeric and drag and drop a

    numeric control inside the Cluster shell.

    6. On the Controls palette, navigate to ModernString & Path and drag and drop

    a String Control inside the Cluster shell.

    7. On the Controls palette, navigate to ModernBoolean and drag and drop a

    Vertical Toggle Switch inside the Cluster shell.

    8. Your cluster should now look similar to the one shown below.

    http://var/www/apps/conversion/current/tmp/scratch9092/
  • 7/31/2019 LabVIEW Small

    26/30

    You can now wire the numeric, string, and Boolean controls throughout the block

    diagram with one wire rather than three separate wires.

    6. Graphs and charts

    Graphs and charts differ in the way they display and update data. VIs with graphsusually collect the data in an array and then plot the data to the graph, which is similar

    to a spreadsheet that first stores the data then generates a plot of it.

    In contrast, a chart appends new data points to those already in the display to create a

    history. On a chart, you can see the current reading or measurement in context with data

    previously acquired.

    Waveform Graphs and ChartsDisplay data typically acquired at a constant rate.

    XY GraphsDisplay data acquired at a non-constant rate and data for multivalued

    functions.Intensity Graphs and ChartsDisplay 3D data on a 2D plot by using color to

    display the values of the third dimension.

    Digital Waveform GraphsDisplay data as pulses or groups of digital lines.

    2D GraphsDisplay 2D data on a 2D front panel plot.

    3D GraphsDisplay 3D data on a 3D front panel plot.

    Agraph indicatorconsists of a two-dimensional display of one or more data arrays

    calledplots. LabVIEW has three types of graphs:XY graphs, waveform graphs, and

    intensity graphs (see theAdditional Topics section at the end of this chapter for

    information on intensity graphs).

    The difference between a graph and a chart is that a graph plots data as a block, whereas

    a chart plots data point by point or array by array.

    Waveform Graphs

    The waveform graph displays one ormore plots of evenly sampled measurements. The

    waveform graph plots only single-valued functions, as iny = f(x), with points evenly

    distributed along the x-axis, such as acquired time-varying waveforms. The following

    front panel shows an example of a waveform graph.

    http://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/types_of_graphs_and_charts/#Displaying_a_Single_Plot_on_Waveform_Graphs%23Displaying_a_Single_Plot_on_Waveform_Graphshttp://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/types_of_graphs_and_charts/#Displaying_Multiple_Plots_on_Waveform_Graphs%23Displaying_Multiple_Plots_on_Waveform_Graphshttp://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/types_of_graphs_and_charts/#Displaying_Multiple_Plots_on_Waveform_Graphs%23Displaying_Multiple_Plots_on_Waveform_Graphshttp://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/types_of_graphs_and_charts/#Displaying_a_Single_Plot_on_Waveform_Graphs%23Displaying_a_Single_Plot_on_Waveform_Graphshttp://zone.ni.com/reference/en-XX/help/371361G-01/lvconcepts/types_of_graphs_and_charts/#Displaying_Multiple_Plots_on_Waveform_Graphs%23Displaying_Multiple_Plots_on_Waveform_Graphs
  • 7/31/2019 LabVIEW Small

    27/30

    7. Formula Node

    TheFormula Node is a resizable box that you can use to enter formulas directly into a

    block diagram. You place the Formula Node on the block diagram by selecting it from

    FunctionStructures. This feature is useful when an equation has many variables or is

    otherwise complicated. For example, consider the equation:

    y = x2 + x + 1.

    If you implement this equation using regular LabVIEW arithmetic functions, the block

    diagram looks like the one in the following illustration.

    You can implement the same equation using a Formula Node, as shown in the

    following illustration.

  • 7/31/2019 LabVIEW Small

    28/30

    With the Formula Node, you can directly enter a complicated formula, or formulas, in

    lieu of creating block diagram subsections. You enter formulas with the Labeling tool.

    You create the input and output terminals of the Formula Node by popping up on the

    border of the node and choosing Add Input (Add Output). Type the variable name in

    the box. Variables are case sensitive. You enter the formula or formulas inside the box.

    Each formula statement must end with a semicolon (;).

    String

    A string is a collection of ASCII characters. You can use strings for more than simple

    text messages. In instrument control, you can pass numeric data as character strings and

    then convert these strings to numbers. Storing numeric data to disk can also involve

    strings.

    Use of the String functions are to concatenate two or more strings, extract a subset of

    strings from a string, convert data into strings, and format a string for use in a wordprocessing or spreadsheet application. Some of string functions are explained below.

    Build Text

    Concatenates an input string. If the input is not a string, this Express VI converts the

    input into a string based on the configuration of the Express VI.

    String Length

    Returns in length the number of characters (bytes) in string. The connector pane

    displays the default data types for this polymorphic function.

    To Lower Case

    Converts all alphabetic characters in string to lowercase characters. Evaluates all

    numbers in string as ASCII codes for characters. This function does not affect non-

    alphabetic characters.

    To Upper Case

    Converts all alphabetic characters in string to uppercase characters. Evaluates allnumbers in string as ASCII codes for characters. This function does not affect non-

    alphabetic characters.

    File I/O

    Use the File I/O functions to read data from or write data to files in three formatstext,

    binary, and datalog.

    You also can read and write data using the Read LabVIEW Measurement File Express

    VI and theWrite LabVIEW Measurement FileExpress VI. These Express VIs read data

    from and write data to aLabVIEW measurement data file (.lvm). You also cancreate,modify, and read a configuration file using the configuration file VIs.

  • 7/31/2019 LabVIEW Small

    29/30

    Build Path

    Creates a new path by appending a name (or relative path) to an existing path.

    Read File

    Reads data from an open file specified by refnum and returns it in data. Reading

    begins at the current file mark or a location in the file specified by pos mode and pos

    offset. How the data is read depends on the format of the specified file. refnum is the

    file refnum associated with the file you want to read. If you want to read more than one

    element at a time, wire the count parameter and use pos mode, pos offset, and offset to

    track the location of the file mark. Ifrefnum refers to a datalog file, the function reads

    the data as records from the file and returns an array of record data in data.

    Write File

    Writes data to an open file specified by refnum. Writing begins at a location specifiedby pos mode and pos offset for byte stream files and at the end of the file for datalog

    files. data, header, and the format of the specified file determine the amount of data

    written. refnum is the file refnum associated with the file to which you want to write. If

    refnum specifies a byte stream file, this function writes to a location specified by pos

    mode and pos offset in the file. If the top-level data type ofdata is of variable length,

    such as a string or array, the function can write a header to the file that specifies the size

    of the data. LabVIEW sets the file mark to the byte following the last byte written.

    Ifrefnum specifies a datalog file, this function writes data as records to the file. You

    only can append data to datalog files, so the function always begins writing at the endof the datalog file. Therefore, LabVIEW sets the file mark to the record following the

    last record written. You do not need to wire the convert eol, header, pos mode, orpos

    offset parameters for datalog files.

    Dynamic Link Library

    A dynamic link library (DLL) is a collection of small programs, any of which can be

    called when needed by a larger program that is running in the computer. The small

    program that lets the larger program communicate with a specific device such as a

    printer or scanner is often packaged as a DLL program (usually referred to as a DLL

    file). DLL files that support specific device operation are known asdevice drivers.

    The advantage of DLL files is that, because they don't get loaded into random access

    memory (RAM) together with the main program, space is saved in RAM. When and if a

    DLL file is needed, then it is loaded and run. For example, as long as a user of

    Microsoft Word is editing a document, the printer DLL file does not need to be loaded

    into RAM. If the user decides to print the document, then the Word application causes

    the printer DLL file to be loaded and run.

    A DLL file is often given a ".dll" file name suffix. DLL files are dynamically linked

    with the program that uses them during program execution rather than being compiled

    with the main program. The set of such files (or the DLL) is somewhat comparable tothe library routines provided with programming languages such as C and C++.

    http://searchenterprisedesktop.techtarget.com/sDefinition/0,,sid192_gci211938,00.htmlhttp://searchenterprisedesktop.techtarget.com/sDefinition/0,,sid192_gci211938,00.htmlhttp://searchmobilecomputing.techtarget.com/sDefinition/0,,sid40_gci214255,00.htmlhttp://whatis.techtarget.com/definition/0,,sid9_gci211824,00.htmlhttp://searchwinit.techtarget.com/sDefinition/0,,sid1_gci211723,00.htmlhttp://searchsqlserver.techtarget.com/sDefinition/0,,sid87_gci211850,00.htmlhttp://searchenterprisedesktop.techtarget.com/sDefinition/0,,sid192_gci211938,00.htmlhttp://searchmobilecomputing.techtarget.com/sDefinition/0,,sid40_gci214255,00.htmlhttp://whatis.techtarget.com/definition/0,,sid9_gci211824,00.htmlhttp://searchwinit.techtarget.com/sDefinition/0,,sid1_gci211723,00.htmlhttp://searchsqlserver.techtarget.com/sDefinition/0,,sid87_gci211850,00.html
  • 7/31/2019 LabVIEW Small

    30/30

    If the DLL is a C/C++ DLL:

    1. Find the header file (*.h) or function prototype definitions.

    2. Identify the function(s) you wish to call. Notice whether the parameters for the

    function contain primitive data type parameters such as int, char, double, etc or

    whether they contain complex data types such as structs, arrays or vectors.3. If the function does not contain any complex data types and you have a header

    file (*.h), a great tool in LabVIEW can help you easily import the DLL (and it

    will create an entire library for the DLL). You can find this option in

    ToolsImportShared Library (.dll)... Continue with the wizard.

    4. If the function does not contain any complex data types and you do not have a

    header file (*.h), first ensure that you are dealing with a C/C++ DLL as most

    programming environments will generate a header file along with the DLL. If

    you are in fact dealing with a C/C++ DLL, find the documentation for the

    function as you will need to identify the parameters for the function you wish to

    call inside of the DLL. Once you have identified the parameters, use the Call

    Library Function Node function in LabVIEW to manually call the function.5. If the function(s) you wish to call contains complex data types, you need to

    manually use a Call Library Function Node function in LabVIEW to directly

    call the DLL, defining the prototype within the configuration dialog (if the DLL

    has been compiled with a Type Library, parameter data and return types will be

    defined automatically). Note that if your complex data type is a struct with

    more than primitive data types (int, double, char), it is easiest to create a

    wrapper DLL from a C-based language.

    Since C/C++ constructs do not always directly correlate to LabVIEW data

    types, a wrapper DLL can appropriately extract the contents of the complex

    structure and translate them to primitive terms. For instance, if you have a

    struct in C which contains a char * (a string or character array), you can create a

    wrapper function which LabVIEW will call that takes in a char * type directly,

    puts that into a structure, and then in turn calls the DLL. Note that if you have

    the DLL source code, you can directly modify the DLL so that it takes in a char

    * instead of the struct.

    Note: There is a very helpful example in the Labview Example finder that explains how

    to handle several different data types to be used with the Call Library Function Node.

    The example is named Call DLL.vi. Refer to this example when dealing with complex

    data types such as arrays or structs. To Find this example go to the LabVIEW ExampleFinder (HelpFind Examples) and select the Directory Structure radio button. In the

    directories list, select dll and then data passing then Call Native Code.llb. The Call

    DLL.vi example is under that directory.

    To view the example for a data type, select the data type in the Data Type list. Then

    click the Open Example VI for Current Data Type button. This will open a new VI

    showing the use of the Call Library Function Node.