Communication Configuration and Example Program Usage

Below are the instructions for using Mech-Center Interface Siemens PLC Client to communicate with the vision system through the software TIA Portal.

Hardware and Software Prerequisites

Hardware

  • The following S7 PLCs from Siemens are supported:

    • S7-300: Integrated PN network port or CP343-1

    • S7-400: Integrated PN network port or CP443-1

    • S7-1200: None

    • S7-1500: None

  • Power adapter: 220V AC to 24V DC

  • Mech-Mind Vision System IPC or host

  • Network cable

Software

  • Siemens PLC programming software TIA Portal V15.1.

  • Control center software Mech-Center 1.4.0 or above, machine vision software Mech-Vision 1.4.0 or above, robot programming software Mech-Viz 1.4.0 or above.

  • Interface file for S7 communication between software Siemens Tia Portal and Mech-Mind Software Suite:

    • Data block file Mech-Mind Interface.db for data communication.

    • File Mech-Mind Interface Program.scl for implementing the functions of various interface commands.

    Hint

    The files are stored under XXXX/Mech-Center-xxx/Robot_Interface/Siemens Snap7/TIA Portal at the file location of Mech-Center, please copy the file to the computer where the software TIA Portal is installed.

Creation and Configuration of PLC Projects

Create a PLC project

  1. Open TIA Portal, click on Create new project , enter project name , select a path, and click on Create. A new window will pop up. Click on Open project view.

    ../../../../_images/build_plc_13.png
  2. In the Project tree section, double-click on Add new device to open the window. Under Controllers, select the module that is consistent with the physical PLC. The default device name can be used. Click on OK.

    ../../../../_images/build_plc_23.png
  3. On the device configuration page, click on Device view , then double-click the network port label of PLC_1. On the Properties/General page, click Ethernet address and set the IP address to 192.168.1.22. The default subnet mask can be used (should be in the same network segment as the vision system’s IPC).

    ../../../../_images/build_plc_33.png

#. Select the device PLC_1 in the project tree, right-click and select Properties, and enter the interface General ‣ Protection & Security in turn in the pop-up window. Under Access level, check Full access (no protection). Under Connection mechanisms, check Permit access with PUT/GET communication from remote partner. Click on OK to save the project.

../../../../_images/build_plc_43.png
../../../../_images/build_plc_52.png

Import the S7 Communication Interface File

  1. Under the project tree, click on External source files and Add new external file. In the pop-up window, select files Mech-Mind Interface.db, Mech-Mind Interface Program.scl, and click on Open to import the files to the new project.

    ../../../../_images/import_s7_files_1.png
  2. Select the newly imported external source files (select Mech-Mind Interface.db first, then select Mech-Mind Interface Program.scl ), right-click, and select Generate blocks from source. Click on OK in the pop-up window (this operation will overwrite the functions and data blocks with the same names in the project, and automatically select an unoccupied number).

    ../../../../_images/import_s7_files_2.png

    Hint

    If the operations are not performed in the order of the selected files above, an error message will appear in the log window.

  3. The functions and data blocks generated by the external source file are as follows, where the DB number of Mech-Mind Interface must be consistent with the DB number in the deployment settings of Mech-Center. The DB Camera_User is used to store user data.

    ../../../../_images/import_s7_files_3.png
  4. In the project, to facilitate the maintenance of Mech-Mind functions and data blocks, you can right-click the program block, select Add new group, name it Mech-Mind, and select all the newly generated function functions and data blocks and move them to the group folder.

    ../../../../_images/import_s7_files_4.png
    ../../../../_images/import_s7_files_5.png

Download the S7 Communication Interface File

  1. Click on Save project , then in the project tree, right-click on the new project PLC_1. Select Download to device ‣ Hardware and software (only changes) in turn, and the download window will pop up.

    ../../../../_images/download_s7_files_1.png
  2. In the download window that pops up, select the network card driver connected to PLC for PG/PC interface, select Direct at slot ‘1 X1’ for Connection to interface/subnet, select Show all compatible devices for Select target device, and then click on Start search. Select the detected CPU device, click Download, click Finish after the download is complete.

    ../../../../_images/download_s7_files_2.png

