1 NI Certification Certified LabVIEW Developer Exam Preparation Course.

Post on 14-Dec-2015

222 views 3 download

Transcript of 1 NI Certification Certified LabVIEW Developer Exam Preparation Course.

1

NI CertificationCertified LabVIEW DeveloperExam Preparation Course

2

Purpose Of This Course

•Prepare you to take the certification exam by:•Reviewing the Certification & Examination Process•Discussing the Topics of Often Missed Questions•Showing Examples of Good Wiring Techniques •Demonstrating Good VI Construction Techniques

Essentially a Collection of Topics and Tips for Taking the Certified LabVIEW Developer Examination

3

Purpose Of This Course

• This course will not give you the questions on the exam, however:

•The topics presented are aimed at the most often missed questions

•The answers to these often missed questions are part of the presentation

4

Schedule of Topics

•Certification Process•Examination Process•Written Examination Topics of special concern•Practical Examination topics of special concern

•VI Construction•Wiring Techniques

5

Benefits:• Use of National Instruments Certification Logo

• Listing on ni.com/training

6

Certification ProcessThe Process ensures:

•Credibility - Fair and Unbiased => Value!•Validity - It Evaluates Important items•Reliability - A Reliable Indicator of Proficiency

7

Certification Process•The Candidate Submits an Application

•The Candidate Takes the Examination

•The Examination is Graded

•Every Examination is Reviewed by at Least Two People

•Ensures Objective Results

•The Candidate Receives a Certificate and Logos

•The Candidate’s Name is Placed on ni.com

8

CLD Examination Details•Two parts: •Written

•Written contains 40 Questions •90 Minute Time Limit•All Multiple Choice Questions

•Practical contains One Project: •Time Depends on Which Exam is provided•Usually 3 ½ to 4 ½ hours

9

CLD Examination DetailsWritten Examination InstructionsCertified LabVIEW Developer Examination

Examinee ____________________________________________ Date: ____________Administrator _________________________________________ Date: ____________

Instructions:There are two sections in this examination. The first section is a set of forty multiple choice questions. The second section is a hands-on project creating a VI that conforms to a set of specifications.Questions 1 through 31 each have one correct response. Questions 33 through 40 have one or more correct choices, and all correct responses must be selected to get credit for that question. You are not allowed to ask the proctor for help. If you believe the intent of a question is not clear, you may note that question, and your reasons for choosing the answer you believe best fits the question. Your comments will be taken into account and credit awarded appropriately when the exam is graded.Each multiple choice question is worth 1.5 points, for a total of 60 points. The project is worth 40 points. The entire examination is therefore worth 100 points. The minimum passing grade is 75%. In addition to the total score, the written and practical components must each receive a passing grade as separate components.This examination may not be taken from the examination area or reproduced in any way. A computer with LabVIEW is the only reference allowed for the examination. The time limit for Section 1 is 90 minutes. The time limit for Section 2 is stated in that section.

10

CLD Examination DetailsTypical Exam Question ConstructionObjective:Describe the following options available on Front Panel Controls and Indicators

•Visible Items•Make Current Value Default•Reinitialize to default•Synchronous Display•Enabled State•Autoscale

Exam Question:Which of the following options determines whether a user can update a Front Panel Control’s value?a.Autoscaleb.Enabled Statec.Synchronous Displayd.Make Current Value Default

11

CLD Examination DetailsPractical Examination InstructionsIntroduction:Your company has received a contract to produce a ----------- system for a local manufacturer. The purpose of the ----------- system is to monitor the ------------- manufacturing --------------- to ------------- ----------- -------------- ------------- -----------.You have been assigned to create the software for this system using LabVIEW. You will create the software for six ------------- ------------, with the actual hardware being simulated by Boolean switches on the Front Panel.

