Get Controller Status

Use Status to get information about what the controller is doing at the current moment in time. Status provides useful information about the current state of the controller. The pieces of information that you collect are known as status items. Status can have variable latency when you retrieve it.

You can get Status by using the concepts that follow.

Many of the status items are dependent on the current units of the controller. Refer to the SetupTaskTimeUnits() function, SetupTaskDistanceUnits() function, and the UnitsName Parameter for more information.

You can get status items from these parts of the controller:

  • Axis - gets information about the behavior of axes and motors

  • Task - gets information about the behavior of tasks and program execution

  • System - gets information about global behaviors of the controller

Controller Status Functions

Each status item function has an overload that has an additional data argument. For some data items, this argument is used for context.

While the motion engine of the controller runs at a rate of 1 kHz, 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.

Get Axis Status

Use the functions that follow to get axis status items.

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.

Use the StatusGetAxisItemFast() function to get status at a rate that is faster than 1 kHz. Some status items are not available at a faster rate. You can only get the status items that follow at a faster rate.

  • Acceleration Command Raw
  • Backlash
  • Galvo Laser Output Raw
  • Jerk Command Raw
  • Position Calibration 2D
  • Position Calibration All
  • Position Command Raw
  • Velocity Command Raw

Use Axis Status Functions

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

Program Example: Determine if an Axis is Enabled

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

Program Example: Determine if an Axis is Homed

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

Program Example: Determine if Motion Commanded on an Axis is Complete

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

Program Example: Read the Position Command of an Axis

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

Program Example: Read the Position Feedback of an Axis

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

Program 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)

Get Task Status

Use the functions that follow to get task status items.

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.

Use the StatusGetTaskItemFast() function to get status at a rate that is faster than 1 kHz. Some status items are not available at a faster rate. You can only get the status items that follow at a faster rate.

  • Coordinated Acceleration Command
  • Coordinated Percent Done
  • Coordinated Position Command
  • Coordinated Speed Command
  • Coordinated Total Distance
  • Ifov Speed Scale

Use Task Status Functions

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

Program Example: Read the Task State of an AeroScript Task

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

Program Example: Read the Program Line Number of an AeroScript Program

var $programLineNumber as real
$programLineNumber = StatusGetTaskItem(TaskGetIndex(), TaskStatusItem.ProgramLineNumber)

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

// Retrieve the Coordinated Position Command at 20 kHz on Task 2 on the axis whose index is 1.
var $speeds[20] as real
StatusGetTaskItemFast(2, TaskStatusItem.CoordinatedPositionCommand, 1, 20, $speeds)

Get System Status

IMPORTANT: There are not "fast" signals to collect for system status.

Use the functions that follow to get system status items.

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.

Use System Status Functions

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

Program 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)

Other Ways to Get Controller Status

You can use the different modules that follow in Automation1 Studio and Automation1 MachineApps to get controller status:

  • Axis Dashboard
  • Buttons & Indicators
  • Message Log Viewer
  • Program Variables
  • Task Status
  • Variables & I/O

You can get status by using the Automation1 Status UtilityAutomation1 Console, and all Automation1 APIs.

You can write an AeroScript program that collects information from the controller and then sends the information over a socket. Refer to the example that follows.

Program Example: Collect Status and Send the Information over a Socket

var $server as handle
var $client as handle

$server = SocketTcpServerCreate(8080)
$client = SocketTcpServerAccept($server)

while true
     var $command as string
     var $response as string

     $command = SocketReadString($client, "\n")
     if StringEquals($command, "position")
          $response = RealToString(StatusGetAxisItem(X, AxisStatusItem.PositionCommand))
     elseif StringEquals($command, "velocity")
          $response = RealToString(StatusGetAxisItem(X, AxisStatusItem.VelocityCommand))
     elseif StringEquals($command, "acceleration")
          $response = RealToString(StatusGetAxisItem(X, AxisStatusItem.AccelerationCommand))
     else
          $response = "Unknown command."
     end

     SocketWriteString($client, $response)
end