Presentation is loading. Please wait.

Presentation is loading. Please wait.

EE 200 Design Tools Laboratory 14

Similar presentations


Presentation on theme: "EE 200 Design Tools Laboratory 14"— Presentation transcript:

1 EE 200 Design Tools Laboratory 14

2 Laboratory 14 Topics LabVIEW Programming
Properties of Front Panel Objects Implicitly and Explicitly Linked Property Nodes Control References Event programming and the Val(Sgnl) property

3 Properties of Front Panel Objects
Front panel objects have properties Properties are attributes that describe the object Numerous properties describe appearance: Color Visibility Position Numeric display format Value Property nodes alter the properties of objects

4 Property Nodes Property nodes allow you to programmatically set the properties of front panel objects Property nodes can be configured to read or write a given property Property nodes can be explicitly or implicitly linked to front panel objects Implicitly linked property nodes are tied to a specific front panel object Explicitly linked property nodes must be linked to front panel objects using control references

5 Implicitly Linked Property Nodes
Right click front a panel object and select Create >> Property Node In the above example, the implicitly linked property node allows us to read the value of the control

6 Property Node Attributes
Right click on the property node Click on Change to Write In the above example, the implicitly linked property node allows us to write a value to the control

7 Exercise 1 Open Exercise_1.vi Use implicitly linked property nodes to
Set LED Control/Indicator visible or invisible Set LED Control status: enabled, disabled, or disabled and grayed out Set the LED Indicator to blink, or not to blink Change the LED Indicator color

8 Exercise 1

9 Exercise 1 Set the LED Color using a Color Box Control

10 Exercise 1 Set the default colors for the LED
Left-click the middle of the color constant box to open the color palette; use the values shown

11 Property Node Execution Order
The property node does not execute if the status of the input error cluster is true The node executes from top to bottom By default, if an error occurs on a terminal, the node stops at that terminal, returns an error, and does not execute any further terminals To override this behavior, right-click and select Ignore Errors Inside Node

12 Exercise 2 Open Exercise_2.vi
The default values for both indicators are zero After the VI executes, what do the indicators display? Verify by executing Exercise_2.vi Why does Numeric Indicator 1 display 2 rather than 3?

13 Control Reference A control reference (refnum) in LabVIEW is analogous to a pointer in C A control reference, or pointer, represents an address A control reference to a front panel object represents an address to the front panel control

14 Creating a Control Reference
Right click the front panel object Select Create >> Reference

15 Explicitly Linked Property Nodes
Programming >> Application Control

16 Explicitly Linked Property Nodes
Link the property node to the front panel object using a control reference (refnum) Right click the property node to set its attributes refnum

17 Exercise 3 Modify the Exercise_1.vi so that is uses explicitly linked property nodes

18 Exercise 4 Open Exercise_4.vi
Use an explicitly linked reference node and an array of control references to set the min and max range of the three control knobs

19 Exercise 4

20 Boolean Control Property Node
When a Boolean control is set to a latching mechanical action, after you change the value of the Boolean control, it will change back to the default once the VI reads its value Depending on when the value of the Boolean control is read by the VI or by the property node, you may miss a change in the value For this reason, use a switched mechanical action if you wish to change a Boolean control using a property node

21 Event Programming Events are notification that something has occurred
Events originate from the user interface, external I/O, or other parts of the program Clicking the mouse generates a mouse event Event-Driven Programming is a method of programming where the program waits on an event to occur before executing one or more functions

22 Types of Events Static events are only for interactions with the front pane A static, notify event would be a “Value Change” for an OK button Dynamic events are for interactions with any part of your block diagram A rising edge on a signal connected to DAQ device

23 The Event Structure Examples of User Interface (Static) Events
Pressing a button on the mouse Pressing a key on the keyboard Changing the value of a numeric control

24 Parts of an Event Structure
Event Selector Label—Identifies event case viewed Timeout—Value in ms to wait for events; default value is –1 (indefinite)

25 Parts of an Event Structure
Event Data Node—Identifies the data LabVIEW provides when the event occurs; similar to the Unbundle By Name function Event Filter Node—Identifies the subset of data available in the Event Data node that the event case can modify

26 Using an Event Structure
Normally contained within a while loop Event structure handles exactly one event per iteration Sleeps when no events occur Minimize the code appearing in the event structure

27 Exercise 5 Open Exercise_5.vi

28 Exercise 5 The Stop button uses latched mechanical action while the Refresh button uses switched mechanical action The Loop Iteration indicator shows the number of times the Refresh button is read The code polls the Refresh and Stop buttons every 10 ms Polling is not efficient While the processor is looping and reading controls, it is not executing other code

29 Exercise 5 Avoid polling the front panel controls by using the event structure on slide 30 Add events as shown on slide 31 The Stop Boolean control uses latched mechanical action and must be located inside the event case to work correctly Verify that the Loop Iteration indicator increments only when the Refresh button is pressed

30 Exercise 5

31 Exercise 5

32 Val(Sgnl) Property Node
Suppose we change the value of the Refresh button in Exercise 5 using a property node The properties Value and Val(sgnl) both change the value of the front panel object, but only the Val(sgnl) property generates a Valued Changed Event within an event structure

33 Exercise 6 Save Exercise_5.vi as Exercise_6.vi
Eliminate the Wait Until Next ms Multiple node Not needed when the loop contains an event structure Add a Boolean control Trigger Refresh that uses switched when released mechanical action Add an event case that executes when the value of the Trigger Refresh control changes value Within the new event case Use a Value property node to set the Refresh control to true Use a Value property node to set the Trigger Refresh control to false

34 Exercise 6

35 Exercise 6 Start the VI Press the Refresh Trigger control
Does the color of the Refresh Button change? Does the One Button Dialog box appear? Does the Loop Iterations indicator increment? Use a Val(Sgnl) property node to set the Refresh control to true Does pressing the Refresh Trigger control button now cause the One Button Dialog box to appear?

36 Exercise 6


Download ppt "EE 200 Design Tools Laboratory 14"

Similar presentations


Ads by Google