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

  1. Open the Control Panel, and go to Network and Internet ‣ Network and Sharing Center ‣ Change adapter settings.

  2. Right-click the Ethernet interface connected to the PLC, and select Properties.

  3. In the pop-up window, double-click Internet Protocol Version 4(TCP/IPv4).

    ../../../../_images/interface_properties.png
  4. 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.

    ../../../../_images/set_computer_ip1.png

Set up “Robot and Interface Configuration” in Mech-Vision

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

  2. Select Listed robot from the Select robot drop-down menu, and then click Select robot model.

  3. Select the robot model that you use, and then click Next.

  4. 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)

  5. 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

  1. Open GX Works2, click icon_new_project 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.

    ../../../../_images/create_plc_14.png
  2. Go to Navigation ‣ Connection Destination ‣ Current Connection, and double-click Connection1.

    ../../../../_images/create_plc_24.png
  3. 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.

    ../../../../_images/create_plc_34.png
  4. In the pop-up window, select USB and click Yes.

    ../../../../_images/create_plc_3_1.png
  5. 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.

    ../../../../_images/create_plc_3_2.png
  6. Click Online in the menu bar and then select Remote Operation.

    ../../../../_images/create_plc_43.png
  7. 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.

    ../../../../_images/create_plc_53.png
  8. A message saying that “The operation(STOP) has been completed” will pop up. Select OK in the window.

    ../../../../_images/create_plc_5_1.png
  9. Click Close in the Remote Operation window and go back to the main interface of GX Works2.

    ../../../../_images/create_plc_62.png

Configure Communication Parameters of Modbus TCP

  1. Go to Navigation ‣ Project ‣ Parameter, and double-click PLC Parameter.

    ../../../../_images/configure_plc_12.png
  2. 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.

    ../../../../_images/configure_plc_22.png
  3. 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.

    ../../../../_images/configure_plc_32.png
  4. Click Tool in the menu bar, and select Predefined Protocol Support Function ‣ Built-in Ethernet, and open the Predefined Protocol Support Function-Built-in Ethernet window.

    ../../../../_images/configure_plc_41.png
  5. In the Predefined Protocol Support Function-Built-in Ethernet window, click the icon_open open icon. Locate and select the Modbus TCP communication configuration file MODBUS_TCP_Protocol Configuration.tpc, and click Open.

    ../../../../_images/configure_plc_51.png
  6. In the Predefined Protocol Support Function-Built-in Ethernet window, click icon_write Write to Module icon.

    ../../../../_images/configure_plc_61.png
  7. 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.

    ../../../../_images/configure_plc_71.png
    ../../../../_images/configure_plc_7_1.png
  8. A message saying “Writing to target memory completed.” will pop up if the writing has been completed successfully. Click OK in the window.

    ../../../../_images/configure_plc_81.png

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.

  1. Go back to the main interface of GX Works2. Click Project in the menu bar, and select Library ‣ Install.

    ../../../../_images/import_file_14.png
  1. In the pop-up Import Library to Project window, select Select Library (Project) for Library List, and click Browse to locate the local MODBUS TCP_Q_Simple_Label.GXW file. Select the file and click Open.

../../../../_images/import_file_24.png
  1. In the Import Library to Project window, click Refresh FB List. Then select all items in the FB List, and then click OK.

    ../../../../_images/import_file_34.png
  2. 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.

    ../../../../_images/import_file_43.png
  3. Click Tool in the menu bar, and select Device/Label Automatic-Assign Setting.

    ../../../../_images/import_file_52.png
  4. In the pop-up window, modify the assignment ranges of word device D and bit device M as shown below, and then click OK.

    ../../../../_images/import_file_62.png
  5. Select Yes in the pop-up window to continue.

    ../../../../_images/import_file_72.png

Build Program and Download to PLC

  1. 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.

    ../../../../_images/download_configuration_13.png
  2. Expand POU ‣ FB_Pool and drag MM_MBTCP to line 0 of MAIN. An Input FB Instance Name window will pop up. Keep the default settings and click OK.

    ../../../../_images/download_configuration_22.png
  3. Click icon_line on the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.

    ../../../../_images/download_configuration_32.png
  4. Click the icon_rebuild Rebuild All icon on the toolbar.

    ../../../../_images/download_configuration_43.png
  5. In the pop-up window asking “Are you sure you want to Rebuild All?”, click Yes.

    ../../../../_images/download_configuration_52.png
  6. Click the icon_write Write to PLC icon on the toolbar.

    ../../../../_images/download_configuration_61.png
  7. An Online Data Operation window will pop up. Select Write, click Parameter+Program, and click Execute.

    ../../../../_images/download_configuration_71.png
  8. In the pop-up window asking “Do you want to execute writing the program?”, click Yes.

    ../../../../_images/download_configuration_81.png
  9. In the pop-up window asking “Are you sure you want to overwrite the existing file?”, click Yes to all.

    ../../../../_images/download_configuration_91.png
  10. In the Write to PLC window, when “Write to PLC: Completed” appears in the panel, click Close .

    ../../../../_images/download_configuration_101.png
  11. Click Online in the menu bar and select Remote Operation.

    ../../../../_images/download_configuration_112.png
  12. In the Remote Operation window, select RUN as the Operation type, and click Execute.

    ../../../../_images/download_configuration_121.png
  13. A message saying “Do you want to execute the operation(RUN)” will pop up. Select Yes in the window.

    ../../../../_images/download_configuration_131.png
  14. A message saying “The operation(RUN) has been completed.” will pop up. Select OK in the window.

    ../../../../_images/download_configuration_14.png
  15. Click Close in the Remote Control window and go back to the main interfacce of GX Works2.

    ../../../../_images/download_configuration_15.png