Requirements:Using a front panel similar to the graphic provided, create a VI that implements the ---------- system requirements listed in this section. All hardware components are to be simulated using LabVIEW controls and indicators. Your solution must consist of code created expressly for this exam using VIs and functions directly available in LabVIEW.Your solution should be hierarchical in nature. All major functions should be performed in SubVIs.The solution should not use 100% CPU time while running, and should respond to any front panel control change, including “Stop Simulation,” in less than 100mS.The resulting VI must be presented to the proctor in two forms. Recommended forms are 3 ½ inch floppy disk, CD-R, or email to mike.fillian@ni.com.

12

Practical Exam Grading

• Practicals are graded on three criteria:– Functionality– Programming Style– Documentation

• Each of these criteria have approximately equal weights• The Practical must be passed independent of the written

portion of the exam• Total practical grade is 40% of composite grade

13

Functionality

• Does the VI properly perform the requirements listed in the specifications?– Is the logic correct for Boolean inputs and outputs?– Does the VI respond to user inputs within the stated time limit?

14

Style

• Is the VI constructed in a professional manner?– Easily maintainable?– Constructed for scalability?– Does it use unnecessary Variables?– Does it improperly use Property Nodes?– Are there unnecessary structures?

• Sequence Structures– Does it use 100% CPU time?– Logical layout with edges lined up

Run Property Node Example

15

Documentation

• Wire data – If the data flowing through a wire is not clear, a specific label should

indicate the purpose of that data• Function of code segments

– Segments of code should have labels describing the function of that code

• Controls and indicators have descriptive names• Standard labels are yellow (found on String SubPalette)

16

Written Examination Topics

David BonalCourse Development Engineer

17

LabVIEW Topics

• Booleans• Memory• Multithreading• Property Nodes• Variables

t

• DLL• ActiveX• VI Server• Synchronization

Nine Areas of Concern

18

LabVIEW Topics

• Booleans• Memory• Multithreading• Property Nodes• Variables

t

• DLL• ActiveX• VI Server• Synchronization

Nine Areas of Concern

19

Booleans• Many programmers do not understand the

functionality of mechanical action of booleans• Switch action:

Control is toggled

until changed by

hand

• Latch action:

Control reverts to

default state when

read by diagram

20

Booleans

• Where to get help:

Help>>Find Examples>>Building User Interfaces>>General>>Mechanical Action of Booleans

21

LabVIEW Topics

• Booleans• Memory• Multithreading• Property Nodes• Variables

t

• DLL• ActiveX• VI Server• Synchronization

Nine Areas of Concern

22

Memory

• The most common and most mysterious reason for

poor performance of VIs

• LabVIEW handles memory management

automatically

– No need to code when to allocate or deallocate

– You have less control over when memory operations occur

23

Memory VI Component Memory Usage

• Data is always loaded• Code is loaded if platforms match

(MacOS, Windows, Sun, Linux)• Panel and Diagram are loaded if needed (recompiling)

Main VI SubVI

Always in memory

Resident sometimes

FrontPanel

BlockDiagram

Code DataSpace

FrontPanel

BlockDiagram

Code DataSpace

24

MemoryCoercion and Consistent Data Types

•Coercion dots imply a conversion of data types

•In general, the compiler creates a new buffer to store the converted data

•Affects performance

25

MemoryCoercion and Consistent Data Types

Method 1 (Incorrect) Method 2 (Incorrect)

Method 3 (Correct)

4 kB for copy to SGL8 kB

8 kB4 kB for FP copy

8 kB

8 kB4 kB to convert

to SGL

4 kB to convert to SGL

4 kB for FP copy

4 kB

4 kB

4 kB for FP copy

24 kB total 28 kB total

12 kB total

26

MemoryBuilding Arrays

Terrible Method

27

MemoryBuilding Arrays

Slightly Better Method

28

MemoryBuilding Arrays

Good Method

29

MemoryBuilding Arrays

Best Method

30

LabVIEW Topics

• Booleans• Memory• Multithreading• Property Nodes• Variables

t

• DLL• ActiveX• VI Server• Synchronization

Nine Areas of Concern

31

Multithreading

• Specific tasks within an application are subdivided• Provides “pseudo-parallelism”• Threads are automatically handled in LabVIEW• Seven execution systems• Five available priorities

Overview

