Virtual Instruments:
Parts of a LabVIEW Program
   LabVIEW Core 1, Module 1
                    Agenda
 Introduction to LabVIEW
 Parts of a LabVIEW Program
   What is a VI?
   Creating a VI
   What are the parts of a VI?
 Quiz
 Exercise
       Introduction to LabVIEW
 LabVIEW is a graphical programming
  language.
 One of its greatest strengths is how intuitive it
  is.
 It can be used to create sophisticated
  programs with elegant user interfaces quickly
  and easily.
              What is a VI?
 The appearance and operation of VIs imitate
  physical instruments, such as oscilloscopes
  and digital multimeters.
                 Creating a VI
 Demo:
   Start LabVIEW, Getting Started Window,
   Open a VI using:
      Most recent VI (File menu)
      Open section or File-Open menu
   Manual creation:
      New section or File-New menu
   Create from a template
     What are the parts of a VI?
 Demo
   Use the Example Finder to open example code
   Analyzing and processing signals section
   Interpolation section
     Open 1D fourier interpolation.vi
     What are the parts of a VI?
 Front Panel, Block Diagram, Connector Pane
   Controls and Indicators are the Input and output
 Open the block diagram using Show block
  diagram
   Crtl + E and to toggle
 Block diagram:
   contains the graphical source code of the program
      What are the parts of a VI?
 Front panel objects:
   appear on the block diagram as terminals
 Icon:
   is a graphical representation of a VI
 Connector pane:
   is a map of the inputs and outputs of a VI and it allows
    a user to use and view a VI as a subVI.
   A subVI is a VI that is found inside another VI
      Similar to a function in a text based programming language
                        Quiz
 What does VI stand for?
  a)   Visual Instrument
  b)   Virtual Instance
  c)   Virtual Instrument
  d)   Virtual Interface
                        Quiz
 What part of a VI interacts with the user?
  a)   Block Diagram
  b)   Connector Pane
  c)   Icon
  d)   Front Panel
                        Quiz
 What are the three steps that can be used to
  effectively create simple data acquisition
  application?
  a)   Display, present, store
  b)   Input, output, process
  c)   Read , interpret, store
  d)   Acquire, analyze, present
                       Quiz
 Which two methods open the Block Diagram?
  a)   Ctrl-B and Window-Show Diagram
  b)   Ctrl-E and File-Display Block Diagram
  c)   Ctrl-E and Window-Show Block Diagram
  d)   Ctrl-B and File-Display Block Diagram
                       Quiz
 Which of these is a great resource for finding
  pre-written code on an unfamiliar topic?
  a)   A new blank project
  b)   The Example Finder
  c)   The Front Panel
  d)   The Project Manager
                  Exercise
Complete the exercise:
   LV1M1_Virtual Instruments
provided inside the moodle course!
Investigate the front panel and block diagram
concepts in more detail!
Projects: Creating LabVIEW
       Project Files
   LabVIEW Core 1, Module 2
                   Agenda
 What is a LabVIEW project?
 Using the Project Explorer to organize our files
 Creating, using, and saving a LabVIEW project
     What is a LabVIEW Project?
 A type of file used to group together both
  LabVIEW and non-LabVIEW files
 Used to create build specifications and deploy
  to targets
 A LabVIEW project must be used when
  building applications and shared libraries
 Great for organizing and tracking files
     What is a LabVIEW Project?
 Creates an .lvproj file
 Contains references to files within the
  LabVIEW project
 Used to work with real-time devices, field-
  programmable gate arrays, or personal digital
  assistant devices.
Using the Project Explorer to organize
               our files
 Demo
   Open Project Explorer (Open Existing or File-Open Project)
   Project Explorer Window
      create and edit
   Items page
      Project Tree
   Files page
      Files on disk
   Default Items
      My Computer, Dependencies, Build Specifications
   Toolbars
      Various operations
Creating, using and saving a LabVIEW
               project
 Demo
   Create a new LabVIEW project (Create Project, File-Create
    Projects)
   Blank Project or Template
   Add Items to it
   Add file to project
   Folders within a LabVIEW project
      Virtual Folder (add Virtual Folder)
      Snapshot (add Snapshot Folder)
      Auto-populating (add Auto-populating Folder)
   Add new VI to project
   File-Save Project
                         Quiz
 Which type of folder always contains the
  current contents of the actual folder?
  a)   VI
  b)   Auto-populating
  c)   Snapshot
  d)   My Computer
                         Quiz
 Which type of folder shows only the contents
  of the actual folder at time of creation?
  a)   VI
  b)   Auto-populating
  c)   Snapshot
  d)   My Computer
                      Quiz
 Why would we use projects in LabVIEW?
  a) To increase the speed of the program
  b) To make our programs organized and easy to
     keep track of a large application
  c) To separate front panels from block diagrams
  d) To provide an interface with connected
     hardware
                    Quiz
 A LabVIEW Project allows us to group together
  both LabVIEW and non-LabVIEW files.
  a) True
  b) False
                     Quiz
 What is the file extension of a LabVIEW
  project file?
  a)   .vi
  b)   .proj
  c)   .viproj
  d)   .lvproj
                     Exercise
Complete the exercise:
   LV1M2_Projects
provided inside the moodle course!
In the exercise for this module, you will create
and modify a LabVIEW project.
Front Panel: Defining
 the User Interface
LabVIEW Core 1, Module 3
                    Agenda
   What is the front panel?
   What is the controls palette?
   What are controls and indicators?
   Using menus, property dialog boxes, and the
    front panel toolbar to customize the front
    panel
       What is the front panel?
 Demo:
   Example Finder, Analysis, Signal Processing and
    Mathematics -> Signal and Noise Generation ->
    Arbitrary Wave Display
    What is the controls palette?
 Demo:
   File-New, Blank VI
   View-Controls Palette or Right-Clicking on the
    Front Panel
   Grouped into categories
   Search field: Slide (Vertical Fill Slide Numeric)
 What are controls and indicators?
 Controls are the interactive inputs of a VI
   Knobs, push buttons, dials, 
   They simulate instrument input devices as well as
    supply data to the block diagram of the VI.
 Indicators are the visual outputs of a VI
   Numeric indicators, string indicators, graphs, LEDs,    
   Indicators simulate instrument output devices and
    display data the block diagram acquires or
    generates.
 What are controls and indicators?
 Continue Demo
   Numeric
      Modern-Numeric-Numeric Control
      Modern-Numeric Indicator
   Boolean
      Modern-Boolean-OK Button
      Modern-Boolean-Square LED
   String data
      String and Path-String Control
      String and Path-String Indicator
  Using menus, property dialog boxes, and the
front panel toolbar to customize the front panel
 Continue Demo:
   Right Click the Numeric Control
      Visible Items
      Properties
         Data Type Tab (other module)
         Documentation Tab (other module)
         Appearance Tab (Label, Enabled State, Caption, Size, Show
          Radix, Increment, Decrement Buttons)
         Data Entry tab (Min, Max, Increment)
         Display Format Tab (Float, Digits)
  Using menus, property dialog boxes, and the
front panel toolbar to customize the front panel
 Continue Demo:
   Front Panel Toolbar
        Run Button (Unbroken, broken  Error List Window)
        Run Continuously Button
        Abort Execution Button
        Pause Button
        Text settings
        Align Objects
        Distribute Objects
        Resize Objects
        Reorder Objects
        Show Context Help Button (Ctrl-H)
                    Quiz
 Which type of data does an LED indicator
  display?
  a)   Numeric
  b)   Boolean
  c)   String
  d)   Error
                    Quiz
 Which type of data does a knob control
  output?
  a)   Numeric
  b)   Boolean
  c)   String
  d)   Error
                         Quiz
 What is the purpose of a front panel?
  a)   A representation of LabVIEW code
  b)   An organization of the VIs within a file
  c)   A user interface of a virtual instrument
  d)   To acquire data from hardware
                        Quiz
 What do you use when you cannot find a
  control in the controls palette?
  a)   Press Ctrl-H
  b)   Look through all the options
  c)   Find a similar control
  d)   Use the search function
                     Quiz
 When you want to stop your program,
  pressing the Abort Execution button is the
  best thing to do.
  a) True
  b) False
                  Exercise
Complete the exercise:
   LV1M3_Front Panel
provided inside the moodle course!
Create a front panel using a variety of different
styles and types of controls and indicators.
Modify their properties, appearance, and layout.
      Block Diagram:
Writing LabVIEW Programs
   LabVIEW Core 1, Module 4
                   Agenda
 What is the block diagram?
 Using terminals on the block diagram
 Using Functions palette and searching to build
  a block diagram
 What are nodes?
 Using wires to make connections on the block
  diagram
 Using the block diagram toolbar
     What is the block diagram?
 Demo:
   Add_a_b_constant.vi
 Block diagram is where we write the code of
  the program
   Terminals, subVIs, functions, constants, structures,
    and wires
   Window-Show Block diagram or Ctrl-E
 Using terminals on the block diagram
 Objects on the front panel appear as terminals
  on the block diagram
 When the block diagram code executes and
  reads the values from the terminals, they will
  take on the values that the user has input on
  the front panel.
      Control, indicator, constants, and node terminals
      Add function
    Using the functions palette and
   searching to build a block diagram
 Contains VIs, functions, and constants
   View-Functions palette or right-clicking on the block
    diagram
   Thumb-tag to fix it to the screen
 Categories od sub-palettes
   Numeric, Boolean, String, Comparison
   Structures
 Search button
   Equal to 0 comparison
 Customize visible palettes
                   What are nodes?
 Nodes are objects on the block diagram which have inputs and/or
  outputs and perform operations when a VI runs.
     Statements, operators, functions and sub-routines in text-based
      languages
     Functions, subVIs or structures
 We can essentially create our own functions by placing VIs inside of
  other VIs.
     subVIs
 Write to Spreadsheet VI from File I/O Functions palette
     Double-click it
 Express VI
     Configured using dialog boxes
     Simulate Signal Express VI from the Express palette, Input
     Expandable node, blue field
  Using wires to make connections on the block
                    diagram
 Wires are of different colors, styles, and thicknesses, depending on
  their data types.
       Boolean wires are green
       String wires are pink
       Numeric wires can be blue or orange
       Colors match the color of the terminal
 When an output terminal is wired to an incompatible input
  terminal, a broken wire appears.
     Dashed black line with a red X in the middle
     Write to Spreadsheet Path output to the Amplitude input of the
      Express VI
     Ctrl-B to delete all broken wires
 Clean Up wire to reroute it or Clean Up Diagram tool (Ctrl-U, Ctrl-Z
  to undo)
         Using the block diagram toolbar
 Similar to the front panel toolbar with a few new
  buttons
   Highlight execution button to display an animation of
    the block diagram when we run our VI to watch the
    execution of the code.
   Retain wire Values button to turn on or off the ability
    to save the wire values at each point in the flow of
    execution.
      When placing a probe, we see the most recent value of the
       data that has passed through the wire.
   Step into, Step over, and Step out buttons (later
    module)
                    Quiz
 The block diagram is where we write the code
  for our program.
  a) True
  b) False
                     Quiz
 Which color is a numeric integer wire?
  a)   Blue
  b)   Green
  c)   Orange
  d)   Purple
                    Quiz
 Which color is a Boolean wire?
  a)   Blue
  b)   Green
  c)   Orange
  d)   Purple
                       Quiz
 What happens when incompatible terminals
  are wired?
  a) The wire turns solid red
  b) A dialog box pops up to indicate that you have
     made a mistake
  c) The wire wont finish as LabVIEW will not allow
     the terminal to be connected
  d) The wire will appear as a dashed black line with
     a red X in the middle
                        Quiz
 What is the easiest way to clean up a block
  diagram?
  a)   Move all functions into better positions
  b)   Rewire all wires that cross
  c)   Save, exit, then reopen the VI
  d)   Press the Clean Up Diagram button in the
       toolbar
                  Exercise
Complete the exercise:
   LV1M4_Block Diagram
provided inside the moodle course!
Create block diagram code, place functions, wire
controls and indicators to functions, and run
code.
  Block Diagram:
  Selecting Tools
