Communication Configuration and Example Program Usage

You are viewing an old version of the documentation. You can switch to the documentation of the latest version by clicking the top-right corner of the page.

This topic provides instructions on setting up the Standard Interface communication based on the PROFINET protocol between a Siemens SIMATIC S7 PLC using the TIA Portal software and the Mech-Mind Vision System.

Hardware and Software Requirements

Hardware

  • Siemens SIMATIC S7 PLC:

    • S7-300 (with PROFINET interface or CP 343-1 integrated to function as a PROFINET IO controller)

    • S7-400 (with PROFINET interface or CP 443-1 integrated to function as a PROFINET IO controller)

    • S7-1200

    • S7-1500

  • AC 220 V to DC 24 V power adapter

  • HMS Ixxat INpact PIR Slave PCIe interface card installed on the IPC in Mech-Mind Vision System

  • Network switch and Ethernet cables

This example adopts S7-1200, CPU 1211C.

The hardware connection is as follows.

hardware connection

Software

  • Siemens PLC programming software TIA Portal V15.1

  • Mech-Vision & Mech-Viz versions: 1.7.0 or above

  • VCI V4 (driver software for INpact PIR Slave PCIe interface card)

  • GSD device description file: GSDML-V2.35-MM-PIR-20220315.xml. If the GSD file version is upgraded, the version or date may differ. The GSD file is located in Mech-Center/Robot_Interface/PROFINET in the installation directory where Mech-Vision and Mech-Viz are installed.

  • PLC Example Programs:

    • Camera_IO.scl (fundamental PROFINET IO communication module)

    • MM Profinet Interface Program.scl (for functions of various interface commands)

    • PLCTags.xlsx (Mech-Mind System Variable Table).

    The example files are stored in Mech-Center/Robot_Interface/PROFINET/Programming Samples/Siemens TIA Portal S7-1200 PLC PROFINET in the installation directory where Mech-Vision and Mech-Viz are installed. Please copy the example file to the computer on which the TIA Portal is installed.

Configure IPC and Initiate Communication

Check PCI-e Card and Driver Software

  1. Check the PCI-e slot on the IPC and make sure the INpact PIR Slave PCIe interface card is installed.

    install communication board
  2. Make sure the driver software is installed on the IPC: Right-click the Windows icon, and click Device Manager to open it. Find VCI4 INpact PCIe under IXXAT VCI V4 Interfaces.

    device manager

Set up “Robot Communication Configuration”

  1. Click Robot Communication Configuration on the toolbar of Mech-Vision.

  2. In the Robot Communication Configuration window, complete the following configurations.

    1. Click the Select robot drop-down menu, and select Listed robot. Click Select robot model, and select the robot model that you use. Then, click Next.

    2. In the Communication mode area, select Standard Interface for Interface service type and select PROFINET-IRT for Protocol.

    3. (Optional) Select Auto enable interface service when opening the solution.

    4. Click Apply.

      profinet irt
  3. On the main interface of Mech-Vision, make sure that the Robot Communication Configuration switch on the toolbar is flipped and turned to blue.

    interface service

Create and Configure the PLC Project

Create PLC Project

If needed, click Save project to save the changes to the project.
  1. Open TIA Portal and click Create new project. Input the Project name and Path, and click Create. Click Open the project view in the pop-up page.

    create plc 1
  2. In the Project tree panel, double-click Add new device. In the new window, click Controllers, and find the CPU module that you are using, and input the name in the blank box under “Device name”. Click OK to confirm adding the device. Here, the device is named PLC_1.

    create plc 2
  3. Select Device configuration under PLC_1 in the Project tree panel, and then click Device view tab on the right. In this tab, double-click the Ethernet icon in PLC_1. Down in the Properties/General tab, click Ethernet addresses to set the IP address of the PLC. Use the default value for Subnet mask.

    create plc 3

