I/O Control

IO Device Types

  • "ROBOT": Control box, with 4DI/4DO/2AI/2AO, interface mapping see User Manual.
  • "FLANGE": Flange, with 2DI/2DO, interface mapping see User Manual.
  • "EXTRA": Expansion board, with 12DI/12DO/2AI/2AO, interface mapping see User Manual.
  • "SHOULDER": Shoulder light board, with 1DI, used as button
  • "FLANGE_BTN": Flange button, with 2DI, used as button

Set Digital IO Mode

Set the direction (input or output) of the specified digital IO pin.

  • Function name: Method set_dio_mode under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Port, starting from 0
    3. mode: [DigitalMode] Pin direction, INPUT input / OUTPUT output
  • Return: None
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "set_dio_mode", "params": [{"device": "ROBOT", "pin": 0, "mode": "OUTPUT"}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {}, "id": 1 }

Example Program

lebai:set_dio_mode("ROBOT", 0, "OUTPUT")

Get Digital IO Mode

Get the direction (input or output) of the specified digital IO pin.

  • Function name: Method get_dio_mode under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Port, starting from 0
  • Return: [DigitalMode] Pin direction, INPUT input / OUTPUT output
JSON-RPC
// Request:
{ "jsonrpc": "2.0", "method": "get_dio_mode", "params": [{"device": "ROBOT", "pin": 0}], "id": 1 }
// Response:
{ "jsonrpc": "2.0", "result": {"mode": "OUTPUT"}, "id": 1 }

Example Program

mode = lebai:get_dio_mode("ROBOT", 0)
print(mode)

Set Digital Output

Set the corresponding DO port on and off. Commonly used for controlling solenoid valves.

  • Function name: Method set_do under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Port, starting from 0
    3. value: [int] Value to set, 0 off / 1 on
  • Return: None

Example Program

lebai:set_do("ROBOT", 0, 1)
lebai:set_do("FLANGE", 0, 1)

Get Digital Output

Get whether the corresponding DO port is on or off.

  • Function name: Method get_do under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Port, starting from 0
  • Return: [int] Returns 0 off, 1 on

Example Program

value = lebai:get_do("ROBOT", 0)
print(value)

Get Multiple Digital Outputs

Get whether the corresponding continuous multiple DO ports are on or off.

  • Function name: Method get_dos under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Starting port number
    3. num: [int] Continuous count
  • Return: [list[int]] Continuous multiple DO output states

Example Program

values = lebai:get_dos("ROBOT", 0, 3)
print(values)

Get Digital Input

Get whether the corresponding DI port has an electrical signal input. Commonly used for photoelectric sensor detection.

  • Function name: Method get_di under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Port, starting from 0
  • Return: [int] Returns 0 no signal, 1 has signal

Example Program

value = lebai:get_di("ROBOT", 0)
print(value)

Get Multiple Digital Inputs

Get whether the corresponding continuous multiple DI ports have electrical signal input. Commonly used for photoelectric sensor detection.

  • Function name: Method get_dis under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Starting port number
    3. num: [int] Continuous count
  • Return: [list[int]] Continuous multiple DI input states

Example Program

values = lebai:get_dis("ROBOT", 0, 3)
print(values)

Set Analog Output

Set the corresponding AO port to output the specified voltage or current.

  • Function name: Method set_ao under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Port, starting from 0
    3. value: [float] Value to set. Voltage type 0-10V, current type 4-20mA
  • Return: None

Note: The control interface has a selection for whether the port outputs voltage or current.

Example Program

lebai:set_ao("ROBOT", 0, 5)

Get Analog Output

Get the voltage or current value output by the corresponding AO port.

  • Function name: Method get_ao under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Port, starting from 0
  • Return: [float] AO port output value

Example Program

value = lebai:get_ao("ROBOT", 0)
print(value)

Get Multiple Analog Outputs

Get the voltage or current values output by the corresponding continuous multiple AO ports.

  • Function name: Method get_aos under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Starting port number
    3. num: [int] Continuous count
  • Return: [list[float]] Continuous multiple AO port output values

Example Program

values = lebai:get_aos("ROBOT", 0, 2)
print(values)

Get Analog Input

Get the voltage or current value input to the corresponding AI port.

  • Function name: Method get_ai under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Port, starting from 0
  • Return: [float] Input value of the corresponding AI port

Example Program

value = lebai:get_ai("ROBOT", 0)
print(value)

Get Multiple Analog Inputs

Get the voltage or current values input to the corresponding continuous multiple AI ports.

  • Function name: Method get_ais under [Robot]
  • Parameters:
    1. device: [IoDevice] Device type
    2. pin: [int] Starting port number
    3. num: [int] Continuous count
  • Return: [list[float]] Continuous multiple AI port input values

Example Program

values = lebai:get_ais("ROBOT", 0, 2)
print(values)