32

Multithreading

VI

User Interface

StandardInstrument

I/OData

AcquisitionOther 1 Other 2

Same as Caller

LabVIEW

Operating System2000/NT/9x, Sun Solaris 2, and Linux

Architecture

33

Multithreading

• Priorities control when a VI is executed within the thread

• Five priorities– Background– Normal– High– Time Critical– Subroutine

Priorities

36

Multithreading

Issues

•SubVI calls are relatively expensive•Calling a subVI in a different execution system can be really expensive•Biggest issue = THREAD SWAPS

Multithreading Demonstration

37

Multithreading

• Deadlock occurs if each thread is requesting a resource held by the other

Issues - Deadlock

Resource A

Thread 1

Thread 2

Resource B

LocksRequested and Waiting

LocksRequested and Waiting

39

MultithreadingIssues – Priority Inversion•A high priority task is requesting a locked resource from a low priority task, causing a lower priority task to gain more CPU time

Time

Prio

rity

High

Low

Thread 1

Thread 2

Thread 3

Running

Blocked

Waiting

Locks Resource

Locks Resource

Resource Unavailable

40

LabVIEW Topics

• Booleans• Memory• Multithreading• Property Nodes• Variables

t

• DLL• ActiveX• VI Server• Synchronization

Nine Areas of Concern

41

Property Nodes

• Properties are characteristics or qualities about an object• Property nodes allow you to programmatically set and

read the properties of front panel objects, including an object’s data value

• Examples of properties:

Overview

•Display colors of front panel objects•Visibility of front panel objects•Menu selections for a ring control

•Scales and cursors on graphs•Size of front panel objects•Location of front panel objects

42

Property NodesCreating Property Nodes• Right-click on a panel object or its diagram

terminal and choose Create»Property Node

• Use the Operating tool to select which property to read or write

43

Property Nodes

• Very fast to program, very slow to execute• Difficult to debug• Violates data flow programming• Property nodes located in a subVI will load the front panel into memory

• Property nodes cause a thread swap to the User Interface thread

• Property nodes execute serially, never in parallel

Issues

44

Property Nodes

• When performing multiple control property changes on a graph, use “Defer Panel Updates”– Disables UI refresh until the property changes are complete

Defer Panel Updates

45

Property Nodes

• Refnum to a specific front panel object• Allows you to control front panel objects with a subVI

Control References

Control References Demonstration

46

LabVIEW Topics

• Booleans• Memory• Multithreading• Property Nodes• Variables

t

• DLL• ActiveX• VI Server• Synchronization

Nine Areas of Concern

47

Variables

• Use local variables to access front panel objects from more than one location in a single VI

• Pass data between block diagram structures that you cannot connect with a wire

Local Variable Overview

48

Variables

• Used to pass data among several VIs• “Pseudo-VI” without a block diagram• Multiple objects can be placed into one global

Global Variable Overview

Create the controls needed as global variables

Each control must have owned label

Right-click using the Operating Tool

49

VariablesRace Conditions

LabVIEW Code Sequential Codex = x * 5x = x + 2

ORx = x + 2x = x * 5

No clear data dependency exists, so the order of execution is not precisely known

50

Variables

• Each control or front panel object must have an owned label associated with it

• Difficult to debug• Contributes to race conditions

Issues

51

LabVIEW Topics

• Booleans• Memory• Multithreading• Property Nodes• Variables

t

• DLL• ActiveX• VI Server• Synchronization

Nine Areas of Concern

52

Dynamic Link Libraries (DLL)Overview• An executable file that can never run on its own• Loaded by operating system as requested by

application• Application uses dll code as part of its binary files• Application does not know what language dll was

originally written in• Dll acts like a ‘black box’ with exported functions• Application need not know how these functions are

actually implemented

53

DLLCall Library Function

Thread-UnsafeRuns in User Interface Thread(Orange)

Thread-SafeRe-entrantCall Library Node(Yellow)

54

DLL Issues

• LabVIEW loads the DLL at the same time the VI is loaded

