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

Generating, Collecting, and Displaying Simulation Data (Control Design and Simulation Module)

LabVIEW 2012 Control Design and Simulation Module Help

Edition Date: June 2012

Part Number: 371894G-01

»View Product Info

The LabVIEW Control Design and Simulation Module includes several functions you use to generate, collect, and display simulation data. The following sections provide information about using these functions.

Generating and Combining Signals

Use the Signal Generation functions to generate many different types of signals, including sine, ramp, step, pulse, and chirp signals. These functions are useful when you want to see how a dynamic system responds to a particular type of input. For example, the Step Signal function generates a step signal, which you commonly use to test controller performance. Each Signal Generation function has configuration options you can use to fit the needs of a particular situation. Use the Signal Arithmetic functions to add, subtract, multiply, and divide signals.

Collecting Simulation Data

You can collect simulation data, such as signal values, continuously at run time or collect and store the value of a signal over the duration of the simulation for later access.

Collecting Signals Continuously at Run Time

You can wire signals from Simulation functions and subsystems directly to graphs and other functions to interact with their values. However, in applications with nested subsystems and multiple functions whose signals you want to collect, wiring values into and out of subsystems can require a lot of wiring. Instead, use the Access Model Hierarchy function to return the signal values at any level in the hierarchy of a simulation diagram without performing those tasks.

When the following block diagram runs, the Access Model Hierarchy function returns the signal values wired from the Waveform Chart output of a SimTime Waveform function in a subsystem.

Note  The Access Model Hierarchy function can access only signals on wires in the simulation diagram where they exist.

Configuring How Often to Collect Signal Values

Before the Access Model Hierarchy function can collect signal values at run time, you must configure a decimation period that controls how often to collect signal values. By default, the decimation period is 0, which means LabVIEW does not collect any values. You configure this value for the simulation hierarchy where the signal resides. For example, the subsystem in the previous block diagram contains the signal, so you configure the decimation period along with other simulation parameters that define the behavior of the simulation in the subsystem.

Collecting signal values with this feature is computationally expensive. If you need only some signal values, you can configure a decimation period to collect signal values at an interval instead of collecting every value. You might decimate the signal if you experience performance issues when running a simulation on an RT target. If you need to monitor a signal only occasionally, similar to using a probe, you can set the decimation period to 0 to halt the signal collection when you do not need the values.

Accessing Signals in Other VIs

You can use the Access Model Hierarchy function to access signals in other VIs, including VIs that run on RT targets. The configuration dialog box for the function allows you to manually identify signals you want to access in a different VI on the local computer. You also can write code similar to how you access model parameters in other VIs to identify a signal in a remote VI programmatically.

Related Resources

Refer to the tutorial about accessing parameters and signals in a simulation hierarchy for information about using this function.

Refer to the SimEx Getting Model Signals at Runtime VI in the labview\examples\Control and Simulation\Simulation\Signal Collection directory for an example of returning signal values at run time.

Storing Signals until the Simulation Finishes

To store all or part of a signal history over the entire simulation for later analysis, use the Collector function. This function stores values in an array, similar to the auto-indexing output tunnel of a For Loop. However, whereas LabVIEW indexes For Loop arrays by the loop iteration, the Control Design and Simulation Module indexes Collector arrays by simulation time. Therefore, after the simulation finishes, you can see the values that correspond with certain points in time.

An alternative to the Collector function is collecting signal histories from any level in the hierarchy of a simulation diagram with the Control & Simulation Loop itself. Configure the Output Node of a Control & Simulation Loop to return the signal history without wiring a signal through subsystems or out of the Control & Simulation Loop to the location where you want to access the signal history.

When the following block diagram runs, the subsystems return scalar waveforms as the simulation executes. When the simulation finishes, the Output Node of the Control & Simulation Loop returns arrays of values stored from the signals you specify.

Specifying How Often to Collect Signal Values

