Recommendations for Configuring Models

NI VeriStand 2018 Help

Edition Date: May 2018

Part Number: 372846M-01

»View Product Info
Download Help (Windows Only)

When you add a model to a system definition file, the Add Simulation Model dialog box allows you to configure the parts of the model and how it executes.

Note  You also can configure some of these settings in the System Explorer window after you add a model to the system definition file.

Related Link

Adding and Configuring a Model

Setting Model Timing

A model is set to run at a certain rate, or step size, as defined in the build options when the model is compiled. However, depending on configuration settings for the system definition, the rate at which the VeriStand Engine actually executes models might differ from the compiled rate. The following equation describes how the VeriStand Engine executes models:

actual model rate = Primary Control Loop (PCL) rate / model decimation

You set these variables at the following locations:

  • PCL rate—On the Controller Configuration page in the System Explorer window, set the PCL rate for the whole system.
  • model decimation—On the Model Configuration page in the System Explorer window, set the decimation for each model individually. This is useful if you have multiple models you want to run at different rates. You also can set this value in the Add Simulation Model dialog box when you add the model to the system definition.

Running Models Faster or Slower than Real Time

You can adjust the PCL rate and model decimation to run the model faster or slower than the rate for which it was compiled. For example, if the model was compiled to run at 100 Hz, you can set the Primary Control Loop to run at 1 kHz, or 10 times faster than real time, assuming the model decimation is 1. This means the model does not run in real time and is potentially unstable.

If both the controller and plant are simulated, such as in model-in-the-loop testing, running your model at a faster rate than the rate for which it was compiled can be desirable. Running faster than real time allows you to accomplish more simulation in a shorter amount of time. However, when you test with real hardware, as in hardware-in-the-loop testing, run your model at the rate for which it was compiled to accurately simulate the system.

Related Link

Understanding the VeriStand Engine

Setting the Initial State of the Model

Choose if the model runs as soon as you deploy the system definition or if its initial state at run time is paused. If you want to change the values of model parameters before the first time step, set the initial state to be paused.

Related Link

Controlling and Monitoring the Execution of Models

Importing Parameters and Signals

Import only parameters and signals that your system requires. Importing many parameters and signals can have a negative impact on the performance of the system even if the model is not running.

Changing the Initial Values of Parameters

By default, the initial values of parameters are the values that were compiled into the model. However, NI VeriStand can automatically apply parameter values from a text file when you deploy the system definition file. This feature is useful because it allows you to quickly switch initial parameter values between tests without recompiling models. Alternatively, you can change the parameter values in the model, and then recompile the model.

Initializing Model Parameter Values

Configuring the Scope of Global Parameters

Compiled models can contain global parameters that by default apply to any other models on the same target that contain global parameters with the same name. Global parameters are similar to workspace variables in The MathWorks, Inc. MATLAB® software. You can configure whether updates to a global parameter affect other models by configuring one of two scopes for all global parameters in a model:

  • Target-level scope—NI VeriStand applies updates to all global parameter with the same name. You can set one parameter value and it applies to any global parameters with the same name in other models that run on the same target. This might be useful, for example, if you want all models to own and share the value of a parameter that represents the environment temperature.
  • Model-level scope—NI VeriStand restricts the scope of updates to just the parameter in the owning model.

Configure the scope for global parameters in a model on the Parameters and Signals page of the Add Simulation Model dialog box or, after you add a model, on the Parameters configuration page in the System Explorer configuration tree. All global parameters in a particular model share the same scope.

Related Links

Differences Between Local and Global Parameters

Importing Inports and Outports

If your model contains a vector inport or outport, choose between maintaining the vector representation or separating each vector element into a separate scalar channel. You must choose this setting in the Add Simulation Model dialog box when you add the model.

Scalar channels provide greater flexibility than vector channels when you connect them to other parts of the system for the following reasons:

  • You can map a vector channel only to another model that contains a vector channel of the same size. For example, if you add a model that contains a 1 × 10 vector outport and you maintain that vector, you must map it to a 1 × 10 vector channel from another model.
  • You cannot map a vector channel to controls or indicators on your workspace or use it with calculated channels, alarms, procedures, and so on.

When you choose to separate a vector inport or outport into scalar channels, a virtual folder of the scalar channels appears in your system definition.

Related Links

Understanding How NI VeriStand Imports Models from The MathWorks, Inc. Simulink® Software

Using LabVIEW VIs as Models

Setting Default Values for Inports

The default value of all inports is 0. You can change the default value for an inport by expanding Inports in the System Explorer configuration tree and selecting the inport you want to modify. Setting the default values can help to prevent your models from ever using invalid values. For example, if the model divides by an inport value, changing the default from 0 avoids an invalid operation.

Note  Your system configuration might cause the initial, default value to go unused. For example, if the PCL execution mode is Low Latency, the model is assigned to the first execution group, and an inport is mapped to hardware, the inport will always receive its value from hardware.

Related Links

Understanding PCL Execution and Model Latency

Determining the Execution Order of Models


Not Helpful