Graphical
Programming with LabVIEW (GPL)
Circuit Analysis
IV
We program the solutions to the same circuit as with GPL III so the equations are the same.
A common programming technique is to convert a repeated group of sentences (or icons in a graphical programming language as LabVIEW) into a subroutine (or sub-VI in our case) to avoid repeated writings, consequently providing less chances for unwanted bugs to show up, and allowing a more elegant presentation and easier reading of long and complicated programs.
In our example we are creating two sub-VI’s to be used in a new version of GPL III:
(1) The parallel equivalent resistance sub-VI:
Given any two resistors R1 and R2, the parallel equivalent resistor RP=R1||R2 is given by
RP=R1*R2/(R1+R2)
Use R1=R2=4 Ohm, you should get RP=2 Ohm. Then save by clicking File-Save. Save everything in a same VI library. If you don’t have a library created, click on VI Library, give a name for the library, then change the VI name from untitled.vi to parallel-create.vi.
To create sub-VI “parallel.vi” , click and drag with the selection/resize/move tool to enclose the three icon-operators in the block diagram, release the mouse button to see them overwritten with dotted lines:
Then click on Edit-Create SubVI to see them replaced by one new icon which can be edited (not necessary) to show the symbol || for parallel.
To save this newly created subVI, click File-Save. Click OK to the prompt. Select the same library you are saving everything in (with extension .llb). Change subVI name untitled.vi to parallel.vi. The sub-VI has been now created and saved, ready to be used.
(2) The next-node-voltage sub-VI:
Given the voltage V1 at the left node of a resistor R through which a current I is flowing, the voltage V2 at the right node is given by
V2=V1-I*R
Repeat the same steps as in creating sub-VI parallel.vi, i.e. start with a Vnext-create.vi, to end up with sub-VI Vnext.vi as shown below (open the sub_VI after you saved it):
With these two sub-VI’s, another version of the block diagram for GPLIII now reads
Note that for V=9V; R1 through R6=1 Ohm in the front panel, you should get the same numbers as in GPL III: I=5.54A; V2=3.46V; V4=1.38V; V6=0.69V.