EtherNet/IP–KEYENCE PLC Functions

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.

This topic introduces the functions for EtherNet/IP communication between a KEYENCE PLC and the Mech-Mind Vision System.

Function Descriptions

Start Mech-Vision Project

This function is used for applications that use Mech-Vision. It runs the corresponding project to acquire and process data. It applies for applications that use Mech-Vision but not Mech-Viz.

start mech vision 1

Variables

INPUT:

  • Vision_Proj_Num: Mech-Vision project ID, which is the number before the project name in the Project List panel in Mech-Vision.

  • Req_Pose_Num: The number of vision points that Mech-Vision is requested to send, from 1 to 20, where 0 indicates “send all”.

  • Robot_Pose_Type: The type of robot pose to input to Mech-Vision. The value range is 0 to 3.

  • Robot_Pose: The pose received from the robot, value depends on the value of Robot_Pose_Type. Data type: two-dimensional array [0..1, 0..5] of DInt, array[0] is joint positions and array[1] is flange pose.

The following table explains the relationship between Robot_Pose_Type and Robot_Pose.

Robot_Pose_Type value Robot_Pose value Description Applicable Scenarios

0

0, 0, 0, 0, 0, 0

No need to input robot pose to Mech-Vision

Project is in the eye-to-hand mode. If the “Path Planning” Step is used in the Mech-Vision project, the planned path starts at the Home point set in the path planning tool.

1

Current joint positions and flange pose of the robot

Robot joint positions and flange pose must be input to Mech-Vision

Project is in the eye-in-hand mode. Applicable to most robots (excluding truss robots).

2

Current flange pose of the robot

Robot flange pose must be input to Mech-Vision

Project is in the eye-in-hand mode. The robot has no joint positions and only flange pose (such as truss robots).

3

Joint positions of the start point of the planned path

The joint positions of the path start point must be input to Mech-Vision

Project is in the eye-to-hand mode and the Mech-Vision project contains the “Path Planning” Step, whose start point needs to be set from the robot side.

Before assigning to the Robot_Pose array, multiply the floating-point numbers that represent joint positions or the robot flange pose by 10000 to convert the data to 32-bit signed integers.
  • Start_Vision: Trigger Mech-Vision project to start when a rising edge occurs.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: If the project is started successfully, the status code 1102 will be returned. Otherwise, the corresponding error code will be returned.

Example

start mech vision 2

Example Description

When Camera_User.Start_Vis is at the rising edge, this example runs Mech-Vision project No.1, asks the Mech-Vision project to send over 1 vision point, and sends the robot joint positions when the Mech-Vision project is started as the image-capturing pose to the vision system.

Get Vision Target(s)

This function is for applications that use Mech-Vision but not Mech-Viz. It obtains the vision result from the corresponding Mech-Vision project.

get mech vision data 1

Variables

INPUT:

  • Vision_Proj_Num: Mech-Vision project ID, which is the number before the project name in the Project List panel in Mech-Vision.

  • Get_VisData: Obtain vision points from Mech-Vision project when a rising edge occurs.

  • Data_Ready: Indicates the pose data is readable when receiving multiple sets of robot pose data.

  • Send_Pose_Num: The number of poses to be sent, from 0 to 20.

  • Start_Empty: Clear the obtained data stored in Target_Pose and Target_Label. This variable will take effect when it is set to 1.

OUTPUT:

  • Target_Pose: The vision pose. The data type is array[0..19, 0..5] of DInt. This array should be divided by 10000 before being used.

  • Target_Label: The label information of the object recognized by Mech-Vision. The data type is array[0..19] of UDInt. The returned values are integers.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: If the vision points are obtained successfully, the status code 1100 will be returned. Otherwise, the corresponding error code will be returned.

  • FromCamera.SEND_POSE_TYPE: The returned value is 2, which suggests that the type of poses obtained via MM_Get_VisData is always in TCP.

Example

get mech vision data 2

Example Description

When there is a rising edge on the variable Camera_User.Get_VisData, vision points of Mech-Vision project No. 1 will be obtained. When Camera_User.Start_Empty is set to 1, data stored in Camera_User.Target_Pose and Camera_User.Target_Label will be cleared.

