Company Events Academic Community Support Solutions Products & Services Contact NI MyNI

Creating a Simulation Subsystem (Control Design and Simulation Module)

LabVIEW 2012 Control Design and Simulation Module Help

Edition Date: June 2012

Part Number: 371894G-01

»View Product Info

You can create a simulation subsystem from a selection of the simulation diagram. In this situation, LabVIEW automatically creates a connector pane for the subsystem inputs and outputs. A connector pane is required if you want to connect that simulation subsystem to inputs and outputs within another Control & Simulation Loop or on a block diagram outside a Control & Simulation Loop. However, you can run a simulation subsystem as a stand-alone VI without creating a connector pane.

You also can create a new simulation subsystem to run as a stand-alone VI. If you want, you can create a connector pane for this subsystem later.

Note  You cannot use local variables in a simulation subsystem.

Creating a Simulation Subsystem from a Selection on the Simulation Diagram

Complete the following steps to create a simulation subsystem and connector pane simultaneously.

  1. Launch LabVIEW and create a new, blank VI.
  2. Place a Control & Simulation Loop on the block diagram.  

  3. Create the simulation diagram code and configure simulation parameters using the Configure Simulation Parameters dialog box.
  4. Select a portion of the simulation diagram code and select Edit»Create Simulation Subsystem. LabVIEW replaces the code you selected with a single function that represents the simulation subsystem. The function shows the block diagram of the simulation subsystem.
  5. Run the subsystem by running the VI that contains the subsystem.

When you create a subsystem using the above method, the LabVIEW Control Design and Simulation Module automatically creates a connector pane and configuration dialog box for the simulation subsystem. To display this configuration dialog box, double-click the subsystem on the block diagram. To edit the front panel window or block diagram window of the subsystem, right-click the subsystem and select Open Subsystem from the shortcut menu.

Creating a New Simulation Subsystem

Complete the following steps to create a simulation subsystem without a connector pane.

  1. Launch LabVIEW.
  2. Select File»New.
  3. Select Other Files»Simulation Subsystem from the Create New tree.
  4. Click the OK button. LabVIEW creates a new, blank VI with a pale yellow block diagram, which is the simulation diagram.
  5. Create the simulation diagram code and configure simulation parameters. Because this new subsystem has no Control & Simulation Loop, you configure simulation parameters, such as the ordinary differential equation(ODE) solver , by selecting Operate»Configure Simulation Parameters.

    You also can configure properties that affect how this subsystem appears and runs. To configure these properties for a stand-alone subsystem, select File»VI Properties to display the VI Properties dialog box.
  6. Save the simulation subsystem.
Note  You also can create a new simulation subsystem by displaying the Project Explorer window, right-clicking a target, and selecting New»Simulation Subsystem from the shortcut menu.

You now can run this simulation subsystem as a stand-alone VI. You also can place this subsystem within the Control & Simulation Loop of another VI or on the block diagram outside a Control & Simulation Loop. However, before doing so, you must build a connector pane for the subsystem. The connector pane defines the relationships between block diagram terminals and subsystem inputs and outputs. After you define a connector pane for a subsystem, the Control Design and Simulation Module creates a configuration dialog box for that subsystem.

As you create the connector pane, consider the parameter requirements and the initial value of each parameter. The default source for a subsystem parameter depends on whether you specify that parameter as required, recommended, or optional. The initial value for the parameter is the default value of the parameter control.

The following list describes the availability and default sources of parameters.

  • If the connection is required, the parameter is available only as a terminal on the simulation diagram. The parameter is not visible in the configuration dialog box.
  • If the connection is recommended, the default source of the parameter is the terminal. You also have the option to configure the parameter using the configuration dialog box.
  • If the connection is optional, the default source of the parameter is the configuration dialog box. You also have the option to configure the parameter using a terminal on the simulation diagram.

Creating Enabled and Triggered Subsystems

Enabled and triggered subsystems execute only when certain conditions are met. You can configure subsystems to be enabled, triggered, or both. Complete the following steps to create a subsystem that is both enabled and triggered.

  1. Double-click the subsystem to display the Subsystem Configuration dialog box.
  2. From the Parameters list, select Execution Control. The Parameter Information section displays options for configuring the execution of the subsystem.
  3. From the Execution Control pull-down menu, select Enable And Trigger.
  4. Select a Trigger Type. This option specifies the direction in which the input signal to the subsystem must cross 0 to trigger the subsystem.
  5. (Optional) Specify a Trigger Offset value to specify a value other than 0 that the input signal must cross to trigger the subsystem.
  6. Select an output of the subsystem from the Parameters list to display configuration options for the output.
  7. Select a Disabled Behavior. If you select Hold, the output returns its last known value, which on first execution is the initial value of the subsystem. If you select Reset, the output resets to its initial value or a default value you specify, depending on whether you enable the Use Configured Default Value option.
  8. (Optional) Place a checkmark in the Use Configured Default Value checkbox to enable the output name field and enter a default value for the output to return if the subsystem does not execute.
  9. Repeat steps 6–8 for all the outputs of the subsystem.
  10. Click the OK button to close the Subsystem Configuration dialog box and apply the execution control settings. Notice that the subsystem now includes Enable and Trigger inputs. The values you wire to these inputs determine whether the subsystem executes.

Creating Polymorphic Subsystems

To create a polymorphic subsystem, you must have two or more subsystems with identical connector pane patterns. Each subsystem should handle a different data type. You then create a single polymorphic VI that points to these subsystems.

Note  Consider naming these VIs on disk to make choosing subsystems easier. LabVIEW convention is to have the data type, or other useful polymorphic information, in parentheses after the VI name. For example, if you have two subsystems, one that operates on a double-precision floating point number and one that operates on a 16-bit integer, you could rename the subsystems to Perform Operation (Double) and Perform Operation (Integer), respectively. LabVIEW uses the contents of these parentheses if you do not explicitly specify an instance name when creating a polymorphic subsystem.

After you create these subsystems, complete the following steps to create a polymorphic subsystem.

  1. Select File»New to display the New dialog box.
  2. Select VI»Polymorphic VI from the Create New tree. The Polymorphic VI window appears.
  3. Click the Add button and select a simulation subsystem to add to the polymorphic VI. Repeat this step for as many simulation subsystems as you want to add. Each subsystem must have an identical connector pane pattern.
    Note  The polymorphic VI breaks if you add a VI that is not a simulation subsystem, a simulation subsystem with a different connector pane pattern, or a simulation subsystem that is broken.
  4. Remove, rename, and rearrange the instances as needed.
  5. Select File»Save to save the polymorphic VI. You now can place this subsystem within the Control & Simulation Loop of another VI or on the block diagram outside a Control & Simulation Loop.

After you place the polymorphic subsystem on the simulation diagram or block diagram, you can perform the following actions:

  • Display the Polymorphic VI window—Right-click the polymorphic subsystem and select Open Polymorphic VI from the shortcut menu.
  • Display the configuration dialog box of the currently displayed subsystem—Double-click the polymorphic subsystem. Notice the Polymorphic instance pull-down menu contains the names you specified for each instance.
  • Edit the currently displayed subsystem—Right-click the polymorphic subsystem and select Open Subsystem from the shortcut menu.

 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit