labview user group university of bristol l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
LabVIEW User Group University of Bristol PowerPoint Presentation
Download Presentation
LabVIEW User Group University of Bristol

Loading in 2 Seconds...

play fullscreen
1 / 73

LabVIEW User Group University of Bristol - PowerPoint PPT Presentation


  • 394 Views
  • Uploaded on

LabVIEW User Group University of Bristol. Ben Lavasani Academic Field Sales Engineer NI UK. Agenda. LabVIEW Design Patterns Overview Coffee break :) LabVIEW for Multi-Touch Applications - David Carberry LabVIEW in Teaching LabVIEW Tips and Tricks.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'LabVIEW User Group University of Bristol' - aimee


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
labview user group university of bristol

LabVIEW User GroupUniversity of Bristol

Ben Lavasani

Academic Field Sales Engineer

NI UK

agenda
Agenda
  • LabVIEW Design Patterns Overview
  • Coffee break :)
  • LabVIEW for Multi-Touch Applications - David Carberry
  • LabVIEW in Teaching
  • LabVIEW Tips and Tricks
what is a design pattern
What Is a Design Pattern?
  • A template or framework for LabVIEW code
  • Widely accepted and well-known
  • Easily recognizable
benefits of using design patterns
Benefits of Using Design Patterns

Simplify the development process

  • Developers can easily understand code
  • Don’t have to “re-invent the wheel”
  • Pre-existing solutions to common problems

Reliability

  • Many have been used for years - they are “tried and true”
  • Large development community and resources online
getting started how do i pick
Getting Started: How Do I Pick?
  • Identify most important aspect of your application:
    • Processes that require de-coupling
    • Clean, easy to read code
    • Mission critical components
  • Select a template based upon potential to improve
caution
Caution

You can needlessly complicate your life if you use an unnecessarily complex design pattern

Don’t forget the most common design pattern of all… dataflow!

basic tools
Basic Tools
  • Loops
  • Shift Registers
  • Case Structures
  • Enumerated Constants
  • Event Structures
today s discussion
Today’s Discussion
  • As we look at each design pattern, we’ll discuss
    • A problem we are trying to solve
    • Background
    • How it works
    • Technical implementation
    • Demonstration
    • Use cases / considerations
design patterns
Design Patterns
  • Functional Global Variable
  • State Machine / Statecharts
  • Producer / Consumer
functional global variables

Functional Global Variables

How do I share data across a application without using Global or Local Variables?

background global and local variables
Background: Global and Local Variables
  • Can cause race conditions
  • Create copies of data in memory
  • Cannot perform actions on data
  • Cannot handle error wires
breaking down the design pattern
Breaking Down the Design Pattern
  • While loop
  • Uninitialized shift registers have memory
  • Case structure
  • Enumerated control
how it works basic actions
How It Works: Basic Actions
  • Set the value of the shift register

INITIALIZE

INITIALIZE

how it works basic actions17
How It Works: Basic Actions
  • Get the value currently stored in the shift register

GET

GET

how it works action engine
How It Works: Action Engine
  • Perform an operation upon stored value and save result
  • You can also output the new value

ACTION

ACTION

technical implementation
Technical Implementation
  • Functional Global Variable is a Non-Reentrant SubVI
  • Actions can be performed upon data
  • Enumerator selects action
  • Stores result in uninitialized shift register
  • Loop only executes once
slide20

Uninitialized shift register has memory

Loop only executes once

Only used in Initialize case

Functional Global Variables

Action determines which case is executed

Examples of other ‘actions’

Demo
benefits comparison
Benefits: Comparison

Global and Local Variables

Functional Global Variables

Prevent race conditions

No copies of data

Can behave like action engines

Can handle error wires

Take time to make

  • Can cause race conditions
  • Create copies of data in memory
  • Cannot perform actions on data
  • Cannot handle error wires
  • Drag and drop
recommendations
Recommendations

Use Cases

  • Communicate data between code without connecting wires
  • Perform custom actions upon data while in storage

Considerations

  • All owning VIs must stay in memory
  • Use clusters to reduce connector pane
  • Using stacked shift registers will track multiple iterations
state machine

State Machine

I need to execute a sequence of events, but the order is determined programmatically

background
Background

Dynamic Sequence: Allows distinct states to operate in a programmatically determined sequence

Static Sequence

soda machine
Soda Machine

Initialize

No input

Wait

Nickel Deposited

Change Requested

Quarter Deposited

Dime Deposited

Total < 50

Total < 50

Total < 50

Quarter

Change

Nickel

Dime

Total >= 50

Total >= 50

Total >= 50

Total > 50

Vend

Total = 50

Exit

Soda costs $0.50

breaking down the design pattern26
Breaking Down the Design Pattern
  • Case Structure inside of a While Loop
  • Each case is a state
  • Current state has decision making code that determines next state
  • Use enumerators to pass value of next state to shift registers