Switch Mech-Vision Recipe

This function specifies which parameter recipe of the Mech-Vision project to use. Parameter recipes can be used to switch parameter settings, including point cloud model for matching, ROI, confidence threshold, etc, in the same Mech-Vision project when it is used to recognize different workpieces. This function must be used BEFORE MM_Start_Vis.

set formula 1

Variables

INPUT:

  • Vision_Proj_Num: Mech-Vision project ID, which is the number before the project name in the Project List panel in Mech-Vision.

  • Vision_Recipe_Num_O: The ID of a parameter recipe in the Mech-Vision project, from 1 to 99.

  • Switch_Recipe: Switch the parameter recipe when a rising edge occurs.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: If the parameter recipe is switched successfully, the status code 1107 will be returned. Otherwise, the corresponding error code will be returned.

Example

set formula 2

Example Description

When there is a rising edge on the variable Camera_User.Switch_Recipe, the parameter recipe will be switched to No. 2 in Mech-Vision project No. 1.

Get Result of Step “Path Planning” in Mech-Vision

After calling MM_Start_Vis, call this function to obtain the collision-free picking path planned by the “Path Planning” Step in the Mech-Vision project.

When using this function, set the Port Type parameter of the “Output” Step in the Mech-Vision project to “Predefined (robot path)”.

Before executing this function, please set Req_Pose_Num in MM_Start_Vis to 0 to reduce the times of execution of this function. If Req_Pose_Num in MM_Start_Vis is set to 1, then every time this function is executed, only 1 waypoint is returned, and this function must be executed multiple times to obtain all the waypoints.
get planned visdate 1

Variables

INPUT:

  • Vision_Proj_Num: Mech-Vision project ID, which is the number before the project name in the Project List panel in Mech-Vision.

  • Request_Pose_Type: This parameter specifies the type of waypoint poses returned by the “Path Planning” Step.

    • 1: The waypoint poses are returned in the form of joint positions (JPs).

    • 2: The waypoint poses are returned in the form of tool center point (TCP).

  • Get_VisData: Obtains the planned path from the “Path Planning” Step in Mech-Vision at the rising edge.

  • Data_Ready: Indicates the pose data is readable when receiving multiple sets of robot pose data.

  • Send_Pose_Num: The number of poses to be sent, from 0 to 20.

  • Start_Empty: Clear the obtained data stored in Camera_User.Target_Pose, Camera_User.Target_Label and Camera_User.Target_Tool_ID.This variable will take effect when it is set to 1.

OUTPUT:

  • Target_Pose: The waypoint pose in TCP. The data type is array[0..19, 0..5] of DInt. This array should be divided by 10000 before being used.

  • Target_Label: The label information of the object recognized by Mech-Vision. The data type is Array[0..19] of UDInt. The returned values are integers.

  • Target_Tool_ID: The tool ID specified in the path planning tool.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: If the planned path is obtained successfully, the status code 1103 will be returned. Otherwise, the corresponding error code will be returned.

  • FromCamera.SEND_POSE_TYPE: The pose type of the waypoint, which is consistent with that of the Request_Pose_Type input parameter. 1 indicates JPs, while 2 indicates TCP.

  • FromCamera.VISUAL_POINT_INDEX: The position of the Vision Move Step in the entire robot motion path.

Example

get planned visdate 2

Example Description

When there is a rising edge on the variable Camera_User.Get_VisData, the path planned by the Mech-Vision project No.1 will be obtained in the form of joint positions. When Camera_User.Start_Empty is set to 1, data stored in Camera_User.Target_Pose, Camera_User.Target_Label, and Camera_User.Target_Tool_ID will be cleared.

Start Mech-Viz Project

This function is for applications that use both Mech-Vision and Mech-Viz. It runs the corresponding Mech-Viz project (which triggers the corresponding Mech-Vision project to run), and then plans the path for picking.

start mech viz 1

Variables