LabVIEW Core 1, Module 5
                   Agenda
 What is the Tools Palette?
 Using the Tools Palette
      What is the Tools Palette?
 Graphical nature of LabVIEW is a great
  strength
 Easy to create user-friendly interfaces
 Simple to write graphical code
 LabVIEW contains a multitude of tools to help
  us create our VIs
        Using the Tools Palette
 Demo: open and use the Tools Palette
   Automatic Tool Selection Mode
   If disabled: change tools manually using the Tab
    key or the spacebar:
      Tab key: cycle through most commonly used tools
      Spacebar: toggle between the two most common tools
         Using the Tools Palette
 Specific tools (enabled by Automatic Tool
  Selection):
   Operating tool: pointing finger
   Positioning tool: arrow (Ctrl key for copying)
   Labeling tool: for a free label double-click in any
    open space
   Wiring tool: manually wire terminals together
        Using the Tools Palette
 Specific tools (not enabled by Automatic Tool
  Selection):
   Object Shortcut Menu tool
   Scrolling tool
   Breakpoint tool
   Probe tool
   Color copy and coloring tool
                       Quiz
 Where is the Tools Palette visible?
  a)   On the front panel
  b)   On the block diagram
  c)   On both the front panel and block diagram
  d)   On the Context Help window
                        Quiz
 With the Automatic Tool Selection enabled,
  how can we add a free label to our code?
  a)   Right-click a control
  b)   Double-click a control
  c)   Press <Tab>
  d)   Double-click in an open area
                       Quiz
 Which of the following tools can be used to
  click a button?
  a)   Operating tool
  b)   Positioning tool
  c)   Object Shortcut Menu tool
  d)   Probe tool
                       Quiz
 Which of the following tools can be used to
  resize a control?
  a)   Operating tool
  b)   Positioning tool
  c)   Object Shortcut Menu tool
  d)   Probe tool
                       Quiz
 Which of the following tools is most useful
  when we have a single button mouse?
  a)   Operating tool
  b)   Positioning tool
  c)   Object Shortcut Menu tool
  d)   Probe tool
                   Exercise
Complete the exercise:
   LV1M5_Selecting Tools
provided inside the moodle course!
Use various tools and Automatic Tool Selection
to interact with the front panel and block
diagram.
     Dataflow:
Code Execution Order
 LabVIEW Core 1, Module 6
                  Agenda
 What is Dataflow?
 Using Execution Highlighting
 Programming with Dataflow
           What is Dataflow?
 Dataflow is the model which defines the order
  in which LabVIEW code executes.
 Two Rules of Dataflow:
   Nodes execute when they receive all of their
    needed inputs.
   When a node executes, it passes on output data
    to the next node.
    Using Execution Highlighting
 Demo: enable Execution Highlighting and
  watch the data in a simple VI.
     Programming with Dataflow
 Example: add two numbers together, subtract
  50 from the result and display the final result
  on the front panel.
 Dataflow is similar to an assembly line: once
  we receive our parts, we can complete our
  task.
 General guideline: create code that executes
  from left to right
                 Parallelism
 Copy the numeric inputs
 Create a multiply function and wire it to the
  new numeric inputs
 Copy the result terminal and wire it to the
  output of the multiply function
 Execute the code: will the add or the multiply
  function execute first?
                       Quiz
 Where is the Highlight Execution button
  located?
  a)   On the front panel toolbar
  b)   On the Controls palette
  c)   On the Functions palette
  d)   On the block diagram toolbar
                       Quiz
 How does execution highlighting affect how
  the code runs?
  a) It runs faster because more data flows through
     the wires
  b) It runs slower because data moves slower
  c) It runs slower because it shows the flow of the
     data at a human pace
  d) It does not affect the speed at which the
     program runs
                       Quiz
 If two segments of code are not connected by
  a wire they are called:
  a)   Perpendicular
  b)   Orthogonal
  c)   Parallel
  d)   Coincident
                       Quiz
 When there are two parallel sets of code,
  which will run first?
  a) The one furthest to the left on the block diagram
  b) The one furthest to the right on the block
     diagram
  c) The one furthest to the top on the block diagram
  d) Indeterminate: it cannot be known which will
     run first
                   Exercise
Complete the exercise:
   LV1M6_Dataflow
provided inside the moodle course!
Use mathematical calculations in parallel and in
series to demonstrate dataflow programming.
Programming a Simple VI
  LabVIEW Core 1, Module 7
                  Agenda
 What is a Simple VI?
 Creating a Simple VI
 Exploring Other Express VIs
          What is a Simple VI?
 In their simplest form, most Vis have three
  main tasks:
   Acquiring data
   Analyzing the data
   Presenting the result
           Creating a Simple VI
 Exercise:
   Express Palette  Input  Simulate Signal
   Add noise checkbox  Gaussian White Noise
   Express Palette  Signal Analysis  Filter (Low pass)
   Express Palette  Signal Manipulation- Merge
    Signals
   Wire
   Right-click output of Merge Signals  Create Graph
    Indicator
     Exploring Other Express VIs
 Acquire task: DAQ Assistant, Simulate Signal,
  Read from Measurement file.
 Analyze task: Amplitude and Level
  Measurements, Statistics, Tone
  Measurements, etc.
 Presenting task: Write to Measurement File,
  Build Text, etc.
                       Quiz
 What does the merge signals function do to
  the input signals?
  a)   Adds them together into one signal
  b)   Subtracts the top one from the bottom one
  c)   Multiplies them together
  d)   Puts them both together in the same wire
                       Quiz
 What are the three tasks of a typical VI?
  a) Acquiring data, analyzing the data and
     presenting the data
  b) Functions, data, and computation
  c) Data inquisition, interpretation, processing
  d) Analyzing data, data flow, parallel loops
                       Quiz
 What does the DAQ Assistant do?
  a)   Generates a signal
  b)   Measures data from a DAQ device
  c)   Outputs data to a DAQ device
  d)   b&c
                        Quiz
 Where do you find Express VIs?
  a)   The Boolean category of the Functions palette
  b)   The Express category of the Controls palette
  c)   The Express category of the Functions palette
  d)   None of the above
                       Quiz
 Which Express VI would be most useful for
  recording data for later use?
  a)   Read from Measurement File Express VI
  b)   Amplitude and Level Measurement Express VI
  c)   Statistics Express VI
  d)   Write to Measurement File Express VI
                  Exercise
Complete the exercise:
   LV1M7_Dataflow
provided inside the moodle course!
Create your own simple VI made from
LabVIEWs Express VIs.
    LabVIEW Help Utilities:
Getting Assistance Creating and
          Editing VIs
     LabVIEW Core 1, Module 8
                 Agenda
 Context Help
 LabVIEW Help
 NI Example Finder
               Context Help
 Context Help displays basic information about
  LabVIEW items
 Bring up:
   Show Context Help (Help menu)
   Ctrl-H
 SubVIs and functions: Window displays the
  icon with terminal names and wires attached
  to each terminal
               Context Help
 Wires: data type is displayed
 Features:
   Lock Context Help
   Hide/Show Optional Terminals and Full Path
   Detailed Help
              LabVIEW Help
 The LabVIEW Help utility contains detailed
  descriptions of most palettes, menus, tools,
  VIs, functions and instructions for using
  LabVIEW features.
 Bring up:
   Help menu
   Context Help window (Detailed help)
 Example: Read From Spreadsheet File VI
             NI Example Finder
   Help menu  Find Examples
   Example: Write to Text File VI
   Browse Tab: pre-written examples
   Search Tab: examples which match our search
                       Quiz
 Which of these can be used to help create
  LabVIEW code?
  a)   Context Help
  b)   LabVIEW Help
  c)   NI Example Finder
  d)   All of the above
                       Quiz
 Which of the following is not a way to bring up
  the Context Help window?
  a) Press <Ctrl-H>
  b) Right click a blank area on the Block Diagram
     and select Context Help
  c) Select Show Context Help from the Help
     menu
                        Quiz
 What is displayed in the Context Help window
  when you hover over a wire?
  a)   Its value
  b)   Nothing
  c)   Its data type
  d)   The function it connects to
                       Quiz
 Where can you find detailed descriptions of
  most palettes, menus, tools, VIs and
  functions?
  a)   Context Help
  b)   LabVIEW Help
  c)   NI Example Finder
  d)   None of the above
                   Exercise
Complete the exercise:
   LV1M8_LabVIEW Help Utilities
provided inside the moodle course!
Use the NI Example Finder to find and open a VI,
use Context Help to identify inputs and outputs
of a VI, and use LabVIEW Help to see the
detailed explanation of a VI.
Basic Debugging Techniques
    LabVIEW Core 1, Module 9
                   Agenda
 What is a broken VI?
 Debugging broken VIs
 Using Execution Highlighting and Single-
  Stepping
 Using Probes to Check Data Values
 Using Breakpoints to Pause the Code
                 What is a broken VI?
 Demo:
     Creating a broken VI
 A broken VI is one which can not run because of a problem in the code.
 We can tell when a VI contains errors because the Run button actually
  appears to be broken.
     Warnings will not prevent a VI from running.
     Errors must be resolved before a VI can run.
 Error list
     View-Error List or clicking the broken Run-button
     Click Show error to highlight the piece of code that is causing the problem
 Common causes for broken VIs:
     A broken wire with either unconnected ends or a mismatch of data type
     A required block diagram terminal that is unwired
     A subVI that is broken
         Debugging broken VIs
 Use the Error List from View Menu
   Show Warnings check-marked
 Triple-click a wire to show its entire path using
  the Position tool
 Use context help to check default values of VIs
 One Object might hide another object
   Using Execution Highlighting and
           Single-Stepping
 Execution can be suspended to edit controls
  and indicators, the number of times the VI
  runs, or to re-execute the VI.
 Demo:
   execution highlighting and single-step mode
 Enter Single-Step Mode by clicking the Step-
  into button
   Step Into, Step Over, Step Out
Using Probes to Check Data Values
 The probe tool is used to observe intermediate
  data values
   To read the data along the wire
 Retain Wire Values button
   To run the code and probe afterwards
 Breakpoints to pause execution, so we can single-
  step or insert probes
 Demo:
   Using probes, retain wire values to see the previous
    value of the wire
 Using Breakpoints to Pause the Code
 To pause the code at a pre-defined position
   right-click the wire, Set breakpoint, or Breakpoint
    tool
 Demo:
   Breakpoint
 When a VI pauses at a breakpoint, LabVIEW
  highlights the object which contains the break
  point.
   Click the pause button to un-pause the VI
                    Quiz
 When you receive a warning, your code will
  not run.
  a) True
  b) False
                      Quiz
 Which of the following will find the cause of
  broken VIs?
  a)   Encountered warnings
  b)   Error list
  c)   Context Help Menu
  d)   Both a and b
  e)   Both b and c
                      Quiz
 Which of the following would not cause a
  broken VI?
  a) Different data types wired into the same
     function
  b) A broken wire with unconnected ends
  c) A broken subVI
  d) Unwired required block diagram terminal
                       Quiz
 What tool is used to triple-click a wire and
  highlight its entire path?
  a)   Text tool
  b)   Wiring tool
  c)   Position tool
  d)   Scroll Tool
                        Quiz
 What values do Vis and functions pass if
  optional inputs are unwired?
  a)   Zero
  b)   One
  c)   The default value
  d)   No value is passed
                  Exercise
Complete the exercise:
   LV1M9_Basic Debugging
provided inside the moodle course!
Use probes, breakpoints, execution highlighting,
and single-stepping to debug code.
   Undefined Data and Error
Handling: Tracking Errors in Code
      LabVIEW Core 1, Module 10
                   Agenda
 What is undefined numerical data?
 Tracking errors in code using error checking
  and error handling
 Reporting errors that occur in the code with
  automatic and manual error handling
What is undefined numerical data?
 Two types of undefined numerical data:
   NaN  Not a number
      E.g. Square root of a negative number
   Inf  Infinity
      Inf converted to an Integer generates a normal value
 Use the Not a Number/Path/Refnum function
  to check if a number is NaN
 Compare to positive and negative Infinity
    Tracking errors in code using error
       checking and error handling
 An error is an output from a function or VI that indicated that it did
  not execute as expected.
 Error checking tells where and why an error occurs and how to
  respond to it.
 Error cluster data structure is a grouping of three different pieces of
  data:
     Status  Boolean; True if an error occurs
     Code  32 bit signed int; identifies the error, if everything is fine the
      code will be 0
     Source  string; gives some explanation of the error
 Error handling follows the dataflow model
 Error cluster controls and indicators should
  be used within subVIs
     Explain error dialog box
 Reporting errors that occur in the code
