Communication Configuration and Example Program Usage
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.
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
-
Check the PCI-e slot on the IPC and make sure the INpact PIR Slave PCIe interface card is installed.
-
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.
Set up “Robot Communication Configuration”
-
Click Robot Communication Configuration on the toolbar of Mech-Vision.
-
In the Robot Communication Configuration window, complete the following configurations.
-
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.
-
In the Communication mode area, select Standard Interface for Interface service type and select PROFINET-IRT for Protocol.
-
(Optional) Select Auto enable interface service when opening the solution.
-
Click Apply.
-
-
On the main interface of Mech-Vision, make sure that the Robot Communication Configuration switch on the toolbar is flipped and turned to blue.
Create and Configure the PLC Project
Create PLC Project
If needed, click Save project to save the changes to the project. |
-
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.
-
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.
-
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.
Install GSD File and Configure Network
-
In the menu bar, select
. -
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.
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 thePROFINET
folder to the computer on which the TIA Portal is installed, and click … to locate the folder. -
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.
-
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.
-
A successful connection should look like this:
-
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.
-
In the Network panel, click the green connection line, and then click the assign icon.
-
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.
-
Double-click mechmind-pir to enter Device view. You can see all the available modules listed.
Download Hardware Configuration to PLC
-
In the Project tree panel, right-click PLC_1, and select Download to device ‣ Hardware configuration.
-
In the pop-up window, select Show all compatible devices for Select target device, and then click Start search.
-
Select the corresponding device in the search result, and click Load.
Check Communication
-
Return to the project, and click PLC_1 in the Project tree panel. Then, click Go online on the toolbar.
-
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.
-
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:
-
If the hardware is properly connected;
-
If the Interface Service has been started successfully in Mech-Vision;
-
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
-
Select PLC_1 in the Project tree panel, and then click Go offline on the toolbar.
-
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. -
In the Project tree panel, double-click
to open the PLC tags window. Then, click the import icon to open the Import window. -
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.The window should look like the figure below if the tags are imported successfully.
-
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
andMM Profinet Interface Program.scl
files. Click Open to import these files. -
Select the two imported external files and then right-click these files. In the right-click menu, select Generate blocks from source.
-
A message saying that “blocks can be overwritten” will pop-up. Select OK in the pop-up window.
-
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.
-
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.
-
Select all the newly generated functions and data blocks, and move them to the 3D_Camera group.
Build Program and Download to PLC
-
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.
-
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.
-
Once the program is downloaded successfully, select PLC_1[CPU 1211C DC/DC/DC] in the Project tree panel, and click Go online.
-
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.
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
-
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.
-
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.
Run Mech-Vision Project and Obtain Vision Points
Configure Programs
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
Drag MM_Get_VisData function to Main Program ‣ Network 3.
-
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.
-
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.
-
In the Program tree panel, right-click PLC_1, and select Download to device ‣ Software (only changes).
-
In the pop-up Load preview window, click Load to download the changes to the PLC.
Trigger the Mech-Vision Project to Run
-
In the Main OB window, click the Monitoring on/off icon.
-
Start the Mech-Vision project: In Network 1, right-click the “Camera_User”.Start_Vis parameter in “MM_Start_Vis”, and select
to 1. Then, reset the value of this parameter. -
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.
Obtain Vision Points from Mech-Vision
-
Right-click the “Camera_User”.Get_VisData parameter in “MM_Get_VisData”, and select
. Then, reset the value of this parameter. -
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.
-
The value of Send_Pose_Num is 1, indicating that one vision point is obtained.
-
The data returned by the Camera_User DB is shown as below. The pose data is stored in TargetPose.
Run Mech-Viz Project and Obtain Planned Path
Configure Programs
-
Drag the “MM_Empty_Target” FC to Network 4 in the Main OB.
-
Click the Camera_User DB. From the Details view panel, drag the parameters to the corresponding input ports of the “MM_Empty_Target” FC.
-
Drag FCs “MM_Start_Viz”, ”MM_Set_Branch”, and ”MM_Get_VizData” respectively to Main Program ‣ Network 5, 6, 7.
-
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”.
-
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.
-
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.
-
In the Program tree panel, right-click PLC_1, and select Download to device ‣ Software (only changes).
-
In the pop-up Load preview window, click Load to download the changes to the PLC.
Trigger the Mech-Viz Project to Run
-
In the Main OB window, click the Monitoring on/off icon.
-
Right-click the “Camera_User”.Start_Empty parameter in “MM_Empty_Target”, and select
. Then, reset the value of this parameter. -
In the Camera_User DB, the value of Target Pose is cleared.
-
Right-click the “Camera_User”.Start_Viz parameter in “MM_Start_Viz”, select
, and start the Mech-Viz project. Then, reset the value of this parameter. -
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.
Set Mech-Viz Branch Exit Port
-
Right-click the “Camera_User”.Set_Branch parameter in “MM_Set_Branch”, select
, and select the exit port for the Mech-Viz project. Then, reset the value of this parameter. -
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.
Obtain Planned Path from Mech-Viz
-
Right-click the “Camera_User”.Get_VizData parameter in “MM_Get_VizData”, select
, and obtain the planned path from Mech-Viz. Then, reset the value of this parameter. -
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.
-
The data returned by the TargetPose variable in the Camera_User DB is shown as below.