Communication Configuration and Example Program Usage

You are viewing an old version of the documentation. You can switch to the documentation of the latest version by clicking the top-right corner of the page.

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 the Mech-Mind Vision System.

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-Vision & Mech-Viz versions: 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 Communication Component/Robot_Interface/Modbus TCP/MITSUBISHI Q serial in the installation directory where Mech-Vision and Mech-Viz are installed. Please copy and paste the example programs to a PC with GX Works2 installed.

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 click View network status and tasks.

    set ip1
  2. In the “Network and Sharing Center” window, click Change adapter settings.

    set ip2
  3. In the “Network Connections” window, double-click the Ethernet interface connected to the PLC, and select Properties in the pop-up Ethernet Status window.

    set ip3
  4. In the Ethernet Properties window, select Networking in the menu bar, and double-click Internet Protocol Version 4(TCP/IPv4).

    set ip4
  5. In the Internet Protocol Version 4 (TCP/IPv4) window, select “Use the following IP address”, and 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 ip5

Set up “Robot Communication Configuration”

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

  2. In the Robot Communication Configuration window, complete the following configurations.

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

    2. In the Communication mode area, select Standard Interface for Interface service type, MODBUS TCP Slave for Protocol, and CDAB for Byte order. Set the Slave ID to 255.

    3. Set the port number to 2000 for the host IP address.

    4. (Optional) Select Auto enable interface service when opening the solution.

    5. Click Apply.

      modbus tcp q series
  3. On the main interface of Mech-Vision, make sure that the Robot Communication Configuration switch on the toolbar is flipped and turned to blue.

    interface service

Create and Configure the PLC Project

Create a PLC Project

  1. Open GX Works2, and click the New icon 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.

    create plc 1
  2. Go to Navigation  Connection Destination  Current Connection, and double-click Connection1.

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

    create plc 3
  4. In the pop-up window, select USB and click Yes.

    create plc 4
  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.

    create plc 5
  6. Click Online in the menu bar and then select Remote Operation.

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

    create plc 7
  8. A message saying that “The operation(STOP) has been completed” will pop up. Select OK in the window.

    create plc 8
  9. Click Close in the Remote Operation window and go back to the main interface of GX Works2.

    create plc 9

Configure Communication Parameters of Modbus TCP

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

    configure plc 1
  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. Then, a Built-in Ethernet Port Open Setting window will pop up.

    configure plc 2
  3. In the pop-up window, configure the parameters on the first line as shown in the figure below. Then, click End and return to the Q Parameter Setting window, and then click End to return to the main interface of GX Works2.

    configure plc 3
  4. In the GX Works2 software window, 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.

    configure plc 4
  5. 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.

    configure plc 5
  6. In the Predefined Protocol Support Function-Built-in Ethernet window, click the Write to Module icon.

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

    configure plc 7
  8. A message saying “Writing to target memory completed.” will pop up if the writing has been completed successfully. Click OK in the window.

    configure plc 8

Import Mech-Mind Example Programs

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. In the toolbar, navigate to Project  Library  Install.

    import file 1
  2. 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.

    import file 2
  3. In the Import Library to Project window, click Refresh FB List. In the Select FB to install area, select all items in the FB List, and then click OK.

    import file 3
  4. 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.

    import file 4
  5. In the GX Works2 software window, go to Tool  Device/Label Automatic-Assign Setting.

    import file 5
  6. In the pop-up window, modify the Assignment Range of Word Device D, and then click OK.

    import file 6
  7. Select Yes in the pop-up window to continue, and return to the GX Works2 software window.

    import file 7

Build Program and Download to PLC

  1. In GX Works2, expand the Program Setting in the Navigation, drag the MAIN under No Execution Type to Scan Program. Then double-click Program.

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

    download configuration 2
  3. Click the Horizontal Line icon in the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.

    download configuration 3
  4. Click the Rebuild All icon in the toolbar.

    download configuration 4
  5. In the pop-up window asking “Are you sure you want to Rebuild All?”, click Yes.

    download configuration 5
  6. Click the Write to PLC icon in the toolbar.

    download configuration 6
  7. An Online Data Operation window will pop up. Select Write, click Parameter+Program, and click Execute.

    download configuration 7
  8. Click Yes in the pop-up window as shown below.

    download configuration 8
  9. Select Yes to all for “Are you sure you want to overwrite the existing file?”.

    download configuration 9
  10. In the Write to PLC window, when “Write to PLC: Completed” appears in the panel, click Close.

    download configuration 10
  11. Click Online in the menu bar and select Remote Operation.

    download configuration 11
  12. In the Remote Operation window, select RUN as the Operation type, and click Execute.

    download configuration 12
  13. A message saying “Do you want to execute the operation(RUN)” will pop up. Select Yes in the window.

    download configuration 13
  14. A message saying “The operation(RUN) has been completed.” will pop up. Select OK in the window.

    download configuration 14
  15. Click Close in the Remote Operation window and go back to the main interface of GX Works2.

    download configuration 15

