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() and SetupTaskDistanceUnits() functions on Motion Setup Functions page and the 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

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.

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.

Get Axis Status

Use the StatusGetAxisItem() and StatusGetAxisItemFast() functions to get axis status items.

The StatusGetAxisItemFast() function get status information at a rate that is faster than 1 kHz. You can only get the status items that follow at a faster rate:

  • Acceleration Command Raw
  • Backlash
  • 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 StatusGetTaskItem() and StatusGetTaskItemFast() functions to get task status items.

The StatusGetTaskItemFast() function gets status information at a rate that is faster than 1 kHz. 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

Use the StatusGetSystemItem() function to get system status items. Note that there are not "fast" signals to collect for system status.

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 of the 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