1 / 73

LabVIEW User Group University of Bristol

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.

aimee
Download Presentation

LabVIEW User Group University of Bristol

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LabVIEW User GroupUniversity of Bristol Ben Lavasani Academic Field Sales Engineer NI UK

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

  3. LabVIEW Design Patterns Overview

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

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

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

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

  8. Basic Tools • Loops • Shift Registers • Case Structures • Enumerated Constants • Event Structures

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

  10. Design Patterns • Functional Global Variable • State Machine / Statecharts • Producer / Consumer

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

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

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

  14. Uninitialized Shift Registers Demo

  15. How It Works: Basic Actions • Set the value of the shift register INITIALIZE INITIALIZE

  16. How It Works: Basic Actions • Get the value currently stored in the shift register GET GET

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

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

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

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

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

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

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

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

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

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

  27. Transition Code Options Step Execution Step Execution Step Execution

  28. State Machine Demo

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

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

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

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

  33. Loop Communication • Variables • Occurrences • Notifier • Queues • Semaphores • Rendezvous

  34. 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)

  35. Producer / Consumer

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

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

  38. LabVIEW in Teaching TheNI LabVIEW Academy

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

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

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

  42. 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)

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

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

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

  46. ni.com/academy

  47. Tips and Tricks to Speed NI LabVIEW DevelopmentUseful Nuggets to Save You Time

More Related