INPUT:

  • Robot_Pose_Type: The robot pose type specifies the type of the pose of the real robot to be input to the Mech-Viz project. The value range is from 0 to 2.

  • Robot_Pose: The pose received from the robot, value depends on the value of Robot_Pose_Type. Data type: two-dimensional array [0..1, 0..5] of DInt, array[0] is joint positions and array[1] is flange pose.

The following table explains the relationship between Robot_Pose_Type and Robot_Pose.

Robot_Pose_Type value Robot_Pose value Description Applicable Scenarios

0

0, 0, 0, 0, 0, 0

No need to input the robot pose to Mech-Viz. The simulated robot in Mech-Viz moves from the initial pose JPs = [0, 0, 0, 0, 0, 0] to the first waypoint.

Project is in the eye-to-hand mode. This setting is not recommended.

1

Current joint positions and flange pose of the robot

Robot joint positions and flange pose must be input to Mech-Viz. The simulated robot in Mech-Viz moves from the input JPs to the first waypoint.

This setting is recommended for projects in the eye-in-hand mode.

2

Specific joint positions of the robot

The robot joint positions of a point determined by teaching must be input to Mech-Viz. The input joint positions are used to trigger Mech-Viz to plan the next path in advance while the robot is not in the camera capture region, as shown below. The simulated robot in Mech-Viz moves from the input joint positions to the first waypoint.

This setting is recommended for projects in the eye-to-hand mode.

The reason for setting Robot_Pose_Type to 2 when the project is in the eye-to-hand mode:

In the eye-to-hand mode, the camera can perform image capturing for the next round of path planning before the robot returns to the camera capture region and picking region, shortening the cycle time. If Robot_Pose_Type is set to 1, the robot’s current pose is sent to Mech-Viz. The simulated robot will move from the input pose to the first waypoint in the planned path, while the real robot might move to another point first, and then move to the first waypoint. Therefore, the path of the real robot may contain unpredicted collisions, leading to safety hazards. In conclusion, Robot_Pose_Type should be set to 2 for projects in the eye-to-hand mode.

robot example
Before assigning to the Robot_Pose array, multiply the floating-point numbers that represent joint positions or the robot flange pose by 10000 to convert the data to 32-bit signed integers.
  • Start_Viz: Trigger Mech-Viz project to start when a rising edge occurs.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: If the Mech-Viz project is started successfully, the status code 2103 will be returned. Otherwise, the corresponding error code will be returned.

Example

start mech viz 2

Example Description

When the variable Camera_User.Start_Viz is at the rising edge, this example runs the corresponding Mech-Viz project, and sends the current joint positions of the robot to the vision system.

Stop Mech-Viz Project

This function is used to stop Mech-Viz project. Please use this function only when there is an infinite loop in the Mech-Viz project or the project cannot be stopped properly.

stop mech viz 1

Variables

INPUT:

  • Stop_Viz: Stop the execution of the Mech-Viz project at the rising edge.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE:If the Mech-Viz project is stopped successfully, the status code 2104 will be returned. Otherwise, the corresponding error code will be returned.

Example

stop mech viz 2

Example Description

When there is a rising edge on the variable Camera_User.Stop_Viz, Mech-Viz project will be stopped.

Select Mech-Viz Branch

This function is used to select along which branch the Mech-Viz project should proceed. Such branching is achieved by adding Branch by Msg Step(s) to the project. This function specifies which exit port such Step(s) should take. MM_Start_Viz should be called BEFORE this subprogram. When executing the “Branch by Msg” Step, Mech-Viz waits for the exit port No. sent by Function 203.

set branch 2

Variables

INPUT:

  • Branch_Name: Step ID of the Branch by Msg Step, which is a positive integer.

  • Branch_Exit_Port: The number of the exit port to take, from 1 to 99.

  • This parameter value should be 1 greater than the exit port number displayed in the Mech-Viz Step. For example, the port 0 displayed in the interface corresponds to Branch_Exit_Port 1.

  • Branch_Name, Branch_Exit_Port, and Index_Name and Index_Counter in the function MM_Set_Index correspond to the same VIZ_TASK_NAME and VIZ_TASK_VALUE tags in the ToCamera struct respectively. If the set values are different, they cannot take effect at the same time.

  • Set_Branch: Specify the port which Branch by Msg Step should take.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: If the branch is set successfully, the status code 2105 will be returned. Otherwise, the corresponding error code will be returned.

