Control Box I/O

The control box has 4DI/4DO/2AI/2AO, see User Manual for interface details.

Relational Operators

The relation parameter appearing in interfaces is generally used to compare the relationship between the actual obtained value and the given value. Available relations are as follows:

RelationSyntaxDescription
Equaleq == =Analog values have precision errors
Not equalneq ne != <> ~=Analog values have precision errors
Less thanlt <
Less than or equallte <=
Greater thangt >
Greater than or equalgte >=

Set Digital Output auto_sync

Sets digital output (control box).

  • Function: set_do from the lua module
  • Parameters:
    1. pin: [int] Port, starting from 0
    2. value: [int] Value to set, 0 off / 1 on
  • Returns: [bool] Whether set successfully

Compatibility Note

In version 2.2 and earlier, the command was:

set_dio(pin, value)

Example

set_do(1, 1)

Get Digital Input

Gets digital input (control box).

  • Function: get_di from the lua module
  • Parameters:
    1. pin: [int] Port, starting from 0
  • Returns: [int] Port current value, 0 off / 1 on

Compatibility Note

In version 2.2 and earlier, the command was:

get_dio(pin)

Example

print(get_di(0))

Wait Digital Input auto_sync

Blocks and waits until the specified port input value meets the specified condition, polling every 10ms.

  • Function: wait_di from the lua module
  • Parameters:
    1. pin: [int] Port, starting from 0
    2. value: [int] Value to compare
    3. relation: [str] Relational Operator
  • Returns: [bool] Whether condition is met

Example

-- Wait until DI1 is in high state
wait_di(1, 1, "=")

Set Analog Output auto_sync

Sets analog output (control box).

  • Function: set_ao from the lua module
  • Parameters:
    1. pin: [int] Port, starting from 0
    2. value: [float] Value to set, specify voltage or current based on output type
  • Returns: [bool] Whether set successfully

Compatibility Note

In version 2.2 and earlier, the command was:

set_aio(pin, value)

Example

-- Set AO0 output 3V
set_ao(0, 3)

Get Analog Input

Gets analog input (control box).

  • Function: get_ai from the lua module
  • Parameters:
    1. pin: [int] Port, starting from 0
  • Returns: [float] Port current value (V)

Compatibility Note

In version 2.2 and earlier, the command was:

get_aio(pin)

Example

local ai0 = get_ai(0)
print(ai0)

Possible output:

3.3

Wait Analog Input auto_sync

Blocks and waits until the specified port input value meets the specified condition.

  • Function: wait_ai from the lua module
  • Parameters:
    1. pin: [int] Port, starting from 0
    2. value: [float] Value to compare
    3. relation: [str] Relational Operator
  • Returns: [bool] Whether condition is met

Compatibility Note

In version 2.2 and earlier, the command was:

wait_aio(pin, value, relation)

Example

-- Wait until AI1 voltage is less than or equal to 4V
wait_ai(1, 4.0, "<=")