Presentation is loading. Please wait.

Presentation is loading. Please wait.

LabVIEW User Group University of Bristol Ben Lavasani Academic Field Sales Engineer NI UK.

Similar presentations


Presentation on theme: "LabVIEW User Group University of Bristol Ben Lavasani Academic Field Sales Engineer NI UK."— Presentation transcript:

1 LabVIEW User Group University of Bristol Ben Lavasani Academic Field Sales Engineer NI UK

2 2

3 3 Agenda LabVIEW Design Patterns Overview Coffee break :) LabVIEW for Multi-Touch Applications - David Carberry LabVIEW in Teaching LabVIEW Tips and Tricks

4 LabVIEW Design Patterns Overview

5 5 What Is a Design Pattern? A template or framework for LabVIEW code Widely accepted and well-known Easily recognizable

6 6 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

7 7 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

8 8 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 !

9 9 Basic Tools Loops Shift Registers Case Structures Enumerated Constants Event Structures

10 10 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

11 11 Design Patterns Functional Global Variable State Machine / Statecharts Producer / Consumer

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

13 13 Background: Global and Local Variables Can cause race conditions Create copies of data in memory Cannot perform actions on data Cannot handle error wires

14 14 Breaking Down the Design Pattern While loop Uninitialized shift registers have memory Case structure Enumerated control

15 15 DEMO Uninitialized Shift Registers

16 16 How It Works: Basic Actions Set the value of the shift register INITIALIZE

17 17 How It Works: Basic Actions Get the value currently stored in the shift register GET

18 18 How It Works: Action Engine Perform an operation upon stored value and save result You can also output the new value ACTION

19 19 1.Functional Global Variable is a Non-Reentrant SubVI 2.Actions can be performed upon data 3.Enumerator selects action 4.Stores result in uninitialized shift register 5.Loop only executes once Technical Implementation

20 20 DEMO Functional Global Variables Uninitialized shift register has memory Action determines which case is executed Only used in Initialize case Loop only executes once Examples of other ‘actions’

21 21 Benefits: Comparison Global and Local Variables Can cause race conditions Create copies of data in memory Cannot perform actions on data Cannot handle error wires Drag and drop Functional Global Variables Prevent race conditions No copies of data Can behave like action engines Can handle error wires Take time to make

22 22 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

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

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

25 25 Soda Machine Initialize Wait Change Quarter Dime Nickel Exit Vend Soda costs $0.50 No input Quarter Deposited Total < 50 Total >= 50 Change Requested Dime Deposited Nickel Deposited Total < 50 Total >= 50 Total > 50 Total = 50

26 26 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

27 27 Transition Code How It Works FIRST STATE NEXT STATE Step Execution Shift registers used to carry state Case structure has a case for every state Transition code determines next state based upon results of step execution

28 28 Transition Code Options Step Execution

29 29 DEMO State Machine

30 30 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

31 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

32 32 Background I want to execute code in parallel and at asynchronous rates, but I need to communicate between them! I have two processes that need to execute at the same time, but I want them to be independent of one another, and I need to make sure one can’t slow the other down

33 33 How It Works 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

34 34 Breaking Down the Design Pattern Data independent loops = Multithreading Master / slave relationship Communication and synchronization between loops

35 35 Loop Communication Variables Occurrences Notifier Queues Semaphores Rendezvous

36 36 Queues Adding Elements to the Queue De-queueing Elements Reference to existing queue in memory Select the data-type the queue will hold Dequeue will wait for data or timeout (defaults to -1)

37 37 Producer / Consumer

38 38 Adding Your Own Design Patterns C:\Program Files\National Instruments\LabVIEW 8.5\templates\Frameworks\DesignPatterns

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

40 40

41 41 LabVIEW in Teaching The NI LabVIEW Academy

42 42 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 Is the NI LabVIEW Academy?