with automatic and manual error handling
 By default a VI or subVI uses automatic error handling
    LabVIEW will suspend execution if an error occurs;
     highlight the portion of code where the error occurred,
     and display the error dialog box.
    Can be disabled in the VI properties, execution cat.
    Demo
 Manual error handling makes use of the error-in and
  error-out terminals
    To enable it, we just need to wire the error-out and error-
     in terminals
    Use the LabVIEW error handling VIs and functions to
     inform the user
       Dialog and User Interface palette, Simple Error Handler VI
                      Quiz
 What does NaN stand for?
  a)   Numeric Access Node
  b)   Not a Number
  c)   Numeric and Null
  d)   Null Access Node
                    Quiz
 Which of these data types is undefined?
  a)   Int
  b)   DBL
  c)   Inf
  d)   Boolean
                    Quiz
 What value would be obtained if infinity was
  converted to a 16-bit integer?
  a)   65535
  b)   32767
  c)   Undefined
  d)   18
                        Quiz
 What are the tree pieces of data in an error
  cluster?
  a)   Boolean Status, Integer Code, String Source
  b)   Boolean Status, Double, String Status
  c)   String Status, Integer Status, Double Status
  d)   Double Status, Code, Boolean Status
                        Quiz
 How would you view a detailed description of
  an error?
  a)   Explain Error Dialog Box
  b)   Error Detail Dialog Box
  c)   Context Help
  d)   Detailed Help
                  Exercise
Complete the exercise:
   LV1M10_Undefined Data and Error Handling
provided inside the moodle course!
Build a VI to demonstrate how NaN numerics
can cause an error and how we can identify an
error that has occurred.
Front Panel Design: Customizing
        the Front Panel
     LabVIEW Core 1, Module 11
                   Agenda
 What is front panel design?
 Designing controls and indicators
 Organizing the front panel using color, space
  and alignment, text and fonts
 User interface tips and tools
     What is Front Panel design?
 Inputs come from:
   Acquiring from a device
   Reading from a file
   Manipulating controls
 Outputs can be used to:
   Display with indicators
   Log to a file
   Output to a device
 Designing controls and indicators
 Demo
 Choose appropriate controls and indicators
    e.g. dial control for frequency,
    thermometer indicator for
     temperature
 Label them clearly,
    for longer descriptions use captions
 Setting the default value for control
    Right-click, Data operations, Make Current Value
     Default
   Organizing the front panel using color,
    space and alignment, text and fonts
 Proper use of color
   Avoid using too many colors!
   Begin with a gray scheme
   Use highlight colors for important
    objects (plots, abort buttons, )
   Small objects need brighter colors and more
    contrast than larger objects
   Use differences in contrast more often than
    differences in color
      Color-blind users!
   Organizing the front panel using color,
    space and alignment, text and fonts
 Spacing and alignment
    the eye generally looks left to right and top to bottom
    Align objects on the same line (horizontally and vertically)
    Do not place objects too closely together
 Fonts
    Use matching fonts and only a few different font sizes
    Font, Style, Size, Color
 UIs for industrial applications
  or touch screens often need
  much larger fonts, more contrast,
  larger controls and indicators.
          User interface tips and tools
 Demo
 Build in tools like system controls, tab controls,
  decorations, menus and automatic resizing.
 Display a dialog to interact with the user.
    a VI can behave like a dialog box
    VI properties, Windows Appearance, Dialog
 Tab control overlap multiple pages
 Use Decorations to group or separate objects
 Automatic Resizing
    VI properties, Window Size, Maintain prop, Scale all Obj
                        Quiz
 A control is also known as:
  a)   An interactive input
  b)   An interactive output
  c)   A Data Type
  d)   None of the above
                        Quiz
 An indicator is also known as:
  a)   An interactive input
  b)   An interactive output
  c)   A Data Type
  d)   None of the above
                     Quiz
 What type of control would be most
  appropriate for controlling the frequency of a
  sine wave?
  a)   Switch
  b)   Dial
  c)   Button
  d)   Tank
                         Quiz
 What type of indicator would be most
  appropriate for displaying a temperature?
  a)   Vertical Progress Bar
  b)   Numerical Indicator
  c)   Thermometer
  d)   Gauge
                      Quiz
 Difference in color is typically better than
  difference in contrast.
  a) True
  b) False
                   Exercise
Complete the exercise:
   LV1M11_Front Panel Design
provided inside the moodle course!
Use front panel labels, captions, color schemes,
and tab controls to organize a front panel.
Understanding and Using Data
           Types
    LabVIEW Core 1, Module 12
                   Agenda
 What are data types?
 Using numeric data types
 Using enums to limit selections to a defined
  list
         What are data types?
 The data type is represented by the color of
  the terminal and the wire
   E.g. Blue is an integer
   Orange is an floating-point number
 The representation can be changed
          Using numeric data types
 Floating-point
    Double-precision numbers (DBL) follow the 64-bit IEEE format
    Single precision numbers need less memory
    For values like amplitude we use floating-point numbers
 Integer
      Word length, number of bits used to store the number
      Integers are represented with the color blue
      Signed and unsigned integer
      For counting we usually use integer, because we cannot count 4 and a
       half times.
 Demo: underflow with U8, 6-8=?
 When using different data types, functions always return the larger
  data type
    Coercion dot
    Using enums to limit selections to a
              defined list
 The term enum is short for enumerated.
   This data type can be used as a control, constant,
    or indicator.
   It assigns a numeric value to each entry in a series
    of items.
 Demo
 Ring & Enum palette, Enum
   Right-click and Edit items
   Add days of the week
                    Quiz
 What color wire represents an integer data
  type?
  a)   Orange
  b)   Blue
  c)   Yellow
  d)   Green
                    Quiz
 What color wire represents a decimal or
  floating-point data type?
  a)   Orange
  b)   Blue
  c)   Yellow
  d)   Green
                    Quiz
 Unsigned integers include negative numbers.
  a) True
  b) False
                      Quiz
 What happens when two different numeric
  representations are wired to an Add function?
  a) A coercion dot appears on the larger
     representation
  b) A coercion dot appears on the smaller
     representation
  c) LabVIEW returns an error
  d) LabVIEW returns a warning
                          Quiz
 Can an enum be used as which of the
  following?
  a)   Control
  b)   Constant
  c)   Indicator
  d)   All of the above
                  Exercise
Complete the exercise:
   LV1M12_Understanding and Using Data Types
provided inside the moodle course!
Implement a simple application using different
numeric data types, representations and enums.
More LabVIEW Data Types
  LabVIEW Core 1, Module 13
                   Agenda
   What are Data Types?
   What is a Boolean?
   What are Strings?
   What is dynamic data?
         What are Data Types?
 Data types describe the type of representation
  of data.
 They have corresponding controls and
  indicators.
What is a Boolean and how is it used?
 A Boolean is a data type whose value is
  limited to two states (True and False).
 LabVIEW stores Booleans as 8-bit values,
  where a value of zero is false and any non-zero
  value is true.
 Demo: Boolean category of the Controls
  palette
 Mechanical Action: Properties  Operation
  What is a String and how is it used?
 A sequence of displayable or non-displayable
  ASCII characters
 A platform-independent format for
  information and data
 Common applications of strings include:
   Creating simple text messages
   Sending text commands to instruments
   Storing numeric data to an ASCII file
  What is a String and how is it used?
 Demo: String & Path category and the List,
  Table & Tree category of the Controls palette
 Right-click and select display mode
 Manipulating strings: String category of the
  Functions palette
What is Dynamic Data and when is it used?
 Dynamic data stores the information
  generated or acquired by an Express VI.
   Dark blue terminal with dark blue wires
 It can be wired to any indicator or input that
  accepts numeric, waveform, or Boolean data.
 For other data types: Convert from Dynamic
  Data Express VI
                   Quiz
 How many states can a Boolean have?
  a)   1
  b)   2
  c)   3
  d)   Infinite
                   Quiz
 How many bits of memory are required to
  store a single element of Boolean data?
  a)   1
  b)   8
  c)   16
  d)   32
                        Quiz
 Which of the following is an option for a
  Booleans mechanical action?
  a)   Switch When Pressed
  b)   Switch Until Released
  c)   Latch When Released
  d)   All of the above
                    Quiz
 What color wire represents a Boolean data
  type?
  a)   Orange
  b)   Blue
  c)   Yellow
  d)   Green
                           Quiz
 Which of the following is not a possible
  display mode for a string?
  a)   Normal Display
  b)   Password Display
  c)   Numeric Display
  d)   \ Codes Display
                  Exercise
Complete the exercise:
   LV1M13_More LabVIEW Data Types
provided inside the moodle course!
Use the Boolean and string data types to create
a basic login interface.
Documenting Code
LabVIEW Core 1, Module 14
                   Agenda
 Why is Documentation important?
 Using tip strips and descriptions to convey
  information to the user
 Using VI Properties to convey VI information
 Using block diagram documentation
Why is documentation important?
 Documenting the block diagram is important
  for maintainability and scalability of every
  LabVIEW VI.
 Documenting the front panel is important for
  explaining proper use of the VI to the user.
 Using Tip Strips and Descriptions
 Tip strips are brief descriptions that show up
  when hovering over an object on the front
  panel.
 Demo: Create numeric control and enter tip.
 Descriptions provide additional information
  about controls and indicators that appear in
  the Context Help window.
 Demo: Enter Description and open Context
  Help window.
            Using VI Properties
 A very useful tool to convey information when
  using subVIs is the Documentation tab of the
  VI Properties.
 Demo: right-click the VI icon and select VI
  Properties, Documentation in the Category
  dropdown
 VI description contains the text that appears
  in the Context Help window when the cursor
  is placed over the VI icon.
            Using VI Properties
 The Help tag contains the HTML filename or
  index keyword of the topic to be linked to in a
  compiled help file.
 The help path contains the path of the HTML
  or compiled help file to be linked.
 More information can be found by pressing
  the Help button.
 Using Block Diagram Documentation
 Block diagram labels:
   Labels on VIs or functions,
   Labels on wires, or
   Free labels.
 Demo: create all three types of labels
                    Quiz
 Documenting code makes it easier to track
  down errors.
  a) True
  b) False
                     Quiz
 What shows up after hovering over an object
  on the front panel?
  a)   Description
  b)   Label
  c)   Caption
  d)   Tip Strip
                     Quiz
 What shows up in the Context Help menu
  when hovering over a subVI?
  a)   Description
  b)   Label
  c)   Caption
  d)   Tip Strip
                          Quiz
 Which is an example of a block diagram label?
  a)   VI Label
  b)   Function Label
  c)   Free Labels
  d)   All of the above
                      Quiz
 Documenting code is important for
  maitainability and scalability of code.
  a) True
  b) False
                   Exercise
Complete the exercise:
   LV1M14_Documenting Code
provided inside the moodle course!
Use tip strips and descriptions for controls and
indicators, use VI Properties to document a VI,
and add block diagram labels to fully document
code.
   While Loops:
Repeating the Code
LabVIEW Core 1, Module 15
                  Agenda
 What is a While Loop?
 Using While Loops to repeat code
 Managing the loop with iteration and
  conditional terminals
 Transferring data into and out of a loop:
  tunnels
 Ensuring smooth execution of the code: error
  checking and handling
         What is a While Loop?
 A While Loop is a structure that continuously
  executes its containing code while or until a
  condition is met.
 Similar to a Do While or Do Until loop in text-
  based programming
         What is a While Loop?
 The code contained within the loop will
  execute, the condition will be checked, and
  the loop will then repeat or end, based of the
  evaluation of the condition.
         What is a While Loop?
 When using a While Loop, it is important to
  note that the code will always execute at least
  once.
Using While Loops to Repeat Code
 Demo: create a While Loop that will iterate
  until a random number generator creates a
  value above 0.5.
 Preserving the code in the loop: right-click on
  the loop border  Remove While Loop.
 Methods for moving code inside the loop:
   Draw the While Loop around
   Drag the code inside
