Controller Status Functions

The Automation1 controller lets you get status items at runtime. These items supply information about the current state of the controller. Many of the status items depend on the current units of the controller. Refer to UnitsName Parameter for more information.

You can get status items from these parts 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.

The motion engine of the controller runs at a rate of 1 kHz, but you can collect data faster by using the fast functions: StatusGetAxisItemFast() and StatusGetTaskItemFast(). 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 Status Functions

Axis status functions get a specified status items from the specified axis. Use the enum AxisStatusItem to specify the axis status item.

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)

Example: 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)

Example: Read the Position Command Raw of an Axis at 20 kHz

// Retrieve the Position Command Raw at 20 kHz on axis X.
var $positions[20] as real
StatusGetAxisItemFast(X, AxisStatusItem.PositionCommandRaw, 0, 20, $positions)

Task Status Functions

Task status functions get a specified status items from the specified task. Use the enum TaskStatusItem to specify the task status item.

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 Status Functions

System status functions get a specified system status item. Use the enum SystemStatusItem to specify the system status item.

How to Use System Status Functions

The example that follows shows you how to get 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)