Establish the communication between PLC and the vision system |
-
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 vision result. Valid values:
-
0: The PLC did not obtain the vision result when the camera was about to capture images or had already captured images, or when Mech-Vision was calculating the vision result.
-
1: The camera captured images, and the PLC obtained the vision result.
-
2: The camera was ready to start capturing images for the first time, and the PLC did not obtain the vision result.
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 |
-
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 vision result, 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-Vision project |
-
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 consistent with 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.
Therefore, Rung 2 indicates that the Mech-Vision project ID is set to 1, and User_Robot_Pose_Type is set to 0.
-
Camera_User.Robot_Pose_JPS[0] to [5]: Six pieces of joint position data of the robot. This value of this parameter should be consistent with the value of Robot_Pose_JPS of the MM_Start_Vis function. In this example, the parameter value is 0. You can modify the value as needed and add the robot flange pose data, i.e., the value of the Robot_Pose_TCP parameter in the MM_Start_Vis function.
Therefore, Rung 3 indicates that if Mech-Vision project ID is set to 1 and User_Robot_Pose_Type is set to 0, Camera_User.Robot_Pose_JPS[0] to Camera_User.Robot_Pose_JPS[5] will be set to 0.
|
Trigger external image capturing |
-
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. 1102 indicates that the PLC successfully triggered the Mech-Vision project to run. 1100 indicates that the PLC successfully obtained the vision result.
-
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_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 vision result 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.
-
An image is captured for the first time. FromCamera.STATUS_CODE is set to 0, and Camera_Pose_Ready is set to 2.
-
An image is captured normally at the next time. FromCamera.STATUS_CODE is set to 1100, and FromCamera.COMMAND_COMPLETE is set to True.
-
An error is reported when an image is captured at the next time. FromCamera.STATUS_CODE is not equal to 1100, 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_Vis and Camera_User.Get_VisData are reset.
|
Trigger the Mech-Vision project to run and determine whether the project is triggered successfully for different processing |
|
For more information about input and output parameters in MM_Start_Vis, see MM_Start_Vis.
|
Rung 5 indicates that if Camera_User.Step_Num is set to 5, the following operations are performed.
-
Enable MM_Start_Vis. In this case, Req_Pose_Num is set to 0, which means all vision points are obtained. The maximum number of vision points is 20.
-
When MM_Start_Vis.EnableOut is set to True and FromCamera.TRIGGER_ACKNOWLEDGE is set to False, reset Camera_User.Start_Vis and the PLC triggers the Mech-Vision project to run.
-
If the value of FromCamera.STATUS_CODE is greater than or equal to 1001 and less than or equal to 1099, 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[0] and reset Camera_User.Start_Vis. For information about the cause of a specific status code, see Standard Interface status codes and error codes.
-
If the value of FromCamera.STATUS_CODE is 1102 and FromCamera.COMMAND_COMPLETE is set to True, the vision system has successfully executed the function sent by the PLC. In this case, the ONS function retrieves the rising edge for the logical output, assigns a value of 10 to Camera_User.Step_Num, and then resets Camera_User.Status_Code_Error[0] and Camera_User.Start_Vis.
|
Obtain the vision result of the Mech-Vision project and determine whether the vision result is obtained successfully for different processing |
|
For more information about input and output parameters in MM_Get_VisData, see MM_Get_VisData.
|
Rung 6 indicates that if Camera_User.Step_Num is set to 10, the following operations are performed.
-
Enable MM_Get_VisData.
-
When MM_Get_VisData.EnableOut is set to True and FromCamera.TRIGGER_ACKNOWLEDGE is set to False, reset Camera_User.Get_VisData and the PLC starts to obtain vision result output by the Mech-Vision project.
-
If the value of FromCamera.STATUS_CODE is greater than or equal to 1001 and less than or equal to 1099, 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.Start_Vis. For information about the cause of a specific status code, see Standard Interface status codes and error codes.
-
If FromCamera.STATUS_CODE is set to 1100 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_VisData. Retrieve the rising edge on the logical output by using the ONS function when FromCamera.STATUS_CODE equals 1100 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 vision result and can forward the vision result to the robot.
|