outline - national instrumentsaustralia.ni.com/sites/default/files/using labview templates...

29
1

Upload: truongdiep

Post on 05-Jun-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

1

Outline

• Motivation

• Terminology

• Summary of templates and sample projects in LabVIEW 2012

• Introduction to the Create Project dialog box

• Desktop Templates • Simple State Machine

• Queued Message Handler

• Desktop Sample Projects (Introduction)

Motivation

• Increase efficiency by starting with more than a blank project/VI

• Templatised architecture

• Reduce errors and increase reuse with included libraries

• Shorten learning curves by only changing relevant code

• User-owned, project-based code from the start

• Use a design recommended by NI

Why should you use a template or a sample project?

Terminology

Template

Common architecture that you must

modify to accomplish your goals.

Sample Project

Functioning, template-based project

that can be further modified to

accomplish your custom goals.

Terminology

Template/Sample Project

• Access with Create Project dialog box

• Basis for an actual application

• User owns the code

• Used to accomplish a goal

What is the difference between a

template/sample project and an example?

Example

• Access with Example Finder

• Illustrates specific concept(s)

• Code is part of LabVIEW

• Used to teach

6

Templates

LabVIEW 2012 Templates

Design Patterns

State Machine

Queued Message handler

Templates – Design Patterns

The need for Design Patterns

Templates – Design Patterns Cont.

How to avoid Spaghetti code

10

Templates – What is a Design Pattern?

• Formal Solution to a problem

• Widely accepted

• Easily recognized

• Implementation

11

Benefits of using Design Patterns

12

Design Patterns – Caution

13

Design Patterns – Basic Tools

• Loops

• Shift Registers

• Case Structures

• Enumerated Constant

• Events Structures

14

Design Patterns – State Machine

15

Why Use a State Machine

16

Background

17

Vending Machine

18

State Machine

19

Defining the State Machine (1/4)

20

Defining the State Machine (2/4)

21

Defining the State Machine (3/4)

22

Defining the State Machine (4/4)

23

State Machine in LabVIEW

24

Demo

25

Design Pattern – Queued Message Handler

Using Templates from Sample Project

Demo

Sample Projects

Conclusion

• Start with more than a blank project/VI

• Only worry about changing relevant code

• User-owned, project-based code from the start

• Use a design recommended by NI