Configure IPC and Start Communication

Configure Mech-Center Communication

  1. Make the IP of the IPC and the IP of the PLC in the same network segment, such as 192.168.1.10. Open the cmd command prompt of the IPC (by searching for cmd), enter ping xxx.xxx.xxx.xxx (the IP address of the PLC), and test whether the connection between the industrial computer and the PLC is normal.

  2. Run Mech-Center and open Deployment Settings.

    ../../../../_images/center_settings_11.png
  3. Do the following in Deployment Settings:

    • Under Mech-Interface, check Use Mech-Interface

    • Select Standard Interface for Interface Service Type

    • Select Siemens PLC Client for Interface Option

    • Please select the robot model according to the actual situation

    • Set PLC IP address to 192.168.1.22, i.e., the PLC IP address set earlier

    • Set the slot number to 1 and the DB number to 2, i.e., the number of the “Mech-Mind Interface” in the PLC project. Click Save to exit the deployment settings.

    ../../../../_images/center_settings_21.png

Check If Communication Is Established

  1. On the main interface of Mech-Center, click on Start Interface icon_1. If the connection is successful, Connect to PLC server successfully will be displayed in the log on the right side; if it fails, please check the configuration and check whether the physical connection is faulty.

    ../../../../_images/center_settings_31.png
  2. Return to the main interface of TIA Portal, select the device PLC_1, and click the Go online.

    ../../../../_images/center_settings_4.png
  3. Under PCL_1 ‣ Program blocks of the project tree, double-click the data block Mech-Mind Interface , then click Monitor all icon_2.

    ../../../../_images/center_settings_5.png

Test the Vision Project

This section describes how to use the Mech-Mind-Siemens TIA S7 interface program for the startup and data acquisition of Mech-Vision and Mech-Viz projects. For the specific functions and introduction of S7 communication parameters, please see Siemens PLC.

Preparation

  1. Construct the Mech-Vision project and enable Autoload Project.

    ../../../../_images/prepared_1.png
  2. In the deployment settings of Mech-Center. Under Mech-Vision, click on the button Sync Project Path icon_3, to number and sort the Mech-Vision projects that have been set to be autoloaded, then click on Save.

    ../../../../_images/prepared_2.png
  3. Construct the Mech-Viz project and enable Autoload.

    ../../../../_images/prepared_3.png
  4. A branch task with task name 1 should be used in the Mech-Viz project for testing, as shown below.

    ../../../../_images/prepared_4.png

Get Vision Points from Mech-Vision

Parameter Settings

  1. In the main interface of TIA Portal, under the project tree, double click Main [OB1] under Program blocks, and drag the function MM_Start_Vis to Network 1 of the main program.

    ../../../../_images/get_visual_point_from_vision_1.png
  2. Set the Mech-Vision project number, i.e., the Mech-Vision project ID shown in the deployment settings in Mech-Center. Set the port value of Vision_Proj_Num to 1, and the Mech-Vision project with ID 1 in the deployment settings will be run.

    ../../../../_images/get_visual_point_from_vision_2.png
    ../../../../_images/get_visual_point_from_vision_3.png
  3. Set the number of poses expected in the vision result from the Mech-Vision project. In this example, set the port value of Req_Pose_Num, indicating expecting that all the poses in the vision result should be returned from Mech-Vision.

  4. Set the image-capturing pose type expected from the robot. In this example, set the port value of Robot_Pose_Type to 0, indicating no image-capturing pose needs to be read from the robot (such as in the eye-to-hand mode).

    ../../../../_images/get_visual_point_from_vision_4.png
  5. Under the project tree, click on the data block Camera_User, and drag the parameters under Details view to the corresponding ports of MM_Start_Vis.

    ../../../../_images/get_visual_point_from_vision_5.png
  6. Drag the MM_Get_VisData function to Network 2 of the main program.

    ../../../../_images/get_visual_point_from_vision_6.png
  7. Set the Mech-Vision project number, i.e., the Mech-Vision project ID shown in the deployment settings in Mech-Center. Set the port value of Vision_Proj_Num to 1, and the Mech-Vision project with ID 1 in the deployment settings will be run.

    ../../../../_images/get_visual_point_from_vision_2.png
    ../../../../_images/get_visual_point_from_vision_8.png
  8. Under the project tree, click data block Camera_User, and drag the parameters under Details view to the corresponding ports of MM_Get_VisData.

    ../../../../_images/get_visual_point_from_vision_9.png
  9. Under the project tree, click to select PLC_1, select Download to device ‣ Software (only changes). Click Load in the pop-up download window to download the latest program to the PLC.

    ../../../../_images/get_visual_point_from_vision_10.png
    ../../../../_images/get_planning_path_from_viz_14.png