• LabVIEW unloads the DLL when the calling VI has been completely removed from memory

• Thread safe DLLs• Global variables or initialization code located in DLL

55

DLL Issues

Suppose we have the following DLL:/* Global Variable */int test = 0;

/* Function to be exported */__declspec (dllexport) void __stdcall secondLevel(int *value){

test = test + 15;*value = test;

}

Called with the following LabVIEW Code:

56

DLL Issues

• We expect the DLL to return 15• The DLL actually returns:

Continued

Run Output

1 15

2 30

3 45

58

LabVIEW Topics

• Booleans• Memory• Multithreading• Property Nodes• Variables

t

• DLL• ActiveX• VI Server• Synchronization

Nine Areas of Concern

59

ActiveX

With ActiveX automation, you can:

• Create applications that expose objects - called automation servers.

• Create and control objects exposed in one application from another application - called an automation client.

Overview

An automation object can have:

• Methods - Functions that perform an action on an object, such as resizing it.

• Properties - Functions that set or return information about the state of an object.

60

Opens an automation refnum that refers to a specific ActiveX Automation object

Invokes a method or action on an ActiveX automation object

Sets or gets ActiveX object property information

Closes an automation refnum. To prevent a memory leak close open automation refnums

ActiveX VIs

61

ActiveXExample

62

ActiveX

• Information about the server• Closing the refnums to prevent memory leaks

Issues

63

LabVIEW Topics

• Booleans• Memory• Multithreading• Property Nodes• Variables

t

• DLL• ActiveX• VI Server• Synchronization

Nine Areas of Concern

64

VI ServerOverview

• Provides programmatic access to LabVIEW and its Applications (your programs)– Call a VI remotely.– Allows you to control a LabVIEW application from another

program.– Update the properties of multiple VI’s.– Edit the properties of a VI and LabVIEW– Load VIs into memory dynamically– Create a plug-in architecture– Retrieve LabVIEW and platform information.

65

VI Server

VI Server

ActiveX Interface

Diagram Functions

TCP/IP

ActiveX AutomationClient

TCP/IPClient

Architecture

66

VI Server

• Two classes of objects- Application—just one per LabVIEW application

- Virtual Instruments

• Each class offers:- Properties—single valued attributes of the object:

read/write, read only, write only- Methods - functions that operate on the object

Objects

67

VI ServerExample

Open Application is only needed if accessing a VI on a remote machine

VI path can be a pathname, or a string

Property Node opens the front panel of the VI

Invoke Node calls the Method ‘Run VI’

Close the session

Check for errors

Open a session to a VI object

68

VI ServerStrictly Typed VI Refnum

A data type that encodes the connector pane type information, but not the VI to call.

Open VI Reference function

Call By Reference

Connector type and VI information

Connector pane type and VI to call

69

VI ServerAdvantages of a Strictly Typed VI Refnum

Using Methods to Write/Read Controls/Indicators

•Same thing using Call by Reference

•Much neater diagram

•Datatypes checked by Open VI Reference

•No type checking when VI called (Strong Typing)

Flatten to String Unflatten from String

70

LabVIEW Topics

• Booleans• Memory• Multithreading• Property Nodes• Variables

t

• DLL• ActiveX• VI Server• Synchronization

Nine Areas of Concern

71

Synchronization

• Powerful, easy to use, underused features• Five Types:

– Occurrences– Notifiers– Queues– Semaphore– Rendezvous

Overview

72

SynchronizationOccurrences

• Software interrupt• Efficient

73

SynchronizationOccurrences - Example

74

SynchronizationNotifiers

•Function like occurrences, but with the added feature of passing data•Area of concern – Notifiers can lose data

75

SynchronizationNotifiers - Example

76

SynchronizationQueues

•Function like notifiers, but retain the data in a FIFO buffer•A non lossy synchronization technique

77

SynchronizationQueues - Example

78

SynchronizationSemaphore

• Protects access to shared resources• Can be used to avoid race conditions

79

SynchronizationSemaphore - Example

80

SynchronizationRendezvous