Managing the Loop with Iteration and
      Conditional Terminals
 The iteration terminal is an output terminal
  that outputs the number of previously-
  completed iterations (starting at 0).
 The conditional terminal is an input terminal
  that receives a Boolean value. It has two
  different behaviors:
   Stop if true
   Continue if true (change with left- or right-click)
 Run the While Loop (Execution Highlighting)
            Transferring Data
 Tunnels route data into and out of structures.
 The tunnel generally appears as a solid block
  on the border of the While Loop.
 Move the numeric constant outside the loop
  and wire it.
 When data is routing out of the loop, the data
  will only be passed out of the loop when the
  loop finishes executing.
            Transferring Data
 Demo: Duplicate the While Loop and wire the
  Boolean of the first loop to the second loop.
 Run the While Loop (Execution Highlighting)
    Error Checking and Handling
 Ensuring smooth execution of the code: wire
  an Error Cluster directly into the conditional
  terminal.
 Demo: While Loop with Simulate Signal
  Express VI, wire Error Out to Conditional
  Terminal
 Demonstrate error: frequency value = 501
                          Quiz
 Which data type is accepted into the condition
  terminal of a While Loop?
  a)   Double
  b)   Integer
  c)   Boolean
  d)   String
  e)   All of the above
                      Quiz
 Which terminal does not exist in a While
  Loop?
  a) Loop Condition
  b) Loop Count
  c) Loop Iteration
                    Quiz
 A While Loop can run zero times.
  a) True
  b) False
                      Quiz
 In which situation would you typically use a
  While Loop?
  a) When you want to acquire 10 points of data
  b) When you want to acquire data until a condition
     occurs
  c) When you want to perform different actions in
     different situations
  d) None of the above
                       Quiz
 What is the value of the iteration terminal on
  the fifth iteration of a While Loop?
  a)   4
  b)   5
  c)   6
  d)   None of the above
                  Exercise
Complete the exercise:
   LV1M15_While Loops
provided inside the moodle course!
Create and use a While Loop to calculate how
many iterations it will take to match a randomly
generated number to a defined number.
         For Loops:
Running Code a Predetermined
      Number of Times
   LabVIEW Core 1, Module 16
                  Agenda
 What is a For Loop and how do we use it?
 What are the terminals on a For Loop?
 Using numeric conversion when defining the
  number of iterations.
          What is a For Loop?
 A For Loop adds the ability to run code a
  predetermined number of times.
 Useful in situations when we are acquiring or
  analyzing data sets of known lengths.
          What is a For Loop?
 Demo: create a For Loop
 Replace While Loop with For Loop (right-click)
What are the Terminals in a For Loop?
 Iteration Terminal: behaves the same way on a
  For Loop as it does on a While Loop
 Count Terminal: input, that is used to
  determine how many times to iterate (must
  be wired)
 Demo: show function of the terminals
 A For Loop can execute zero times!
What are the Terminals on a For Loop?
 Conditional Terminal: has to be added by
  right-clicking the border  it behaves exactly
  the same as in a While Loop.
 In a For Loop, the loop will stop running when
  it has reached its defined count even if the
  condition hasnt been met.
 Demo: stop For Loop when iteration count = 2
   Using Numeric Conversion When
   Defining the Number of Iterations
 The number of iterations must be specified in
  non-negative integers.
 Demo: wire a double-precision floating-point
  numeric to the count terminal  LabVIEW
  converts to 32-bit signed integer
                    Quiz
 Which data type is used by the count
  terminal?
  a)   String
  b)   Boolean
  c)   Integer
  d)   Double
                     Quiz
 A For Loop can run zero times.
  a) True
  b) False
                      Quiz
 In which situation would you typically use a
  For Loop?
  a) When you want to acquire 10 points of data
  b) When you want to acquire data until a condition
     occurs
  c) When you want to perform different actions in
     different situations
  d) None of the above
                     Quiz
 It is possible to stop a For Loop before the
  requested number of iterations is complete.
  a) True
  b) False
                       Quiz
 What happens when a double numeric
  constant is wired into the count terminal?
  a) A fraction of the loop will run based on the
     decimal part of the value
  b) An error occurs
  c) The loop will run indefinitely
  d) The value will be coerced into a 32-bit integer
                  Exercise
Complete the exercise:
   LV1M16_For Loops
provided inside the moodle course!
Create and use For Loops and compare them to
While Loops.
Timing Functions, Iterative Data
  Transfer and Shift Registers:
Controlling the Timing of a Loop
    LabVIEW Core 1, Module 17
                    Agenda
   Why use timing functions?
   How do we use timing functions?
   What is iterative data transfer?
   Using shift registers.
      Why use timing functions?
 Free running loops consume all the
  performance of the CPU.
   Demo: Free running while loop, loop count
    indicator, observe the task manager
 By using timing functions we can control the
  frequency at which a loop executes.
   e.g. acquiring data every two seconds
 How do we use timing functions?
 Demo: Timing palette, Wait function (100ms),
  observe the task manager
 Wait until Next ms Multiple function
   Useful for synchronizing activities across loops or
    for setting a sampling rate
 Tick count function
    What is iterative data trasfer?
 A shift-register allows data to flow between loop
  iterations.
 Demo: right-clicking the border of the loop, Add
  Shift Register, initialize by wireing a value into the
  left side, (remove afterwards the init)
    The value which comes out on the left side after the
     first iteration will be the value which was stored on
     the right side on the previous iteration.
 If we want to remember values of multiple
  previous iterations, we can create stacked shift
  registers.
           Using shift registers
 Demo: calculate the time between the
  iterations of a loop.
   Tick Count function
 Uninitialized shift registers return a default
  value of zero (if the loop has never run) or the
  value of the last iteration.
                         Quiz
 Which is the preferred method to pass data
  between loop iterations?
  a)   Tunnels
  b)   Shift registers
  c)   Indicators
  d)   Controls
                      Quiz
 An uninitialized shift register will cause a
  broken Run button
  a) True
  b) False
                       Quiz
 Which data type can be used in a shift
  register?
  a)   Integer
  b)   Double
  c)   Boolean
  d)   All of the above
  e)   None of the above
                     Quiz
 You can use shift registers to access data from
  previous iterations
  a) True
  b) False
                     Quiz
 You can use more than one shift register in a
  loop
  a) True
  b) False
                   Exercise
Complete the exercise:
   LV1M17_Timing Functions
provided inside the moodle course!
Use the Tick Count and Wait timing functions
and use shift registers on while loops to store
data between iterations.
Case Structures: Allowing Our
 Program to Make Decisions
    LabVIEW Core 1, Module 18
                  Agenda
 What is a case structure?
 Selecting a case.
 Using case structures with different data
  types.
 Transferring data into and out of case
  structures with input and output tunnels.
       What is a case structure?
 If the code needs to decide which action to take
  next, we need to use a case structure.
   has two or more subdiagrams or cases
   case selector chooses which case to execute
 Demo: place case structure from structures
  palette into the while loop
              Selecting a case
 Demo
 The selector terminal can be wired with
  Boolean values, strings, numerics, enums and
  error cluster values.
 The case selector lable contains the name of
  the current case.
   Right-click to Add case..., Duplicate case, Delete
    case
   Transferring data into and out of case
 structures with input and output tunnels
 Demo:
   Increment/Decrement switch,
   wire the initialized shift register into the case
    structure,
      TRUE: increment function,
      FALSE: decrement function,
   wire output to numeric indicator
 Use default if unwired
   not a good programming practice
 Using case structures with different
              data types
 Demo:
   Numeric control Dec (0), Inc (1), Reset (2), U8
    wired into the case selector
   Add a new case: reset case 2, wire 0 to the output
    tunnel, Make this case default
 Demo:
   Create an enum (Inc, Dec, Reset)
   connect it to the case selector
                    Quiz
 A case structure can be used to
  programmatically choose an action.
  a) True
  b) False
                     Quiz
 A case structure will always run code multiple
  times.
  a) True
  b) False
                       Quiz
 Which data type can be wired into the
  selector terminal of a case structure?
  a)   Boolean
  b)   Numeric
  c)   String
  d)   All of the above
  e)   None of the above
                       Quiz
 Which data type can be used to make case
  names more descriptive?
  a)   Boolean
  b)   Numeric
  c)   Enum
  d)   None of the above
                       Quiz
 Use Default if Unwired is a property which can
  be applied to which of the following?
  a)   Output tunnel
  b)   Shift register
  c)   Input tunnel
  d)   Case selector
  e)   None of the above
                  Exercise
Complete the exercise:
   LV1M18_Case Structures
provided inside the moodle course!
Use case structures to perform different actions
based on the values of controls.
Wiring and Debugging
     Techniques
LabVIEW Core 1, Module 19
                 Agenda
 Wiring techniques
 Debugging techniqes
            Wiring techniques
 Left to right: enforced by LabVIEW
 Avoid crossing of wires whenever possible
 Avoid unneccessary wire kinks
   Press the space-bar to change the orientation of
    the wiring path
 Minimize the size of the block diagram to the
  size of one screen
   Place repeated code or sprawling code inside
    subVIs
   If scrolling, than scroll only in one direction
         Debugging techniques
 Error list window
   to highlight the error on the block diagram
 Probes on certain wires to check values
 Execution highlighting to watch the code run
 Breakpoints to pause the code
   Single-stepping once the breakpoint is reached
                       Quiz
 On a block diagram, in which direction should
  code be written or read?
  a)   Right to left
  b)   Top to bottom
  c)   Left to right
  d)   Bottom to top
                       Quiz
 How do you select all branches of a wire?
  a)   Single-click
  b)   Double-click
  c)   Triple-click
  d)   Control-click
                        Quiz
 While creating a wire, how can we change the
  orientation of the wire?
  a)   Press the spacebar while wiring
  b)   Double-click while wiring
  c)   Right-click while wiring
  d)   Hold <Ctrl-O> while wiring
                        Quiz
 Which debugging tool is associated with a
  broken Run button?
  a)   Probes
  b)   Error List Window
  c)   Execution highlighting
  d)   Single stepping
                    Quiz
 Execution highlighting slows down the
  execution of code.
  a) True
  b) False
                  Exercise
Complete the exercise:
   LV1M19_Wiring and Debugging Techniques
provided inside the moodle course!
Clean up a block diagram and use probes, single-
stepping, and breakpoints to debug code.
Arrays: Grouping Data
LabVIEW Core 1, Module 20
                    Agenda
   What is an array?
   How can we create and use arrays?
   Auto-indexing array inputs and outputs.
   Using arrays with loops.
            What is an array?
 Data structure that:
   Consists of elements
   Has one or more dimensions
   Is used to group data of the same data type
How do we create and use arrays?
 Demo:
    Add array shell to the front panel, place a data object
     into the shell, enlarge the array to 5 elements and set
     them
 The index value indicates the position of the
  element inside the array
    Zero-indexed (like loops)
 We can not create an array within another array
    we can increase the dimension
    2D-array is like a spreadsheet, rows and columns
    Right-click index display, add dimension
How do we create and use arrays?
 Demo:
   To create an array constant, add an array shell to
    the block diagram, place a constant into the shell,
    ...
   the rest is similar to an array shell on the front
    panel
  Auto-indexing Array Inputs and Outputs
 Arrays store data produced in a loop, each
  iteration produces one element.
 Auto-indexing is used to link each iteration of the
  loop to an element from the array.
 Demo:
    Modify the case example; use a for loop, run it 500
     times, wire the counter output to the edge of the for
     loop, create an indicator outside the loop
 Auto-indexing is turned on by default in the case
  of for-loops
  Auto-indexing Array Inputs and Outputs
 Nested loops will
  generate multi-
  dimensional arrays
 Auto-indexing allows us to
  leave the count terminal
  unwired
    The count information is
     derived from the array size
                    Quiz
 Arrays can be used to group items with
  different data types.
  a) True
  b) False
                     Quiz
 Wires in the block diagram for arrays are the
  same color as the corresponding scalar
  a) True
  b) False
                       Quiz
 Which of the following data types can be used
  to create an array?
  a)   Boolean
  b)   String
  c)   Numeric
  d)   All of the above
  e)   None of the above
                     Quiz
 Arrays are a good tool for storing data
  produced by a loop.
  a) True
  b) False
                   Quiz
 Arrays con contain more than one dimension
  a) True
  b) False
                    Exercise
Complete the exercise:
   LV1M20_Arrays
provided inside the moodle course!
Manipulate arrays using the auto-indexing
feature of For Loops.
 Array Functions:
