Data Collection

This AeroScript program configures data collection, starts collection to a file, executes motion, and then stops collecting data.

// Data Collection Example:
// Shows how to configure data collection to automatically collect points to a file without
// using the Automation1 Studio application.
// This program starts data collection, performs motion, and then stops collection.

program

	// Configure data collection to collect 5000 points using
	// a 1 millisecond sampling time.
	var $numSamples as integer = 5000
	var $sampleTime as integer = 1
	var $fileName as string = "testData.dat"
	var $axes[] as axis = [X, Y]

	// Reset the data collection configuration.
	DataCollectionReset()

	// Configure items to be collected during data collection.
	DataCollectionAddSystemSignal(SystemDataSignal.DataCollectionSampleTime)
	foreach var $axis in $axes
		DataCollectionAddAxisSignal($axis, AxisDataSignal.PositionCommand)
		DataCollectionAddAxisSignal($axis, AxisDataSignal.PositionFeedback)
		DataCollectionAddAxisSignal($axis, AxisDataSignal.CurrentFeedback)
		DataCollectionAddAxisSignal($axis, AxisDataSignal.AxisStatus)
	end
	DataCollectionAddTaskSignal(1, TaskDataSignal.TaskState)

	// Enable and home the axes.
	Enable($axes)
	Home($axes)

	// Trigger the data collection.
	DataCollectionStart($fileName, $numSamples, $sampleTime)

	// An example motion command.
	// Move X and Y to (10, 20) at a speed of 10 units/sec.
	MoveAbsolute($axes, [10, 20], [10, 10])

	// Wait for X and Y to be in position.
	WaitForInPosition($axes)

	// Stop the data collection.
	DataCollectionStop()
	
	// Disable the axes.
	Disable($axes)

end