Communication Configuration and Example Program Usage¶
This topic provides instructions on setting up the Standard Interface communication based on the Modbus/TCP protocol between a Mitsubishi MELSEC-Q Series PLC and Mech-Mind Software Suite.
Hardware and Software Requirements¶
Hardware¶
CPU: MELSEC-Q Series Q03UDVCPU
Power supply: Mitsubishi Q61P
Base unit: Mitsubishi Q33B
Mech-Mind Vision System IPC or host PC
USB Type A male to USB Mini-B male cable
Ethernet cables
Software¶
Mitsubishi PLC Engineering Software: GX Works2
Mech-Mind Software Suite: 1.7.0 or above
Example programs:
MODBUS_TCP_Protocol Configuration.tpc (used to establish communication via Modbus TCP/IP)
MODBUS TCP_Q_Simple_Label.GXW (used to execute commands with different functions of the standard interface)
The example programs are stored in xxx\Mech-Mind Software Suite-x.x.x\Mech-Center\Robot_Interface\Modbus TCP\MITSUBISHI Q serial in the installation directory of Mech-Mind Software Suite. Please copy and paste the example programs to a PC with GX Works2 installed.
Attention
The firewall on the IPC must be turned off.
Configure IPC and Initiate Communication¶
Set IP Address of the IPC¶
Open the Control Panel, and go to
.Right-click the Ethernet interface connected to the PLC, and select Properties.
In the pop-up window, double-click Internet Protocol Version 4(TCP/IPv4).
Select Use the following IP address, and then set the IP address, subnet mask and default gateway (must be in the same subnet as the PLC). Then, click OK to save the changes.
Set up “Robot and Interface Configuration” in Mech-Vision¶
Click Robot and Interface Configuration on the toolbar of Mech-Vision.
Select Listed robot from the Select robot drop-down menu, and then click Select robot model.
Select the robot model that you use, and then click Next.
Select the following options and click Apply.
Interface Type: Standard Interface
Protocol: Modbus TCP SLAVE
Port number of Host IP address: according to your needs (set to 2000 here)
Byte order: CDAB
Slave ID: according to your needs (set to 255 here)
Make sure the Interface Service is started: on the toolbar of Mech-Vision, the Interface Service switch on the far right is flipped and turned to blue.
Create and Configure the PLC Project¶
Create a PLC Project¶
Open GX Works2, click on the toolbar. In the New Project window, select QCPU (Q mode) as the series, Q03UDV as the type, Simple Project as the project type. Select Use Label, and select Ladder as the language. After setting, click OK to save changes.
Go to
, and double-click Connection1.A Transfer Setup Connection1 window will pop up. Select Serial USB in the PC side I/F panel, and select QCPU (Q mode) as the PLC mode. Then click PLC Direct Coupled Setting.
In the pop-up window, select USB and click Yes.
Go back to the Transfer Setup Connection1 window, click Connection Test. If GX Works2 is connected with the PLC successfully, a message saying “Successfully connected with the Q03UDVCPU” will pop up. Click OK to dismiss this message. Then, in the Transfer Setup Connection1 window, click OK to go back to the main interface of GX Works2.
Click Online in the menu bar and then select Remote Operation.
A Remote Operation window will pop up, select STOP as the Operation type, and click Execute. A message saying that “Do you want to execute the operation(STOP)” will pop up. Select Yes in the window.
A message saying that “The operation(STOP) has been completed” will pop up. Select OK in the window.
Click Close in the Remote Operation window and go back to the main interface of GX Works2.
Configure Communication Parameters of Modbus TCP¶
Go to
, and double-click PLC Parameter.In the pop-up Q Parameter Setting window, click the Built-in Ethernet Port Setting tab, and set the IP address, subnet mask, and default router IP address in the IP Address Setting area. Then, click Open Settings.
Hint
Please note that the IP address should be in the same subnet as that of the IPC.
Then, a Built-in Ethernet Port Open Setting window will pop up. Please configure the parameters on the first line as shown in the figure below. After configuration, click End and return to the Q Parameter Setting window, and then click End to return to the main interface of GX Works2.
Click Tool in the menu bar, and select
, and open the Predefined Protocol Support Function-Built-in Ethernet window.In the Predefined Protocol Support Function-Built-in Ethernet window, click the open icon. Locate and select the Modbus TCP communication configuration file MODBUS_TCP_Protocol Configuration.tpc, and click Open.
In the Predefined Protocol Support Function-Built-in Ethernet window, click Write to Module icon.
In the pop-up Module Write window, click Execute. If a pop-up message saying “Protocol setting file already exists in target memory. Do you want to overwrite?”, select Yes.
A message saying “Writing to target memory completed.” will pop up if the writing has been completed successfully. Click OK in the window.
Import Mech-Mind Example Programs¶
Note
Before you add the example program to a project already in use, it is recommended to import it to a new project and test it first.
Go back to the main interface of GX Works2. Click Project in the menu bar, and select
.
In the Import Library to Project window, click Refresh FB List. Then select all items in the FB List, and then click OK.
A message saying “Are you sure to overwrite?” will pop up. Select Yes in the window and go back to the main interface of GX Works2.
Click Tool in the menu bar, and select Device/Label Automatic-Assign Setting.
In the pop-up window, modify the assignment ranges of word device D and bit device M as shown below, and then click OK.
Select Yes in the pop-up window to continue.
Build Program and Download to PLC¶
In the Navigation Window of GX Works2, expand Program Setting, and drag MAIN under No Execution Type to Scan Program. The program structure after the adjustment is shown in the figure below. Then double-click Program under MAIN.
Expand OK.
and drag MM_MBTCP to line 0 of MAIN. An Input FB Instance Name window will pop up. Keep the default settings and clickClick on the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.
Click the Rebuild All icon on the toolbar.
In the pop-up window asking “Are you sure you want to Rebuild All?”, click Yes.
Click the Write to PLC icon on the toolbar.
An Online Data Operation window will pop up. Select Write, click Parameter+Program, and click Execute.
In the pop-up window asking “Do you want to execute writing the program?”, click Yes.
In the pop-up window asking “Are you sure you want to overwrite the existing file?”, click Yes to all.
In the Write to PLC window, when “Write to PLC: Completed” appears in the panel, click Close .
Click Online in the menu bar and select Remote Operation.
In the Remote Operation window, select RUN as the Operation type, and click Execute.
A message saying “Do you want to execute the operation(RUN)” will pop up. Select Yes in the window.
A message saying “The operation(RUN) has been completed.” will pop up. Select OK in the window.
Click Close in the Remote Control window and go back to the main interfacce of GX Works2.
Check Communication¶
Click the Start Monitoring (All Windows) icon on the toolbar.
Select Yes in the pop up window asking “Do you want to start the monitoring of all windows.”.
Double-click the MM_MBTCP on line 0 of MAIN, and scroll to line 423 of the program. If the connection is successful, the monitored value of MM_Camera.Heartbeat will be changing constantly.
The PLC is successfully connected if the following message is displayed in the Console tab of Mech-Vision Log panel: client connected.
Note
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 PLC program has been successfully downloaded to the PLC.
Test with Mech-Vision/Mech-Viz Project¶
This section introduces how to run the Mech-Vision/Mech-Viz project and obtain data from the project using the example program.
Prerequisites¶
Mech-Vision project(s):
Executable
Set to autoload: right-click the solution and select Autoload Solution. Projects in the solution are also autoloaded.
Mech-Viz project:
Executable
Set to autoload: right-click the project name in Resources and select Autoload Project
Contains a “Branch by Msg” Step that has been renamed to 1.
Run Mech-Vision Project and Obtain Vision Points¶
Configure Programs¶
In GX Works2, click in the menu bar, and then click the Monitor(Write Mode) icon.
A window saying “Execute the function below when mode is changed.” will pop up. Click OK in the window.
Expand OK.
, and drag MM_Start_Vis to line 8 of MAIN. An Input FB Instance Name window will pop up. Keep the default settings and clickClick on the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.
Set Mech-Vision project ID: set the port value of Vision_Proj_Num to 1, and project No. 1 in Mech-Vision will be run.
Set the number of vision points to be sent by Mech-Vision: set the port value of Req_Pose_Num to 0, and all poses in the vision result will be returned from Mech-Vision.
Set the type of pose to be sent by the robot: setting the port value of Robot_Pose_Type to 0 indicates that the project is in Eye-to-Hand mode, and the image-capturing pose is not needed.
Double-click in the blue frame area on the left of Start_Vision port of MM_Start_Vis FB. Select Open Contact in the pop-up window, and enter the global label Camera_User.Start_Vis. Then click OK to connect the Start_Vision port with the bus line.
Drag MM_Get_VisData to line 8 of MAIN. An Input FB Instance Name window will pop up. Keep the default settings and click OK. Click on the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.
Set Mech-Vision project ID: set the port value of Vision_Proj_Num to 1, and project No. 1 in Mech-Vision will be run.
Double-click in the blue frame area on the left of Get_VisData port of MM_Get_VisData FB. Select Open Contact in the pop-up window, and enter the global label Camera_User.Get_VisData. Then click OK to connect the Get_VisData port with the bus line.
Click the Online Program Change icon on the toolbar.
Click OK in the pop-up Confirm Build Method for Online Program Change window.
Click Yes in the pop-up Caution window.
Lastly, click OK to complete downloading the program to PLC.
Trigger Mech-Vision Project to Run¶
In the interface of MAIN, right-click the input variable Camera_User.Start_Vis of MM_Start_Vis FB, and select
in the context menu.In the pop-up Modify Value window, click ON to trigger Mech-Vision project to run. Then click OFF to reset the value.
Right-click on the blank space, select Register to Watch, and enter the global label MM_Camera.Status_Code. If the project is started successfully, the status code 1102 will be returned. Otherwise, the corresponding error code will be returned. Please refer to Status Codes and Troubleshooting for troubleshooting.
Obtain Vision Points¶
Right-click the input variable Camera_User.Get_VisData of MM_Get_VisData FB, and select
in the context menu.In the pop-up Modify Value window, click ON to obtain vision points. Then click OFF to reset the value.
Right-click on the blank space, select Register to Watch, and enter the global label MM_Camera.Status_Code. If the vision points are obtained successfully, the status code 1100 will be returned. Otherwise, the corresponding error code will be returned. Then, enter the global label MM_Camera.Target_Pose, and the pose data of vision points will be returned.
Run Mech-Viz Project and Obtain Planned Path¶
Configure Programs¶
Drag MM_Start_Empty to line 54 of MAIN. An Input FB Instance Name window will pop up. Keep the default settings and click OK. Click on the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.
Double-click in the blue frame area on the left of Start_Empty port of MM_Start_Vis FB. Select Open Contact in the pop-up window, and enter the global label Camera_User.Start_Empty. Then click OK to connect the Start_Empty port with the bus line.
Drag MM_Start_Viz, MM_Set_Branch, and MM_Get_VizData to line 54 of MAIN respectively. An Input FB Instance Name window will pop up. Keep the default settings and click OK. Click on the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FBs.
Set the type of pose to be sent by the robot: setting the port value of Robot_Pose_Type to 0 indicates that the project is in Eye-to-Hand mode, and the image-capturing pose is not needed.
Double-click in the blue frame area on the left of EN1 port of MM_Start_Viz FB. Select Close Contact in the pop-up window, and enter the global label Camera_User.Get_VizData. Then, click OK to connect the EN1 port with the left bus line.
Double-click in the blue frame area on the left of Start_Viz port of MM_Start_Viz FB. Select Open Contact in the pop-up window, and enter the global label Camera_User.Start_Viz. Then, click OK to connect the Start_Viz port with the left bus line.
Set the branch parameters in Mech-Viz project: set the port value of Branch_Name and Branch_Exit_Port to 1 respectively, and the Mech-Viz project will take the exit port 1 for the “Branch by Msg” Step named 1.
Double-click in the blue frame area on the left of Set_Branch port of MM_Set_Branch FB. Select Open Contact in the pop-up window, and enter the global label Camera_User.Set_Branch. Then click OK to connect the Set_Branch port with the left bus line.
Set the pose type of the obtained waypoints: set the port value of Request_Pose_Type to 1, and Mech-Viz will return waypoints in JPs.
Attention
The Request_Pose_Type here and Robot_Pose_Type of the MM_Start_Vis and MM_Start_Viz FB all correspond to the Pose Type variable of the global label MM_Camera. Therefore, if these parameters are set to different values, the programming should ensure that the two values do not take effect at the same time.
Double-click in the blue frame area on the left of EN1 port of MM_Get_VizData FB. Select Close Contact in the pop-up window, and enter the global label Camera_User.Start_Viz. Then click OK to connect the EN1 port with the left bus line.
Double-click in the blue frame area on the left of Get_VizData port of MM_Get_VizData FB. Select Open Contact in the pop-up window, and enter the global label Camera_User.Get_VizData. Then click OK to connect the Get_VizData port with the left bus line.
Click the Online Program Change icon on the toolbar.
Click OK in the pop-up Confirm Build Method for Online Program Change window.
Click Yes in the pop-up Caution window.
Lastly, click OK to complete downloading the program to PLC.
Trigger Mech-Viz Project to Run¶
In the interface of MAIN, right-click the input variable Camera_User.Start_Empty of MM_Start_Empty FB, and select
in the context menu.In the pop-up Modify Value window, click ON to clear the previously obtained waypoint data. Then click OFF to reset the value.
Right-click on the blank space, select Register to Watch, and enter the global label MM_Camera.Status_Code. The status code 3103 should be returned, and the variable values of Camera_User.Target Pose, Camera_User.Target Label, and Camera_User.Speed Percentage should be cleared.
In the interface of MAIN, right-click the input variable Camera_User.Start_Viz of MM_Start_Viz FB, and select
in the context menu.In the pop-up Modify Value window, click ON to trigger the Mech-Viz project to run. Then click OFF to reset the value.
Right-click on the blank space, select Register to Watch, and enter the global label MM_Camera.Status_Code. If the project is started successfully, the status code 2103 will be returned. Otherwise, the corresponding error code will be returned. Please refer to Status Codes and Troubleshooting for troubleshooting.
Set Branch Exit Port¶
In the interface of MAIN, right-click the input variable Camera_User.Set_Branch of MM_Set_Branch FB, and select
in the context menu.In the pop-up Modify Value window, click ON to set the exit port of the branch for the Mech-Viz project. Then click OFF to reset the value.
Right-click on the blank space, select Register to Watch, and enter the global label MM_Camera.Status_Code. If the branch is set successfully, the status code 2105 will be returned. Otherwise, the corresponding error code will be returned. Please refer to Status Codes and Troubleshooting for troubleshooting.
Obtain Planned Path¶
In the interface of MAIN, right-click the input variable Camera_User.Get_VizData of MM_Get_VizData FB, and select
in the context menu.In the pop-up Modify Value window, click ON to obtain the planned path from Mech-Viz. Then click OFF to reset the value.
Right-click on the blank space, select Register to Watch, and enter the global label MM_Camera.Status_Code. If the planned path is obtained successfully, the status code 2100 will be returned. Otherwise, the corresponding error code will be returned. Then enter the global label MM_Camera.Target_Pose, and the JPs of the waypoints in the path will be returned.