Example

set branch 3

Example Description

When there is a rising edge on the variable Camera_User.Set_Branch, Mech-Viz will take exit port 1 for the Branch by Msg Step whose Step ID is 1.

Set Move Index

This function sets the value for the Current Index parameter of Steps. Steps that have this parameter include Move by List, Move by Grid, Custom Pallet Pattern, and Smart Pallet Pattern. MM_Start_Viz must be called BEFORE this function.

set index 2

Variables

INPUT:

  • Index_Name: The ID of the Step, an integer.

  • Index_Counter: The parameter’s value should be the current index value in Mech-Viz plus 1. The index value that should be set the next time this Step is executed. When this function is sent, the current index value in Mech-Viz will become the parameter value minus 1. When the Mech-Viz project runs to the Step specified by this function, the current index value in Mech-Viz will be increased by 1 to become the parameter’s value.

    Index_Name, Index_Counter, and Branch_Name and Branch_Exit_Port in the function MM_Set_Index correspond to the same VIZ_TASK_NAME and VIZ_TASK_VALUE tags in the ToCamera struct respectively. If the set values are different, they cannot take effect at the same time.
  • Set_Index: The trigger signal to set the index. The rising edge does the trigger.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: If the index is set successfully, the status code 2106 will be returned. Otherwise, the corresponding error code will be returned.

Example

set index 3

Example Description

When there is a rising edge on the variable Camera_User.Set_Index, the Current Index value for the Step whose Step ID is 5 will be set to 4. When the Step is executed, the Current Index value will be added 1 and become 5.

Get Planned Path

This function obtains the planned path from Mech-Viz.

get mech viz date 1

Variables

INPUT:

  • Request_Pose_Type: Pose type of the waypoints to be obtained.

    • 1: The pose type returned by Mech-Viz is joint positions.

    • 2: The pose type returned by Mech-Viz is TCPs.

  • Get_VizData: Obtain planned path from Mech-Viz project when a rising edge occurs.

  • Data_Ready: Indicates the pose data is readable when receiving multiple sets of robot pose data.

  • Send_Pose_Num: The number of waypoints returned by Mech-Viz, from 0 to 20.

  • Start_Empty: Clear the obtained data stored in Target_Pose, Target_Label, and Target_Tool_ID.This variable will take effect when it is set to 1.

OUTPUT:

  • Target_Pose: The vision pose. The data type is array[0..19, 0..5] of DInt. This array should be divided by 10000 before being used.

  • Target_Label: The label information of the object recognized by Mech-Vision. The data type is array[0..19] of UDInt. The returned values are integers.

  • Target_Tool_ID: The tool ID specified in the Mech-Viz project.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: If the planned path is obtained successfully, the status code 2100 will be returned. Otherwise, the corresponding error code will be returned.

  • FromCamera.SEND_POSE_TYPE: The pose type of the waypoint, which is consistent with that of the Request_Pose_Type input parameter. 1 indicates JPs, while 2 indicates TCP.

  • FromCamera.VISUAL_POINT_INDEX: The position of the vision point, which is generated from the “Vision Move” Step, in the planned path.

Example

get mech viz date 2

Example Description

When there is a rising edge on the variable Camera_User.Get_VizData, waypoints in TCP of Mech-Viz project will be obtained. When the Camera_User.Start_Emptyvariable is set to 1, data stored in Camera_User.Target_Pose, Camera_User.Target_Label, and Camera_User.Target_Tool_ID will be cleared.

Get DO Signal List

This function obtains the planned DO Signal list for controlling multiple sections of a sectioned vacuum gripper. MM_Get_VizData must be executed BEFORE this function.

Please refer to the suction_zone.viz template in XXXX/Communication Component-xxx/tool/viz_project/suction_zone, and set the suction cup configuration file before calling the function.
get do list 1

