Skip to content

5. IO

API List

IO

The IO of the xArm series robots is divided into two parts: controller box IO and robot arm IO.

API FunctionDescription
set_cgpio_digital()Set controller box digital IO output
get_cgpio_digital()Get controller box digital IO input
set_cgpio_analog()Set controller box analog IO output
get_cgpio_analog()Get controller box analog IO input
set_cgpio_digital_input_function()Set the function of the controller's digital input
set_cgpio_digital_output_function()Set the function of the controller's digital output
set_tgpio_digital()Set the end-effector digital IO output
get_tgpio_output_digital()Get the end-effector digital IO output
get_tgpio_digital()Get the end-effector digital IO input
get_tgpio_analog()Get the end-effector analog input

Controller Box IO

The controller box IO is located on the controller and is usually used for signal interaction with external devices such as PLCs and sensors.

Set Controller Box Digital Output

Use set_cgpio_digital(io_num, value) to set the output level of a controller box digital IO port.

  • io_num: IO port number, range 0-15 (0-7 for Lite 6).
  • value: IO level, 0 for low, 1 for high.

Example: Set controller IO 7 high.

python
arm.set_cgpio_digital(7, 1)

Get Controller Box Digital Input

Use get_cgpio_digital() to obtain the input levels of all controller box digital IO ports. The return value is a tuple containing the error code and IO values.

Example: Get and print the status of all controller box digital inputs.

python
code, digitals = arm.get_cgpio_digital()
if code == 0:
    print("Controller box digital input status:", digitals)

Set Controller Box Analog Output

Use set_cgpio_analog(io_num, value) to set the value of a controller box analog IO.

  • io_num: Analog IO port number, typically 0 or 1.
  • value: Analog value to set, range 0-10.0 (volts).

Example: Set controller analog output AO 0 to 5.0V.

python
arm.set_cgpio_analog(0, 5.0)

Get Controller Box Analog Input

Use get_cgpio_analog() to get the value of a controller box analog IO.

  • io_num: Analog IO port number, 0 or 1.

Example: Get the value of controller analog input CI0.

python
code, analog_val = arm.get_cgpio_analog(0)
if code == 0:
    print("Controller box analog input 0 value:", analog_val)

Robot Arm IO

The robot arm IO (tool IO) functions and APIs are similar to the controller box IO:

IO TypeAPI FunctionDescription
Digital Output (DO)set_tgpio_digital()Set tool digital output level
Digital Input (DI)get_tgpio_digital()Get tool digital input level
Analog Input (AI)get_tgpio_analog()Get tool analog input value

Set Controller Box Digital Input Function

Use set_cgpio_digital_input_function(ionum, fun) to configure the function of a controller box digital input port.

  • ionum: IO port number, range 0-15.
  • fun: Function mode:
    • 0: General Input
    • 1: Stop Motion
    • 2: Protection Reset
    • 11: Offline Task
    • 12: Manual Mode
    • 13: Reduced Mode
    • 14: Enable Robot

Example: Configure digital input CI0 to stop motion. When CI0 receives a signal, the robot stops immediately and clears buffered commands, equivalent to set_state(4) without cutting power.

python
# Configure CI0 (ionum=0) as external emergency stop (fun=1)
arm.set_cgpio_digital_input_function(0, 1)

# Restore CI0 to general input
arm.set_cgpio_digital_input_function(0, 0)

Set Controller Box Digital Output Function

Use set_cgpio_digital_output_function(ionum, fun) to configure the function of a controller box digital output port.

  • ionum: IO port number, 0-7 for CO0~CO7 and 8-15 for DO0~DO7.
  • fun: Function mode:
    • 0: General Output
    • 1: Motion Stop
    • 2: Moving
    • 11: Has Error
    • 12: Has Warn
    • 13: Collision
    • 14: In Manual Mode
    • 15: In Offline Task
    • 16: In Reduced Mode
    • 17: Robot Is Enabled
    • 18: Emergency Stop is Pressed

Example: Configure digital output CO0 to indicate a robot error. When the robot reports an error, CO0 outputs high level.

python
# Configure CO0 (ionum=0) to indicate error state (fun=11)
arm.set_cgpio_digital_output_function(0, 11)

# Restore CO0 to general output
arm.set_cgpio_digital_output_function(0, 0)