总线寄存器
不同版本的控制器、插件和上位机支持不同的 lua API 指令,开发者可在 DobotStudio Pro “应用” 菜单,“脚本编程” 的指令侧边栏查看具体支持的 lua API
指令列表 总线寄存器指令用于读写 Profinet 或 Ethernet/IP 总线寄存器。
说明: Magician E6 不支持这组指令。
| 指令 | 功能 |
|---|---|
| GetInputBool | 获取输⼊寄存器指定地址的 bool 值 |
| GetInputInt | 获取输⼊寄存器指定地址的 int 值 |
| GetInputFloat | 获取输⼊寄存器指定地址的 float 值 |
| GetOutputBool | 获取输出寄存器指定地址的 bool 值 |
| GetOutputInt | 获取输出寄存器指定地址的 int 值 |
| GetOutputFloat | 获取输 出寄存器指定地址的 float 值 |
| SetOutputBool | 设置输出寄存器指定地址的 bool 值 |
| SetOutputInt | 设置输出寄存器指定地址的 int 值 |
| SetOutputFloat | 设置输出寄存器指定地址的 float 值 |
GetInputBool
原型:
GetInputBool(address)
描述:
获取输⼊寄存器指定地址的 bool 类型的数值。
必选参数:
address:寄存器地址,取值范围[0-63]
返回:
指定的寄存器地址的值,为 0 或 1
示例:
-- 当输入寄存器0的值为1时,执行后续操作。
if(GetInputBool(0)==1)
then
-- 执行后续操作
end
GetInputInt
原型:
GetInputInt(address)
描述:
获取输⼊寄存器指定地址的 int 类型的数值。
必选参数:
address:寄存器地址,取值范围[0-23]
返回:
指定的寄存器地址的值,为整型数(int32)
示例:
-- 读取输入寄存器1的值并赋值给变量regInt。
local regInt = GetInputInt(1)
GetInputFloat
原型:
GetInputFloat(address)
描述:
获取输⼊寄存器指定地址的 float 类型的数值。
必选参数:
address:寄存器地址,取值范围[0-23]
返回:
指定的寄存器地址的值,为单精度浮点数(float)
示例:
-- 读取输入寄存器2的值并赋值给变量regFloat。
local regFloat = GetInputFloat(2)
GetOutputBool
原型:
GetOutputBool(address)
描述:
获取输出寄存器指定地址的 bool 类型的数值。
必选参数:
address:寄存器地址,取值范围[0-63]
返回:
指定的寄存器地址的值,为 0 或 1
示例:
-- 当输出寄存器0的值为1时,执行后续操作。
if(GetOutputBool(0)==1)
then
-- 执行后续操作
end