Check Communication

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

    establish communication 1
  2. Click Yes in the pop-up window as shown below.

    establish communication 2
  3. Double-click 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.

    establish communication 3
  4. The PLC is successfully connected if the following message is displayed in the Console tab of Mech-Vision Log panel: client connected. If you don’t see this log message, please check if:

    1. If the hardware is properly connected;

    2. If the Interface Service has been started successfully in Mech-Vision;

    3. If the PLC program has been successfully downloaded to the PLC.

Test with Mech-Vision/Mech-Viz Project

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.

Prerequisites

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

  2. Mech-Viz project: Right-click the project name in Resources in 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.

    preparation 4

Run Mech-Vision Project and Obtain Vision Points

Configure Programs

  1. In GX Works2, under the Navigation/Project, click the Monitor (Write Mode) icon in the toolbar.

    test vision 1
  2. A window saying “Execute the function below when mode is changed.” will pop up. Click OK in the window.

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

    test vision 3
  4. Click Horizontal Line icon in the toolbar. Click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.

    test vision 4
  5. Set Mech-Vision project ID, namely, the number before the project name in the project list in Mech-Vision. set the port value of Vision_Proj_Num to 1, and project No. 1 in Mech-Vision will run.

  6. Set the number of poses to be sent by Mech-Vision project. 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 value of Robot_Pose_Type to 0 indicates that the project is in the Eye-to-Hand mode, and the image-capturing pose is not needed.

  8. Double-click 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 on the left.

    test vision 5
    test vision 6
  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 Horizontal Line icon in the toolbar, and click OK in the pop-up window to connect the left bus line with the EN1 input port of the FB.

    test vision 7
  10. Set Mech-Vision project ID, namely, the number before the project name in the project list in Mech-Vision. 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.

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

    test vision 8
  12. Click the Online Program Change icon in the toolbar.

    test vision 9
  13. Click OK in the pop-up Confirm Build Method for Online Program Change window.

    test vision 10
  14. Click Yes in the pop-up window as shown below.

    test vision 11
  15. Lastly, click OK to complete downloading the program to PLC.

    test vision 12

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.

    test vision 13
  2. In the pop-up Modify Value window, click ON to trigger the Mech-Vision project to run. Then click OFF to reset the value.

    test vision 14
  3. Right-click 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.

    test vision 15

Obtain Vision Points from Mech-Vision

  1. Select the input variable Camera_User.Get_VisData of MM_Get_VisData FB, and click ON in the pop-up window to obtain vision points. Then click OFF to reset the value.

    test vision 16
  2. Right-click 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. Please refer to Status Codes and Troubleshooting for troubleshooting. Then, enter the global label MM_Camera.Target_Pose, and the pose data of vision points will be returned.

    test vision 17

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 Horizontal Line icon in the toolbar to connect the left bus line with the EN1 input port of the FB.

    test viz 1
  2. Double-click 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.

    test viz 2
  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 Horizontal Line icon in the toolbar to connect the left bus line with the EN1 input port of the FB.

    test viz 3
    test viz 4
    test viz 5
  4. Set the type of pose to be sent by the robot. Setting the value of Robot_Pose_Type to 0 indicates that the project is in the Eye-to-Hand mode, and the image-capturing pose is not needed.

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

    test viz 6
  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. 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 bus line.

    test viz 7
  8. 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).

    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.
  9. Double-click 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.

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

    test viz 8
  11. Click the Online Program Change icon in the toolbar.

    test viz 9
  12. Click OK in the pop-up Confirm Build Method for Online Program Change window.

    test viz 10
  13. Click Yes in the pop-up window as shown below.

    test viz 11
  14. Lastly, click OK to complete downloading the program to PLC.

    test viz 12

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. In the pop-up Modify Value window, click ON to clear the previously obtained vision result. Then click OFF to reset the value.

    test viz 13

    In the Watch1 window, 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.

    test viz 14
  2. In the interface of MAIN, right-click the input variable Camera_User.Start_Viz of MM_Start_Viz FB. In the pop-up Modify Value window, click ON to trigger the Mech-Viz project to run. Then click OFF to reset the value.

    test viz 15
  3. In the Watch1 window, 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.

    test viz 16

Set Mech-Viz Branch Exit Port

  1. In the interface of MAIN, right-click the input variable Camera_User.Set_Branch of MM_Set_Branch FB. In the pop-up Modify Value window, click ON to choose the Mech-Viz branch. Then click OFF to reset the value.

    test viz 17
  2. In the Watch1 window, 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.

    test viz 18

Get Mech-Viz Planned Path

  1. In the interface of MAIN, right-click the input variable Camera_User.Get_VizData of MM_Get_VizData FB. In the pop-up Modify Value window, click ON to obtain the planned path from Mech-Viz. Then click OFF to reset the value.

    test viz 19
  2. Right-click the blank space, select Register to Watch, and enter the global label MM_Camera.Status_Code. If the planned path are obtained successfully, the status code 2100 will be returned. Otherwise, the corresponding error code will be returned. Please refer to Status Codes and Troubleshooting for troubleshooting. Then enter the global label MM_Camera.Target_Pose, and the JPs of the waypoints in the path planned by Mech-Viz will be returned.

    test viz 20

We Value Your Privacy

We use cookies to provide you with the best possible experience on our website. By continuing to use the site, you acknowledge that you agree to the use of cookies. If you decline, a single cookie will be used to ensure you're not tracked or remembered when you visit this website.