Example Program 3: MM_S3_Vis_Path

Program Introduction

Description

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

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 project

The Mech-Vision project should contain a Path Planning Step, and the Port Type parameter of the Output Step should be set to Predefined (robot path).

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_S3_Vis_Path example program.

sample1 1
sample1 2
sample1 3
sample3 4
sample1 5
sample3 6

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

sample3 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

sample1 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-Vision was calculating the planed 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

sample1 2
  • "Camera_User".Status_Code_Error[0]: A vision system status code exception flag. True indicates that the Mech-Vision 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-Vision 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-Vision project

sample1 3
  • "User_Vision_Project_Num": The Mech-Vision project ID.

  • "User_Robot_Pose_Type": Specify the pose type of the real robot to input to the Mech-Vision 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 0. You can modify the value as needed.

  • "Camera_User".Robot_Pose[0,0]\~[0,5]: Six pieces of joint position data of the robot. This value of this parameter should be set as the value of Robot_Pose[0,0]~[0,5] of the MM_Start_Vis function. In this example, the parameter value is 0.0. You can modify the value as needed and add the robot flange pose data, i.e., the value of the Robot_Pose[1,0]~[1,5] parameter in the MM_Start_Vis function.

As such, in Network 3, Mech-Vision project ID is set to 1 and "User_Robot_Pose_Type" is set to 0. If the Mech-Vision project ID is set to 1 and "User_Robot_Pose_Type" is set to 0, "Camera_User".Robot_Pose[0,0]~[0,5] are set to 0.0 sequentially.

Trigger external image capturing

sample3 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. 1102 indicates that the PLC successfully triggered the Mech-Vision project to run. 1103 indicates that the PLC successfully obtained the planned path.

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

  • "Camera_User".Get_VisData: The flag that triggers the retrieval of Mech-Vision 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 1103.

  3. An error is reported when an image is captured at the next time. "MM Interface".FromCamera."FromCamera.STATUS_CODE does not equal 1103, 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_Vis and "Camera_User".Get_VisData are reset, and "Camera_Pose_Ready" is set to 0.

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

sample1 5
For more information about input and output parameters in MM_Start_Vis, see MM_Start_Vis.

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

  1. MM_Start_Vis is enabled. In this case, Req_Pose_Num is set to 0, which means all waypoints are obtained. The maximum number of waypoints is 20.

  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_Vis is set and the PLC triggers the Mech-Vision project to run.

  3. If the value of "MM Interface".FromCamera."Status Code" is greater than or equal to 1001 and less than or equal to 1099, 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_Vis 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 1102, 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_Vis and "Camera_User".Status_Code_Error[0] are reset.

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

sample3 6
For more information about input and output parameters in MM_Get_Planned_VisData, see MM_Get_Planned_VisData.

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

  1. MM_Get_Planned_VisData 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_VisData is set and the PLC starts to obtain planned path output by the Mech-Vision project.When "

  3. Trigger Acknowledge" is set to False and "Camera_User".Status_Code_Error[1] is set to False, "Camera_User".Get_VisData is set and the PLC starts to obtain planned path output by the Mech-Vision project.If the value of "MM Interface"FromCamera."Status Code" is greater than or equal to 1001 and less than or equal to 1099, 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_VisData 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 1103, the vision system has successfully executed the function sent by the PLC. In this case, "Camera_User".Get_VisData 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 1103), 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 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.