Communication Configuration and Example Program Usage

The procedures for setting up communication between a Mitsubishi MELSEC-Q Series PLC and Mech-Mind Software Suite via Modbus TCP/IP are as follows.

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: Mech-Center 1.6.1 or above, Mech-Vision 1.6.0 or above, and Mech-Viz 1.6.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 XXXX/Mech-Center-xxx/Robot_Interface/Modbus TCP/MITSUBISHI Q serial in the installation directory of Mech-Center. 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_ip.png

Configure Mech-Interface in Mech-Center

  1. Open Mech-Center, and click Deployment Settings.

  2. Go to Mech-Interface, check Use Mech-Interface and then select Standard Interface for Interface Service Type.

    ../../../../_images/center_configuration_1.png
  3. In Interface Options, select MODBUS TCP SLAVE, and then change the following settings:

    • Host Address Port: according to your needs (set to 2000 here)

    • Byte order: CDAB

    • Slave ID: according to your needs (set to 255 here)

    Then, click Save to save the changes.

    ../../../../_images/center_configuration_2.png
  4. Click Start Interface in the toolbar. A MODBUS TCP SLAVE icon will appear in the Service Status panel, and the following message will be displayed in Mech-Center Log panel:

    Start MODBUS TCP Slave interface.

Create and Configure the PLC Project

Create a PLC Project

  1. Open GX Works2, click icon_new_project in 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_12.png
  2. Go to Navigation ‣ Connection Destination ‣ Current Connection, and double-click Connection1.

    ../../../../_images/create_plc_22.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_32.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_42.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_52.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_61.png

Configure Communication Parameters of Modbus TCP

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

    ../../../../_images/configure_plc_1.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_2.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_3.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_4.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_5.png
  6. In the Predefined Protocol Support Function-Built-in Ethernet window, click icon_write Write to Module icon.

    ../../../../_images/configure_plc_6.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_7.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_8.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_12.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_22.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_32.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_41.png
  3. Click Tool in the menu bar, and select Device/Label Automatic-Assign Setting.

    ../../../../_images/import_file_5.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_6.png
  5. Select Yes in the pop-up window to continue.

    ../../../../_images/import_file_7.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_12.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 in 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 in the toolbar.

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

    ../../../../_images/download_configuration_51.png
  6. Click the icon_write Write to PLC icon in the toolbar.

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

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

    ../../../../_images/download_configuration_8.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_9.png
  10. In the Write to PLC window, when “Write to PLC: Completed” appears in the panel, click Close .

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

    ../../../../_images/download_configuration_111.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_13.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 in the toolbar.

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

    ../../../../_images/establish_communication_22.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_31.png
  4. In Mech-Center, if the Log panel displays a Mech-Center: Client connected message, the PLC is successfully connected to Mech-Center.

    ../../../../_images/check_communication_2.png

Note

If you don’t see this log message, please check if:

  • The hardware are properly connected;

  • If Mech-Interface has been started by clicking on Start Interface in the toolbar;

  • 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

    • The Project list in Mech-Center ‣ Deployment Settings ‣ Mech-Vision is synced by clicking on sync_icon, and the order of Mech-Vision projects have been adjusted according to actual needs.

      ../../../../_images/prerequisite_16.png
  • Mech-Viz project:

    • Executable

    • Set to autoload

    • Contains a branch_by_msg Task 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_12.png
  2. A window saying “Execute the function below when mode is changed.” will pop up. Click OK in the window.

    ../../../../_images/test_vision_22.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_32.png
  4. Click icon_line in 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_42.png
  5. Set Mech-Vision project ID: set the port value of Vision_Proj_Num to 1, and Mech-Vision project No. 1 in the Project list of Mech-Center 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 image-capturing pose type 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_52.png
    ../../../../_images/test_vision_62.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 in 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_72.png
  10. Set Mech-Vision project ID: set the port value of Vision_Proj_Num to 1, and Mech-Vision project No. 1 in the Project list of Mech-Center 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_81.png
  12. Click the icon_program_change Online Program Change icon in the toolbar.

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

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

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

    ../../../../_images/test_vision_121.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_13.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_14.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 Trouble Shooting for troubleshooting.

    ../../../../_images/test_vision_15.png
    ../../../../_images/test_vision_16.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_17.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_18.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 in 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_12.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_22.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 in 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_32.png
    ../../../../_images/test_viz_42.png
    ../../../../_images/test_viz_52.png
  4. Set the image-capturing pose type 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_62.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 Task 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_72.png
  9. Set the pose type of the obtained targets: set the port value of Request_Pose_Type to 1, and Mech-Viz will return targets 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_82.png
  12. Click the icon_program_change Online Program Change icon in the toolbar.

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

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

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

    ../../../../_images/test_viz_121.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 target data. Then click OFF to reset the value.

    ../../../../_images/test_viz_13.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_14.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_15.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 Trouble Shooting for troubleshooting.

    ../../../../_images/test_viz_16.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_17.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 Trouble Shooting for troubleshooting.

    ../../../../_images/test_viz_18.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_19.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 the global label MM_Camera.Target_Pose, and the JPs of the targets in the path will be returned.

    ../../../../_images/test_viz_20.png