43 43 What Does the NI LabVIEW Academy Do? Increases the pool of qualified LabVIEW developers Emphasises LabVIEW professional certification Empowers institutions to teach LabVIEW

44 44 Instructor Requirements Two instructors must be Certified LabVIEW Associate Developers (CLADs) and teach at participating organisations Instructor Requirements Two instructors must be Certified LabVIEW Associate Developers (CLADs) and teach at participating organisations NI LabVIEW Academy Program Requirements 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 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

45 45 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 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 NI LabVIEW Academy Instructional Materials Student Materials LabVIEW Academy Workbook (student purchase) 300+ questions Recommended LabVIEW textbook (student purchase) Student Materials LabVIEW Academy Workbook (student purchase) 300+ questions Recommended LabVIEW textbook (student purchase)

46 46 NI LabVIEW Academy Teaching Materials Curriculum for both learning LabVIEW and teaching LabVIEW Recommended LabVIEW Textbooks NI LabVIEW Academy Teaching Materials

47 47 NI LabVIEW Academy Student Workbook

48 48 NI LabVIEW Academy Student Workbook

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

50 50 “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 “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 “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 AcademicIndustry The NI LabVIEW Academy Bridging the Gap

51 51 ni.com/academy

52 52

53 Tips and Tricks to Speed NI LabVIEW Development Useful Nuggets to Save You Time

54 54 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

55 55 Automatically Select the Right Tool Avoid manually switching among many tools Operate Value Tool Position/Size/Select Tool Edit Text Tool Connect Wire Tool Auto Tool 1 / 20

56 56 Hold down Ctrl + Space to launch Quick Drop Quickly Drop Palette Objects 2 / 20 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

57 57 Access via File  New … Well-known designs Producer/Consumer State Machine Queued Message Handler Design Pattern Templates 3 / 20

58 58 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 4 / 20 Demo

59 59 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 5 / 20

60 60 Quickly Find the Right Palette Right-click on a block diagram object for a palette shortcut 6 / 20 Add To More Specific Class Index Array Demo

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

62 62 Selective Insert Location Right-Click Slightly above Wire Right-Click Slightly below Wire Wire Connected to Lower Terminal Wire Connected to Upper Terminal 8 / 20

63 63 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 9 / 20 Note: Only available in LabVIEW 8.6 and later. Demo

64 64 Quickly Wire Multiframe Structures 10 / 20 Note: Only available in LabVIEW 8.6 and later Right-click an output tunnel and select “Linked Input Tunnel » Create & Wire Unwired Cases”

65 65 Matrix Size function replaces old method Assess size of 2D array regardless of data type Easily Assess 2D Array Size 11 / 20 Note: Only available in LabVIEW 2009 and later

66 66 Breakpoint Manager Select View » Breakpoint Manager Right-click and select Breakpoint » Breakpoint Manager 12 / 20 Note: Only available in LabVIEW 8.6 and later

67 67 Ctrl + Shift +E from an open VI with open project Quickly Find VIs in the Project Window 13 / 20 Note: Only available in LabVIEW 2009 and later

68 68 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 14 / 20 Demo

69 69 Highlight all desired front panel or block diagram objects Right-click and select “Properties” Edit Multiple Objects Simultaneously 15 / 20 Demo

70 70 Automatically Create Control References Simply drag a control into a Control Refnum Automatically creates a class-specific, type-specific reference 16 / 20 Note: To keep the original control, use Ctrl-Drag instead

71 71 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 17 / 20

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

73 73 Implement a For Loop Progress Bar 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”) 19 / 20 Demo

74 74 Automatically Analyse Your VIs Tools >> VI Analyzer >> Analyze VIs –Check performance, style, UI, documentation, and more –Save LabVIEW VI Analyzer settings for later use 20 / Demo

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

76 76


Download ppt "LabVIEW User Group University of Bristol Ben Lavasani Academic Field Sales Engineer NI UK."

Similar presentations


Ads by Google