Application Data Collection Functions

You can use the Application Data Collection functions to configure signals for 1D Data Collection and collect data from AeroScript in the Data Visualizer module.

Use the Data Visualizer module to configure, collect, and look at data from the controller and also set the rate at which data collection occurs. You can also save, open, and look at plot files. To use the condensed version of this module in the Develop workspace, see Data Visualizer Module. To use the larger version of this module in the Visualize workspace, see Visualize Workspace. In an AeroScript program or library, use the functions on this page to configure and collect data for the Data Visualizer module.

Configure Data Collection

Use the AppDataCollectionAdd*Signal() functions to configure the items for which data should be collected. When you add an item to data collection, you can use the AppDataCollectionSnapshot() function to collect data. You can start and stop data collection from any task after it is configured. Use the AppDataCollectionReset() function to remove all the configured items from data collection.

function AppDataCollectionReset()

Resets the application's data collection configuration.

Configure Axis Signals

Use the functions that follow to configure the axis signals to collect for data collection:

function AppDataCollectionAddAxisSignal($axis as axis, $dataSignal as AxisDataSignal)

Adds an axis status signal to the application's data collection configuration.

Arguments

$axis  The axis from which to retrieve the status signal value.

$dataSignal  The data signal to retrieve.

function AppDataCollectionAddAxisSignal($axis as axis, $dataSignal as AxisDataSignal, $additionalData as integer)

Adds an axis status signal to the application's data collection configuration.

Arguments

$axis  The axis from which to retrieve the status signal value.

$dataSignal  The data signal to retrieve.

$additionalData  Additional data for the specified status signal. This argument is required by some status signals.

Configure Task Signals

Use the functions that follow to configure the task signals to collect for data collection:

function AppDataCollectionAddTaskSignal($taskIndex as integer, $dataSignal as TaskDataSignal)

Adds a task status signal to the application's data collection configuration.

Arguments

$taskIndex  The task from which to retrieve the status signal value.

$dataSignal  The data signal to retrieve.

function AppDataCollectionAddTaskSignal($taskIndex as integer, $dataSignal as TaskDataSignal, $additionalData as integer)

Adds a task status signal to the application's data collection configuration.

Arguments

$taskIndex  The task from which to retrieve the status signal value.

$dataSignal  The data signal to retrieve.

$additionalData  Additional data for the specified status signal. This argument is required by some status signals.

Configure System Signals

Use the functions that follow to configure the system signals to collect for data collection:

function AppDataCollectionAddSystemSignal($dataSignal as SystemDataSignal)

Adds a system status signal to the application's data collection configuration.

Arguments

$dataSignal  The data signal to retrieve.

function AppDataCollectionAddSystemSignal($dataSignal as SystemDataSignal, $additionalData as integer)

Adds a system status signal to the application's data collection configuration.

Arguments

$dataSignal  The data signal to retrieve.

$additionalData  Additional data for the specified status signal. This argument is required by some status signals.

Configure Industrial Ethernet Signals

Use the function that follows to configure the Industrial Ethernet signals to collect for data collection. Refer to EtherCAT Overview for more information about Industrial Ethernet.

function AppDataCollectionAddIndustrialEthernetMappingSignal($variableName as string)

Adds an Industrial Ethernet mapping signal to the application's data collection configuration.

Arguments

$variableName  The variable name of the Industrial Ethernet mapping to retrieve.

How to Use Industrial Ethernet Data Collection Functions

The examples that follow show you how to retrieve some Industrial Ethernet signals.

Program Example: Collect a Scalar Industrial Ethernet Mapping

// Configure Data Collection to collect a scalar mapping (with a Count of 1) named "inputBit".
var $value
$value = AppDataCollectionAddIndustrialEthernetMappingSignal("inputBit")

Program Example: Collect an Element of an Industrial Ethernet Array Mapping

// Configure Data Collection to collect an element of an array mapping (with a Count that is more than 1) that
// is named "outputBits".
var $value
$value = AppDataCollectionAddIndustrialEthernetMappingSignal("outputBits[2]")

Configure the Number of Samples and Sample Time for Data Collection

Use the function that follows to configure the number of samples and the sample time for data collection.

function AppDataCollectionConfigure($numSamples as integer, $sampleTime as real)

Configures application data collection.

Arguments

$numSamples  Specifies the number of data samples to collect.

$sampleTime  Specifies the sample time in milliseconds.

