Example program 2: MM_S2_Viz_Basic

You are currently viewing the documentation for the latest version (2.1.2). To access a different version, click the "Switch version" button located in the upper-right corner of the page.

■ If you are not sure which version of the product you are currently using, please feel free to contact Mech-Mind Technical Support.

Program Introduction

Description

The PLC triggers the Mech-Viz project to run and then obtains the path planned by Mech-Viz.

File path

The example files are stored in Communication Component/Robot_Interface/PROFINET/Programming Samples/sample applications/SampleProjectProfinet.zip in the directory where Mech-Vision and Mech-Viz are installed.

Project

Mech-Vision and Mech-Viz projects

Prerequisites

This example program is provided for reference only. Before using the program, please modify the program according to the actual scenario.

Program Description

This part describes the MM_S2_Viz_Basic example program.

sample2 1
sample2 2
sample2 3
sample2 4
sample2 5
sample2 6

The figure below describes the process of the above example program.

sample2 7

The table below explains the above example program.

  • For the Standard Interface commands for PROFINET communication in Siemens PLCs, you can click the hyperlink to the command name in the following explanation to view the detailed description of the command.

  • For common commands that come with Siemens S7 Series PLC, see Common Commands.

Feature Description

Establish the communication between PLC and the vision system

sample2 1
  • "CameraIO".MM.ToCamera.COMM_ENABLE: Determine whether communication is enabled. Valid values:

    • False: The communication is disabled. The vision system will ignore the command sent by the PLC.

    • True: The communication is enabled. The vision system will receive the command sent by the PLC.

  • P_TRIG: Detect the rising edge of the logical operation result when "CameraIO".MM.ToCamera.COMM_ENABLE is True.

  • MOVE: Set "Camera_Pose_Ready" to 2.

  • "Camera_Pose_Ready": Indicate whether the PLC obtained the planned path.

    • 0: The PLC did not obtain the planned path when the camera was about to capture images or had already captured images, or when Mech-Viz was calculating the planned path.

    • 1: The camera captured images, and the PLC obtained the planned path.

    • 2: The camera was ready to start capturing images for the first time, and the PLC did not obtain the planned path.

As such, Network 1 indicates that only when "CameraIO".MM.ToCamera.COMM_ENABLE is set to True and P_TRIG detects a rising edge, "Camera_Pose_Ready" is initialized to 2.

Reset vision system status code exception flags

sample2 2
  • "Camera_User".Status_Code_Error[0]: A vision system status code exception flag. True indicates that the Mech-Viz project was not successfully run, i.e., an exception occurred in the vision system.

  • "Camera_User".Status_Code_Error[1]: A vision system status code exception flag. True indicates that the Mech-Viz project failed to output the planned path, i.e., an exception occurred in the vision system.

  • "External_Reset_Camera_Error": An external reset signal. When an exception occurs in the vision system and the signal changes from False to True, the succeeding "Camera_User".Status_Code_Error[0] and "Camera_User".Status_Code_Error[1] are reset.

As such, Network 2 indicates that when "External_Reset_Camera_Error" is conducting, "Camera_User".Status_Code_Error[0] and "Camera_User".Status_Code_Error[1] are reset.

Set interface parameters for the Mech-Viz project

sample2 3
  • "User_Robot_Pose_Type": Specify the pose type of the real robot to input to the Mech-Viz project. This value of this parameter should be set as the value of Robot_Pose_Type of the MM_Start_Vis command. In this example, the parameter value is 2. You can modify the value as needed.

  • "Camera_User".Robot_Pose[0,0] ~ [0,5]: Six pieces of joint position data of the robot. When "User_Robot_Pose_Type" is set to 2, the joint position data is custom joint position data defined at the robot side. The value of "Camera_User".Robot_Pose[0,0]~[0,5] should be set as the value of the Robot_Pose[0,0]~[0,5] parameter in the MM_Start_Viz command. In this example, the joint positions of robot J1~J6 are set to 10000, 20000, 30000, 40000, 50000, and 60000 in sequence. You can modify the value as needed and add the robot flange pose data (that is, the value of the Robot_Pose[1,0]~[1,5] parameter in the MM_Start_Viz command).

As such, Network 3 indicates that if "User_Robot_Pose_Type" is set to 2, "Camera_User".Robot_Pose[0,0]~[0,5] will be set to 10000, 20000, 30000, 40000, 50000, and 60000 sequentially.

Trigger external image capturing

