Example program 2: MM_S2_Viz_Basic

You are currently viewing the documentation for the latest version (2.1.0). 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

You can find the program file by using the Communication Component/Robot_Interface/Siemens Snap7/TIA Portal/sample applications/SampleProjectSnap7.zip path in the installation directory of Mech-Vision and Mech-Viz.

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 functions of Siemens S7 Series PLC, you can click the hyperlink to the function name in the following explanation to view the detailed description of the function.

  • For common functions that come with Siemens S7 Series PLC, see Common Functions.

Feature Description

Initialize the parameters

sample2 1
  • "MM Interface".FromCamera."Status Code": A vision system status code.

  • P_TRIG: Detect the signal rising edge for the logical operation result ("MM Interface".FromCamera."Status Code" equals 0).

  • 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 "MM Interface".FromCamera."Status Code" equals 0 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 function. 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 function. In this example, the joint positions of J1 to J6 of the robot are set to 1.0, 2.0, 3.0, 4.0, 5.0, and 6.0 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 function).

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 1.0, 2.0, 3.0, 4.0, 5.0, and 6.0 sequentially.

Trigger external image capturing

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

  • "MM Interface".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. "MM Interface".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. "MM Interface".FromCamera."Status Code" equals 2100.

  3. An error is reported when an image is captured at the next time. "MM Interface".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 Interface".FromCamera."Trigger Acknowledge" is set to False and "Camera_User".Status_Code_Error[0] is set to False, "Camera_User".Start_Viz is set and the PLC triggers the Mech-Viz project to run.

  3. If the value of "MM Interface".FromCamera."Status Code" is greater than or equal to 2001 and less than or equal to 2099, an exception occurred in the vision system. In this case, after the rising edge for the logic output is obtained by using the P_TRIG function, "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 the value of "MM Interface".FromCamera."Status Code" is 2103, the vision system has successfully executed the function sent by the PLC. In this case, the P_TRIG function is called to retrieve the rising edge for the logical output, a value of 10 is assigned to "Camera_User".Step_Num, and "Camera_User".Start_Viz and "Camera_User".Status_Code_Error[0] are reset.

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 Interface".FromCamera."Trigger Acknowledge" is set to False and "Camera_User".Status_Code_Error[1] is set to False, "Camera_User".Get_VizData is set and the PLC starts to obtain planned path output by the Mech-Viz project.

  3. If the value of "MM Interface".FromCamera."Status Code" is greater than or equal to 2001 and less than or equal to 2099, an exception occurred in the vision system. In this case, after the rising edge for the logic output is obtained by using the P_TRIG function, "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 the value of "MM Interface".FromCamera."Status Code" is 2100, the vision system has successfully executed the function sent by the PLC. In this case, "Camera_User".Get_VizData and "Camera_User".Status_Code_Error[1] are reset. The P_TRIG function is called to retrieve the rising edge for the logical output ("MM Interface".FromCamera."Status Code" equals 2100), a value of 0 is assigned to "Camera_User".Step_Num, and a value of 1 is assigned to "Camera_Pose_Ready". This indicates that the PLC has obtained the planned path of Mech-Viz and can forward the planned path to the robot.

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.