Check Communication

  1. Click the icon_monitor_all Start Monitoring (All Windows) icon on the toolbar.

    ../../../../_images/establish_communication_14.png
  2. Select Yes in the pop up window asking “Do you want to start the monitoring of all windows.”.

    ../../../../_images/establish_communication_23.png
  3. 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.

    ../../../../_images/establish_communication_32.png
  4. 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

  1. In GX Works2, click icon_more in the menu bar, and then click the icon_write_monitor Monitor(Write Mode) icon.

    ../../../../_images/test_vision_18.png
  2. A window saying “Execute the function below when mode is changed.” will pop up. Click OK in the window.

    ../../../../_images/test_vision_24.png
  3. Expand POU ‣ FB_Pool, and drag MM_Start_Vis to line 8 of MAIN. An Input FB Instance Name window will pop up. Keep the default settings and click OK.

    ../../../../_images/test_vision_34.png
  4. Click icon_line on the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.

    ../../../../_images/test_vision_44.png
  5. 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.

  6. 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.

  7. 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.

  8. 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.

    ../../../../_images/test_vision_54.png
    ../../../../_images/test_vision_64.png
  9. 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 icon_line on the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.

    ../../../../_images/test_vision_74.png
  10. 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.

  11. 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.

    ../../../../_images/test_vision_83.png
  12. Click the icon_program_change Online Program Change icon on the toolbar.

    ../../../../_images/test_vision_92.png
  13. Click OK in the pop-up Confirm Build Method for Online Program Change window.

    ../../../../_images/test_vision_102.png
  14. Click Yes in the pop-up Caution window.

    ../../../../_images/test_vision_113.png
  15. Lastly, click OK to complete downloading the program to PLC.

    ../../../../_images/test_vision_122.png

Trigger Mech-Vision Project to Run

  1. In the interface of MAIN, right-click the input variable Camera_User.Start_Vis of MM_Start_Vis FB, and select Debug ‣ Modify Value in the context menu.

    ../../../../_images/test_vision_132.png
  2. In the pop-up Modify Value window, click ON to trigger Mech-Vision project to run. Then click OFF to reset the value.

    ../../../../_images/test_vision_141.png
  3. 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.

    ../../../../_images/test_vision_151.png
    ../../../../_images/test_vision_161.png

Obtain Vision Points

  1. Right-click the input variable Camera_User.Get_VisData of MM_Get_VisData FB, and select Debug ‣ Modify Value in the context menu.

  2. In the pop-up Modify Value window, click ON to obtain vision points. Then click OFF to reset the value.

    ../../../../_images/test_vision_171.png
  3. 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.

    ../../../../_images/test_vision_181.png

Run Mech-Viz Project and Obtain Planned Path

Configure Programs

  1. 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 icon_line on the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.

    ../../../../_images/test_viz_110.png
  2. 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.

    ../../../../_images/test_viz_24.png
  3. 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 icon_line on the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FBs.

    ../../../../_images/test_viz_34.png
    ../../../../_images/test_viz_44.png
    ../../../../_images/test_viz_54.png
  4. 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.

  5. 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.

  6. 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.

    ../../../../_images/test_viz_64.png
  7. 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.

  8. 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.

    ../../../../_images/test_viz_74.png
  9. 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.

  10. 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.

  11. 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.

    ../../../../_images/test_viz_84.png
  12. Click the icon_program_change Online Program Change icon on the toolbar.

    ../../../../_images/test_viz_94.png
  13. Click OK in the pop-up Confirm Build Method for Online Program Change window.

    ../../../../_images/test_viz_103.png
  14. Click Yes in the pop-up Caution window.

    ../../../../_images/test_viz_114.png
  15. Lastly, click OK to complete downloading the program to PLC.

    ../../../../_images/test_viz_122.png

Trigger Mech-Viz Project to Run

  1. In the interface of MAIN, right-click the input variable Camera_User.Start_Empty of MM_Start_Empty FB, and select Debug ‣ Modify Value in the context menu.

  2. In the pop-up Modify Value window, click ON to clear the previously obtained waypoint data. Then click OFF to reset the value.

    ../../../../_images/test_viz_132.png
  3. 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.

    ../../../../_images/test_viz_142.png
  4. In the interface of MAIN, right-click the input variable Camera_User.Start_Viz of MM_Start_Viz FB, and select Debug ‣ Modify Value in the context menu.

  5. In the pop-up Modify Value window, click ON to trigger the Mech-Viz project to run. Then click OFF to reset the value.

    ../../../../_images/test_viz_151.png
  6. 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.

    ../../../../_images/test_viz_161.png

Set Branch Exit Port

  1. In the interface of MAIN, right-click the input variable Camera_User.Set_Branch of MM_Set_Branch FB, and select Debug ‣ Modify Value in the context menu.

  2. 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.

    ../../../../_images/test_viz_171.png
  3. 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.

    ../../../../_images/test_viz_181.png

Obtain Planned Path

  1. In the interface of MAIN, right-click the input variable Camera_User.Get_VizData of MM_Get_VizData FB, and select Debug ‣ Modify Value in the context menu.

  2. In the pop-up Modify Value window, click ON to obtain the planned path from Mech-Viz. Then click OFF to reset the value.

    ../../../../_images/test_viz_191.png
  3. 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.

    ../../../../_images/test_viz_201.png