Manipulating Arrays
LabVIEW Core 1, Module 21
                  Agenda
 Introduction
 Creating and manipulating arrays
 Exploring other array functions in LabVIEW
 Creating and Manipulating Arrays
 Is there a way to create and manipulate an array
  without using loops?
 Demo: Small business wants to track the vacation days
  of its employees
    Initialize Array function; Size: 5; Element: 10, Indicator to
     display output
 Arrays are great tools for storing multiple pieces of
  data of the same data type
 Demo: modify an element
    Index Array function, Index 1, Decrement Function
    Replace Array Subset function, Index Value: 1, Create
     Indicator
 Creating and Manipulating Arrays
 Demo: Adding Elements to the array
   Insert Into Array function, Index 2, New Value: 8,
    Create Indicator
 Because arrays are zero indexed, the value for
  the position will be one less than the order of
  the element.
 Another method to add an entry to the end of
  the array:
   Build Array function (concatenating inputs)
 Creating and Manipulating Arrays
 Demo: Tracking vacation days and sick days at
  the same time
   Form a two-dimensional array using the Build
    Array function (concatenate inputs turned OFF!)
   Index Array function (note: expanding), Column
    Index 2
          Exploring Other Array
          Functions in LabVIEW
 Delete From Array will delete a subset of an
  array defined by index and length.
 Search 1D Array will search an array for a
  defined element, and return the index of the
  first instance of that element that is found.
                        Quiz
 Which function can we use to create an array?
  a)   Initialize
  b)   Build
  c)   Index
  d)   Replace
  e)   Both a) and b)
                        Quiz
 Which function can output an array with a
  higher dimension than the input?
  a)   Initialize
  b)   Build
  c)   Index
  d)   Replace
  e)   Both a) and b)
                        Quiz
 Which function can output an array with a
  smaller dimension than the input?
  a)   Initialize
  b)   Build
  c)   Index
  d)   Replace
  e)   Both b) and c)
                        Quiz
 Which function can output an array with the
  same dimension as the input?
  a)   Initialize
  b)   Build
  c)   Index
  d)   Replace
  e)   Both b) and d)
                     Quiz
 The Insert Into Array function can only be
  used to add a single element to an array.
  a) True
  b) False
                   Exercise
Complete the exercise:
   LV1M21_Array Functions
provided inside the moodle course!
Use functions in the Array sub-palette to
manipulate arrays.
Clusters: Grouping Data
 LabVIEW Core 1, Module 22
                  Agenda
 Introduction
 What is a cluster?
 How do we create and use clusters?
            What is a Cluster?
 Arrays group together data elements of the
  same type.
 Clusters group together data elements of
  mixed types.
 An error cluster is an example.
 Similar to a record or a struct in text-based
  programming languages
            What is a Cluster?
 Elements that make up a cluster must be
  added individually.
 It is either a control or an indicator, and
  cannot contain a mixture of controls and
  indicators.
           What is a Cluster?
 We often pass many pieces of data between
  structures or subVIs.
 We can use clusters to pass the data more
  easily and with less clutter.
 The connector pane has 28 terminals at most,
  therefore we can use a cluster to pass more
  data.
 How do we create and use Clusters?
 Demo: create a cluster
   Place cluster shell (Array, Matrix, & Cluster
    palette)
   Drag data objects or elements into the cluster
    shell (enum -> rename to Command)
   Add three numerics and call them Counter, Max,
    and Min (integers)
   Arrange: AutoSizing and options
   Cluster order: maybe different from order in block
    diagram -> re-order!
 How do we create and use Clusters?
 Demo: using Bundle and Unbundle functions
   Wire cluster into shift register of an For loop
   Drop Unbundle by Name function (compare to
    Unbundle function)
   To replace the values of one or more elements in a
    cluster -> Bundle by Name function (wire cluster
    to the middle terminal)
   Wire output into right terminal of the shift register
How do we create and use Clusters?
                    Quiz
 Clusters can be used to group items with
  different data types.
  a) True
  b) False
                          Quiz
 Clusters can be used as which type of object?
  a)   Controls
  b)   Indicators
  c)   Constant
  d)   All of the above
                    Quiz
 The Unbundle function will always unbundle
  all elements of the cluster.
  a) True
  b) False
                   Quiz
 The Unbundle by Name function will always
  unbundle all elements of the cluster.
  a) True
  b) False
                     Quiz
 Clusters must always have a fixed size.
  a) True
  b) False
                   Exercise
Complete the exercise:
   LV1M22_Clusters
provided inside the moodle course!
Create clusters on the front panel window,
reorder clusters, and use the cluster functions to
assemble and disassemble clusters.
Plotting Data: Graphs and Charts
      LabVIEW Core 1, Module 23
                   Agenda
   Introduction
   How to plot data
   What are waveform charts?
   What are waveform graphs?
   What are XY graphs?
How to Plot Data
    What are Waveform Charts?
 A waveform chart is a special type of numeric
  indicator that displays one or more plots of
  data, typically acquired at a constant rate.
     What are Waveform Charts?
 A chart is used to update data as it is acquired.
 It is also an effective way to display data with
  history.
 A waveform chart can have one of three updates
  modes: Strip Chart, Scope Chart, and Sweep
  Chart.
 Demo: Waveform chart; change modes
 To wire multiple plots on the waveform chart, we
  use a cluster of numerics.
 Demo: change plot legend, scale legend
    What are Waveform Graphs?
 Waveform graphs are used to plot single-value
  functions, with evenly-distributed points along
  the x-axis.
 These graphs can also have single or multiple
  plots.
 Data for a waveform graph is usually collected
  in an array.
 Demo: Waveform graph
    What are Waveform Graphs?
 Waveform graphs are different from charts in that
  they dont display data being added point by
  point.
 Notice that the x-axis is labelled as Time, but
  what is actually being used is the index of the
  element in the array.
 We can also use a waveform data type to plot
  data on the graph, which allows us to define a
  starting time and a time between points.
 Demo: Build Waveform function
What are Waveform Graphs?
          What are XY Graphs?
 Both of the waveform chart and waveform
  graph that we just examined assume that the
  data that is distributed evenly along the x-axis.
 When this is not the case, we can use an XY
  graph to associate specific X values with our
  data points.
 The spacing of data is non-uniform, and XY
  graphs can also have single or multiple plots.
        What are XY Graphs?
 Demo: XY Graph
                       Quiz
 Which type of graph keeps a history of
  previously plotted data?
  a)   Waveform Chart
  b)   Waveform Graph
  c)   XY Graph
  d)   All of the above
  e)   None of the above
                       Quiz
 Which type of graph would we use to display
  an evenly distributed function?
  a)   Waveform Chart
  b)   Waveform Graph
  c)   XY Graph
  d)   All of the above
  e)   None of the above
                       Quiz
 Which type of graph would we use to display
  data points associated with non-evenly
  distributed points in time?
  a)   Waveform Chart
  b)   Waveform Graph
  c)   XY Graph
  d)   All of the above
  e)   None of the above
                       Quiz
 Which type of graph is capable of displaying
  multiple plots?
  a)   Waveform Chart
  b)   Waveform Graph
  c)   XY Graph
  d)   All of the above
  e)   None of the above
                          Quiz
 Which function is used to define the start time
  and increment for a waveform?
  a)   Build Waveform
  b)   Unbundle
  c)   Build Array
  d)   All of the above
                  Exercise
Complete the exercise:
   LV1M23_Plotting Data
provided inside the moodle course!
Plot multiple data sets on a single waveform
chart and customize the chart.
Type Definition: Custom Controls
      LabVIEW Core 1, Module 24
                    Agenda
   Introduction
   What is a Type Definition?
   How do we create Type Definitions?
   Customizing the appearance of controls
      What is a Type Definition?
 It is important to modularize code into subVIs,
  so that it is easy to modify, scale, and to
  debug.
 Clusters can be used to simplify the usage of
  multiple pieces of data.
 Type definitions can be used to define and
  save data types.
      What is a Type Definition?
 Type of customized control used to define a
  customized data type.
 Can be used in multiple instances across a
  project.
 Saved as a .ctl file
      What is a Type Definition?
 By making a change to the type definition, we
  can change all instances.
 We can maintain one instance of the type
  definition, acting like a single central location
  for all instances.
 Type definitions can be used as controls,
  constants, and indicators.
      What is a Type Definition?
 Type definitions will only maintain the data
  type, not the appearance or specific data
  inside the control, constant, or indicator.
 To maintain the appearance of custom
  controls, we can use strict type definitions.
  How do we create Type Definitions?
 Demo: right-click control or indicator, select
  Advanced, then Customize.
 Use Type Definition Status pull-down to
  choose between Type Def., Strict Type Def., or
  Custom Control.
 Start with Type Def., change it later to Strict
  Type Def., Save
 Extend Enum, Save and Update
    Customizing the Appearance of
              Controls
 Demo: customize the appearance of a
  numeric control.
 Select Window  Show Parts
 Import pictures
    Customizing the Appearance of
              Controls
 Demo: search for controls in the NI Example
  Finder
 Open the Using Custom Controls example
                      Quiz
 Type definitions act as a single central location
  for our customized data types.
  a) True
  b) False
                          Quiz
 Type definitions can be used as which type of
  object?
  a)   Controls
  b)   Indicators
  c)   Constants
  d)   All of the above
                     Quiz
 A Type Definition will maintain the
  appearance of a control.
  a) True
  b) False
                      Quiz
 A Strict Type Definition will maintain the
  appearance of a control.
  a) True
  b) False
                     Quiz
 Individual items of a control, such as the
  increment button, cannot be customized.
  a) True
  b) False
                   Exercise
Complete the exercise:
   LV1M24_Type Definitions
provided inside the moodle course!
Create a type definition and a strict type
definition and identify the differences.
Understanding File I/O
 LabVIEW Core 1, Module 25
                   Agenda
 What is file I/O?
 What are the different file types?
 How do we use high-level file I/O VIs?
             What is File I/O?
 Create or Open the file
   Unique ID - Refnum
 Read from or Write to the file
 Close the file
 Error handling
  What are the different file types?
 Binary File
    Underlying file format of all other file formats
    least amount of overhead, small and fast
 ASCII File, Text File
    Specific type of binary file that is a standard used by most
     programs
 LVM - LabVIEW measurement data
    a tab-delimited text file you can open with a spreadsheet
     application or a text-editing application
 TDMS File
    Type of binary file created for NI products consisting of
     two separate files: a binary file and a binary index file
How do we use high-level file I/O VIs?
 Perform all three steps (open
  read/write, close) for common
  file I/O operations.
 Might not be as efficient as the
  functions configured of
  designed for individual
  operations.
 Low-Level File I/O VIs
    Individual VI for each step
    Used for writing to a file in a loop.
How do we use high-level file I/O VIs?
 Demo
   place a Write to Spreadsheet File VI outside the For
    loop
   wire the Min and Max Values to the edge of the For
    loop and Build Array with Counter, Min and Max
   look into the context help of the File VI
 Demo
   New VI, Read from Spreadsheet File VI
   Choose a constant for the path, right-click and browse
    for path
   Create a Waveform Graph and display the data
                       Quiz
 Which sequence of steps is required for file I/O?
  a)   Open, Authenticate, Read/Write, Close
  b)   Open, Read/Write, Close
  c)   Scan, Open, Transfer, Close
  d)   Open Analyze, Close
                      Quiz
 Binary file types are typically smaller than text
  files containing the same data
  a) True
  b) False
                      Quiz
 Which file type is not used in LabVIEW?
  a)   Text File
  b)   LabVIEW Measurement Data File
  c)   TDMS File
  d)   Universal Transfer File
                     Quiz
 High-level VIs allow more control and
  flexibility than low-level VIs when performing
  I/O.
  a) True
  b) False
                       Quiz
 What happens when a specified path to read
  from in invalid
  a) An error occurs
  b) The path will default to the C: directory
  c) The VI will skip the function
                    Exercise
Complete the exercise:
    LV1M25_Understanding File IO
