在这个例子中,您将了解如何启用OPC UA外接程序和RoboDK转换成一个OPC UA服务器。我们会浏览一些设置通过使用UaExpert软件和Beckhoff TwinCAT3 TF6100。
OPC UA插件允许您配置一些设置,比如服务器端口。你也可以选择激活服务器,其停用或与RoboDK自动启动。
与OPC UA启用插件,选择OPC UA-OPC-UA设置配置您的OPC UA设置。
OPC UA设置屏幕左边显示,如下图所示。
如果您将看到一条消息,如“RoboDK OPC UA服务器运行在端口4840上”这意味着OPC UA服务器RoboDK开始。
您可以测试的OPC UA与任何RoboDK站连接一个或多个机器人。
你可以使用软件测试连通性UaExpert RoboDK OPC UA服务器。
您可以下载免费版雷电竞app下载安卓的UaExpert软件统一自动化网站:https://www.unified-automation.com/雷电竞app下载安卓downloads/opc-ua-clients.html。
启动UaExpert并点击“+”按钮添加RoboDK OPC UA服务器。
扩大定制的发现和选择<双点击添加服务器。>选择添加RoboDK OPC UA服务器。
输入的URL OPC UA服务器,opc.tcp: / / 127.0.0.1:48440您在上一步中配置。
连接OPC UA与“没有一个”安全服务器。
服务器配置。
现在你可以连接到从UaExpert RoboDK OPC UA服务器。
你可以看到节点建立连接时和方法。
里面有一些节点RoboDK OPC服务器UA让你站交换一些基本的信息。
RoboDK节点是一个节点,提供的实际版本RoboDK软件。
RoboDK 64位版本v5.5.3.23031是本例中使用。
仿真速度是一个节点,显示实际的仿真速度和允许用户覆盖当前的仿真速度。
节点值是引用滑杆的仿真速度。
当前的仿真可以从这个节点读取,可以覆盖仿真速度。
站节点是一个节点,它允许用户获取当前RoboDK车站的名字。
如你所见,车站节点引用RoboDK“车站名称”。
位置参数和值是一对设置节点,允许用户获取或设置任何参数在你站。RoboDK OPC UA服务器将持续监测的实际价值“StationParameter”的值,并返回“StationParameter”,从车站节点值。
你可以通过右键点击查看站参数RoboDK站>站参数。
在恒定的参数字段,您可以看到默认的电台参数及其值。
站参数引用“参数”字段和站值是引用到“价值”字段中。
和我们可以创建自己的参数通过单击“添加”按钮。
添加一个新的站参数。
输入参数名和参数值,然后按申请保存它。
你可以得到你自己的站参数。
节点是一个节点,允许您获取当前时间的RoboDK站。
返回一个值与DataTime格式。
这个节点是不断更新。
RoboDK OPC UA服务器还提供了一些方法,允许用户动态地访问RoboDK站的数据。
我们可以点击右键>调用执行方法的方法。
getItem是一种方法,允许用户获取项的指针。
InputArguments,设备名称是必需的,你可以图像设备名称是你站的名字,机器人的名字…等…和项ID是OutputArguments返回的指针装置。
在这个例子中,我收到我的项目ID(指针)ABB机器人,被命名为“ABB_RB1”。
返回0,如果物品的名称是无效的或不存在在你的站。
getJonits是一个方法,允许用户从车站得到机器人的共同价值,基于项ID。
项ID的指针值你的项目,你可以把它从getItem()方法。
我们将这种“ABB_RB1”项的项ID名称,并返回UInt64值。
关节返回值传递项ID在我们在前面的方法。
getJointsStr是一个方法,允许用户获取关节值基于一个字符串值。
我们可以通过机器人的名称(字符串)这种方法。
我在车站,ABB_RB1机器人是我的名字。
我们可以通过“ABB_RB1”机器人名称参数,调用该方法,则返回字符串格式的共同价值。
setJointsStr是一个方法,允许用户设置机器人的关节值,基于一个字符串值。
在机器人的名字,ABB_RB1是过去了,我们可以通过一个字符串与关节参数的共同价值。
例如:-0.000000,0.000000,-0.000000,-0.000000,-0.0,-0.000000
现在我们可以插入OPC UA客户机通过I / O设备> >添加新项。
选择虚拟OPC UA设备从OPC > OK。
OPC UA虚拟插入。
我们需要添加一个OPC UA客户机访问RoboDK OPC UA服务器。
选择设备1 >右键>添加新项。
选择“OPC UA客户机(模块)”和好的。
OPC UA端插入。
打开OPC UA客户>去Settings选项卡>单击“选择端点”配置OPC UA服务器端点,你想访问。
进入RoboDK OPC UA服务器URL和更新它。
按“添加节点”浏览节点在OPC UA服务器。
如果TwinCAT和OPC UA服务器之间建立连接,您可以浏览OPC服务器UA的细节。
选择所有方法和好的。
方法是插入您的配置。
配置你的名字前缀。
按“创建Plc代码”创建从TwinCAT Plc代码。
OpcUaClient文件夹中创建您的项目,所有RoboDK方法中创建IEC61131-3功能块的格式。
本节显示了一个示例程序的Beckhoff TwinCAT PLC与RoboDK OPC通信的代理服务器。
项目主要
VAR
bConnected: BOOL;
StationPointer:力;
iStep: INT;
bStart: BOOL;;
我:INT;
吨:吨;
bReset: BOOL;
bWrite: BOOL;
TON2:吨;
bShow: BOOL: = TRUE;
英属维尔京群岛:BOOL: = True;
END_VAR
VAR
Robot_name: STRING (80): =“ABB_RB1”;
Item_ID: ULINT;
arrJoints: ARRAY [0 . .LREAL 11);
strJoints:字符串(80):= ";
arrJointsFromStr: ARRAY [1 . .LREAL 11);
sSeparator: STRING (1): = " ";
arrJointsCommand: ARRAY [1 . .LREAL 11);
strJointsCommand:字符串(80);
END_VAR
VAR常数
cStepWaitCmd: INT: = 0;
cStepInit: INT: = 5;
cStepGetItem: INT: = 10;
cStepGetItemReset: INT: = 20;
cStepGetItemError: INT: = 990;
cStepGetJoints: INT: = 30;
cStepGetJointsReset: INT: = 40;
cStepGetJointsError: INT: = 991;
cStepGetJointsStr: INT: = 50;
cStepGetJointsStrReset: INT: = 60;
cStepGetJointsStrError: INT: = 992;
cStepSetJointStrDelay: INT: = 69;
cStepSetJointsStr: INT: = 70;
cStepSetJointsStrReset: INT: = 80;
cStepSetJointsStrError: INT: = 993;
cStepEnd: INT: = 300;
cStepWaitReset: INT: = 999;
END_VAR
VAR
aSplit: ARRAY [1 . .11)的字符串(80);
bResultSplit: BOOL;
调试:BOOL;
URL:字符串:= ' http://192.168.3.42:8091 ';
END_VAR
bConnected: = OPCUA_VirtualClient_RoboDK_Station.bConnected;
案例iStep
cStepWaitCmd:
如果bStart那么
iStep: = cStepInit;
bStart: = FALSE;
END_IF
cStepInit:
StationPointer: = 0;
我:= 1到11
arrJoints[我]:= 0.0;
arrJointsFromStr[我]:= 0.0;
aSplit[我]:= ";
END_FOR
如果不是OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy
而不是OPCUA_VirtualClient_RoboDK_Station.getItem.bError
而不是OPCUA_VirtualClient_RoboDK_Station.getJoints.bBusy
而不是OPCUA_VirtualClient_RoboDK_Station.getJoints.bError
而不是OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bBusy
而不是OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bError
而不是OPCUA_VirtualClient_RoboDK_Station.setJoints.bBusy
而不是OPCUA_VirtualClient_RoboDK_Station.setJoints.bError
而不是OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bBusy
而不是OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bError
然后
iStep: = cStepGetItem;
END_IF
iStep: = cStepGetItem;
cStepGetItem:
如果OPCUA_VirtualClient_RoboDK_Station.getItem。bDone然后
iStep: = cStepGetItemReset;
Item_ID: = OPCUA_VirtualClient_RoboDK_Station.getItem.Item_ID;
ELSIF OPCUA_VirtualClient_RoboDK_Station.getItem。bError然后
iStep: = cStepGetItemError;
END_IF
cStepGetItemReset:
如果不是OPCUA_VirtualClient_RoboDK_Station.getItem.bError
而不是OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy
然后
iStep: = cStepGetJoints;
END_IF
cStepGetJoints:
如果OPCUA_VirtualClient_RoboDK_Station.getJoints.bDone
而不是OPCUA_VirtualClient_RoboDK_Station.getJoints.bBusy
然后
iStep: = cStepGetJointsReset;
ELSIF OPCUA_VirtualClient_RoboDK_Station.getJoints。bError然后
iStep: = 991;
END_IF
cStepGetJointsReset:
如果不是OPCUA_VirtualClient_RoboDK_Station.getItem.bError
而不是OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy
然后
iStep: = cStepGetJointsStr;
END_IF;
cStepGetJointsStr:
如果OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bDone
而不是OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bBusy
然后
iStep: = cStepGetJointsStrReset;
ELSIF OPCUA_VirtualClient_RoboDK_Station.getJointsStr。bError然后
iStep: = cStepGetJointsStrError;
END_IF
cStepGetJointsStrReset:
如果不是OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bError
而不是OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bBusy
然后
iStep: = cStepSetJointStrDelay;
END_IF;
cStepSetJointStrDelay:
strJointsCommand: = ";strJointsCommand: = CONCAT (LREAL_TO_STRING (arrJointsCommand [1]), strJointsCommand);
strJointsCommand: = CONCAT (strJointsCommand ', ');
strJointsCommand: = CONCAT (strJointsCommand LREAL_TO_STRING (arrJointsCommand [2]));
strJointsCommand: = CONCAT (strJointsCommand ', ');
strJointsCommand: = CONCAT (strJointsCommand LREAL_TO_STRING (arrJointsCommand [3]));
strJointsCommand: = CONCAT (strJointsCommand ', ');
strJointsCommand: = CONCAT (strJointsCommand LREAL_TO_STRING (arrJointsCommand [4]));
strJointsCommand: = CONCAT (strJointsCommand ', ');
strJointsCommand: = CONCAT (strJointsCommand LREAL_TO_STRING (arrJointsCommand [5]));
strJointsCommand: = CONCAT (strJointsCommand ', ');
strJointsCommand: = CONCAT (strJointsCommand LREAL_TO_STRING (arrJointsCommand [6]));
TON2 (: = TRUE, PT: = T # 0.2秒);
如果TON2。问那么
TON2 (: = FALSE);
iStep: = cStepSetJointsStr;
END_IF
cStepSetJointsStr:
如果(
OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bDone
而不是
OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bBusy
)
不信bWrite
然后
iStep: = cStepSetJointsStrReset;
ELSIF OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bError
然后
iStep: = cStepSetJointsStrError;
END_IF
cStepSetJointsStrReset:
bWrite: = FALSE;
OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bExecute: = FALSE;
如果不是OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bError
而不是OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bBusy
然后
iStep: = cStepEnd;
END_IF;
cStepEnd:
吨(:= TRUE, PT: = T # 0.1秒);
如果吨。问那么
吨(:= FALSE);
如果没有调试
iStep: = 10;
其他的
iStep: = cStepSetJointStrDelay;
END_IF;
END_IF
cStepGetItemError:
Item_ID: = 0;
iStep: = cStepWaitReset;
cStepGetJointsError:
我:= 0到11
arrJoints[我]:= -99999.99;
END_FOR
iStep: = cStepWaitReset;
cStepGetJointsStrError:
strJoints: = ";
iStep: = cStepWaitReset;
cStepWaitReset:
如果bReset那么
iStep: = cStepInit;
bReset: = FALSE;
END_IF;
END_CASE
aSplit [1]: = strJoints;
我:= 1到7
bResultSplit: = FindAndSplit (
pSeparator: = ADR (sSeparator)
pSrcString: = ADR (aSplit[我])
pLeftString: = ADR (aSplit[我])
nLeftSize: = SIZEOF (aSplit[我])
pRightString: = ADR (aSplit (i + 1))
nRightSize: = SIZEOF (aSplit (i + 1))
bSearchFromRight: = FALSE);
如果不是bResultSplit那么
退出;
END_IF
END_FOR
我:= 1到6
arrJointsFromStr[我]:= STRING_TO_LREAL (aSplit[我]);
END_FOR;
/ /
OPCUA_VirtualClient_RoboDK_Station.getItem (
bExecute: = iStep = cStepGetItem
Item_Name: = Robot_name
);
OPCUA_VirtualClient_RoboDK_Station.getJoints (
bExecute: = iStep = cStepGetJoints
Item_ID: = Item_ID关节= > arrJoints
);
OPCUA_VirtualClient_RoboDK_Station.getJointsStr (
bExecute: = iStep = cStepGetJointsStr
Robot_name: = Robot_name关节= > strJoints
);
如果bWrite那么
OPCUA_VirtualClient_RoboDK_Station.setJointsStr (
bExecute: = TRUE
Robot_name: = Robot_name关节:= strJointsCommand);
END_IF;