Install GSD File and Configure Network

  1. In the menu bar, select Options  Manage general station description files (GSD).

    gsd file 1
  2. In the pop-up window, click Installed GSDs, and then click to the right of Source path. Locate the path where the GSD file is stored. Check this file in Content of imported path, and then click Install. Close the window after the installation completes.

    gsd file 2
    The GSD file can be found in the Mech-Mind IPC. The GSD file is located in Mech-Center/Robot_Interface/PROFINET in the installation directory where Mech-Vision and Mech-Viz are installed. Copy the PROFINET folder to the computer on which the TIA Portal is installed, and click to locate the folder.
  3. Return to Device configuration, and go to Network view. Click Hardware catalog, and double-click DAP under General/Mech-Mind Robotics Technologies Ltd/MechMind-PIR to display mechmind-pir in Network view.

    gsd file 3
  4. In Network view, click the Ethernet icon in PLC_1 and drag it to the Ethernet icon in mechmind-pir, and release the button when a black connection line appears.

    gsd file 4
  5. A successful connection should look like this:

    gsd file 5
  6. Click the Ethernet icon in mechmind-pir. Down in the Properties tab, in the General tab, click Ethernet addresses to set the IP address. This IP address should be in the same subnet as that of the PLC. Make sure Generate PROFINET device name automatically is checked.

    gsd file 6
  7. In the Network panel, click the green connection line, and then click the assign icon.

    gsd file 7
  8. In the pop-up window, select mechmind-pir for PROFINET device name, and then click Update list. When the device appears in the list, check whether the PROFINET device name is mechmind-pir. If not, click Assign name. Once Status is OK, click Close to close the window.

    gsd file 8
  9. Double-click mechmind-pir to enter Device view. You can see all the available modules listed.

    gsd file 9

Download Hardware Configuration to PLC

  1. In the Project tree panel, right-click PLC_1, and select Download to device ‣ Hardware configuration.

    download configuration 1
  2. In the pop-up window, select Show all compatible devices for Select target device, and then click Start search.

    download configuration 2
  3. Select the corresponding device in the search result, and click Load.

    download configuration 3

Check Communication

  1. Return to the project, and click PLC_1 in the Project tree panel. Then, click Go online on the toolbar.

    establish communication 1
  2. In the Project tree panel, click Device configuration, and then click the Device view tab on the right. Select mechmind-pir. In Device overview, check marks with a green background in front of module names indicate normal connection.

    establish communication 2
  3. The PLC is successfully connected if the following message is displayed in the Console tab of Mech-Vision Log panel: Connect to PROFINET-IRT controller successfully. If you don’t see this log message, please check:

    1. If the hardware is properly connected;

    2. If the Interface Service has been started successfully in Mech-Vision;

    3. If the hardware configuration has been downloaded to the PLC.

Import Example Program and Download to PLC

Before you add the Mech-Mind example program to a project already in use, it is recommended to import it to a new project and test it first. In the following steps, the project created earlier is used to import and test the example program.

Import Mech-Mind Example Programs

  1. Select PLC_1 in the Project tree panel, and then click Go offline on the toolbar.

    import file 1
  2. In Network view, double-click mechmind-pir to enter Device view. Change the I addresses and Q addresses according to the actual requirement. Here, 500 is used as the lowest module start address.

    For a module occupying multiple bytes, the addresses assigned must be continuous, and the module start address must be of an even number.
    import file 2
  3. In the Project tree panel, double-click PLC tags  Show all tags to open the PLC tags window. Then, click the import icon to open the Import window.

    import file 3
  4. In the pop-up window, click to the right of the input field, and locate the PLCTags.xlsx file. Click OK to import the CameraIO tag table.

    import file 4

    The window should look like the figure below if the tags are imported successfully.

    import file 5
  5. In the Project tree panel, double-click External source files, and then double-click Add new external file. In the pop-up window, locate and select the Camera_IO.scl and MM Profinet Interface Program.scl files. Click Open to import these files.

    import file 6
  6. Select the two imported external files and then right-click these files. In the right-click menu, select Generate blocks from source.

    import file 7
  7. A message saying that “blocks can be overwritten” will pop-up. Select OK in the pop-up window.

    import file 8
  8. The functions and data blocks generated from external source files are shown in the figure below. Camera_User[DB2] stores user data. The variable address of CameraIO[DB1] in the variable table must be consistent with the modified starting address in the device configuration.

    import file 9
  9. In the project, to facilitate the maintenance of functions and data blocks, select Program blocks, right-click and select Add new group, and name it 3D_Camera.

    import file 10
  10. Select all the newly generated functions and data blocks, and move them to the 3D_Camera group.

    import file 11