Trigger the Running of the Mech-Vision Project

  1. In the main program window of Main [OB1], click Enable/Disable Monitoring icon_2 to enable monitoring.

    ../../../../_images/get_planning_path_from_viz_15.png
  2. Right-click on the input-side parameter “Camera_User”.Start_Vis of MM_Start_Vis and change its value to 1 to trigger the running of the Mech-Vision project, and then reset this parameter. At this time, the parameter StatusCode of Mech-Mind Interface should have a returned value of 1102. Otherwise, an error has occurred, and please see Status Codes and Trouble Shooting for further instructions.

    ../../../../_images/get_visual_point_from_vision_13.png
    ../../../../_images/get_visual_point_from_vision_14.png

Get Vision Target(s) Calculated by Mech-Vision

  1. Right-click on the input-side parameter “Camera_User”.Start_Vis of MM_Get_VisData and change its value to 1 to obtain the vision result, and reset its value. At this time, the parameter StatusCode of Mech-Mind Interface should have a returned value of 1100. Otherwise, an error has occurred, and please see Status Codes and Trouble Shooting for further instructions.

    ../../../../_images/get_visual_point_from_vision_15.png

The returned data from Mech-Mind Interface is as follows. The value of “Number of Pose Sent” is 1, meaning 1 pose has been obtained. The pose data is stored in “TargetPose”.

../../../../_images/get_visual_point_from_vision_16.png

Mech-Vision Automatic Control Logic Sample

../../../../_images/get_visual_point_from_vision_17.png
../../../../_images/get_visual_point_from_vision_18.png

Get Planned Path from Mech-Viz