how it works
How It Works

Transition code determines next state based upon results of step execution

Case structure has a case for every state

FIRST STATE

Step Execution

Shift registers used to carry state

Transition Code

NEXT STATE

FIRST STATE

transition code options
Transition Code Options

Step Execution

Step Execution

Step Execution

recommendations30
Recommendations

Use Cases

  • User interfaces
  • Data determines next routine

Considerations

  • Creating an effective State Machine requires the designer to make a table of possible states.
  • Use LabVIEW Statechart to abstract this process for more sophisticated applications
producer consumer

Producer / Consumer

I have two processes that need to execute at the same time, and I need to make sure one can’t slow the other down

how it works32
How It Works

Master

  • One or more slave loops are told by a master loop when they can run
  • Allows for a-synchronous execution of loops
  • Data-independence breaks dataflow and allows multi-threading
  • De-couples processes

Slave 1

Slave 2

breaking down the design pattern33
Breaking Down the Design Pattern
  • Data independent loops = Multithreading
  • Master / slave relationship
  • Communication and synchronization between loops
loop communication
Loop Communication
  • Variables
  • Occurrences
  • Notifier
  • Queues
  • Semaphores
  • Rendezvous
queues
Queues

Adding Elements to the Queue

Select the data-type the queue will hold

Reference to existing queue in memory

De-queueing Elements

Dequeue will wait for data or timeout (defaults to -1)

adding your own design patterns
Adding Your Own Design Patterns

C:\Program Files\National Instruments\LabVIEW 8.5\templates\Frameworks\DesignPatterns

resources
Resources
  • Example Finder
  • New >> Frameworks >> Design Patterns
  • ni.com/labview/power
  • Expressionflow.com
  • Visit ni.com/info and enter exhkqe
slide40

LabVIEW in Teaching

TheNI LabVIEW Academy

slide41

What Is the NI LabVIEW Academy?

The NI LabVIEW Academy program provides classroom curriculum, instructional materials, and hands-on exercises to high schools, community colleges, and universities for the specific purpose of teaching LabVIEW.

LabVIEW Academy is for anyone seeking LabVIEW education and knowledge through an academic institution.

what does the ni labview academy do
What Does the NI LabVIEW Academy Do?

Empowers institutions to teach LabVIEW

Emphasises LabVIEW professional certification

Increases the pool of qualified LabVIEW developers

slide43

NI LabVIEW Academy Program Requirements

Instructor Requirements

Two instructors must be Certified LabVIEW Associate Developers (CLADs) and teach at participating organisations

Program Requirements

  • Current teaching site license
  • At least one dedicated classroom (a computer lab will suffice)
  • 40 hours of classroom LabVIEW specific instruction time
  • One PC per student (with LabVIEW software)
  • NI DAQ equipment required for lab component (2:1 student ratio)
  • Submit course syllabus to NI for approval
slide44

NI LabVIEW Academy Instructional Materials

  • Instructor Materials
  • LabVIEW Basics I & II Instructor Manual
  • LabVIEW Basics I & II Lecture Slides
  • LabVIEW Basics I & II Exercises and Solutions
  • Instructor Version of Student Workbook
  • 50 LabVIEW Exam/Homework Questions

Student Materials

  • LabVIEW Academy Workbook (student purchase)
    • 300+ questions
  • Recommended LabVIEW textbook (student purchase)
ni labview academy teaching materials
NI LabVIEW Academy Teaching Materials

Curriculum for both learning LabVIEW and teaching LabVIEW

NI LabVIEW Academy Teaching Materials

Recommended LabVIEW Textbooks

ni labview academy clad opportunity
NI LabVIEW Academy CLAD Opportunity

The NI LabVIEW Academy gives students the opportunity to take the CLAD exam as part of the program

slide47

The NI LabVIEW Academy Bridging the Gap

Academic

Industry

  • “LabVIEW is getting more popular in academia and industry and many researchers and companies are on the lookout for competent LabVIEW programmers. This program will help bridge the gap between the two.”
  • – Khanjan Mehta, Professor, Penn State University
  • “In our exhaustive search for qualified LabVIEW developers to fill key roles in our organization, we greatly anticipate the new pool of qualified candidates coming out of the National Instruments LabVIEW Academy schools.“
  • – Marvin Landrum, Section Manager, Texas Instruments
agenda51
Agenda
  • 20 Tips and Tricks for LabVIEW Development
    • Beginner: Simple tricks to save time
    • Intermediate: LabVIEW tips you probably did not know about
    • Advanced: Useful nuggets to put you ahead of the game
automatically select the right tool

/

1

20

Automatically Select the Right Tool
  • Avoid manually switching among many tools

Operate Value Tool

