Example Program 4: MM_S4_Vis_SwitchRecipe

Program Introduction

Description

The PLC triggers Mech-Vision to switch the parameter recipe, triggers the Mech-Vision project to run, and then obtains the vision result.

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 parameter recipe must be configured beforehand.)

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

The only difference between the MM_S4_Vis_SwitchRecipe example program and the MM_S1_Vis_Basic example program is that MM_S4_Vis_SwitchRecipe can switch the parameter recipe in the Mech-Vision project (Network 5). As such, only the feature of switching the parameter recipe is described in the following part. For information about the parts of MM_S4_Vis_SwitchRecipe that are consistent with those of MM_S1_Vis_Basic, see Example Program 1: MM_S1_Vis_Basic.
sample4 1
sample4 2
sample4 3
sample4 4
sample4 5
sample4 6
sample4 7

The figure below describes the process of the above example program. The feature of switching the parameter recipe in the Mech-Vision project in the above program is shown in the section indicated by the red line in the figure below.

sample4 8

The table below describes the process of switching the parameter recipe in the Mech-Vision project.

  • 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

Switch the Mech-Visionparameter recipe and determine the subsequent operations based on whether the recipe is switched successfully

sample4 5
  • "Camera_User".Switch_Recipe: The flag that triggers the parameter recipe in the Mech-Vision project to be switched when a rising edge occurs.

  • "Camera_User".Status_Code_Error[10]: A vision system status code exception flag. True indicates that the parameter recipe in the Mech-Vision project failed to be switched, which means that the vision system is abnormal.

For more information about input and output parameters in MM_Switch_Recipe, see MM_Switch_Recipe.

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

  1. MM_Switch_Recipe is enabled. In this case, the parameter recipe ID is 1 (Vision_Recipe_Num is set to 1) by default. You can modify the ID based on actual scenarios.

  2. When "MM Interface".FromCamera."Trigger Acknowledge" is set to False and "Camera_User".Status_Code_Error[10] is set to False, "Camera_User".Switch_Recipe is set and the PLC triggers the Mech-Vision project to switch the parameter recipe.

  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[10] is set and "Camera_User".Switch_Recipe 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 1107, 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 5 is assigned to "Camera_User".Step_Num, and "Camera_User".Switch_Recipe and "Camera_User".Status_Code_Error[10] are reset.

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.