Variables

INPUT:

  • Get_DoList: Obtain the planned DO Signal list when a rising edge occurs.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: If the DO Signal list is obtained successfully, the status code 2102 will be returned. Otherwise, the corresponding error code will be returned.

  • FromCamera.DO_LIST: The DO signals returned by Mech-Viz. FromCamera.DO_LIST consists of 8 (0 to 7) bytes. Each byte consists of 8 bits (0 to 7). Therefore, the 0 to 63 bits of FromCamera.DO_LIST correspond to 0 to 63 DO signals. For example, the 0th position in the DO list represents the 0 DO signal. If the value of this position is True, the DO signal is valid. If the value is False, the DO signal is invalid.

Example

get do list 2

Example Description

When there is a rising edge on the variable Camera_User.Get_DoList, the DO signal list planned by Mech-Viz will be stored in DO array.

Input Object Dimensions to Mech-Vision

This function inputs object dimensions to the Mech-Vision project and must be used BEFORE MM_Start_Vis.

read object dimensions 2

Variables

INPUT:

  • Vision_Proj_Num: The Project ID of the Mech-Vision project; you can check the project ID before the project name in the Project List panel in Mech-Vision.

  • External_Input_Box_Dimension: The unit is in mm, for example, the dimensions of a box (length, width, height). Multiply each dimension by 10000 and then assign the results to External_Input_Box_Dimension[0-2].

    External_Input_Box_Dimension here and External_Input_Pose in the function MM_Set_Pose correspond to the same EXT_INPUT_DATA tag of the ToCamera struct. If the set values are different, they cannot take effect at the same time.
  • Set_Box_Dimension: Inputs the object dimensions in the Mech-Vision project dynamically at the rising edge.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: If the object dimensions are set successfully, the status code 1108 will be returned. Otherwise, the corresponding error code will be returned.

Example

read object dimensions 3

Example Description

When there is a rising edge on the variable Camera_User.Set_Box_Dimension, the object dimensions in the Read Object Dimensions Step will be set as the values assigned in External_Input_Box_Dimension[0-2].

Get Software Status

This function is currently capable of checking whether Mech-Vision ready to run projects. In the future, this function can be used for obtaining the software execution status.

get software state 1

Variables

INPUT:

  • Get_Status: Check whether Mech-Vision is ready to run projects at the rising edge.

Returned Data from Variable FromCamera:

  • FromCamera.STATUS_CODE: Software status.

Example

get software state 2

Example Description

When there is a rising edge on the variable Camera_User.Get_Status, the system status code will be returned and stored in the variable FromCamera.STATUS_CODE.

Get Message from Notify Step

After the Mech-Vision or Mech-Viz project is triggered, this function can be called to get message from the “Notify” Step.

When the “Notify” Step is executed in the Mech-Vision or Mech-Viz project, the message remains in the buffer of the vision system for only 1 second. Therefore, users should consider the timing of calling this function to ensure successful message retrieval. Additionally, after the PLC receives the message, the program should trigger the variable ToCamera.CLEAR_NOTIFY to clear the register data.
get notify 1

Variables

INPUT:

  • Get_Notify: Get a message from the “Notify” Step, triggered at a rising edge.

Returned Data from Variable FromCamera:

  • NOTIFY_MSG: The message from the Notify Step, which is an integer.

Example

For example, the message set in the “Notify” Step is 777, and the PLC is obtaining a message in the automatic mode.

get notify 2

Example Description

In this example, when Camera_User.Step_Num is set to 3 in the automatic mode, the value of FromCamera.NOTIFY_MSG is not 777. After the MM_Get_Custom_Notify function is enabled, when the Camera_User.Get_Notify variable is at the rising edge, the program retrieves the message from the “Notify” Step. If the message retrieval was successful, the value of FromCamera.NOTIFY_MSG changes to 777. Otherwise, if the value remains unchanged, the PLC will prompt an error after 3 seconds.

Appendix

Description of the Status Codes

Please refer to Status Codes and Troubleshooting for detailed information.

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.