Vous pouvez utiliser le logiciel Beckhoff TwinCAT 3 pour tester la connectivité avec le serveur OPC UA RoboDK.
Vous pouvez commencer par créer le client OPC UA en sélectionnant I/O>Devices>Add New Item.
Sélectionnez Virtual OPC UA Device from OPC >OK.
OPC UA Virtual est inséré.
Nous devons ajouter un client OPC UA pour accéder au serveur OPC UA de RoboDK.
Sélectionnez Device 1 >Cliquez avec le bouton droit de la souris >Ajouter un nouvel élément.
Sélectionnez "OPC UA Client(Module)" et Ok.
Le client OPC UA est inséré.
Ouvrez le client OPC UA >Allez dans l'onglet Paramètres>cliquez sur "Sélectionner un point de terminaison" pour configurer le point de terminaison du serveur OPC UA auquel vous souhaitez accéder.
Saisissez l'URL du serveur OPC UA de RoboDK et mettez-le à jour.
Appuyez sur "Add Nodes" pour parcourir le nœud qui se trouve à l'intérieur du serveur OPC UA.
Si la connexion entre TwinCAT et le serveur OPC UA est établie, vous pouvez parcourir les détails du serveur OPC UA.
Sélectionnez toutes les méthodes et cliquez sur Ok.
Les méthodes sont insérées dans votre configuration.
Configurez votre préfixe de nom dans ce champ.
Appuyez sur "Create Plc Code" pour créer le code PLC à partir de TwinCAT.
Un dossier OpcUaClient est créé dans votre projet et toutes les méthodes RoboDK sont créées au format IEC61131-3 Function Block.
Cette section présente un exemple de programme d'un automate Beckhoff TwinCAT qui communique avec le serveur OPC UA de RoboDK.
PROGRAMME PRINCIPAL
VAR
bConnected :BOOL ;
StationPointer :DINT ;
iStep :INT ;
bDébut :BOOL; ;
i :INT ;
TON :TON ;
bReset :BOOL ;
bWrite :BOOL ;
TON2 :TON ;
bShow :BOOL:=TRUE ;
bVis :BOOL:=True ;
END_VAR
VAR
Nom du robot :STRING(80):='ABB_RB1' ;
Item_ID :ULINT ;
arrJoints :ARRAY[0..11]OF LREAL ;
strJoints :STRING(80):='' ;
arrJointsFromStr:ARRAY[1..11]OF LREAL ;
sSeparator :STRING(1) := ',' ;
arrJointsCommand:ARRAY[1..11]OF LREAL ;
strJointsCommand:STRING(80) ;
END_VAR
VAR CONSTANT
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] OF STRING(80) ;
bResultSplit :BOOL ;
débogage :BOOL ;
URL :STRING:='http://192.168.3.42:8091';
END_VAR
bConnected:=OPCUA_VirtualClient_RoboDK_Station.bConnected ;
CASE iStep OF
cStepWaitCmd :
SI bStart ALORS
iStep:=cStepInit ;
bStart:=FALSE ;
END_IF
cStepInit :
StationPointer:=0 ;
FOR i :=1 TO 11 DO
arrJoints[i]:=0.0 ;
arrJointsFromStr[i]:=0.0 ;
aSplit[i]:='' ;
END_FOR
IF NOT OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy
AND NOT OPCUA_VirtualClient_RoboDK_Station.getItem.bError
AND NOT OPCUA_VirtualClient_RoboDK_Station.getJoints.bBusy
AND NOT OPCUA_VirtualClient_RoboDK_Station.getJoints.bError
AND NOT OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bBusy
AND NOT OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bError
AND NOT OPCUA_VirtualClient_RoboDK_Station.setJoints.bBusy
AND NOT OPCUA_VirtualClient_RoboDK_Station.setJoints.bError
AND NOT OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bBusy
AND NOT OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bError
ALORS
iStep:=cStepGetItem ;
END_IF
iStep:=cStepGetItem ;
cStepGetItem :
IF OPCUA_VirtualClient_RoboDK_Station.getItem.bDone ALORS
iStep:=cStepGetItemReset ;
Item_ID:=OPCUA_VirtualClient_RoboDK_Station.getItem.Item_ID ;
ELSIF OPCUA_VirtualClient_RoboDK_Station.getItem.bError ALORS
iStep:=cStepGetItemError ;
END_IF
cStepGetItemReset :
IF NOT OPCUA_VirtualClient_RoboDK_Station.getItem.bError
AND NOT OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy
ALORS
iStep:=cStepGetJoints ;
END_IF
cStepGetJoints :
IF OPCUA_VirtualClient_RoboDK_Station.getJoints.bDone
AND NOT OPCUA_VirtualClient_RoboDK_Station.getJoints.bBusy
ALORS
iStep:=cStepGetJointsReset ;
ELSIF OPCUA_VirtualClient_RoboDK_Station.getJoints.bError ALORS
iStep:=991 ;
END_IF
cStepGetJointsReset :
IF NOT OPCUA_VirtualClient_RoboDK_Station.getItem.bError
AND NOT OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy
ALORS
iStep:=cStepGetJointsStr ;
END_IF ;
cStepGetJointsStr :
IF OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bDone
AND NOT OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bBusy
ALORS
iStep:=cStepGetJointsStrReset ;
ELSIF OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bError ALORS
iStep:=cStepGetJointsStrError ;
END_IF
cStepGetJointsStrReset :
IF NOT OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bError
AND NOT OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bBusy
ALORS
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(IN:=TRUE,PT:=T#0.2S) ;
SI TON2.Q ALORS
TON2(IN:=FALSE) ;
iStep:=cStepSetJointsStr ;
END_IF
cStepSetJointsStr :
SI (
OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bDone
ET NON
OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bBusy
)
OR NOT bWrite
ALORS
iStep:=cStepSetJointsStrReset ;
ELSIF OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bError
ALORS
iStep:=cStepSetJointsStrError ;
END_IF
cStepSetJointsStrReset :
bWrite:=FALSE ;
OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bExecute:=FALSE ;
IF NOT OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bError
AND NOT OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bBusy
ALORS
iStep:=cStepEnd ;
END_IF ;
cStepEnd :
TON(IN:=TRUE,PT:=T#0.1S) ;
SI TON.Q ALORS
TON(IN:=FALSE) ;
IF NOT debug ALORS
iStep:=10 ;
ELSE
iStep:=cStepSetJointStrDelay ;
END_IF ;
END_IF
cStepGetItemError :
Item_ID:=0 ;
iStep:=cStepWaitReset ;
cStepGetJointsError :
FOR i :=0 TO 11 DO
arrJoints[i]:=-99999.99;
END_FOR
iStep:=cStepWaitReset ;
cStepGetJointsStrError :
strJoints:='' ;
iStep:=cStepWaitReset ;
cStepWaitReset :
IF bReset THEN
iStep:=cStepInit ;
bReset:=FALSE ;
END_IF ;
END_CASE
aSplit[1] := strJoints ;
FOR i:=1 TO 7 DO
bResultSplit := FindAndSplit(
pSeparator := ADR(sSeparator)
pSrcString := ADR(aSplit[i])
pLeftString:= ADR(aSplit[i])
nLeftSize := SIZEOF(aSplit[i])
pRightString:= ADR(aSplit[i+1])
nRightSize := SIZEOF(aSplit[i+1])
bSearchFromRight := FALSE ) ;
IF NOT bResultSplit THEN
SORTIE ;
END_IF
END_FOR
FOR i :=1 TO 6 DO
arrJointsFromStr[i]:=STRING_TO_LREAL(aSplit[i]) ;
END_FOR ;
//
OPCUA_VirtualClient_RoboDK_Station.getItem(
bExecute:=iStep=cStepGetItem
Nom_de_l'objet:=Nom_du_robot
) ;
OPCUA_VirtualClient_RoboDK_Station.getJoints(
bExecute:=iStep=cStepGetJoints
Item_ID:=Item_ID,Joints=>arrJoints
) ;
OPCUA_VirtualClient_RoboDK_Station.getJointsStr(
bExecute:=iStep=cStepGetJointsStr
,Nom_du_robot:=Nom_du_robot,Joints=>strJoints
) ;
SI bWrite ALORS
OPCUA_VirtualClient_RoboDK_Station.setJointsStr(
bExecute:=TRUE
Nom_du_robot:=Nom_du_robot,Joints:=strJointsCommand) ;
END_IF ;