provided inside the moodle course!
Use a high-level file I/O VI to write to a
spreadsheet-readable file.
Understanding Low-Level File I/O
      LabVIEW Core 1, Module 26
                    Agenda
 What is low-level file I/O?
 Disk streaming
             High-Level File I/O VIs
 High-level file I/O VIs make programming simple, by
  wrapping up all of the steps of the I/O process:
      Opening a file
      Writing to a file
      Reading from a file
      Closing the file
      What if Low-Level file I/O?
 Low-level file I/O VIs and functions perform
  one piece of the file I/O process and are faster
  and more efficient than high-level ones.
 Low-level file I/O includes functions to open,
  read, write, and close files.
                        Disk Streaming
 Disk streaming is a technique for keeping files open while we perform
  multiple write operations within a loop.
 Demo:
     Place an Open/Create/Replace File function to the left of the For loop and a
      Close file function to the right of the For loop.
     Place a Write to Text File function inside our loop.
     Wire it together, replace the refnum and error tunnel with shift registers
     Operation: open or create
     Place a Number to Decimal String function inside our loop (Counter Value)
     Place a Concatenate String function with a Carriage return constant
 Demo:
     Blank VI, Open/Create/Replace File function, Close File function, and Read
      from Text File function
     Create a path constant, Browse for Path
     Create a String indicator
                     Quiz
 Low-level file I/O VIs and functions perform
  more than one piece of the file I/O process.
  a) True
  b) False
                       Quiz
 What is a technique for keeping file open
  while multiple write operations are performed
  within a loop?
  a)   Write Looping
  b)   Disk Streaming
  c)   Low-Level Looping
  d)   All of the Above
                     Quiz
 When continuously saving with low-level file
  I/O functions, the file is opened before the
  loop starts and closed once when the loop
  finishes.
  a) True
  b) False
                     Quiz
 What is a character called which signifies a
  separation between pieces of data in a
  spreadsheet file?
  a)   Placeholder
  b)   Threshold
  c)   Separator
  d)   Delimiter
                     Quiz
 Low-level file I/O VIs are more efficient when
  performing multiple write-operations
  a) True
  b) False
                   Exercise
Complete the exercise:
   LV1M26_Understanding Low Level File IO
provided inside the moodle course!
Modify a VI to create an ASCII file using disk
streaming.
DAQ: Acquiring Data
LabVIEW Core 1, Module 27
                  Agenda
 What is DAQ?
 Using DAQ Software
 Using the DAQ Assistant
                DAQ Programming
 DAQ - Data Acquisition
      1. Signal
      2. Terminal Block
      3. Cable
      4. DAQ Device
      5. Computer
              What is DAQ?
 Use LabVIEW to interface and communicate
  with the DAQ system.
 Acquire data using the DAQ Assistant Express
  VI.
 Use LabVIEW to process, analyze, save, and
  display data.
          Using DAQ Software
 Demo:
   Measurement and Automation Explorer - MAX
   Devices and Interfaces
   Create New: Simulated NI-DAQmx Device or
    Instrument
   X-Series, NI PICe 6351 Device
                NI-DAQmx
 Driver-level software that can be installed
  with LabVIEW
 Set of VIs which can be used to program DAQ
  applications
 Configurable Express VI used to create a DAQ
  application
       Using the DAQ Assistant
 Demo:
   Blank VI, Measurement I/O, NI-DAQmx, DAQ
    Assistant
   Acquire Signals, Analog Input, Voltage, a0-a3
   Acquisition mode: Continuous, click Run-button to
    try, OK
   Create a Graph Indicator for the data
                    Quiz
 DAQ stand for Data Acquisition.
  a) True
  b) False
                       Quiz
 The first step to configure a DAQ program uses
  which tool?
  a)   The DAQ API
  b)   The DAQ Assistant
  c)   MAX
  d)   None of the above
                    Quiz
 The Advanced Timing tab allows you to
  choose from internal or external sample clock
  sources.
  a) True
  b) False
                      Quiz
 Which data file type can be enabled to log
  data using the DAQ Assistant?
  a)   LVM
  b)   TDMS
  c)   TDM
  d)   None of the Above
                     Quiz
 If you are acquiring data continuously you
  should run the DAQ Assistant in a loop.
  a) True
  b) False
                  Exercise
Complete the exercise:
   LV1M27_Data Acquisition_DAQ
provided inside the moodle course!
Build a simple example with the DAQ Assistant.
 DAQ Programming
LabVIEW Core 1, Module 28
                Agenda
 What is the DAQmx API?
 Programming with DAQmx
        What is the DAQmx API?
 The DAQmx API is a set of VIs which allows us to read
  from and write to DAQ devices.
 DAQmx API VIs takes advantage of the powerful and
  flexible DAQ options available within LabVIEW.
     Programming with DAQmx
 Processes of a DAQ Program
   Creating a task
   Configuring the task
   Starting the task
   Acquiring or generating data
   Clearing the task
     Programming with DAQmx
 Demo:
   Example Finder, Search DAQmx,
      Acq One Sample.vi,
      Cont Acq&Chart Samples-Int.vi
      Acq&Graph Voltage-Int.vi
   Configure DAQ channels, ai0-ai3
   Examine the block diagram
                       Quiz
 Which process is involved in a basic DAQ
  program?
  a)   Creating a task
  b)   Starting a task
  c)   Acquiring and generating data
  d)   Clearing the task
  e)   All of the above
                    Quiz
 A polymorphic VI can have different forms.
  a) True
  b) False
                    Quiz
 What are the different forms of a Polymorphic
  VI called?
  a)   Cases
  b)   Methods
  c)   Instances
  d)   Procedures
                       Quiz
 Which type of channel can be read with the
  DAQmx Read VI?
  a)   Analog
  b)   Digital
  c)   Counter
  d)   All of the above
  e)   None of the above
                       Quiz
 Which VI is not part of the DAQmx API
  a)   DAQmx Read VI
  b)   DAQmx Clear Task VI
  c)   DAQmx Timing VI
  d)   All of the above
  e)   None of the above
                  Exercise
Complete the exercise:
   LV1M28_DAQ Programming
provided inside the moodle course!
Explore a DAQmx example program that
continuously acquires data, and modify it to
wait on a digital trigger.
Instrument Control
LabVIEW Core 1, Module 29
                    Agenda
   Introduction
   What is instrument control?
   Instrument control software?
   What are instrument drivers?
   Using instrument drivers
    What is Instrument Control?
 Refers to the use of software to control an
  instrument
 Important application of LabVIEW
 Uses instrument control buses to
  communicate with devices
            Instrument Control
   General Purpose Interface Bus (GPIB)
   Serial
   Ethernet
   Universal Serial Bus (USB)
   IEEE 1394 (FireWire)
    Instrument Control Software
 Measurement & Automation Explorer (MAX)
 MAX can be accessed from inside LabVIEW by
  selecting Measurement & Automation
  Explorer from the Tools menu.
 Only in the Lab: select the Agilent 33521A
  Function/Arbitrary Waveform Generator.
   What are Instrument Drivers?
 Set of high-level functions
 Controls and communicates with a
  programmable instrument
 Generally use the LabVIEW VISA application
  programming interface (API)
           Instrument Driver VIs
   Are not required to use the instruments
   Simplify instrument control
   Reduce test program development time
   Eliminate the need to learn the complex low-
    level programming commands
       Using Instrument Drivers
 Demo: Open the Instrument Driver Finder by
  selecting Instrumentation from the Tools menu
  and then selecting Find Instrument Drivers.
 Install the driver for our Agilent 33521A.
 Find Examples: Frequency Sweep.
 Examine the Block Diagram: The VIs in an
  instrument driver are organized into six
  categories. These categories are: Init, Config,
  Action/Status, Data, Utility, and Close.
                    Quiz
 Instruments can only be connected to the
  computer using the USB bus.
  a) True
  b) False
                       Quiz
 What is the purpose of the Measurement &
  Automation Explorer?
  a) It uses the VISA API functions to communicate
     with a device
  b) It downloads instrument drivers
  c) It configures the hardware that is installed on
     the computer
  d) Both a) and b) are correct
                     Quiz
 Which of the following is not true about
  instrument drivers?
  a) They are required to use the instrument
  b) Manufacturers sometimes provide instrument
     driver VIs
  c) They can be downloaded using the NI
     Instrument Drivers Finder
  d) They can simplify instrument control
                       Quiz
 Which of the following is not one of the
  categories that the VIs in an instrument driver
  are divided into?
  a)   Init
  b)   Config
  c)   Action/Status
  d)   Data
  e)   Reference
                     Quiz
 The instrument driver VIs make calls to low-
  level device driver VIs.
  a) True
  b) False
                  Exercise
Complete the exercise:
   LV1M29_Instrument Control
provided inside the moodle course!
Use an instrument driver to communicate
effectively with an instrument.
Instrument Control Programming
     LabVIEW Core 1, Module 30
                    Agenda
   Introduction
   Using the Instrument I/O Assistant
   What is the VISA API?
   VISA programming
Using the Instrument I/O Assistant
 Some of the commands will be common
  among many devices, like the identify
  command.
 These common commands are defined by the
  Standard Commands for Programmable
  Instruments, or SCPI, standard.
 The Instrument I/O Assistant is a great tool for
  quickly interfacing with a device.
Using the Instrument I/O Assistant
 Demo: open Express VI Instrument I/O
  Assistant
 This Express VI is similar to the DAQ Assistant,
  but communicates with a VISA device instead
  of a DAQ device.
 To add a step, we can click Add Step at the top
  of the screen -> add one of each step
Using the Instrument I/O Assistant
 Demo: enter *IDN? in the Query and Parse
  (Abfragen und Analysieren) step  this is the
  identify command.
 Click the Auto Parse (Autom. Analyse) button.
 Click the To End of Data (Nach Ende der
  Daten) button.
 Rename the tokens and return to LabVIEW,
  wire a string indicator.
     What is the VISA Application
     Programming Interface (API)?
 LabVIEW includes device drivers to
  communicate with instrumentation.
 VISA functions allow you to send specific
  commands to the instrument.
                 VISA API
 High-level API
 Calls low-level drivers
 Uses the same functions to communicate with
  different instruments
 Uses the same functions to interact with a
  large number of communication protocols
            VISA Terminology
 Resource  any instrument in the system
 Instrument descriptor  the exact name of a
  resource
 Session  connection
 VISA Alias  a user-defined name
           VISA Programming
 VISA functions operate similar to File I/O
  functions.
 First, we open a session with a VISA resource,
  i.e. the instrument.
 Then we perform I/O operations.
 Finally, we close the session to the VISA
  resource.
           VISA Programming
 Demo: search for GPIB in the NI Example Finder
 Open GPIB-VISA.vi; delete step no. 2
 VISA Open establishes a communication line to
  resource.
 We use the VISA Write function to send a
  command or query string to an instrument
  (*IDN?)
 We use the VISA Read function to read a
  response from the instrument.
 VISA Close will close the session.
                      Quiz
 Which of the following is a benefit of using the
  VISA functions?
  a) VISA functions provide interface independence
  b) VISA functions allow faster connection between
     hardware and computer
  c) VISA functions convert codes for other serial
     devices
  d) VISA functions install the drivers for the
     hardware
                         Quiz
 Which of the following is not a step inside the
  instrument I/O Assistant?
  a)   Write
  b)   Query and Parse
  c)   Read and Parse
  d)   Timeout
                      Quiz
 Which of the following is true about the
  Instrument I/O Assistant Express VI?
  a) The Query and Parse step can only read and
     parse the data
  b) It is located in the Structures Palette
  c) The Write step reads the data from the device
  d) It communicates with a VISA Instrument
                      Quiz
 What is the Auto Parse button used for?
  a) It automatically converts raw data received from
     the instrument into a usable data type
  b) It automatically receives raw data from the
     instrument
  c) It automatically converts usable data into raw
     data to send to the instrument
  d) It automatically writes the command to the
     instrument
                       Quiz
 Which of the following is not part of the
  typical VISA program flow?
  a)   Writing string commands
  b)   Closing a session
  c)   Connecting the instrument to the computer
  d)   Reading the response strings
  e)   Opening a session
                  Exercise
Complete the exercise:
   LV1M30_Instrument Control Programming
