Controller Status Functions

The Automation1 controller allows for the retrieval of various status items at runtime. These items provide useful information about the current state of the controller. Many of the status items are dependent on the current units of the controller. Refer to UnitsName Parameter for more information.

Status items can be retrieved from these areas of the controller:

  • Axis - configures the behavior of axes and motors
  • Task - configures the behavior of tasks and program execution
  • System - configures global behaviors of the controller

Each status item function has an overload that contains an additional data argument. For some data items, this argument is used to provide context. See the data items in the tables that follow for more information.

While the motion engine of the controller runs at a rate of 1KHz, it is possible to collect data at an increased rate by using the Fast functions. These functions return an array of values that are proportional to the supplied sample rate. To see the supported motion rates, refer to Motion Functions.

Axis

function StatusGetAxisItem($axis as axis, $statusItem as AxisStatusItem) as real

Gets the specified status item value from the specified axis.

Arguments

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

$statusItem  The status item to retrieve.

Returns

The value of the specified axis status item.

function StatusGetAxisItem($axis as axis, $statusItem as AxisStatusItem, $additionalData as integer) as real

Gets the specified status item value from the specified axis.

Arguments

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

$statusItem  The status item to retrieve.

$additionalData  Additional data for the specified status item. This argument is required by some status items.

Returns

The value of the specified axis status item.

function StatusGetAxisItemFast($axis as axis, $statusItem as AxisStatusItem, $additionalData as integer, $sampleRate as integer, ref $values[] as real)

Gets the specified status item value from the specified axis at a rate that is faster than 1 kHz.

Arguments

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

$statusItem  The status item to retrieve.

$additionalData  Additional data for the specified status item. This argument is required by some status items. If additional data is not required, specify a value of 0 for this argument.

$sampleRate  The number of samples to collect. This must be 1, 10, 20, 50, or 100.

ref $values  An array variable in which to retrieve the data. The length of the variable must be sufficient to store the number of samples that are specified by the $sampleRate argument.

How to Use Axis Status Functions

Example: Determine if an axis is enabled

// Determine if the Enabled bit of the DriveStatus item is set on axis X.
var $isEnabled
$isEnabled = (StatusGetAxisItem(X, AxisStatusItem.DriveStatus, DriveStatus.Enabled) == DriveStatus.Enabled)

Example: Determine if an axis is homed

// Determine if the Homed bit of the AxisStatus item is set on axis X.
var $isHomed
$isHomed = (StatusGetAxisItem(X, AxisStatusItem.AxisStatus, AxisStatus.Homed) == AxisStatus.Homed)

Example: Determine if motion is done being commanded on an axis

// Determine if the MotionDone bit of the AxisStatus item is set on axis X.
var $isMotionDone
$isMotionDone = (StatusGetAxisItem(X, AxisStatusItem.AxisStatus, AxisStatus.MotionDone) == AxisStatus.MotionDone)

Read the Position Command of an axis

// Retrieve the Position Command on axis X.
var $positionCommand
$positionCommand = StatusGetAxisItem(X, AxisStatusItem.PositionCommand)

Example: Read the Position Feedback of an axis

// Retrieve the Position Feedback on axis X.
var $positionFeedback
$positionFeedback = StatusGetAxisItem(X, AxisStatusItem.PositionFeedback)

Example: Read the Program Position of an axis

// Retrieve the Program Position on axis X.
var $programPosition
$programPosition = StatusGetAxisItem(X, AxisStatusItem.ProgramPosition)

Task

function StatusGetTaskItem($taskIndex as integer, $statusItem as TaskStatusItem) as real

Gets the specified status item value from the specified task.

Arguments

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

$statusItem  The status item to retrieve.

Returns

The value of the specified task status item.

function StatusGetTaskItem($taskIndex as integer, $statusItem as TaskStatusItem, $additionalData as integer) as real

Gets the specified status item value from the specified task.

Arguments

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

$statusItem  The status item to retrieve.

$additionalData  Additional data for the specified status item. This argument is required by some status items.

Returns

The value of the specified task status item.

function StatusGetTaskItemFast($taskIndex as integer, $statusItem as TaskStatusItem, $additionalData as integer, $sampleRate as integer, ref $values[] as real)

Gets the specified status item value from the specified task at a rate that is faster than 1 kHz.

Arguments

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

$statusItem  The status item to retrieve.

$additionalData  Additional data for the specified status item. This argument is required by some status items. If additional data is not required, specify a value of 0 for this argument.

$sampleRate  The number of samples to collect. This must be 1, 10, 20, 50, or 100.

ref $values  An array variable in which to retrieve the data. The length of the variable must be sufficient to store the number of samples that are specified by the $sampleRate argument.

How to Use Task Status Functions

The examples that follow show you how to retrieve some task status items.

Example: Read the Task State of an AeroScript task

// Read the Task State of Task 2. See the TaskState enum for more information.
var $programLineNumber
$programLineNumber = StatusGetTaskItem(2, TaskStatusItem.TaskState)

Example: Read the Program Line Number of an AeroScript program

// Read the Program Line Number of the currently running task.
var $programLineNumber
$programLineNumber = StatusGetTaskItem(TaskGetIndex(), TaskStatusItem.ProgramLineNumber)

System

function StatusGetSystemItem($statusItem as SystemStatusItem) as real

Gets the specified system status item value.

Arguments

$statusItem  The status item to retrieve.

Returns

The value of the specified system status item.

function StatusGetSystemItem($statusItem as SystemStatusItem, $additionalData as integer) as real

Gets the specified system status item value.

Arguments

$statusItem  The status item to retrieve.

$additionalData  Additional data for the specified status item. This argument is required by some status items.

Returns

The value of the specified system status item.

How to Use System Status Functions

The example that follows shows you how to retrieve a system status item.

Example: Get the value of a Timer

// Read the value of Timer 0 using a system status item instead of TimerRead().
var $timer as real
$timer = StatusGetSystemItem(SystemStatusItem.Timer, 0)