Position/Size/Select Tool

Auto Tool

Edit Text Tool

Connect Wire Tool

slide53

/

2

20

Quickly Drop Palette Objects

Hold down Ctrl + Space to launch Quick Drop

  • Ctrl + D – Create controls and indicators on selected diagram object(s)
  • Ctrl + R – Remove diagram object(s) and reconnect wires
  • Ctrl + T – Move control and indicator terminal labels to the left and right sides

Demo

slide54

/

3

20

Design Pattern Templates

  • Access via File  New …
  • Well-known designs
    • Producer/Consumer
    • State Machine
    • Queued Message Handler
switch terminal wires easily

/

4

20

Switch Terminal Wires Easily

Hold Down Ctrl

and Left-Click on Input Terminal

Note: This works only for functions with two inputs when both

inputs have already been wired

Demo

easily scroll through structures

/

5

20

Easily Scroll Through Structures
  • You can use Ctrl + Mouse Scroll to scroll through:
    • Case Structures
    • Event Structures
    • Stacked Sequence Structures
    • Diagram Disable Structures

Ctrl + Mouse Scroll Wheel

quickly find the right palette

/

6

20

Quickly Find the Right Palette
  • Right-click on a block diagram object for a palette shortcut

Add

Index Array

To More Specific Class

Demo

easily navigate arrays

/

7

20

Easily Navigate Arrays
  • Right-click on an array and select Visible Items >> HorizontalScrollbar (or Visible Items >> Vertical Scrollbar)
  • To view last element, select Advanced >> Show Last Element
  • Both horizontal and vertical scrollbars available (depending on array dimensions)

Demo

slide59

/

8

20

Selective Insert Location

Right-Click Slightly above Wire

Right-Click Slightly below Wire

Wire Connected to Lower Terminal

Wire Connected to Upper Terminal

block diagram clean up

/

9

20

Block Diagram Clean-Up
  • Click Clean Up Diagram button on toolbar or press Ctrl + U
  • Highlight a portion of the diagram for partial cleanup
  • Right-click and select “Exclude from Diagram Cleanup” option

Note: Only available in LabVIEW 8.6 and later.

Demo

slide61

/

10

20

Quickly Wire Multiframe Structures

  • Right-click an output tunnel and select “Linked Input Tunnel » Create & Wire Unwired Cases”

Note: Only available in LabVIEW 8.6 and later

slide62

/

11

20

EasilyAssess 2D Array Size

  • Matrix Size function replaces old method
  • Assess size of 2D array regardless of data type

Note: Only available in LabVIEW 2009 and later

breakpoint manager

/

12

20

Breakpoint Manager
  • Select View » Breakpoint Manager
  • Right-click and select Breakpoint » Breakpoint Manager

Note: Only available in LabVIEW 8.6 and later

slide64

/

13

20

Quickly Find VIs in the Project Window

  • Ctrl + Shift +E from an open VI with open project

Note: Only available in LabVIEW 2009 and later

easily add enumeration items

/

14

20

Easily Add Enumeration Items
  • Press Ctrl while hovering over an Enum to use the Text Tool
  • Use Shift + Enter to repeatedly add items

Shift + Enter

Demo

slide66

/

15

20

Edit Multiple Objects Simultaneously

  • Highlight all desired front panel or block diagram objects
  • Right-click and select “Properties”

Demo

automatically create control references

/

16

20

Automatically Create Control References
  • Simply drag a control into a Control Refnum
  • Automatically creates a class-specific, type-specific reference

Note: To keep the original control, use Ctrl-Draginstead

drag and drop to save time

/

17

20

Drag and Drop to Save Time
  • Drag an image into your VI icon
  • Select a file and drag into a path constant
  • Take a URL from Internet Explorer and drag into a string constant
  • Drag items from disk or Project Explorer into a LabVIEW block diagram
quickly browse properties and methods

/

18

20

Quickly Browse Properties and Methods
  • View >> Class Browser
  • Shortcut: Ctrl + Shift + B
  • Drag a property or method directly into your VI

Demo

implement a for loop progress bar

/

19

Implement a For Loop Progress Bar

20

  • Place Progress Bar VI inside a for loop
  • Opens automatically after a specified amount of time
  • Download sample code from ni.com/forums (search for “For Loop Progress Bar”)

Demo

automatically analyse your vis

/

20

20

Automatically Analyse Your VIs
  • Tools >> VI Analyzer >> Analyze VIs
    • Check performance, style, UI, documentation, and more
    • Save LabVIEW VI Analyzer settings for later use

Demo

other resources
Other Resources
  • Darren’s LabVIEW Nuggets(decibel.ni.com/content/docs/DOC-4002)
  • LAVA: Favorite Tips and Shortcuts (forums.lavag.org)
  • LabVIEW Wiki (labviewwiki.org)