provided inside the moodle course!
Use the VISA API functions to communicate
effectively with an instrument.
Understanding Modularity
  LabVIEW Core 1, Module 31
                    Agenda
   Introduction
   What is modularity?
   What is a subVI?
   Using subVIs
          What is Modularity?
 When programming in LabVIEW, complex
  programs can be built easily using the variety
  of functions provided.
 Express VIs and low-level VIs allow us to write
  applications, including
   Complex acquisition
   Sophisticated analysis
   Robust data presentation
   Flexible file I/O
          What is Modularity?
 LabVIEW code is easily-written, easily-debugged,
  and can be easily-modified.
 Modularity refers to the degree to which a
  program is composed of discrete modules, such
  that a change to one module has minimal impact
  on other modules.
 It allows us to buid code faster using reusable
  pieces.
 It allows us to change the code quickly in one
  location.
          What is Modularity?
 Type definitions are an example of creating
  modular controls, indicators, and constants.
 Changing a type definition in one place,
  changes all instances of it automatically.
 Modules in LabVIEW are called subVIs.
             What is a SubVI?
 A subVI is a VI that has been configured to run
  within another VI.
 It can be placed on the block diagram and it
  appears with a customizable icon.
 It can also be configured to pass data in and
  out.
             What is a SubVI?
 SubVIs correspond to subroutines in text-
  based programming languages.
 The upper-right corner of both the front panel
  and block diagram displays the icon for the VI.
               Using SubVIs
 One use of subVIs is centralizing code into a
  discrete module.
 Demo: select code and Create subVI
 Next step: customize icon and rearrange the
  connector pane (later module)
                     Quiz
 Modularity refers to the degree to which a
  program is composed of discrete modules,
  such that a change to one module has
  minimal impact on other modules.
  a) True
  b) False
                        Quiz
 Which of the following are modular elements
  of LabVIEW code?
  a)   SubVIs
  b)   Type definitions
  c)   Built-in LabVIEW functions
  d)   All of the above
                     Quiz
 A subVI is a VI that has been configured to run
  within another VI.
  a) True
  b) False
                       Quiz
 Which of the following is true when creating a
  subVI?
  a) The code within it is replaced on the block
     diagram with a subVI containing a default icon.
  b) The wires required to run into and out of the
     subVI have been automatically arranged to the
     connector pane.
  c) The subVI has a customizable icon
  d) All of the above
                    Quiz
 SubVIs can be used to perform a task and
  return a result.
  a) True
  b) False
                  Exercise
Complete the exercise:
   LV1M31_Understanding Modularity
provided inside the moodle course!
Identify elements that make an effective subVI
and convert a piece of code into a subVI.
 Building the Icon
and Connector Pane
LabVIEW Core 1, Module 32
                   Agenda
   Introduction
   Why do we use the Icon and Connector Pane?
   Creating an Icon
   Setting up the Connector Pane
      Why do we use the Icon and
          Connector Pane?
 When programming with modularity in mind,
  we almost always need to use subVIs.
 To effectively use a VI as a subVI, we need to
  create a meaningful icon and well organized
  connector pane.
 Every VI has an icon associated with it, which
  is displayed in the upper-right corner of the
  front panel and block diagram.
      Why do we use the Icon and
          Connector Pane?
 The icon is a graphical representation of a
  subVI that identifies it on the block diagram of
  another VI.
 The connector pane defines the input and
  output terminals of our subVI when it is
  placed on the block diagram. These are
  required to pass data into and out of a subVI.
              Creating an Icon
 Once we've opened or created a VI to be used
  as a subVI, the next step is to customize the
  icon.
 Demo: modify the previous example by
  replacing the Case Structure with a subVI.
   It simplifies and cleans up the Block Diagram;
   Code can be easily used in another place.
 Open the subVI by double-clicking it, right-
  click the Icon and select Edit Icon.
             Creating an Icon
 Demo: modify the Icon:
   Select a template with two boxes;
   Fill the upper box with red;
   Save as Template: Red Box;
   Enter Text;
   Modify Layers and Opacity.
 Click the Help button for more information.
   Setting up the Connector Pane
 Once we've created the icon, the next step to
  configuring a VI to work as a subVI is to define
  connections on the connector pane.
 Each rectangle on the connector pane
  represents a terminal.
 By default, a subVI created from existing code
  will be generated using the default pattern,
  which is this one:
   Setting up the Connector Pane
 If we need to add more inputs or outputs than
  can be handled by this pattern, we can select
  a different pattern by right-clicking the
  connector pane and selecting patterns from
  the shortcut menu.
 In general, we should avoid using connector
  panes with more than 16 terminals.
 Demo: Rearrange terminals of our subVI.
   Setting up the Connector Pane
 In general, top terminals are reserved for
  references, or the main input to a subVI.
 Bottom terminals are usually reserved for
  error clusters.
                       Quiz
 Where on the front panel and block diagram
  are the icon and connector pane located?
  a)   Upper-left corner
  b)   Upper-right corner
  c)   Bottom-right corner
  d)   Bottom-left corner
                    Quiz
 The connector pane is defined on the block
  diagram of a VI.
  a) True
  b) False
                       Quiz
 Which is a tab in the Icon Editor?
  a)   Layers
  b)   Icon Text
  c)   Glyphs
  d)   All of the above
  e)   None of the above
                     Quiz
 A subVI is represented by its icon on the block
  diagram of another VI.
  a) True
  b) False
                     Quiz
 It is important to have a meaningful icon and a
  well-organized connector pane for your
  subVIs.
  a) True
  b) False
                  Exercise
Complete the exercise:
   LV1M32_Building the Icon and Connector Pane
provided inside the moodle course!
Create an example VI with a descriptive icon and
properly arranged connector pane.
    Using SubVIs
LabVIEW Core 1, Module 33
                 Agenda
 How do we place and open a subVI?
 Terminal settings
 Handling errors in subVIs
 How do we place and open a subVI?
 Demo:
   Method 1:
     Block diagram, Select a VI on the functions palette,
      select a subVI and place it on the block diagram, wire it
   Method 2:
     Have the VI open, drag the Icon onto the block diagram
     Double click it to open the front panel, to display the
      block diagram, hold the Ctrl-Key and double click the
      icon
             Terminal settings
 When creating subVIs, it is a good idea to
  manage the status of the terminals for the
  subVI
   If there is a subVI which cannot and should not be
    run without one of the inputs being wired, the
    terminal can be changed to be a required terminal
 Demo:
   Open a subVI, right-click the desired terminal and
    select This connector is required
   Required option is only available for inputs
             Terminal settings
 If an input is used in an uncritical way, we can
  set the terminal to be optional
   Here, most of the time the default value is
    sufficient to run the VI.
 Demo:
   Read from Spreadsheet File.vi, Context Help
   The short lines without labels are optional
    terminals, Click Show optional terminals and full
    path
       Handling errors in subVIs
 We need to pass errors in and out of the subVI
  using the error clusters.
 Demo:
   Open a subVI and create Error in and Error out
    clusters on the front panel
   Connect them to the connector pane
   On the block diagram, create a case structure covering
    all the code
   Wire the error in to the case selector, wire the error
    through the case and into the error out cluster
                     Quiz
 How do optional terminals appear in the
  Context Help window?
  a)   Bold text
  b)   Italics
  c)   Grayed text
  d)   Normal text
                     Quiz
 How do required terminals appear in the
  Context Help window?
  a)   Bold text
  b)   Italics
  c)   Grayed text
  d)   Normal text
                     Quiz
 The Required option is available for both
  inputs and outputs.
  a) True
  b) False
                       Quiz
 In which way can a subVI be placed on the
  block diagram?
  a) Take a selection of existing code and select
     Create SubVI from the Edit menu
  b) Navigate to a VI via Select a VI on the Functions
     palette and double click it
  c) Drag the icon of an open VI on the block diagram
  d) All of the above
                      Quiz
 To handle errors in a subVI, error in and error
  out clusters are required.
  a) True
  b) False
                  Exercise
Complete the exercise:
   LV1M33_Using SubVIs
provided inside the moodle course!
Modify a subVI to handle errors.
Using Sequential Programming
    LabVIEW Core 1, Module 34
                 Agenda
 What is sequential programming
 Methods for ensuring sequential order.
 How do we use sequential programming?
  What is sequential programming
 If pieces of code are not linked by wires, they will run in
  parallel.
 Most VIs accomplish tasks in a sequential manner.
      Read data from a device
      Prompt the user to make a change to the system
      Read data again
      Prompt the user again
 Here, all parts would run in parallel
Methods for ensuring sequential order
 Create a data dependency in the code
   Wiring the error cluster through VIs and subVIs is
    a very common and preferred method for
    ensuring sequential execution
   But, not all VIs and subVIs have error terminals
Methods for ensuring sequential order
 Use a sequence structure to force the execution order of the code
     The sequence structure is a structure with frames, in which each frame
      executes in order.
 Demo:
     Place a flat sequence structure (stacked sequence structures behave in the
      same way) from the structures palette on the block diagram
     Add frame after by right-clicking the border
     Add frame before the current frame
     Delete a frame
 Avoid the overuse of sequence structures because they prohibit parallel
  execution
       How do we use sequential
            programming?
 Demo:
   Remove the sequence structures from before and
    place a case structure instead
   Wire the errors through the code
                    Quiz
 It is only possible to use sequential
  programming by connecting error wires.
  a) True
  b) False
                         Quiz
 Which of the following features of LabVIEW
  automatically enforces sequential
  programming?
  a)   Variables
  b)   Loop Structures
  c)   Dataflow
  d)   Modularity
                     Quiz
 Sequential programming refers to performing
  each task individually and in a certain order.
  a) True
  b) False
                     Quiz
 Which of the following methods does not use
  sequential programming?
  a) Creating data dependencies
  b) Using sequence structures
  c) Using variables
                      Quiz
 It is best to use as little forced-sequencing as
  possible in order to make use of LabVIEWS
  inherent parallelism.
  a) True
  b) False
                  Exercise
Complete the exercise:
   LV1M34_Using Sequential Programming
provided inside the moodle course!
Use sequential programming to ensure code
executes in the proper order.
Understanding State
  Programming
LabVIEW Core 1, Module 35
                  Agenda
 What is state programming?
 What is a state machine?
 Creating a basic state machine
      What is state programming?
 Sequential Programming:
    Sequence structures and sequentially wired subVIs can be used to ensure
     code runs in a desired order
    Sufficient for simple applications, but not always the best choice for the
     program architecture.
 What if the order of the sequence needs to change?
 What if we need to stop the program immediately, rather than
  waiting until the end of the sequence?
 A state programming approach may be more effective than a
  sequential programming approach.
 A state programming approach allows a program to be easily
  modified or expanded.
         State transition diagram
 A type of flowchart that indicates the states of a
  program and transitions between states.
    Bubbles represent states
    Lines represent transitions
         What is a state machine?
 A state machine is a common and useful design pattern.
 State machines implement a state diagram or flowchart.
 State machines are commonly used to create a user interface
  for a program.
 State machines are also used in process tests.
  Creating a Basic State Machine
 Demo:
   While loop, shift register, enum constant (init, stop) and
    make a type def., case-structure
      State functionality code implements the function of the code
      State transition code determines the next state in a sequence
   Create enum constants for each case (to make the
    transitions
   Add a Timing function
   True Constant for the conditional terminal of the while
    loop from the Stop Case
   False Constant for the conditional terminal of the while
    loop from the Init Case
                   Quiz
 State programming ensures that code always
  runs in the same order.
  a) True
  b) False
                      Quiz
 Which of the following is true about state
  machines?
  a) They can only exit when every state has been
     visited once
  b) A state may map to multiple other states
  c) Multiple states may run at the same time
  d) States execute in numeric order
                    Quiz
 A state transition diagram is a type of
  flowchart that indicates the states of a
  program and the related transitions between
  states.
  a) True
  b) False
                      Quiz
 How does a state machine transition between
  states?
  a) According to a pre-set timer
  b) As soon as the code in the state is finished
     executing
  c) Using previous and next buttons activated by the
     user
  d) By using a transition function to evaluate a
     condition
                    Quiz
 In a state machine diagram, the individual
  states are represented by arrows which point
  in the direction of the next state.
  a) True
  b) False
                  Exercise
Complete the exercise:
   LV1M35_Understanding State Programming
