Example of Robot Control by SRCI

An example of performing robot control from a Siemens PLC is described below.

  • Use "TIA Portal V20" as the client software of Siemens PLC.
  • Create a new project on the TIA Portal from the Archive file in "SIMATIC Robot Library V1.2" provided by Siemens.
  • Perform robot control through SCL (Structured Control Language).
  1. Change the setting of PLC model number to your PLC model number.

    1. Under [Project tree], double-click [Device & networks], and then double-click [PLC_1] at the center of the screen.

    2. Right-click the PLC shown in [Device view], and select [Change device].

    3. Select your PLC model number, and press the [OK] button.

  2. Make the settings for communication between the PLC and controller.

    1. See below and make the settings for communication between the PLC and controller.
      Setting a Siemens PLC

    2. Under [Project tree], select [PLC_1] - [PLC_tags], and then double-click and open [RobotCommunication].

    3. Copy and paste [Xxx_To_PLC] and [PLC_To_Xxx] defined for other companies, and then change the name.

    4. Change the [Address] setting to the value set in the input/output module of [RC800-PROFINET-IO].

  3. Set the RobotTask function block for Epson robot control.

    1. Under [Project tree], create the [Epson] group below [PLC_1] - [Program blocks] - [Robots].

    2. Under [Project tree], copy the following data blocks set in the group for other robot vendors below [PLC_1] - [Program blocks] - [Robots], paste them to the group created in i., and change the names:

      • AxesGroupXxx

      • Robot_User_Data_Xxx

    3. Right-click [PLC_1] and select [Compile] - [Hardware and software (only changes)]. A warning is displayed regarding duplication of the data block numbers copied in ii. Press [OK] to resolve the duplicate numbers.

    4. From [PLC_1] - [Program blocks] - [Robots], double-click [Cyclicinterrupt_McRobotTask].

    5. Open [Network 8], and from [PLC_1] - [Program blocks] - [SRL] - [LRob], drag & drop [MC_RobotTask_LRob], and press the [OK] button in the [Call options] dialog box.

    6. The data block configured in step v. appears under [PLC_1] - [Program blocks] - [Robots]. Move it to the [Epson] group and rename it.

    7. Set each parameter of the RobotTask function block.

      Parameter name Data name
      RobotInData “Epson_To_PLC”.Arm1
      RobotOutData “PLC_To_Epson”.Arm1
      UserData “Robot_User_Data_Epson”.UserData
      ToolData “Robot_User_Data_Epson”.ToolData
      FrameData “Robot_User_Data_Epson”.FrameData
      LoadData “Robot_User_Data_Epson”.LoadData
      SoftwareLimit “Robot_User_Data_Epson”.SwLimits
      DefaultDynamics “Robot_User_Data_Epson”.DefaultDynamics
      ReferenceDynamics “Robot_User_Data_Epson”.ReferenceDynamics
      WorkArea “Robot_User_Data_Epson”.WorkAreaData
      MessageLog “Robot_User_Data_Epson”.MessageLog
      SystemLog “Robot_User_Data_Epson”.SystemLog
      ConstantData “Lrob_ConstantData”
      AxesGroup “AxesGroupEpson”
  4. Write the SCL program for robot control.

    1. From [PLC_1] - [Program blocks] - [Robots], right-click [Epson], select [Add new block], set [Type] to Global DB, and create a data block. In the data block that is created, define two instances of data having the Data type as Lrob_typeRobotCartesianPosition, as shown in the figure below.

    2. From [PLC_1] - [Program blocks] - [Robots], right-click [Epson], select [Add new block], set [Language] to SCL, and create the two function blocks described below.

      • SrciFBs
      • MoveBetweenTwoPoints
    3. In the function blocks created in ii., define the data as shown in the figure below.

    4. In the function block created in ii., write the following source code.

    #SetOperationMode_Instance(AxesGroup := "AxesGroupEpson");
    #EnableRobot_Instance(AxesGroup := "AxesGroupEpson");
    #MoveDirectAbsolute_Instance(AxesGroup := "AxesGroupEpson");
    #ChangeSpeedOverride_Instance(AxesGroup := "AxesGroupEpson");
    #GroupReset_Instance(AxesGroup := "AxesGroupEpson");
    #GroupContinue_Instance(AxesGroup := "AxesGroupEpson");
    
    1. In the function blocks created in ii., define the data as shown in the figure below.

    2. In the function block created in ii., write the following source code.

    CASE #State OF
    #STATE_INIT:
        IF #Start THEN
            "SrciFBs_DB".ChangeSpeedOverride_Instance.Override := 10.0;
            "SrciFBs_DB".MoveDirectAbsolute_Instance.VelocityRate := 100.0;
            "SrciFBs_DB".MoveDirectAbsolute_Instance.AccelerationRate := 100.0;
            "SrciFBs_DB".MoveDirectAbsolute_Instance.DecelerationRate := 100.0;
            "SrciFBs_DB".MoveDirectAbsolute_Instance.JerkRate := -1.0;
            
            "SrciFBs_DB".SetOperationMode_Instance.OperationMode := 4;
            "SrciFBs_DB".SetOperationMode_Instance.Execute := TRUE;
            
            "SrciFBs_DB".GroupReset_Instance.Execute := TRUE;
            #State := #STATE_ENABLE_RA;
        END_IF;
        
    #STATE_ENABLE_RA:
        IF "SrciFBs_DB".SetOperationMode_Instance.Done THEN
            "SrciFBs_DB".EnableRobot_Instance.Enable := TRUE;
            #State := #STATE_WAIT_RA_ENABLED;
        END_IF;
        
    #STATE_WAIT_RA_ENABLED:
        IF "SrciFBs_DB".EnableRobot_Instance.Enabled THEN
            "SrciFBs_DB".ChangeSpeedOverride_Instance.Execute := TRUE;
            "SrciFBs_DB".GroupContinue_Instance.Execute := TRUE;
            #State := #STATE_MOVE_P1;
        END_IF;
        
    #STATE_MOVE_P1:
        "SrciFBs_DB".MoveDirectAbsolute_Instance.Position := "Position".P1;
        "SrciFBs_DB".MoveDirectAbsolute_Instance.Execute := TRUE;
        #State := #STATE_WAIT_FOR_REACHED;
        
    #STATE_MOVE_P2:
        "SrciFBs_DB".MoveDirectAbsolute_Instance.Position := "Position".P2;
        "SrciFBs_DB".MoveDirectAbsolute_Instance.Execute := TRUE;
        #State := #STATE_WAIT_FOR_REACHED;
        
    #STATE_WAIT_FOR_REACHED:
        IF "SrciFBs_DB".MoveDirectAbsolute_Instance.Done THEN
            "SrciFBs_DB".MoveDirectAbsolute_Instance.Execute := FALSE;
            IF #IsDestinationP1 THEN
                #State := #STATE_MOVE_P2;
            ELSE
                #State := #STATE_MOVE_P1;
            END_IF;
            #IsDestinationP1 := NOT #IsDestinationP1;
        END_IF;
        
        IF NOT #Start THEN
            "SrciFBs_DB".SetOperationMode_Instance.Execute := FALSE;
            "SrciFBs_DB".EnableRobot_Instance.Enable := FALSE;
            "SrciFBs_DB".ChangeSpeedOverride_Instance.Execute := FALSE;
            "SrciFBs_DB".GroupReset_Instance.Execute := FALSE;
            "SrciFBs_DB".GroupContinue_Instance.Execute := FALSE;
            #State := #STATE_INIT;
        END_IF;
    END_CASE;
    
    
    1. From [PLC_1] - [Program blocks], double-click and open [Main], drag & drop the function blocks that were created to [Network 1], and then press the [OK] button in the dialog box that is displayed.

    2. From [PLC_1] - [Program blocks], change the "Start" parameter of the function block "MoveBetweenTwoPoints" set in [Main] to ""MoveBetweenTwoPoint_DB".Start".

  5. Operate the robot using the project that is created.

    1. Right-click [PLC_1] and select [Compile] - [Hardware and software (only changes)].

    2. Right-click [PLC_1] while the PC and the PLC are connected, select [Download to device] - [Hardware and software (only changes)], and update the hardware settings and software settings of the PLC unit.

    3. Press either the [Run] button on the PLC unit or the [Start CPU] button on the TIA Portal to start the program on the PLC.

    4. From [PLC_1] - [Program blocks], open [Main], and then press the [Monitoring on/off] button to enable monitoring.

    5. Right-click "Start" for the "MoveBetweenTwoPoints" function block, and then select [Modify] - [Modify to 1]. The state transition of the [MoveBetweenTwoPoints] function block starts, and the robot operates.

    6. Right-click "Start" for the "MoveBetweenTwoPoints" function block, and then select [Modify] - [Modify to 0] to stop the robot operation.