The $numSamples argument specifies the number of samples collected by data collection. The $sampleTime argument specifies the number of milliseconds between each sample that is collected. You can convert a sample frequency to a sample time with the formula that follows.

For example, to collect data with a sample rate of 20 kHz, specify a value of (1.0 / 20.0) or 0.05 for the $sampleTime argument. For more information about sample rates that the controller supports, refer to Data Collection Rates.

You can determine the duration of data collection with the formula that follows.

Use the DataCollectionItems Parameter and the DataCollectionPoints Parameter to configure the amount of controller memory that is available for data collection. To determine how much memory is available for data collection, use the formula that follows.

Memory allocation is necessary for collecting data. If the memory allocation does not complete correctly, a memory allocation error occurs. If memory resources are low, you can decrease the value of the DataCollectionItems parameter and the DataCollectionPoints parameter to release memory for other Automation1 features.

How to Configure the Data Collection Rate and Number of Samples

The examples that follow show you how to configure the number of samples and the sample time used for data collection.

Program Example: Collect 10 Seconds of Data at 1 kHz

// Configure Data Collection to collect data for 10 seconds at a rate of 1 kHz (1 / 1 = 1 msec per sample).
AppDataCollectionConfigure(10 * 1000 * 1, 1)

Program Example: Collect 10 seconds of data at 20 kHz

// Configure Data Collection to collect data for 10 seconds at a rate of 20 kHz (1 / 20 = 0.05 msec per sample).
AppDataCollectionConfigure(10 * 20.0 * 1000, 1.0 / 20.0)		

Start and Stop Data Collection with AppDataCollection Functions

After you have configured data collection, use the functions that follow to start data collection. You can only collect snapshots of data with these functions. You cannot collect continuous data.

function AppDataCollectionSnapshot()

Triggers data collection.

function AppDataCollectionSnapshot($id as integer)

Triggers data collection in the specified application.

Arguments

$id  The ID that corresponds to the application in which to trigger data collection.

When you issue the AppDataCollectionSnapshot() function, the controller continues to collect data for the specified number of samples. You can use the AppDataCollectionStop() function to stop data collection before the controller has collected the specified number of samples.

function AppDataCollectionStop()

Stops data collection.

Configure Auto-Save for Snapshots

Use the AppDataCollectionAutoSaveOn() function to automatically save snapshots collected with AppDataCollectionSnapshot(). You must specify the path and the type of the file to save. Relative paths are supported and are relative to the Automation1 folder in your Documents folder. To save to an absolute path outside of the MDK folder, toggle the Allow Automatic Saving to Absolute Paths setting to On in the Data Visualizer module settings in Automation1 Studio. Network and controller paths are not supported. Supported file types include Automation1 Plot, CSV, and JSON.

If auto-save is enabled, each snapshot overwrites the file you specify. The file overwrite does not occur if you issue the AppDataCollectionAutoSaveOn() function with a different file name before each snapshot or if automatic timestamps are enabled. To enable automatic timestamps, toggle the Timestamp Saved AppDataCollection Snapshots setting to On. To find this, click the Settings button on the top-right corner of Studio. When the Settings dialog comes into view, select the Data Visualizer tab.

Use the functions that follow to configure auto-saving.

function AppDataCollectionAutoSaveOn($mdkFilePath as string, $fileType as DataCollectionFileType)

Enables automatic saving of data collected through AppDataCollectionSnapshot(). To generate a unique file name for each snapshot, enable automatic timestamps in the application's settings.

Arguments

$mdkFilePath  The path that specifies where the data collection data will be saved. If the application settings do not allow saving to absolute paths, the file path will be relative to the MDK documents folder.

$fileType  The format of the data collection file that will be saved.

function AppDataCollectionAutoSaveOff()

Disables automatic saving of data collected through the application.

App Data Collection Example

The example that follows shows how to perform data collection with the AppDataCollection*() functions.

#define DATA_RATE      1.0 // kHz
#define DATA_DURATION  5.0 // seconds

AppDataCollectionReset()

AppDataCollectionAddAxisSignal(X, AxisDataSignal.PositionCommand)
AppDataCollectionAddAxisSignal(X, AxisDataSignal.VelocityCommand)
AppDataCollectionAddAxisSignal(X, AxisDataSignal.AccelerationCommand)

AppDataCollectionConfigure(DATA_DURATION * DATA_RATE * 1000.0, 1.0 / DATA_RATE)

AppDataCollectionSnapshot()