Before the Control & Simulation Loop can collect signal values at run time, you must configure how often to collect signal values. By default, the decimation period is 0, which means LabVIEW does not collect any values. You configure this value for the simulation hierarchy where the signal resides. For example, the Control & Simulation Loop in the previous block diagram contains the signal, so you configure the decimation period along with other simulation parameters that define the behavior of the simulation in the loop.

Collecting signal values with this feature is computationally expensive. If you need only some signal values, you can configure a decimation period to collect signal values at an interval instead of collecting every value. You might decimate the signal if you experience performance issues when running a simulation on an RT target. If you need to monitor a signal only occasionally, similar to using a probe, you can set the decimation period to 0 to halt the signal collection when you do not need the values.

Related Resources

Refer to the SimEx Collecting Model Signals VI in the labview\examples\Control and Simulation\Simulation\Signal Collection directory for an example of collecting signal histories and returning them from the Control & Simulation Loop when the simulation finishes.

Indexing Simulation Data

The opposite of the Collector function is the Indexer function, which takes an array of data and returns the correct value based on the simulation time. For example, you can define an arbitrary signal as an array of timestamps and values at each timestamp. You then wire this array to the Input input of an Indexer function. When you run the simulation, this function returns the correct array value at the correct time. If you do not define a value for a specific time, this function linearly interpolates the expected result according to several options you can specify. The Indexer function operates similarly to the auto-indexing input tunnel of a For Loop, except LabVIEW indexes For Loop arrays by loop iteration instead of simulation time.

Displaying Simulation Data

The SimTime Waveform function and Buffer XY Graph function operate similarly to the LabVIEW Waveform Chart and XY Graph objects. However, whereas LabVIEW displays the loop iteration on the x-axis of these objects, the Simulation versions of these functions properly display simulation time on the x-axis. This distinction is important when you are using a variable step-size ordinary differential equation (ODE) solver. In this situation, the simulation might not return a value at every loop iteration, due to changes in the step size. However, the LabVIEW Waveform Chart still plots a value every loop iteration. The SimTime Waveform function corrects this behavior and properly displays unevenly-spaced values on the x-axis.

The following front panel image shows how a SimTime Waveform Chart and a LabVIEW Waveform Chart display the output of the Pulse Signal function when simulated for 30 seconds using a variable step-size ODE solver.

Notice the irregularities in the LabVIEW Waveform Chart when compared to the SimTime Waveform Chart.

Note  When you place a SimTime Waveform function or Buffer XY Graph function on the simulation diagram, LabVIEW automatically creates a chart or graph object connected to the function output.

Storing Precalculated Data in Lookup Tables

Lookup tables are useful for defining sets of experimental data, such as the result of a function, and then retrieving that data without calculating the function. If you store the data in a lookup table, the simulation does not have to compute the function every time step. Instead, you call the lookup table to obtain the appropriate value. In this situation, you improve computation performance by reducing the need to calculate functions at each iteration of the Control & Simulation Loop.

A lookup table consists of two data sets: a set of table values and a corresponding set of data values. When you specify an input value, the lookup table matches that input value to a table value and returns the appropriate data value.

For example, consider a lookup table with table values of [0 1 5] and data values of [4 2 8]. If you specify an input value of 0, the lookup table returns 4. If you specify an input value of 5, the lookup table returns 8. You also can configure how the lookup table operates if you specify an input value that does not exist as a table value. For example, you can configure a lookup table to interpolate or extrapolate the appropriate data value from the available table values. Use the Method parameter of the Lookup Tables functions to define this behavior.

This example uses a one-dimensional lookup table; however, the Control Design and Simulation Module also includes functions that implement two- and three-dimensional lookup tables.

Transferring Data Between Control & Simulation Loop Iterations

Use the Memory function to transfer the value of a signal from one iteration of the Control & Simulation Loop to the next. This function behaves similarly to a shift register you can place on a While Loop. This function is polymorphic and accepts any data type you wire to the Initial Value input. To implement a fixed-time delay, use the Discrete Delay function.


 

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