1 / 18

Witold Nocoń, Ph.D

Graphical Programming - fall 2004 Lecture 6 - SubVI’s, Global Variables, Dynamical Loading of VI’s. Witold Nocoń, Ph.D. http://terminator.ia.polsl.gliwice.pl/ dydaktyka/ virtual. connector pane.

rusty
Download Presentation

Witold Nocoń, Ph.D

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. Graphical Programming- fall 2004 Lecture 6 - SubVI’s, Global Variables,Dynamical Loading of VI’s Witold Nocoń, Ph.D http://terminator.ia.polsl.gliwice.pl/dydaktyka/virtual

  2. connector pane Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. How to create a SubVI? Every VI you create, can be used as a SubVI. To use it as a SubVI however, inputs and outputs for this SubVI need to be specified. Basically any control can serve as the SubVI’s input connector, and every indicator can serve as the SubVI’s output connector. To start specifying inputs and outputs, right-click on the VI’s Icon (in the front panel) and select Show Connector.

  3. wiring tool Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. How to create a SubVI? By default, the number of terminals will match the number of all controls and indicators already placed on the front panel. To start assigning different controls and indicators to the appropriate terminals on the icon, select the wiring tool (while working on the front panel). Now, click the appropriate control or indicator and than click the appropriate terminal to “connect” this terminal to the control or indicator. When connecting a control to a terminal an input terminal will be created. When connecting an indicator to a terminal an output terminal will be created. The colour of the terminal will match the type of the control of indicator.

  4. Design a good-looking icon for the SubVI commands for manipulating with terminals Not all inputs to the subVI are always required. In some cases you may just want to use default values in most of the cases. You may change the behaviour of a subVI in case a certain terminal is not connected. Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. How to create a SubVI? The pull-down menu offers a wide range of functions useful while creating the connector pane.

  5. When an input is required, you cannot run a the VI as a subVI without wiring a value to the terminal. this option only applies to inputs (controls) Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. How to create a SubVI? When an input or output is recommended, you can run a the VI as a subVI without wiring a value, but the Error List window will list a warning (if you have warnings enabled) that tells you a recommended input or output is not wired. When an input is optional, no restrictions are enforced, and such connection is often considered advanced.

  6. With a simple editor you can change the appearance of the icon that will appear on the diagram. Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. How to create a SubVI? Design a good-looking icon for the SubVI

  7. Click on the Select VI icon on the Functions Palette... ...a dialog box will appear enabling selection of the saved VI... ...just place the icon on the diagram. Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. How to use a your own SubVI?

  8. Example: gp6_1 Write a subVI that will add two numeric values and will check whether the integer part of the result is even. Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Example

  9. Select the portion of the diagram, that you would like to see as a subVI... ... a sub VI is automatically created: Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Another way to create a SubVI. Select form menu Edit - Create SubVI... ... open this new subVI and save it!

  10. Example: gp6_2 Write a subVI, that will compute the value of the following function: Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Examples Example: gp6_3.llb - the program with container rewritten

  11. Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Libraries of VI’s When having multiple VI’s in one project, it is advised to make a library of functions (.llb files). File - Save - New VI Library You can add VI’s to the library simply by saving those in llb files (treated as “folders”) To edit a library select Tools - Edit VI library

  12. Select the Global Variable structure form the structures menu... ... and place this structure on the diagram. Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Global variables Global variables are very similar to local variables, only that they are “visible“ in multiple VI’s. If you now double-click on it a front panel will appear named Global 1...

  13. Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Global variables This front panel is similar to other VI’s, only that is possesses no diagram. You can now start placing components just like on the front panel. Now, you should save this “VI” just like any other. Example: gp6_4.llb

  14. Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Global variables Remember: Global variables are perhaps the most misused and abused structure in programming. Globals are more often then not the cause of mysterious bugs, unexpected behaviour, and awkward structures There are situations in which usage of globals should be advised... .. but you should never use those if you don’t have a reason to do so.

  15. 3. Close it (dump from memory when no longer needed) 1. Open VI reference (load it into memory) 2. Call By Reference (execute the loaded VI - many times if you want) Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Dynamical loading of VI’s There is a possibility on LabVIEW to dynamically load VI’s into memory, use them, and dump whenever needed.

  16. Example: gp6_5.vi An mathematical operation should be made on two numbers (add,sub,mul,div), but the VI’s executing those operations should be loaded dynamically. Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Dynamical loading of VI’s

  17. In our program we have a Data Space (array of numeric values). We want to be able to dynamically load functions into the memory, that will be performing any operations on those numbers having two inputs and out output, for example:. Add Sub Mul Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Dynamical loading of VI’s Example: gp6_6.llb a more complex example Let’s add some functions to the container example.

  18. Graphical Programming Lecture 6- SubVI’s, Global Variables, Dynamical Loading of VI’s presented by Witold Nocoń Ph.D. Dynamical loading of VI’s Example: gp6_6.llb a more complex example We will do this by dynamically loading functions (plugins) into the memory, specifying inputs and output. This information about all loaded plugins will be stored in our container.

More Related