Può utilizzare il software Beckhoff TwinCAT 3 per testare la connettività con il Server RoboDK OPC UA.
Può iniziare creando il client OPC UA selezionando I/O>Devices>Add New Item.
Selezionare Dispositivo OPC UA virtuale da OPC >OK.
OPC UA Virtual è inserito.
Dobbiamo aggiungere un client OPC UA per accedere al server RoboDK OPC UA.
Selezioni il Dispositivo 1 >Click destro >Aggiungi nuovo elemento.
Selezionare "OPC UA Client(Module)" e Ok.
Il client OPC UA è inserito.
Apra il client OPC UA >Andare alla scheda Impostazioni>cliccare su "Seleziona endpoint" per configurare l'endpoint del server OPC UA a cui desidera accedere.
Inserisca l'URL del server RoboDK OPC UA e lo aggiorni.
Prema "Aggiungi nodi" per sfogliare il nodo che si trova all'interno del Server OPC UA.
Se la connessione tra TwinCAT e il server OPC UA è stabilita, può sfogliare i dettagli del server OPC UA.
Selezionare tutti i metodi e cliccare su Ok.
I metodi sono inseriti nella sua Configurazione.
Configuri il prefisso del suo nome in questo campo.
Premere "Crea codice Plc" per creare il codice PLC da TwinCAT.
Nel suo progetto viene creata una cartella OpcUaClient e tutti i RoboDK Method vengono creati nel formato IEC61131-3 Function Block.
Questa sezione mostra un esempio di programma di un PLC Beckhoff TwinCAT che comunica con il server RoboDK OPC UA.
PROGRAMMA PRINCIPALE
VAR
bConnesso :BOOL;
StazionePointer :DINT;
iStep :INT;
bInizio :BOOL;;
i :INT;
TON :TON;
bReset :BOOL;
bScrivere :BOOL;
TON2 :TON;
bShow :BOOL:=TRUE;
bVis :BOOL:=Vero;
END_VAR
VAR
Nome_robot :STRING(80):='ABB_RB1';
ID_articolo :ULINT;
arrGiunti :ARRAY[0..11]DI LREAL;
strJoints :STRING(80):='';
arrJointsFromStr:ARRAY[1..11]DI LREAL;
sSeparatore :STRING(1) := ',';
arrJointsCommand:ARRAY[1..11]DI LREAL;
strJointsCommand:STRING(80);
END_VAR
VAR COSTANTE
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] DI STRINGA(80);
bResultSplit :BOOL;
debug :BOOL;
URL :STRING:='http://192.168.3.42:8091';
END_VAR
bConnected:=OPCUA_VirtualClient_RoboDK_Station.bConnected;
CASO iStep di
cStepWaitCmd:
SE bStart ALLORA
iStep:=cStepInit;
bStart:=FALSE;
END_IF
cStepInit:
StationPointer:=0;
PER i :=1 A 11 FARE
arrJoints[i]:=0,0;
arrJointsFromStr[i]:=0.0;
aSplit[i]:='';
FINE_FOR
SE NON OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy
E NON OPCUA_VirtualClient_RoboDK_Station.getItem.bError
E NON OPCUA_VirtualClient_RoboDK_Station.getJoints.bBusy
E NON OPCUA_VirtualClient_RoboDK_Station.getJoints.bError
E NON OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bBusy
E NON OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bError
E NON OPCUA_VirtualClient_RoboDK_Station.setJoints.bBusy
E NON OPCUA_VirtualClient_RoboDK_Station.setJoints.bError
E NON OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bBusy
E NON OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bError
ALLORA
iStep:=cStepGetItem;
END_IF
iStep:=cStepGetItem;
cStepGetItem:
SE OPCUA_VirtualClient_RoboDK_Station.getItem.bDone ALLORA
iStep:=cStepGetItemReset;
Item_ID:=OPCUA_VirtualClient_RoboDK_Station.getItem.Item_ID;
ELSIF OPCUA_VirtualClient_RoboDK_Station.getItem.bError ALLORA
iStep:=cStepGetItemError;
END_IF
cStepGetItemReset:
SE NON OPCUA_VirtualClient_RoboDK_Station.getItem.bError
E NON OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy
ALLORA
iStep:=cStepGetJoints;
END_IF
cStepGetJoints:
SE OPCUA_VirtualClient_RoboDK_Station.getJoints.bDone
E NON OPCUA_VirtualClient_RoboDK_Station.getJoints.bBusy
ALLORA
iStep:=cStepGetJointsReset;
ELSIF OPCUA_VirtualClient_RoboDK_Station.getJoints.bError ALLORA
iStep:=991;
END_IF
cStepGetJointsReset:
SE NON OPCUA_VirtualClient_RoboDK_Station.getItem.bError
E NON OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy
ALLORA
iStep:=cStepGetJointsStr;
END_IF;
cStepGetJointsStr:
SE OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bDone
E NON OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bBusy
ALLORA
iStep:=cStepGetJointsStrReset;
ELSIF OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bError ALLORA
iStep:=cStepGetJointsStrError;
END_IF
cStepGetJointsStrReset:
SE NON OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bError
E NON OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bBusy
ALLORA
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:=VERO,PT:=T#0,2S);
SE TON2.Q ALLORA
TON2(IN:=FALSE);
iStep:=cStepSetJointsStr;
END_IF
cStepSetJointsStr:
SE (
OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bDone
E NON
OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bBusy
)
O NON bWrite
ALLORA
iStep:=cStepSetJointsStrReset;
ELSIF OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bError
ALLORA
iStep:=cStepSetJointsStrError;
END_IF
cStepSetJointsStrReset:
bWrite:=FALSE;
OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bExecute:=FALSE;
SE NON OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bError
E NON OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bBusy
ALLORA
iStep:=cStepEnd;
END_IF;
cStepEnd:
TON(IN:=VERO,PT:=T#0,1S);
SE TON.Q ALLORA
TON(IN:=FALSE);
SE NON debug ALLORA
iStep:=10;
ELSE
iStep:=cStepSetJointStrDelay;
END_IF;
END_IF
cStepGetItemError:
ID_articolo:=0;
iStep:=cStepWaitReset;
cStepGetJointsError:
PER i :=0 A 11 FARE
arrJoints[i]:=-99999.99;
FINE_FOR
iStep:=cStepWaitReset;
cStepGetJointsStrError:
strJoints:='';
iStep:=cStepWaitReset;
cStepWaitReset:
SE bReset ALLORA
iStep:=cStepInit;
bReset:=FALSE;
END_IF;
END_CASE
aSplit[1] := strJoints;
PER i:=1 A 7 FARE
bResultSplit := FindAndSplit(
pSeparatore := ADR(sSeparatore)
pSrcString := ADR(aSplit[i])
pLeftString:= ADR(aSplit[i])
nLeftSize := SIZEOF(aSplit[i])
pRightString:= ADR(aSplit[i+1])
nDimensione destra := SIZEOF(aSplit[i+1])
bSearchFromRight := FALSE );
SE NON bResultSplit ALLORA
USCIRE;
END_IF
FINE_FOR
PER i :=1 A 6 FARE
arrJointsFromStr[i]:=STRING_TO_LREAL(aSplit[i]);
END_FOR;
//
OPCUA_VirtualClient_RoboDK_Station.getItem(
bExecute:=iStep=cStepGetItem
Nome_oggetto:=Nome_Robot
);
OPCUA_VirtualClient_RoboDK_Station.getJoints(
bExecute:=iStep=cStepGetJoints
ID_articolo:=ID_articolo, Giunti=>arrGiunti
);
OPCUA_VirtualClient_RoboDK_Station.getJointsStr(
bExecute:=iStep=cStepGetJointsStr
Nome_robot:=Nome_robot,Giunti=>strGiunti
);
SE bScrittura ALLORA
OPCUA_VirtualClient_RoboDK_Station.setJointsStr(
bExecute:=TRUE
Nome_robot:=Nome_robot,Giunti:=strComandoGiunti);
END_IF;