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:
| Relation | Syntax | Description |
|---|---|---|
| Equal | eq == = | Analog values have precision errors |
| Not equal | neq ne != <> ~= | Analog values have precision errors |
| Less than | lt < | |
| Less than or equal | lte <= | |
| Greater than | gt > | |
| Greater than or equal | gte >= |
Set Digital Output auto_sync
Sets digital output (control box).
- Function:
set_dofrom the lua module - Parameters:
- pin: [int] Port, starting from 0
- 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_difrom the lua module - Parameters:
- 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_difrom the lua module - Parameters:
- pin: [int] Port, starting from 0
- value: [int] Value to compare
- 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_aofrom the lua module - Parameters:
- pin: [int] Port, starting from 0
- 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_aifrom the lua module - Parameters:
- 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_aifrom the lua module - Parameters:
- pin: [int] Port, starting from 0
- value: [float] Value to compare
- 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, "<=")
