3.4.2 - Dice Throws 3_SubVIs

In this tutorial, you will replace the dice throws in the Dice Throws 3 tutorial with subVIs. However, you will design the subVIs to return any integer between two user-defined values:

  • Open DiceThrows3.viScreen Shot 2012-04-13 at 11.19.03
  • Save it as DiceThrows3_SubVI.vi
  • Mark the dice throw functions (shown to the right) and make them into a subVI:
    • Edit -> Create SubVI
  • Double-click the icon to open your newly created subVI
  • Edit the icon to indicate the function of the subVI
    • Right-click the icon to the top right on the Block Diagram and choose: Edit Icon
    • Create a new icon - you can use the icon for the subVI at the bottom of the page as inspiration, but anything goes:)
  • Add two numeric controls on the Front Panel
    • Name them Min and Max
    • Rename the indicator RandomNumber
  • Connect the controls/indicator with the connector panel
    • Right-click the icon on the Front Panel and choose "Show Connector"
    • Right-click the Connector and choose Panels - select the icon with two inputs on the left and an output on the right
    • Click on each terminal on the Connector Icon, and then on the corresponding control/indicator on the Front Panel
  • Edit the wiring on the Block Diagram as below
  • Save your SubVI as RandomIntegerMinMax.vi
  • Close it
  • On the Block Diagram for DiceThrows3_SubVI.vi:
    • Delete your old dice throw functions
    • Copy your new subVI and inser another 3 copies instead of the other dice throws.
    • Create two new constants and set them to 1 (min) and 6 (max). Connect them to the repective terminals on all four subVIs
  • Run the program and check if everything functions correctly
  • Save your VI

Inspiration:

Skærmbillede 2012-04-08 kl. 01.11.41
Skærmbillede 2012-04-08 kl. 01.18.52


Created by Samuel Thrysøe © 2013