•Used to synchronize multiple tasks•Allows for parallel tasks to wait for each other before proceeding

81

SynchronizationRendezvous - Example

82

Questions?

83

Practical Examinations

84

About the Practical

• A PC with LabVIEW is required• LabVIEW Help may be used

– You are not allowed to plagiarize shipping examples!

• No other resources are allowed

• Time varies a small amount based on the requirements– Generally 3 ½ to 4 ½ hours

85

The Intent of the Practical

• The practical evaluates overall LabVIEW Programming skills

• What is required:– Good LabVIEW programming techniques– Problem solving skills in LabVIEW– Good Programming Style

• Must have mastery of these skills to complete the exam in the time allotted

86

Example: 4-Way Intersection Traffic Lights

• Green-Yellow-Red for:– Northbound– Southbound– Eastbound– Westbound

• North and South bound are green at the same time• East and West bound are green at the same time• May need to add left-hand turn lanes later as traffic

increases at this intersection

87

Traffic Lights: Version 1

• Successfully directs traffic flow• What are the drawbacks?

– Cannot stop in the middle of a cycle– Not easy to modify for future traffic needs– Difficult to determine what function each Boolean performs

88

Traffic Lights: Version 2

• Improvements:• Uses a Case Structure vs. a Sequence Structure

– Allows the Traffic Engineer to break into the cycle– Can also add cases for future modifications

89

Traffic Lights: Version 3

• Improvements:• Additional Documentation added to Describe Code

Functions and Wire Data• Group front Panel Objects into Clusters

– Makes all indicators easily available in all cases– Adds inherent documentation– Note with updating the indicators outside the case, the timing must

also reside outside the case

90

Traffic Lights: Version 4

• Improvements:• Use of a Type Defined Enumerated Control for determining

the next state– Type Definition allows for scalability of the design. New states can be

added to the control and all constants made from that control are updated

91

Traffic Lights: Version 5

• Improvements:• Incorporate a timing method that allows for immediate

control of the execution– For most applications, immediate control is needed to allow the system

to respond to critical inputs– Note the addition of the time delay in the loop. This prevents

LabVIEW from taking 100% CPU time for it’s execution

92

Traffic Lights: Version 6

• Adding Indicators for Left Turn Signals:• With the indicators in clusters, adding indicators is

straightforward– Add the indicators on the front panel by copying the existing indicators– On the Block Diagram, create constants for each indicator– Add the constants to the cluster constant on the left-side of the Block

Diagram– All indicators are now available in every state

93

Traffic Lights: Version 7

• Adding Turn Lane sensors:• Add the Booleans and copy the Enum constants to direct

the program flow– The sensors are checked when the yellow light is illuminated for the

opposite direction• This is a complete, working version of the application

– It is completely dataflow driven, no variables were needed

– It is easily scalable

– It is documented

94

Traffic Lights: Version 8

• This version is similar to version 7, however it incorporates a case structure rather than discrete Selectors

• It is also a completely acceptable solution

95

Traffic Lights: Version 9

• Again, this is similar to version 7, only this implementation uses Queues to select the next state

96

Additional Notes on Programming Style

• What Style issues would cost points in this Block Diagram?

97

Additional Notes on Programming Style

• What is the source for this Error Cluster?

• Left to right flow is important for readability

98

Additional Notes on Programming Style

• Watch for unnecessary bends in wires

99

Additional Notes on Programming Style

• Wire into and out of tunnels

100

Additional Notes on Programming Style

• Wire to obvious terminals on objects

101

Additional Notes on Programming Style

• Do not wire underneath objects

102

Additional Notes on Programming Style

• Do not cover objects with other objects

103

Additional Notes on Programming Style

• Wire into and out of the correct terminal locations

104

Additional Notes on Programming Style

• Always place a time delay in loops

?

105

Additional Notes on Programming Style

• Adjust the size of structures to show objects in all cases

106

Question / Answer Session on Certification

• Technical Questions• Exam Administration Questions

• Best wishes on your Certification Exam

David Bonal

Mike Fillian

107

Thank you!