Collecting Data

Use Data Collection to collect a set of time-series data in a real-time, deterministic way. You can look at plots of data that were collected from the controller in the Data Visualizer module.

Data collection occurs in real time, and the intervals between samples in one data collection instance are deterministic. The time between when data collection starts and when the first data point occurs, and the time between when the last data point is collected and when data collection stops is not completely deterministic. This is because start and stop operations occur from a non-real-time thread and have a variability of 10 milliseconds or more. You can collect only one set of data at a time on an Automation1 controller.

You can collect data by using the concepts that follow:

The pieces of information that you collect are called data signals. Data signals can be in the axis, task, or system category. All data signals are double-precision floating-point numbers. Some data signals represent enumerations or masks. Data signals include axis positions, axis-homed states, axis faults, I/O values, task states, task errors, and more.

The signals are collected from the drive at a slower rate than signals collected from the SMC because of the communication delay time with the drive. You can use the DriveMotionDelay axis status item to determine the delay time between the SMC signals and drive signals. Because virtual drives are emulated by the SMC without physical hardware, they have no communication delay.

Use the Data Visualizer Module to Collect Data

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. Refer to the pages that follow for more information:

  • 1D Data Collection - includes procedures for how to configure and collect 1D (one-dimensional) data signals in the Data Visualizer module.
  • 2D Data Collection - includes procedures for how to configure and collect 2D (two-dimensional) data signals in the Data Visualizer module.
  • 3D Data Collection - includes procedures for how to configure and collect 3D (three-dimensional) data signals in the Data Visualizer module.

Data Collection Functions

Use the DataCollection*() functions to collect and write sampled data from an AeroScript program or library without using the Data Visualizer module. The plots that result are .dat files. The .dat file is a text file that uses ASCII characters to show the data that you collected. Position values are given in counts, and time values are given as seconds. The .dat file format is compatible with the Data Visualizer module. You can collect many types of data and specify the sample time at which the commands collect data.

Configure Data Collection

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

function DataCollectionReset()

Resets the data collection configuration.

Configure Axis Signals

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

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

Adds an axis status signal to the data collection configuration.

Arguments

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

$dataSignal  The data signal to retrieve.

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

Adds an axis status signal to the 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 DataCollectionAddTaskSignal($taskIndex as integer, $dataSignal as TaskDataSignal)

Adds a task status signal to the data collection configuration.

Arguments

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

$dataSignal  The data signal to retrieve.

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

Adds a task status signal to the 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 DataCollectionAddSystemSignal($dataSignal as SystemDataSignal)

Adds a system status signal to the data collection configuration.

Arguments

$dataSignal  The data signal to retrieve.

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

Adds a system status signal to the 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.

Start and Stop Data Collection

After you have configured data collection, use the function that follows to start data collection. Use the $controllerFileName argument to specify the name and location for the .dat file.

function DataCollectionStart($controllerFileName as string, $numSamples as integer, $sampleTime as real)

Starts real-time data collection.

Arguments

$controllerFileName  The path, file name, and extension of the file on the controller file system to write data samples.

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

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

function DataCollectionStop()

Stops real-time data collection.

Data Collection Example

The example that follows shows you how to collect data with the DataCollection*() functions.

Program Example: Using Data Collection Functions

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

DataCollectionReset()

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

DataCollectionStart("results.dat", DATA_DURATION * DATA_RATE * 1000.0, 1.0 / DATA_RATE)

Other Ways to Collect Data

Signal Log is a monitoring and diagnostic tool that is included in the Motion Health® module. When enabled, Signal Log continuously collects diagnostic data and monitors the data for Signal Log trigger events. When a Signal Log trigger event occurs, Signal Log automatically saves the diagnostic data to a .dat file. You can open the .dat file in the Data Visualizer module.

You can perform data collection with all of the Automation1 APIs.

You can write an AeroScript program or library that collects information from the controller and then saves the information to a file. You can create a deterministic sample interval of 1 millisecond or multiples of 1 millisecond by issuing the CriticalSectionStart(), CriticalSectionEnd(), and Dwell() functions in a critical section of your program. Refer to the example that follows.

Program Example: Collect Status in a Critical Section and Save Results to a File

var $file as handle
var $values[1000] as real
var $index as integer

CriticalSectionStart()
for $index = 0 to (length($values) - 1)
        $values[$index] = StatusGetAxisItem(@0, AxisStatusItem.PositionCommand)
        Dwell(0.001)
end

$file = FileOpenText("results.dat", FileMode.Overwrite)

for $index = 0 to (length($values) - 1)
        FileTextWriteString($file, RealToString($values[$index]) + "\n")
end

FileClose($file)
CriticalSectionEnd()		

Data Collection Rates

When you configure data collection, you specify a sample time in milliseconds. If you specify a data collection rate of 1 kHz (1 msec) or faster, you must specify one of the values that follow for the sample time:

  • 1 msec (1 kHz)

  • 0.1 msec (10 kHz)

  • 0.05 msec (20 kHz)

  • 0.01 msec (100 kHz) This collection rate is available only on the PC-based controller.

  • 0.005 msec (200 kHz) This collection rate is available only on the PC-based controller.

Automatically Collected Signals During Data Collection

When collecting data, Studio automatically adds a set of signals to the data collection configuration for axes that have at least one configured signal. These signals are:

  • Position Command

  • Position Feedback

  • Position Error

  • Velocity Command

  • Velocity Feedback

  • Velocity Error

  • Acceleration Command

  • Acceleration Error

  • Acceleration Feedback

  • Current Command

  • Current Feedback

  • Current Error

  • Axis Status

  • Drive Status

These signals are only automatically included at data collection rates of 1 kHz or slower. By default, the signals are not visible on the resulting plot. You can display the signals on the plot using the Edit Plot dialog and clicking the Visibility icon next to the signal.

Data Collection Limitations

  • The rate of Data Collection is limited to the servo loop update rate of the drive associated with that axis. Refer to the hardware manual for your drive to find the servo loop update rate.

  • If you collect data on a virtual axis, make sure that the data collection rate is 1 kHz or slower. Virtual axes do not support collecting some signals at rates greater than 1 kHz.

  • If the controller finds an error during data collection, some data signals might report NaN (not a number).

  • Make sure that real-time errors do not occur on the controller during data collection. Real-time errors can also cause signals to report as NaN. You can review real-time errors by retrieving the Communication Real Time Errors system status item or in the Controller tab of the Status Utility.

Data Collection Status

To get information about data collection, use the status items that follow:

  • Data Collection Sample Time
  • Data Collection Sample Index
  • Data Collection Status
  • Scopetrig Id

Use the Automation1 Status Utility to see Data Collection status on the Data Collection tab.