sample2 4
  • "External_Photo_Signal": The external signal to trigger image capturing when a rising edge occurs.

  • "CameraIO".MM.FromCamera.STATUS_CODE: A vision system status code. 2103 indicates that the PLC successfully triggered the Mech-Viz project to run. 2100 indicates that the PLC successfully obtained the planned path from Mech-Viz.

  • "Camera_User".Start_Viz: The flag that triggers the Mech-Viz project to run when the rising edge occurs.

  • "Camera_User".Get_VizData: The flag that triggers the retrieval of Mech-Viz planned path when the rising edge occurs.

As such, Network 4 indicates that the external signal to trigger image capturing when a rising edge occurs is retrieved, and then the following three image capturing operations are performed.

  1. An image is captured for the first time. "CameraIO".MM.FromCamera.STATUS_CODE is set to 0, and "Camera_Pose_Ready" is set to 2.

  2. An image is captured normally at the next time. "CameraIO".MM.FromCamera.STATUS_CODE is set to 2100.

  3. An error is reported when an image is captured at the next time. "CameraIO".MM.FromCamera.STATUS_CODE does not equal 2100, and both "Camera_User".Status_Code_Error[0] and "Camera_User".Status_Code_Error[1] are set to False.

Finally, "Camera_User".Step_Num is set to 5, "Camera_User".Start_Viz and "Camera_User".Get_VizData are reset, and "Camera_Pose_Ready" is set to 0.

Trigger the Mech-Viz project to run and determine whether the project is triggered successfully for different processing

sample2 5
For more information about input and output parameters in MM_Start_Viz, see MM_Start_Viz.

Network 5 indicates that if "Camera_User".Step_Num is set to 5, the following operations are performed.

  1. MM_Start_Viz is enabled.

  2. When "MM_Start_Viz".ENO is set to True and "CameraIO".MM.FromCamera.TRIGGER_ACKNOWLEDGE is set to False, reset "Camera_User".Start_Viz and the PLC triggers the Mech-Viz project to run.

  3. If "CameraIO".MM.FromCamera.STATUS_CODE is between 2001 and 2099 (inclusive), it indicates a vision system error. At this point, the rising edge of this logical output is captured using the P_TRIG command, "Camera_User".Status_Code_Error[0] is set, and "Camera_User".Start_Viz is reset. For information about the cause of a specific status code, see Standard Interface status codes and error codes.

  4. If "CameraIO".MM.FromCamera.STATUS_CODE equals 2103, it means the vision system has successfully executed the command sent by the PLC. At this point, the rising edge of this logical output is captured using the P_TRIG command, "Camera_User".Status_Code_Error[0] and "Camera_User".Start_Viz are reset, and "Camera_User".Step_Num is set to 10.

Obtain the planned path of the Mech-Viz project and determine whether the planned path is obtained successfully for different processing

sample2 6
For more information about input and output parameters in MM_Get_VizData, see MM_Get_VizData.

Network 6 indicates that if "Camera_User".Step_Num is set to 10, the following operations are performed.

  1. MM_Get_VizData is enabled.

  2. When "MM_Get_VizData".ENO is True and "CameraIO".MM.FromCamera.TRIGGER_ACKNOWLEDGE is False, "Camera_User".Get_VizData is set and the PLC begins retrieving the planning path output by the Mech-Viz project.

  3. If "CameraIO".MM.FromCamera.STATUS_CODE is between 2001 and 2099 (inclusive), it indicates a vision system error. At this point, the rising edge of this logical output is captured using the P_TRIG command, "Camera_User".Status_Code_Error[1] is set, and "Camera_User".Get_VizData is reset. For information about the cause of a specific status code, see Standard Interface status codes and error codes.

  4. If "CameraIO".MM.FromCamera.STATUS_CODE equals 2100 and "CameraIO".MM.FromCamera.COMMAND_COMPLETE is True, it means the vision system has successfully executed the command sent by the PLC. At this point, "Camera_User".Status_Code_Error[1] and "Camera_User".Get_VizData are reset. The P_TRIG command is used to capture the rising edge of the logical output when "CameraIO".MM.FromCamera.STATUS_CODE equals 2100 and "CameraIO".MM.FromCamera.COMMAND_COMPLETE is True, "Camera_User".Step_Num is set to 0, and "Camera_Pose_Ready" is set to 1. This indicates that the PLC has received the path planned by Mech-Viz and can now forward the path to the robot for use.

Is this page helpful?

You can give a feedback in any of the following ways:

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.