Parameter Settings

  1. Drag the function MM_Empty_ Target to Network 2.

    ../../../../_images/get_planning_path_from_viz_1.png
  2. Click the data blocks Camera_User and Mech-Mind Interface respectively, and drag the parameters in the detailed view to the corresponding input-side ports of MM_Empty_ Target.

    ../../../../_images/get_planning_path_from_viz_2.png
    ../../../../_images/get_planning_path_from_viz_3.png
  3. Drag and drop the functions MM_Start_Viz , MM_Set_Branch , MM_Get_VizData to Network 4, 5, and 6 respectively.

    ../../../../_images/get_planning_path_from_viz_4.png
    ../../../../_images/get_planning_path_from_viz_5.png
    ../../../../_images/get_planning_path_from_viz_6.png
  4. Set the image-capturing pose type expected from the robot. In this example, set the port value of Robot_Pose_Type to 0, indicating no image-capturing pose needs to be read from the robot (such as in the eye-to-hand mode). Click the data block Camera_User, and drag the parameters in the detailed view to the corresponding input-side ports of MM_Start_Viz.

    ../../../../_images/get_planning_path_from_viz_7.png
    ../../../../_images/get_planning_path_from_viz_8.png
  5. Set the branch parameters in the Mech-Viz project. In this example, set the port values of Branch_Name and Branch_Exit_Port to 1 respectively, which means that when the Mech-Viz project is controlled to execute to branch 1, it will continue to execute along exit 1. Click the data block Camera_User, and drag the parameters in the detailed view to the corresponding input-side ports of MM_Set_Branch.

    ../../../../_images/get_planning_path_from_viz_9.png
    ../../../../_images/get_planning_path_from_viz_10.png
  6. Set the expected type of targets on the planned path. In this example, set the port value of Request_Pose_Type to 1, indicating the expected target type is JPs. Click the data block Camera_User, and drag the parameters in the detailed view to the corresponding input-side ports of MM_Get_VizData.

    ../../../../_images/get_planning_path_from_viz_11.png
    ../../../../_images/get_planning_path_from_viz_12.png

    Attention

    In this example, Request_Pose_Type and Robot_Pose_Type in the functions MM_Start_Vis and MM_Start_Viz correspond to the same parameter Pose Type in Mech-Mind Interface. If the set values are different, they cannot take effect at the same time.

  7. Under the project tree, right-click on PLC_1, select Download to device ‣ Software (only changes), and click Load in the pop-up download window to download the latest program to the PLC.

    ../../../../_images/get_planning_path_from_viz_13.png
    ../../../../_images/get_planning_path_from_viz_14.png

Trigger the Running of the Mech-Viz Project

  1. In the main program window of Main [OB1], click Enable/Disable Monitoring icon_2 to enable monitoring.

    ../../../../_images/get_planning_path_from_viz_15.png
  2. Right-click on the input-side parameter “Camera_User”.Start_Empty of MM_Empty_Target, set its value to 1 to empty the vision result obtained in the last round, and then reset its value.

    ../../../../_images/get_planning_path_from_viz_16.png

    At this time, the value of the data block Target Pose of Mech-Mind Interface has been cleared.

    ../../../../_images/get_planning_path_from_viz_17.png
  3. Right-click on the input-side parameter “Camera_User”.Start_Viz of MM_Start_Viz, set its value to 1 to start the running of the Mech-Viz project and then reset its value. At this time, the parameter StatusCode of Mech-Mind Interface should have a returned value of 2103. Otherwise, an error has occurred, and please see Status Codes and Trouble Shooting for further instructions.

    ../../../../_images/get_planning_path_from_viz_18.png
    ../../../../_images/get_planning_path_from_viz_19.png

Set the Mech-Viz Branch Exit

Right-click on the input-side parameter “Camera_User”.Set_Branch of MM_Set_Branch, set its value to 1 to specifiy the branch exit, and then reset its value.

At this time, the parameter StatusCode of Mech-Mind Interface should have a returned value of 2105. Otherwise, an error has occurred, and please see Status Codes and Trouble Shooting for further instructions.

../../../../_images/get_planning_path_from_viz_20.png
../../../../_images/get_planning_path_from_viz_21.png

Obtain Planned Path from Mech-Viz

Right-click on the input-side parameter “Camera_User”.Get_VizData of MM_Get_VizData, set its value to 1 to obtain the planned path from Mech-Viz and then reset its value.

At this time, the parameter StatusCode of Mech-Mind Interface should have a returned value of 2100. Otherwise, an error has occurred, and please see Status Codes and Trouble Shooting for further instructions.

../../../../_images/get_planning_path_from_viz_22.png

The returned data of Mech-Mind Interface is as follows. The value of Number of Pose Sent is 6, which means that 6 sets of JPs data are obtained, and the data is stored in TargetPose. Index of Vision Move is 3, indicating that the position number of the vision point, i.e., the “visual_move” Task in the path, is 3.

../../../../_images/get_planning_path_from_viz_23.png

Mech-Vision Automatic Control Logic Sample

../../../../_images/get_planning_path_from_viz_24.png
../../../../_images/get_planning_path_from_viz_25.png
../../../../_images/get_planning_path_from_viz_26.png