벡호프

Beckhoff TwinCAT 3 소프트웨어를사용하여 RoboDK OPC UA 서버와의연결을테스트할수있습니다.

트윈캣3 서버 추가

I/O>장치>새 항목 추가를 선택하여 OPC UA 클라이언트를 생성하여 시작할 수 있습니다.

OPC UA - 영상 48

OPC > 확인에서 가상 OPC UA 장치를 선택합니다.

OPC UA - 영상 49

OPC UA Virtual이삽입됩니다.

OPC UA - 영상 50

RoboDK OPC UA 서버에액세스하려면 OPC UA 클라이언트를추가해야합니다.

장치 1 > 마우스오른쪽버튼클릭 > 새항목추가를선택합니다.

OPC UA - 영상 51

"OPC UA 클라이언트(모듈)"를선택하고확인을선택합니다.

OPC UA - 영상 52

OPC UA 클라이언트가삽입됩니다.

OPC UA - 영상 53

서버 구성

OPC UA 클라이언트를열고 > 설정탭으로이동한후 > "엔드포인트선택"을클릭하여액세스하려는 OPC UA 서버엔드포인트를구성합니다.

OPC UA - 영상 54

RoboDK OPC UA 서버 URL을입력하고업데이트합니다.

OPC UA - 영상 55

RoboDK 서버 메서드 추가

"노드추가"를눌러 OPC UA 서버내부에있는노드를찾습니다.

OPC UA - 영상 56

트윈캣과 OPC UA 서버 간의 연결이 설정되면, OPC UA 서버의 세부 정보를 찾아볼 수 있습니다.

OPC UA - 영상 57

모든방법을선택하고확인을선택합니다.

OPC UA - 영상 58

메소드가구성에삽입됩니다.

OPC UA - 영상 59

자동 생성 RoboDK 메서드

이필드에서이름접두사를구성합니다.

OPC UA - 영상 60

트윈캣에서 PLC 코드를생성하려면 "Create Plc Code"를누르세요.

OPC UA - 영상 61

프로젝트에 OpcUaClient 폴더가생성되고모든 RoboDK 메서드는 IEC61131-3 기능블록형식으로생성됩니다.

OPC UA - 영상 62

PLC 프로그램 예제

이섹션에서는 RoboDK OPC UA 서버와통신하는 Beckhoff TwinCAT PLC의샘플프로그램을보여줍니다.

프로그램 주요 내용

VAR

   bConnected      :BOOL;

   스테이션 포인터    :DINT;

   iStep           :INT;

   bStart          :BOOL;;

   i               INT;

   TON             TON;

   bReset          :BOOL;

   bWrite          :BOOL;

   TON2            :TON;

   bShow           :BOOL:=TRUE;

   bVis            :BOOL:=True;

END_VAR

 

VAR

   로봇_이름         :문자열(80):='abb_rb1';

   Item_ID         :ULINT;

   arrJoints       :array[0..11]의 lreal;

   strJoints       :문자열(80):='';

   arrJointsFromStr:ARRAY[1..11]OF LREAL;

   sSeparator      :문자열(1) := ',';

   arrJointsCommand:ARRAY[1..11]OF LREAL;

   strJointsCommand:STRING(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] OF STRING(80);

      bResultSplit :BOOL;

        debug      :BOOL;

     URL              :STRING:='http://192.168.3.42:8091';

END_VAR

bConnected:=OPCUA_VirtualClient_RoboDK_Station.bConnected;

 

사례 i단계

  

 

   cStepWaitCmd:

        IF bStart THEN

              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

      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:

 

        IF OPCUA_VirtualClient_RoboDK_Station.getItem.bDone THEN

              iStep:=cStepGetItemReset;

        Item_ID:=OPCUA_VirtualClient_RoboDK_Station.getItem.Item_ID;

        ELSIF OPCUA_VirtualClient_RoboDK_Station.getItem.bError THEN

              iStep:=cStepGetItemError;

        END_IF

       

   cStepGetItemReset:

 

      OPCUA_VirtualClient_RoboDK_Station.getItem.bError가 아닌 경우

              그리고 OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy가 아닙니다.

              그때

              iStep:=cStepGetJoints;

        END_IF

   cStepGetJoints:

 

        IF OPCUA_VirtualClient_RoboDK_Station.getJoints.bDone

              그리고 OPCUA_VirtualClient_RoboDK_Station.getJoints.bBusy가 아닙니다.

              그때

              iStep:=cStepGetJointsReset;

        ELSIF OPCUA_VirtualClient_RoboDK_Station.getJoints.bError THEN

              iStep:=991;

        END_IF

       

   cStepGetJointsReset:

 

      OPCUA_VirtualClient_RoboDK_Station.getItem.bError가 아닌 경우

              그리고 OPCUA_VirtualClient_RoboDK_Station.getItem.bBusy가 아닙니다.

       

              그때

              iStep:=cStepGetJointsStr;

        END_IF;

       

   cStepGetJointsStr:

 

        IF OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bDone

              그리고 OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bBusy가 아닙니다.

              그때

              iStep:=cStepGetJointsStrReset;

        ELSIF OPCUA_VirtualClient_RoboDK_Station.getJointsStr.bError THEN

              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(IN:=TRUE,PT:=T#0.2S);

        IF TON2.Q THEN

              ton2(in:=false);

              iStep:=cStepSetJointsStr;

        END_IF

  

   cStepSetJointsStr:

 

       

        IF (

        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;

        IF NOT OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bError

              그리고 OPCUA_VirtualClient_RoboDK_Station.setJointsStr.bBusy가 아닙니다.

              그때

              아이스텝:=c스텝엔드;

        END_IF;

       

   cStepEnd:

        TON(IN:=TRUE,PT:=T#0.1S);

        IF TON.Q THEN

              ton(in:=false);

              디버그하지 않으면

                   iStep:=10;

              기타

                   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

        EXIT;

    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

,Item_Name:=로봇_이름

);

 

 

OPCUA_VirtualClient_RoboDK_Station.getJoints(

bExecute:=iStep=cStepGetJoints

,Item_ID:=Item_ID,Joints=>arrJoints

);

 

 

OPCUA_VirtualClient_RoboDK_Station.getJointsStr(

bExecute:=iStep=cStepGetJointsStr

,로봇_이름:=로봇_이름,조인트=>strJoints

);

 

IF bWrite THEN

OPCUA_VirtualClient_RoboDK_Station.setJointsStr(

   bExecute:=TRUE

   ,로봇_이름:=로봇_이름,조인트:=strJointsCommand);

END_IF;