Build Program and Download to PLC

  1. In the Project tree panel, double-click the Main OB in Program blocks to open it. Then, select the Camera_IO FC and drag it to Network 1.

    build plc 1
  2. In the Project tree panel, right-click PLC_1, and select Download to device ‣ Hardware and software (only changes). In the pop-up window, select Show all compatible devices for Select target device, and then click Start search to download the program to PLC. Select the corresponding device in the search result, and click Load.

    build plc 2
  3. Once the program is downloaded successfully, select PLC_1[CPU 1211C DC/DC/DC] in the Project tree panel, and click Go online.

    build plc 3
  4. In the Project tree panel, double-click Program blocks ‣ CameraIO[DB1] and then click the monitor icon. Double-click to expand FromCamera. If the monitor value of HEARTBEAT keeps changing, then the I/Q addresses of modules in mechmind-pir have been successfully transferred to the CameraIO FB.

    build plc 4

Test with Vision Projects

This section introduces how to use the example program function block to trigger the Mech-Vision project to obtain vision points and trigger the Mech-Viz project to obtain the planned path. For detailed information on the IO modules, please refer to xref:profinet-siemens-simatic-s7-interface-commands.adoc[PROFINET.

Prerequisites

  1. Mech-Vision project(s): Right-click the solution and select Autoload Solution. Projects in the solution are also autoloaded. Meanwhile, the project number will show up before each project name.

  2. Mech-Viz project: Right-click the project name in Resources of Mech-Viz and select Autoload Project.

    The Mech-Viz project used for testing should contain a “Branch by Msg” Step that has been renamed to 1 as shown below.

    preparation 4

Run Mech-Vision Project and Obtain Vision Points

Configure Programs

  1. Establish communication: In the CameraIO DB, double-click the monitor value of COMM_ENABLE in ToCamera. If a warning message pops up, click Yes to confirm changing the monitor value.

    test vision 1
  2. In the Project tree panel, double-click Main [OB1] to open the main program, and drag the “MM_Start_Vis” function to Main Program ‣ Network 1.

    test vision 2
  3. Change the port value of Vision_Proj_Num to the ID of the Mech-Vision project you wish to run. For example, if the value is changed to 1, then project No.1 in Mech-Vision will be started.

  4. Set the number of poses returned by the Mech-Vision project: Set the port value of Req_Pose_Num to 0, indicating that Mech-Vision returns all pose results.

  5. Set the type of pose sent from the robot. Set the port value of Robot_Pose_Type to 0, indicating that the project is in the Eye-to-Hand mode, and there is no need to send the image-capturing pose. If the project is in Eye-in-Hand mode, please set the Robot_Pose_Type port value to 1, and set the current robot flange pose to the Robot_Pose port.

    test vision 3
  6. In the Project tree panel, navigate to Program blocks and click the Camera_User DB. From the Details view panel, drag the parameters to the corresponding input ports of the MM_Start_Vis FC.

    test vision 4
  7. Drag MM_Get_VisData function to Main Program ‣ Network 3.

    test vision 5
  8. Change the port value of Vision_Proj_Num to the ID of the Mech-Vision project you wish to run. Set the port value of Vision_Proj_Num to 1, and the vision recognition result of Project No.1 in Mech-Vision will be obtained.

  9. In the Project tree panel, navigate to Program blocks and click the Camera_User DB. From the Details view panel, drag the parameters to the corresponding input ports of the MM_Get_VisData FC.

    test vision 6
  10. In the Program tree panel, right-click PLC_1, and select Download to device ‣ Software (only changes).

    test vision 7
  11. In the pop-up Load preview window, click Load to download the changes to the PLC.

    test vision 8

Trigger the Mech-Vision Project to Run

  1. In the Main OB window, click the Monitoring on/off icon.

    test vision 9
  2. Start the Mech-Vision project: In Network 1, right-click the “Camera_User”.Start_Vis parameter in “MM_Start_Vis”, and select Modify  Modify to 1. Then, reset the value of this parameter.

    test vision 10
  3. Check the return value of the STATUS_CODE variable in the CameraIO data block. 1102 means that the project is started successfully. Otherwise, the corresponding error code will be returned. Please refer to Status Codes and Troubleshooting for troubleshooting.

    test vision 11

Obtain Vision Points from Mech-Vision

  1. Right-click the “Camera_User”.Get_VisData parameter in “MM_Get_VisData”, and select Modify  Modify to 1. Then, reset the value of this parameter.

    test vision 12
  2. Double-click MM Modbus TCP Interface DB to open it, and check the monitor value of Status Code. 1100 represents that the vision points are obtained successfully. Otherwise, the corresponding error code will be returned. Please refer to Status Codes and Troubleshooting for troubleshooting.

    test vision 13
  3. The value of Send_Pose_Num is 1, indicating that one vision point is obtained.

    test vision 14
  4. The data returned by the Camera_User DB is shown as below. The pose data is stored in TargetPose.

    test vision 15

Automate the Process of Getting Vision Result from Mech-Vision

The previous section introduces how to manually obtain vision results from Mech-Vision. To automate the process of obtaining vision results from Mech-Vision, connect the programs as the following example.

get vis results automatically 1
get vis results automatically 2
get vis results automatically 3

Run Mech-Viz Project and Obtain Planned Path

Configure Programs

  1. Drag the “MM_Empty_Target” FC to Network 4 in the Main OB.

    test viz 1
  2. Click the Camera_User DB. From the Details view panel, drag the parameters to the corresponding input ports of the “MM_Empty_Target” FC.

    test viz 2
  3. Drag FCs “MM_Start_Viz”, ”MM_Set_Branch”, and ”MM_Get_VizData” respectively to Main Program ‣ Network 5, 6, 7.

    test viz 3
  4. Set the type of pose sent from the robot. Change the value of the Robot_Pose_Type port. If the value is set to 0, no image-capturing pose will be sent (for the Eye-to-Hand installation). If the project is in Eye-in-Hand mode, please set the Robot_Pose_Type port value to 1, and set the current robot flange pose to the Robot_Pose port. Click the Camera_User DB. From the Details view panel, drag the parameters to the corresponding input ports of “MM_Start_Viz”.

    test viz 4
  5. Set the branch parameters in Mech-Viz project. Set the value of Branch_Name and Branch_Exit_Port to 1, and Mech-Viz will take exit port 1 for the “Branch by Msg” Step whose Step ID is 1. Click the Camera_User DB. From the Details view panel, drag the parameters to the corresponding input ports of the “MM_Set_Branch” FC.

    test viz 5
  6. Set the pose type of the obtained waypoints. Change the value of “Request_Pose_Type” to 1, and Mech-Viz will return data in the format of joint positions (instead of TCP). Click the Camera_User DB. From the Details view panel, drag the parameters to the corresponding input ports of the “MM_Get_VizData” FC.

    test viz 6
  7. In the Program tree panel, right-click PLC_1, and select Download to device ‣ Software (only changes).

    test viz 7
  8. In the pop-up Load preview window, click Load to download the changes to the PLC.

    test viz 8

Trigger the Mech-Viz Project to Run

  1. In the Main OB window, click the Monitoring on/off icon.

    test viz 9
  2. Right-click the “Camera_User”.Start_Empty parameter in “MM_Empty_Target”, and select Modify  Modify to 1. Then, reset the value of this parameter.

    test viz 10
  3. In the Camera_User DB, the value of Target Pose is cleared.

    test viz 11
  4. Right-click the “Camera_User”.Start_Viz parameter in “MM_Start_Viz”, select Modify  Modify to 1, and start the Mech-Viz project. Then, reset the value of this parameter.

    test viz 12
  5. Check the return value of the STATUS_CODE variable in the CameraIO data block. 2103 means that the project is started successfully. Otherwise, the corresponding error code will be returned. Please refer to Status Codes and Troubleshooting for troubleshooting.

    test viz 13

Set Mech-Viz Branch Exit Port

  1. Right-click the “Camera_User”.Set_Branch parameter in “MM_Set_Branch”, select Modify  Modify to 1, and select the exit port for the Mech-Viz project. Then, reset the value of this parameter.

    test viz 14
  2. Check the return value of the STATUS_CODE variable in the CameraIO data block. 2105 means that the branch is set successfully. Otherwise, the corresponding error code will be returned. Please refer to Status Codes and Troubleshooting for troubleshooting.

    test viz 15

Obtain Planned Path from Mech-Viz

  1. Right-click the “Camera_User”.Get_VizData parameter in “MM_Get_VizData”, select Modify  Modify to 1, and obtain the planned path from Mech-Viz. Then, reset the value of this parameter.

    test viz 16
  2. Check the return value of the STATUS_CODE variable in the CameraIO data block. 2100 means that the planned path is obtained successfully. Otherwise, the corresponding error code will be returned. Please refer to Status Codes and Troubleshooting for troubleshooting.

    test viz 17
  3. The data returned by the TargetPose variable in the Camera_User DB is shown as below.

    test viz 18
    test viz 19

Automate the Process of Getting Planned Path from Mech-Viz

The previous section introduces how to manually obtain the planned path from Mech-Viz. To automate the process of obtaining the planned path from Mech-Viz, connect the programs as the following example.

get viz results automatically 1
get viz results automatically 2
get viz results automatically 3
get viz results automatically 4

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.