provided inside the moodle course!
Use a state flow diagram to learn about state
programming and state machines.
Using State Machines
LabVIEW Core 1, Module 36
                  Agenda
 Creating state machines in LabVIEW
 Controlling state machines
       Creating State Machines
 Demo:
   Reuse the last demo; right click the enum
    constant, open type def., new items: Acquire,
    Analyze and Save between Init and Stop, Save
    Type def.
   Right-click the case structure, add case for every
    value
         Controlling state machines
 How can we define different types of state transitions?
    Select function to transition between two states
 Demo:
      Create False constants for the boolean outputs at the unwired cases
      Init state: transits to Acquire
      Acquire state: transits to Analyze
      Analyze state: Select function, Two-button dialog function
       Controlling state machines
 How can we define different types of state
  transitions?
    Using a case structure or select one out of an array
 Demo:
    Save state, place Array constant, copy the enum type def.
     into the array, expand the array to acquire, save and stop
    Index Array Function
    Place one-button dialogs into init, stop and acquire to
     display text
    Place three-button dialog into
     save to simulate state transitions
                    Quiz
 To add new states to the state machine, we
  simly add new items to the enum constant
  a) True
  b) False
                        Quiz
 What does the state machine use to keep
  track of the state during execution?
  a)   Enum Constant
  b)   Iteration Terminal
  c)   Shift Register
  d)   Local Variable
                    Quiz
 The While Loop used to create a state
  machine ensures that each state executes only
  once.
  a) True
  b) False
                       Quiz
 What is the best way to ensure that the state
  machine is easily scalable?
  a) Ensure that the shift register uses default values
     if unwired
  b) Use a type definition for the enum control
  c) Ensure that each state only maps to one other
  d) Turn the While Loop into a type definition
                      Quiz
 Which of the following are not required for
  building a state machine in LabVIEW?
  a)   Array
  b)   While Loop
  c)   Shift Register
  d)   Type-defined enum
  e)   Case structure
                  Exercise
Complete the exercise:
   LV1M36_Using State Machines
provided inside the moodle course!
Create a State Machine in LabVIEW.
     Parallelism
LabVIEW Core 1, Module 37
                 Agenda
 Introduction
 What is Parallelism?
 Avoiding Data Dependencies
          What is Parallelism?
 We often need to program multiple tasks so
  that they execute at the same time.
 LabVIEW will run tasks in parallel whenever
  there is no data dependency between them.
          What is Parallelism?
 Demo: modify the example:
   Add Stop button to second loop
   Add Two Button Dialog to first loop
   Run the VI
    Avoiding Data Dependencies
 Passing the data between the loops without
  creating a data dependency can present a
  challenge.
 Demo:
   First attempt: wire a boolean control to both loops;
   Run the VI with Highlight Execution enabled.
   Second attempt: place the Boolean control in the first
    loop and wire its output into the second loop.
   Run the VI with Highlight Execution enabled.
    Avoiding Data Dependencies
 A third attempt might lead us to try writing
  the value of the Boolean from loop 1 into a
  file, read that file in loop 2, and wiring the
  value into the conditional terminal in loop 2.
 A method which would solve our problem
  involves finding the location in memory where
  the Boolean button data is stored, and reading
  that memory location directly.
                     Quiz
 When two tasks are configured to run in
  parallel, they cannot interact with each other.
  a) True
  b) False
                      Quiz
 When does LabVIEW automatically run tasks
  in parallel?
  a) When parallel processing is enabled in the
     Options menu
  b) When there is no data dependency
  c) When the computer executing the code has
     multiple processors
  d) When the tasks are wired together
                   Quiz
 Variables break the dataflow programming
  paradigm.
  a) True
  b) False
                      Quiz
 Which of the following is true about
  parallelism?
  a) Variables may be used to pass data between
     parallel tasks
  b) Parallelism can only be done by repeatedly
     reading and writing to a temporary file
  c) Parallelism can be easily activated by wiring
     together parallel tasks
  d) When the tasks are wired together, they will run
     in parallel
                    Quiz
 A single Boolean terminal can stop two loops
  running in parallel
  a) True
  b) False
                  Exercise
Complete the exercise:
   LV1M37_Parallelism
provided inside the moodle course!
Build a VI that demonstrates parallelism and
data dependency.
      Variables
LabVIEW Core 1, Module 38
                    Agenda
   Introduction
   What are Variables?
   What are Local Variables?
   What are Shared Variables?
          What are Variables?
 Creating parallel tasks in LabVIEW is easy, but
  stopping them at the same time requires
  careful attention.
 How then, can we communicate data between
  parallel loops without creating data
  dependencies?
                 Variables
 Variables pass data from one place to another
  without wires.
 Allow us to create complex programs that take
  advantage of multi-core processing.
 Variables are block diagram elements that
  allow us to read data from more than one
  place in our code.
                     Variables
 Local variables:
   Store data in front panel controls and indicators
 Single-process shared variables:
   Store data in different ways
 Functional global variables:
   Store data in While Loop shift registers
      What are Local Variables?
 We can use a local variable to pass data
  between loops in a single VI.
 Demo: right-click the Boolean control in our
  previous example and selecting Create and
  then Local Variable.
 Right-click and select Change to Read.
 Change the Mechanical Action to Switch.
      What are Local Variables?
 Demo: create another Local Variable, place it
  outside the loops, set it False and wire it to
  both loops.
     What are Shared Variables?
 Local variables work for communicating data
  between loops in a single VI, but what if we
  want to communicate data between VIs?
 Shared variables share data among multiple
  VIs.
 To terminate While Loops running in separate
  VIs, a shared variable can be used with only a
  single Boolean control.
             Shared Variables
 They are similar to a local variable, but can
  also be used to share data across a network.
 They can be single-process or network-
  published.
             Shared Variables
 Demo: create two VIs with one loop each, similar
  to the last example.
 Create a new project and add both VIs.
 Right-click My Computer and select New and
  then Variable.
 Select Single Process under Variable Type.
 Change Data Type to Boolean and Name to Stop,
  click OK.
 Save the Library.
               Shared Variables
 Drop a shared variable shell, from the Structures
  palette, onto the block diagram of our first example,
  click inside the shell and select the variable.
 Move it into the loop and copy it in the second loop.
 Change Access Mode in the first loop to Write, wire it
  to the Stop button.
 Wire the variable in the second loop to the Conditional
  Terminal.
 Create another instance of the variable outside Loop 1,
  initialize it with a False constant and wire the Error
  Cluster.
                    Quiz
 Variables pass data from one location to
  another without connecting them with a wire.
  a) True
  b) False
                        Quiz
 Which of the following is not a type of
  variable?
  a)   Single-Process Shared Variable
  b)   Local Variable
  c)   Type-Defined Variable
  d)   Functional Global Variable
                      Quiz
 When creating variables, it is best to not
  initialize them with a value in order to save
  memory.
  a) True
  b) False
                        Quiz
 Which of the following is a type of shared
  variable?
  a)   Dynamic Shared Variable
  b)   Static Shared Variable (SSV)
  c)   Relational Database Shared Variable
  d)   Network-Published Shared Variable
                     Quiz
 Local variables can only be used to pass
  information within a single VI.
  a) True
  b) False
                   Exercise
Complete the exercise:
   LV1M38_Variables
provided inside the moodle course!
Use local variables to write to and read from a
control.
Functional Global Variables
   LabVIEW Core 1, Module 39
                   Agenda
 Introduction
 What is a Functional Global Variable?
 Using Functional Global Variables
 What is a Functional Global Variable?
 A functional global variable is an alternative to
  a shared variable.
 Shift Registers retain the last piece of
  information stored if uninitialized.
 What is a Functional Global Variable?
 We can use this to our advantage so that
  information is stored, but we also get all the
  processing and manipulation abilities of a
  subVI.
 What is a Functional Global Variable?
 To create a functional global variable, we
  place a loop in a subVI and use a shift register
  to store data that can be read from or written
  to, as is the case with a shared variable.
      Functional Global Variables:
             Re-entrancy
 A functional global variable is a subVI that
  must not be set to be re-entrant.
 The same copy of the subVI will be used when
  called from multiple locations.
 This can help prevent race conditions.
 Using Functional Global Variables
 Many VIs that perform measurement and
  automation require some form of timing.
 A functional global variable has an action
  input control that specifies which task the VI
  performs.
 The shift register needs a While Loop to
  contain it, although the loop will run only
  once.
 Using Functional Global Variables
 Demo: Reset Time
 Using Functional Global Variables
 Demo: Elapsed Time
                    Quiz
 When using functional global variables, enums
  are the best way to determine which action to
  execute.
  a) True
  b) False
                       Quiz
 Functional global variables use which of the
  following to store their data?
  a)   For Loop
  b)   Shift Register
  c)   Sequence Structure
  d)   Case Structure
                     Quiz
 Every instance of a functional global variable
  will call the same subVI.
  a) True
  b) False
                         Quiz
 Which of the following is not used in
  functional global variables?
  a)   While Loops
  b)   Case Structure
  c)   Shift Registers
  d)   File I/O
                        Quiz
 In which case can functional global variables
  be used?
  a)   Reading Values
  b)   Writing Values
  c)   Performing Calculations
  d)   All of the Above
                   Exercise
Complete the exercise:
   LV1M39_Functional Global Variables
provided inside the moodle course!
Use a timing functional global to perform
multiple actions, including recording the start
time and calculating the elapsed time.
  Race Conditions
LabVIEW Core 1, Module 40
                 Agenda
 Introduction
 What is a Race Condition?
 How can we avoid Race Conditions?
      What is a Race Condition?
 Weve discussed in a previous modules how
  parallelism is a benefit which comes from
  LabVIEWs dataflow architecture.
 We also investigated how variables can be
  used in order to pass data between parallel
  tasks.
      What is a Race Condition?
 However, variables must be used with care.
 Since they break from the dataflow approach,
  and allow us to write data in multiple
  locations, there exists a very real possibility of
  accidentally overwriting our data.
      What is a Race Condition?
 Race conditions describe when data is
  accidentally overwritten due to the timing of
  events or scheduling of tasks.
 Race conditions are a common problem for
  programs that execute multiple tasks in
  parallel and share data between them.
      What is a Race Condition?
 Demo: create VI that produces race
  conditions:
             Race Condition
 They are difficult to identify and debug
  because the outcome depends on the order
  tasks are executed.
 This order is random.
 Enabling execution highlighting can hide the
  problem!
      Avoiding Race Conditions
1. Control and limit shared resources.
2. Identify and protect critical sections within
   the code.
3. Properly sequence instructions.
 Most common when two tasks have both read
  and write access to a resource.
       Avoiding Race Conditions
 Most common resources are shared data
  storage, such as variables.
 Other resources include files and references to
  hardware resources.
 Resources altered from multiple locations
  makes a race condition possible.
       Avoiding Race Conditions
 Try to use only one writer or controller for a
  shared resource.
      Avoiding Race Conditions
 A second method for avoiding race conditions
  is protecting critical sections of code.
 Critical code is code that must behave
  consistently in all circumstances.
       Avoiding Race Conditions
 When using multi-tasking programs, one task
  may interrupt another.
 If this alters a shared resource that the
  interrupted task assumes is constant, a race
  condition occurs.
 Solution: place critical code in non-reentrant
  subVIs (Functional Globals)
 Another possibility: Semaphors
          Avoiding Race Conditions
 Example:
   Outcome 1: Value = (Value x 5) + 2
   Outcome 2: Value = (Value + 2) x 5
   Outcome 3: Value = Value x 5
   Outcome 4: Value = Value + 2
 Solution: enforce proper sequential
  programming!
                      Quiz
 Why are race conditions hard to debug?
  a) They depend upon the order in which the
     operating system executes scheduled tasks
  b) They depend upon the timing of external events
  c) Use of execution highlighting will hide the race
     condition
  d) All of the above
                       Quiz
 How can you avoid race conditions?
  a) By controlling and limiting shared resources
  b) By identifying and protecting critical sections
     within our code
  c) By properly sequencing code
  d) All of the above
                   Quiz
 Race conditions are most common when two
  tasks have both read and write access to a
  resource.
  a) True
  b) False
                        Quiz
 What are two of the most effective methods
  fro protecting critical sections of code when
  trying to avoid race conditions?
  a)   Use of sequencing
  b)   Local variables and disk streaming
  c)   Use of parallelism and state machines
  d)   Use of functional global variables and
       semaphores
                     Quiz
 By default, a semaphore allows multiple tasks
  to acquire it at a time.
  a) True
  b) False
                   Exercise
Complete the exercise:
   LV1M40_Race Conditions
provided inside the moodle course!
Eliminate a race condition in a VI.