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. Before you use these functions, you can use their related AppDataCollection*IsRegistered() functions to see if they are registered with an Automation1 Studio, Automation1 MachineApps, or a custom .NET application.

Configure Axis Signals

Use the AppDataCollectionAddAxisSignal() and AppDataCollectionAddAxisSignalIsRegistered() functions to configure the axis signals to collect for data collection:

Configure Task Signals

Use the AppDataCollectionAddTaskSignal() and AppDataCollectionAddTaskSignalIsRegistered() functions to configure the task signals to collect for data collection:

Configure System Signals

Use the AppDataCollectionAddSystemSignal() and AppDataCollectionAddSystemSignalIsRegistered() functions to configure the system signals to collect for data collection:

Configure Industrial Ethernet Signals

Use the AppDataCollectionAddIndustrialEthernetMappingSignal() and AppDataCollectionAddIndustrialEthernetMappingSignalIsRegistered() functions to configure the Industrial Ethernet signals to collect for data collection. See EtherCAT Overview, Modbus TCP/IP Overview, or EtherNet/IP Overview for more information about Industrial Ethernet.

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".
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".
AppDataCollectionAddIndustrialEthernetMappingSignal("outputBits[2]")

Configure the Number of Samples and Sample Time for Data Collection

Use the AppDataCollectionConfigure() function to configure the number of samples and the sample time for data collection. Before you use this function, you can use the related AppDataCollection*IsRegistered() functions to see if it is registered with an Automation1 Studio, Automation1 MachineApps, or a custom .NET application.

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. 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.

Calculate 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 AppDataCollectionSnapshot() function to start data collection. You can only collect snapshots of data with these functions. You cannot collect continuous data.

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.

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, turn on the Allow Automatic Saving to Absolute Paths toggle 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, turn on the Timestamp Saved AppDataCollection Snapshots toggle. 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 AppDataCollectionAutoSave* functions to configure auto-saving. Before you use these functions, you can use their related AppDataCollection*IsRegistered() functions to see if they are registered with an Automation1 Studio, Automation1 MachineApps, or a custom .NET 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()