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 navigate to the installation directory of Mech-Viz and Mech-Viz and find the file by using the Communication Component/Robot_Interface/EthernetIP/Programming Samples/AB PLC EthernetIP/sample applications/ExportedRoutineOfSampleProjects/MM_S2_Viz_Basic.L5X path.

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
sample2 7

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

sample2 8

The table below explains the above example program.

  • For the Standard Interface functions of AB 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 AB PLC, please refer to Common Functions.

Feature Description

Establish the communication between PLC and the vision system

sample2 1
  • ToCamera.COMM_ENABLE: Specify whether to enable the triggering of the signal. True indicates that the trigger signal will work, and the vision system will receive the function sent by the PLC. False indicates that the vision system will ignore the function sent by the PLC.

  • S:FS: Conducted only during the first scan cycle.

  • MOV: 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.

Therefore, Rung 0 indicates that ToCamera.COMM_ENABLE is reset, and Camera_Pose_Ready is set to 2 in the first scan cycle.

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, reset the succeeding Camera_User.Status_Code_Error[0] and Camera_User.Status_Code_Error[1].

Therefore, Rung 1 indicates that when External_Reset_Camera_Error is triggered, reset Camera_User.Status_Code_Error[0] and Camera_User.Status_Code_Error[1].

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 consistent with the value of Robot_Pose_Type of the MM_Start_Viz function. In this example, the parameter value is 2. You can modify the value as needed.

Therefore, Rung 2 indicates that User_Robot_Pose_Type is set to 2.

sample2 4
  • Camera_User.Robot_Pose_JPS[0] to [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 values of Camera_User.Robot_Pose_JPS[0] to [5] should be consistent with the value of the Robot_Pose_JPS parameter of the MM_Start_Viz function. In this example, the joint positions of robot J1 to 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_TCP parameter in the MM_Start_Viz function).

Therefore, Rung 3 indicates that if User_Robot_Pose_Type is set to 2, Camera_User.Robot_Pose_JPS[0] to Camera_User.Robot_Pose_JPS[5] will be set to 10000, 20000, 30000, 40000, 50000, and 60000.

Trigger external image capturing

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

  • Camera_User.Set_Edge[0]: Obtain the rising edge for External_Photo_Signal by running the ONS function.

  • FromCamera.STATUS_CODE: The 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.

  • FromCamera.COMMAND_COMPLETE: Indicate whether the vision system completed executing the function sent by the PLC. True indicates that the function was executed, while False indicates that the function was not executed.

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

Therefore, Rung 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, as shown in the figure.

  1. An image is captured for the first time. 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. FromCamera.STATUS_CODE is set to 2100, and FromCamera.COMMAND_COMPLETE is set to True.

  3. An error is reported when an image is captured at the next time. FromCamera.STATUS_CODE is not equal to 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_Pose_Ready is set to 0, and Camera_User.Start_Viz and Camera_User.Get_VizData are reset.

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

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

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

  1. Enable MM_Start_Viz.

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

  3. If the value of FromCamera.STATUS_CODE is greater than or equal to 2001 and less than or equal to 2099, an exception occurs in the vision system. In this case, after receiving the rising edge for the logic output by using the ONS function, set Camera_User.Status_Code_Error[0] and reset Camera_User.Start_Viz. For information about the cause of a specific status code, see Standard Interface status codes and error codes.

  4. If the value of FromCamera.STATUS_CODE is 2103 and FromCamera.COMMAND_COMPLETE is set to True, the vision system has successfully executed the function sent by the PLC. In this case, call the ONS function to retrieve the rising edge for the logical output, assign a value of 10 to Camera_User.Step_Num, and then reset Camera_User.Status_Code_Error[0] and Camera_User.Start_Viz.

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

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

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

  1. Enable MM_Get_VizData.

  2. When MM_Get_VizData.EnableOut is set to True and FromCamera.TRIGGER_ACKNOWLEDGE is set to False, reset Camera_User.Get_VizData and the PLC starts to obtain planned path output by the Mech-Viz project.

  3. If the value of FromCamera.STATUS_CODE is greater than or equal to 2001 and less than or equal to 2099, an exception occurs in the vision system. In this case, after retrieving the rising edge for the logic output by using the ONS function, set Camera_User.Status_Code_Error[1] and reset Camera_User.Get_VizData. For information about the cause of a specific status code, see Standard Interface status codes and error codes.

  4. If FromCamera.STATUS_CODE is set to 2100 and FromCamera.COMMAND_COMPLETE is set to True, the vision system has successfully executed the function sent by the PLC. In this case, reset Camera_User.Status_Code_Error[1] and Camera_User.Get_VizData. Retrieve the rising edge on the logical output by using the ONS function when FromCamera.STATUS_CODE equals 2100 and FromCamera.COMMAND_COMPLETE equals True and set Camera_Pose_Ready to 1 and Camera_User.Step_Num to 0. This means that the PLC has obtained the planned path from 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.