Presentation is loading. Please wait.

Presentation is loading. Please wait.

Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 4 SubVIs  Read Bishop, Chapter 4.  Lab #4 and Homework #4 due next week.

Similar presentations


Presentation on theme: "Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 4 SubVIs  Read Bishop, Chapter 4.  Lab #4 and Homework #4 due next week."— Presentation transcript:

1 Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 4 SubVIs  Read Bishop, Chapter 4.  Lab #4 and Homework #4 due next week.

2 Floyd, Digital Fundamentals, 10 th ed Modular Programming  When writing a complex program, good programmers divide their programs into separate parts that can be written and tested independently, and that can be re-used in other programs.  In text-based programming languages, these parts are called subroutines.  In LabVIEW they’re called subVIs. (Bishop, p. 173)

3 Floyd, Digital Fundamentals, 10 th ed Hierarchy of VIs  Your main VI can contain one or more subVIs.  Each of those subVIs can contain one or more subVIs.  Each of those subVIs can contain subVIs.  And so on…

4 Floyd, Digital Fundamentals, 10 th ed A Little Poem “Great fleas have little fleas upon their backs to bite 'em, And little fleas have lesser fleas, and so ad infinitum. And the great fleas themselves, in turn, have greater fleas to go on, While these again have greater still, and greater still, and so on.” Augustus DeMorgan (1806-1871)

5 Floyd, Digital Fundamentals, 10 th ed Example: E-Mail Notification.vi  In LabVIEW’s Example Finder, browse according to Task. Open Networking folder, then open Internet & Web folder. Then open E-Mail Notification.vi.  In its block diagram, double-click on SMTP Email Send Message.vi.  In its block diagram, double-click on SMTP Email Send Message Charset.vi.  And so on…

6 Floyd, Digital Fundamentals, 10 th ed Hierarchy Window  LabVIEW’s VI Hierarchy Window shows how all of these VIs are related to each other.  Open the window by using View > VI Hierarchy in pull-down menus. (Bishop, p. 196)

7 Floyd, Digital Fundamentals, 10 th ed Example: E-Mail Notification.vi

8 Floyd, Digital Fundamentals, 10 th ed A Simpler Example  Suppose you’re writing a program that lets the user enter values for x, y, and z, and then calculates x 3 + y 3 + z 3. Rather than placing all of the multiply functions to compute x 3, y 3, and z 3 individually, consider building a subVI that will cube any number.

9 Floyd, Digital Fundamentals, 10 th ed Steps in Creating a SubVI 1. Create the VI. 2. Create the icon. 3. Create the connector with the correct number of input and output terminals. 4. Assign the connector’s terminals to the VI’s controls and indicators. 5. Add a description. 6. Save the VI.

10 Floyd, Digital Fundamentals, 10 th ed Icon  A subVI is represented by an icon on the block diagram of a VI that uses the subVI.  When a VI’s front panel or block diagram is open, the VI’s icon appears in the upper right corner.  The default icon is the LabVIEW logo along with a number. (Bishop, p. 177)

11 Floyd, Digital Fundamentals, 10 th ed Icon Editor  If you plan to use a VI as a subVI, you should replace the default icon with a more informative icon.  Use the icon editor to do this. Right-click on the icon in the front panel and select Edit Icon…. (Bishop, p. 177)

12 Floyd, Digital Fundamentals, 10 th ed Connector  To use a VI as a subVI, you must assign it a connector so that you’ll be able to attach wires to it on the block diagram of a VI that uses it as a subVI.  The connector contains one terminal for each of the subVI’s inputs and outputs. (Bishop, p. 180) Connector Input terminalsOutput terminal

13 Floyd, Digital Fundamentals, 10 th ed Creating the Connector  To create the connector, right-click the icon in the front panel and select Show Connector.  You can choose a different connector pattern by right-clicking the connector and selecting Patterns. (Bishop, p. 181)

14 Floyd, Digital Fundamentals, 10 th ed Assigning Terminals to Controls and Indicators  Next, assign terminals on the connector to your front-panel controls and indicators.  To do this, click on a terminal with the Wiring tool and then click on the control or indicator that you want to assign to that terminal.  Always assign terminals on the left to inputs (controls), and terminals on the right to outputs (indicators). (Bishop, p. 183)

15 Floyd, Digital Fundamentals, 10 th ed Required, Recommended, Optional Terminals  You can identify each terminal as being required, recommended, or optional.  If required terminals are left unwired, then the VI will not run as a subVI. But it will run when recommended or optional terminals are left unwired.  By default, all terminals are recommended.  To change a terminal’s status, right-click the terminal and select This Connection Is. (Bishop, p. 185)

16 Floyd, Digital Fundamentals, 10 th ed Context Help Window  Information about a subVI appears automatically in the Context Help window when you roll the mouse over the subVI’s icon on a block diagram.  This information includes the subVI’s name and icon the name of each terminal (in bold text if it’s required, in plain text if it’s recommended, in gray text if it’s optional) The subVI’s description, if you added one (Bishop, p. 184)

17 Floyd, Digital Fundamentals, 10 th ed Adding a Description  You should document your VI by adding a description of what it does.  To do this, choose File > VI Properties… in the pull-down menus, then select Documentation from the drop-down box, and then type your description. (Bishop, p. 187)

18 Floyd, Digital Fundamentals, 10 th ed Adding More Detailed Info  In addition to a description for the entire VI, you can also add a description for each control and indicator on the VI’s front panel.  To do this, right-click on the control or indicator and choose Description and Tip…. Then type a description and a brief tip.  Now when you roll over the object, its description will appear in the Context Help window and its tip will appear next to the object. (Bishop, p. 188)

19 Floyd, Digital Fundamentals, 10 th ed Summary: Creating a SubVI 1. Create the VI. 2. Create the icon. 3. Create the connector with the correct number of input and output terminals. 4. Assign the connector’s terminals to the VI’s controls and indicators. 5. Add a description. 6. Save the VI.

20 Floyd, Digital Fundamentals, 10 th ed Using a VI as a SubVI  After you’ve created and saved a VI, how do you call it as a subVI inside another program?  Choose All Functions on the Functions palette, then choose Select a VI… and then locate your VI. (Bishop, p. 188)

21 Floyd, Digital Fundamentals, 10 th ed SubVI Is a Separate File  CAUTION: When you save a program that calls a subVI, the subVI is not saved as part of that “caller” VI. The two files are totally distinct.  So if you send someone the caller VI, you must also send the separate subVI file, or the person won’t be able to run your program.


Download ppt "Floyd, Digital Fundamentals, 10 th ed EET 2259 Unit 4 SubVIs  Read Bishop, Chapter 4.  Lab #4 and Homework #4 due next week."

Similar presentations


Ads by Google