PROFINET - Siemens SIMATIC S7 PLC Commands

This topic introduces the commands for PROFINET communication between a Siemens SIMATIC S7 PLC and Mech-Mind Software Suite.

Start Mech-Vision Project

This command starts the running of the Mech-Vision project, which executes image capturing, and performs vision recognition.

If the project works in the eye-in-hand mode, the robot pose for image capturing needs to be transmitted by this command into the project.

This command is for scenarios using only Mech-Vision.

../../../../_images/start_vision.png

Command Sent

  • Vision_Proj_Num

    The integer ID number of the Mech-Vision project, displayed in the Project List panel in Mech-Vision. The ID number can be adjusted by dragging the projects.

  • Req_Pose_Num

    The number of vision points (i.e., vision poses and their corresponding point clouds, labels, indices, etc.) to expect Mech-Vision to output.

    • 0: Get all the vision points from the Mech-Vision project’s recognition results.

    • integers > 0: Get the specified number of vision points.

      • If the total number of vision points is smaller than the parameter value, all the available vision points will be returned.

      • If the total number of vision points is greater than or equal to the parameter value, vision points in the quantity of the parameter value will be returned.

    Note

    The command to obtain the vision points is Get Vision Target(s).

  • Robot_Pose_Type

    This parameter indicates the type of pose of the real robot to input to Mech-Vision. The value range is 0–3.

  • Robot_Pose

    This parameter is the robot pose sent to Mech-Vision. Its value depends on Robot_Pose_Type.

    Data format: two-dimensional array [0..1, 0..5] of DINT, array[0] is JPs 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 scenario

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, 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 as the image-capturing pose.

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 as the image-capturing pose.

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.

  • Start_Vision

    Trigger the start of the Mech-Vision project. The rising edge does the trigger.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Start_Vision” in the last scan cycle to prevent unnecessary repetition of triggering.

Data Returned

Returned data from the CameraIO data block FromCamera:

  • Status code

    If there is no error, status code 1102 will be returned. Otherwise, the corresponding error code will be returned.

Example

In this example, when the parameter “Camera_User”.Start_Vis has a rising edge, Mech-Vision project 1 will be triggered and will be expected to return the vision result, and PLC will send the robot JPs and flange pose to Mech-Vision when the Mech-Vision project is started.

../../../../_images/start_vision_example.png

Get Vision Target(s)

This command gets the vision result, i.e., vision points, after executing command 101.

../../../../_images/get_vision_targets.png

Command Sent

  • Vision_Proj_Num

    The integer ID number of the Mech-Vision project, displayed in the Project List panel in Mech-Vision. The ID number can be adjusted by dragging the projects.

  • Get_VisData

    The signal to request the result from the Mech-Vision project. The rising edge does the trigger.

  • Data_Ready

    The signal to indicate the data has newly arrived and can be read.

  • Send_Pose_Num

    The number of targets expected to be returned by executing this command once.

    • 0: Return all the vision targets.

    • 1–20: Return a specified number of vision targets.

    Note

    For using Profinet on Siemens Simatic S7, by default, executing this command once can only fetch at most 20 vision targets. So this command may need to be executed multiple times to get all the vision targets wanted.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Get_VisData” in the last scan cycle to prevent unnecessary repetition of triggering.

  • Data_Ready_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Data_Ready” in the last scan cycle to prevent unnecessary repetition of reading.

Data Returned

  • Target Pose

    The robot waypoint poses (as TCPs) converted from the vision poses of the Mech-Vision project.

    Data type: DINT array of 20*6. The data needs to be divided by 10000 before use.

  • Target Label

    The labels reflecting object info corresponding to the waypoints. The labels are integers.

    Data type: UDINT array of length 20.

Returned data from the CameraIO data block FromCamera:

  • Status code

    If there is no error, status code 1100 will be returned. Otherwise, the corresponding error code will be returned.

  • 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

In this example, when the parameter “Camera_User”.Get_VisData has a rising edge, it is used to get the vision targets from Mech-Vision project 1.

../../../../_images/get_vision_target_example.png

Switch Mech-Vision Recipe

This command switches the parameter recipe used by the Mech-Vision project.

In Mech-Vision, you can change the settings of a group of parameters by switching the parameter recipe.

Parameters involved in recipe switching usually include point cloud matching model, image matching template, ROI, confidence threshold, etc.

This command needs to be used before executing command 101 which starts the Mech-Vision project.

../../../../_images/switch_recipe1.png

Command Sent

  • Vision_Proj_Num

    The integer ID number of the Mech-Vision project, displayed in the Project List panel in Mech-Vision. The ID number can be adjusted by dragging the projects.

  • Vision_Recipe_Num

    The ID number of the parameter recipe to switch to, i.e., the number on the left of the parameter recipe name in Project Assistance ‣ Parameter Recipe ‣ Parameter Recipe Editor in Mech-Vision.

  • Switch_Recipe

    The trigger signal to switch the recipe. The rising edge does the trigger.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Switch_Recipe” in the last scan cycle to prevent unnecessary repetition of triggering.

Data Returned

Returned data from the CameraIO data block FromCamera:

  • Status code

    If there is no error, status code 1107 will be returned. Otherwise, the corresponding error code will be returned.

Example

In this example, when the parameter “Camera_User”.Switch_Recipe has a rising edge, it will switch the recipe of Mech-Vision project 1 to recipe 2.

../../../../_images/switch_recipe_example.png

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

This command is for applications that use Mech-Vision but not Mech-Viz. It obtains the collision-free path planned by the “Path Planning” Step from the corresponding Mech-Vision project.

Note

  • MM_Start_Vis must be executed before this command.

  • The Port Type parameter of the “Procedure Out” Step in the Mech-Vision project must be set to “Predefined (robot path)”.

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

../../../../_images/get_planned_visdate_15.png

Command Sent

  • Vision_Proj_Num

    The integer ID number of the Mech-Vision project, displayed in the Project List panel in Mech-Vision. The ID number can be adjusted by dragging the projects.

  • Request_Pose_Type

    This parameter specifies the type of waypoint poses to return from Mech-Vision.

    • 1: The waypoint poses returned should be in JPs.

    • 2: The waypoint poses returned should be in TCP.

  • Get_VisData

    The trigger signal to obtain the planned path from Mech-Vision. The rising edge does the trigger.

  • Data_Ready

    The signal for indicating the data is newly arrived and can be read when receiving poses multiple times. The rising edge does the trigger.

  • Send_Pose_Num: The number of waypoints returned from Mech-Vision by executing this command this time.

    Default range: 0–20.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Get_VisData” in the last scan cycle to prevent unnecessary repetition of triggering.

  • Data_Ready_Edge:

    This parameter does not need to be set by the user.

    It stores the value of “Data_Ready” in the last scan cycle to prevent unnecessary repetition of reading.

Data Returned

  • Target_Pose:

    Obtained pose data (TCP) of waypoints.

    Data type: DINT array of 20*6.

    The data needs to be divided by 10000 before use.

  • Target_Label:

    Obtained label data of waypoints.

    Data type: UDINT array of length 20.

  • Speed_Percentage:

    Obtained velocity data of waypoints.

    Range: 1–100.

Returned data from the CameraIO data block FromCamera:

  • Status code

    If there is no error, status code 1103 will be returned. Otherwise, the corresponding error code will be returned.

  • Send_Pose_Type: The pose type of waypoints. Same as Request_Pose_Type.

    • 1: The waypoint poses returned are in JPs.

    • 2: The waypoint poses returned are in TCP.

  • Visual_Point_Index:

    • The position of the Vision Move Step, i.e., the move to the vision pose (usually the pose for picking the object) in the entire robot motion path.

    • For example, if the path is composed of Steps Move_1, Move_2, Vision Move, Move_3 sequentially, the position of Vision Move is 3.

    • If in the path there is no Vision Move Step, the returned value will be 0.

Start Mech-Viz Project

This command is for scenarios using both Mech-Vision and Mech-Viz.

This command starts the running of the Mech-Viz project, calls the corresponding Mech-Vision project, and lets the Mech-Viz project plan the robot path based on the vision points from Mech-Vision.

Please see Example Mech-Viz Projects for Standard Interface for the description of example Mech-Viz projects.

../../../../_images/start_viz.png

Command Sent

  • Robot_Pose_Type

    This parameter indicates the type of the robot pose of the real robot to input to Mech-Viz. The value range is 0–2.

  • Robot_Pose

    This parameter is the robot pose sent to Mech-Viz. Its value depends on Robot_Pose_Type.

    Data format: two-dimensional array [0..1, 0..5] of Real, array[0] is JPs 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 scenario

    0

    0, 0, 0, 0, 0, 0

    No need to input robot pose to Mech-Viz. The simulated robot in Mech-Viz moves from joint positions = [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 joint positions 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.

    ../../../../_images/robot_example10.png
  • Start_Viz

    The signal to trigger the running of the Mech-Viz project. The rising edge does the trigger.

    • Set_Edge

      This parameter does not need to be set by the user.

      It stores the value of “Start_Viz” in the last scan cycle to prevent unnecessary repetition of triggering.

Data Returned

Returned data from the CameraIO data block FromCamera:

If there is no error, status code 2103 will be returned. Otherwise, the corresponding error code will be returned.

Example

../../../../_images/start_viz_example.png

In this example, when the variable “Camera_User”.Start_Viz has a rising edge, the Mech-Viz project will be triggered to run, and the current JPs and flange pose of the robot will be sent to Mech-Vision.

Stop Mech-Viz Project

This command stops the running of the Mech-Viz project. This command is needed only when the Mech-Viz project falls into an infinite loop or cannot be stopped normally.

../../../../_images/stop_viz.png

Command Sent

  • Stop_Viz

    The trigger signal to stop the running of the Mech-Viz project, the rising edge is valid;

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Stop_Viz” in the last scan cycle to prevent unnecessary repetition of triggering.

Data Returned

Returned data from the CameraIO data block FromCamera:

  • Status code

    If there is no error, status code 2104 will be returned. Otherwise, the corresponding error code will be returned.

Example

In this example, the Mech-Viz project is stopped when a rising edge occurs on the variable “Camera_User”.Stop_Viz.

../../../../_images/stop_viz_example.png

Select Mech-Viz Branch

This command specifies which branch the project should run along. For this command, the branching is implemented by a “Branch by Msg” Step, and this command selects the branch by specifying an exit port of the Step.

Before executing this command, the Mech-Viz project needs to be started by executing command 201.

When the Mech-Viz project runs to the “Branch by Msg” Step, it will wait for command 203 to specify which exit port of the Step, i.e., the branch, the project should run along.

../../../../_images/set_branch.png

Command Sent

  • Branch_ID

    The Step ID of the Branch by Msg Step.

    This parameter is for specifying which Branch by Msg Step the branch selection should apply to.

    The Step ID can be read in the Step’s parameters.

  • Branch_Exit_Port

    This parameter is for specifying which exit port of the specified Step, i.e., the branch, the project should run along. The value should be an integer ([1, N]).

    Note

    An exit port number is the 1-based index of the specified exit port on the Step. For example, if the specified exit port is the second exit port of the Step from left to right, the exit port number is 2.

    Note

    Here, 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 variables of the CameraIO data block respectively. If the set values are different, they cannot take effect at the same time.

  • Set_Branch

    The trigger signal for setting the branch. The rising edge does the trigger.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Set_Branch” in the last scan cycle to prevent unnecessary repetition of triggering.

Data Returned

Returned data from the CameraIO data block FromCamera:

  • Status code

    If there is no error, status code 2105 will be returned. Otherwise, the corresponding error code will be returned.

Example

In this example, when the variable “Camera_User”.Set_Branch has a rising edge, it will specify that the project should run along the 1st outport of the Step whose Step ID is 1 when executing the Step.

../../../../_images/set_branch_example.png

Set Move Index

This command is for setting the index parameter of a Step that involves sequential or separate motions or operations.

Steps with index parameters include Move by List, Move by Grid, Custom Pallet Pattern, Smart Pallet Pattern, etc.

Before executing this command, MM_Start_Viz needs to be executed to start the Mech-Viz project.

../../../../_images/set_index.png

Command Sent

  • Index_Name

    The Step ID of the Branch by Msg Step.

    This parameter specifies which Step the index setting should apply to.

    The Step ID can be read in the Step’s parameters.

  • Index_Counter

    The index value that should be set the next time this Step is executed.

    When this command 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 command, the current index value in Mech-Viz will be increased by 1 to become the parameter’s value.

    Note

    Here, Index_Name, Index_Counter and Branch_Name and Branch_Exit_Port in the function MM_Set_Branch correspond to the same VIZ_TASK_NAME and VIZ_TASK_VALUE variables in the CameraIO data block 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.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Set_Index” in the last scan cycle to prevent unnecessary repetition of triggering.

Data Returned

Returned data from the CameraIO data block FromCamera:

Example

In this example, when the parameter “Camera_User”.Set_Index has a rising edge, in the Mech-Viz project, the index of the Step whose Step ID is 5 will be set to “4”. Later, when the project runs to this Step, the index value will be incremented by 1 to be “5” .

../../../../_images/set_index_example.png

Get Planned Path

This command gets the robot motion path planned by Mech-Viz after command 201 is executed to start the Mech-Viz project.

Note

If one of the waypoints in the path is not supposed to be sent to the robot, please clear the parameter “Send Waypoint” checkbox of the corresponding move-type Step.

../../../../_images/get_planned_path.png

Command Sent

  • Request_Pose_Type

    This parameter specifies the type of path waypoint poses to return from Mech-Viz.

    • 1: The waypoint poses returned should be in JPs.

    • 2: The waypoint poses returned should be in TCP.

  • Get_VizData

    The trigger signal to obtain the planned path from Mech-Viz. The rising edge does the trigger.

  • Data_Ready

    The signal for indicating the data is newly arrived and can be read when receiving poses multiple times. The rising edge does the trigger.

  • Send_Pose_Num: The number of waypoints returned from Mech-Viz by executing this command this time.

    Default range: 0–20.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Get_VizData” in the last scan cycle to prevent unnecessary repetition of triggering.

  • Data_Ready_Edge:

    This parameter does not need to be set by the user.

    It stores the value of “Data_Ready” in the last scan cycle to prevent unnecessary repetition of reading.

Data Returned

  • Target_Pose:

    Obtained pose data (TCP) of waypoints.

    Data type: DINT array of 20*6.

    The data needs to be divided by 10000 before use.

  • Target_Label:

    Obtained label data of waypoints.

    Data type: UDINT array of length 20.

  • Speed_Percentage:

    Obtained velocity data of waypoints.

    Range: 1–100.

Returned data from the CameraIO data block FromCamera:

  • Status code

    If there is no error, status code 2100 will be returned. Otherwise, the corresponding error code will be returned.

  • Send_Pose_Type: The pose type of waypoints. Same as Request_Pose_Type.

    • 1: The waypoints returned are in JPs.

    • 2: The waypoints returned are in TCP.

  • Visual_Point_Index:

    • The position of the Vision Move Step, i.e., the move to the vision pose (usually the pose for picking the object) in the entire robot motion path.

    • For example, if the path is composed of Steps Move_1, Move_2, Vision Move, Move_3 sequentially, the position of Vision Move is 3.

    • If in the path there is no Vision Move Step, the returned value will be 0.

Example

In this example, when the variable “Camera_User”.Get_VizData has a rising edge, it is used to receive the robot movement path planned by Mech-Vison, and the waypoint poses in the path are in the form of JPs.

../../../../_images/get_planned_visdate_25.png

Get DO Signal List

This command gets the planned DO signal list when there are multiple grippers, such as suction cup sections, to control.

The command “Get Planned Path” needs to be executed before executing this command.

For using this command:

In the parameters of the “set_do_list” Step:

  • Check “StandardInterface” under “Receiver”

  • Check “Get DO List from VisualMove”

  • Select a “Vision Move” Step that needs the DO signal list at the bottom of the parameter panel

Hint

Please refer to the Mech-Viz template project in xxx\Mech-Mind Software Suite-x.x.x\Mech-Center\tool\viz_project\suction_zone, and set the corresponding suction cup configuration file in the project before running.

../../../../_images/get_do.png

Command Sent

  • Get_DoList

    Trigger signal for obtaining the DO signal list. The rising edge does the trigger.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Get_DoList” in the last scan cycle to prevent unnecessary repetition of triggering.

Data Returned

  • Status code

    If there is no error, 2102 will be returned. Otherwise, the corresponding error code will be returned.

  • DO

    The sixty-four DO signal values returned by executing this command. A valid DO value is in the range of [0, 999], and -1 is a placeholder value.

Example

In this example, when the parameter “Camera_User”.Get_DoList has a rising edge, the DO values from Mech-Viz will be stored in the DO list.

../../../../_images/get_do_example.png

Input Object Dimensions to Mech-Vision

This command is for dynamically inputting object dimensions to the Mech-Vision project, and has to be executed before executing MM_Start_Vis. The corresponding Mech-Vision project must contain the “Read Object Dimensions” Step, and the Read Sizes from Properties parameter of this step must be checked.

../../../../_images/set_dim.png

Command Sent

  • Vision_Proj_Num

    The integer ID number of the Mech-Vision project, displayed in the Project List panel in Mech-Vision. The ID number can be adjusted by dragging the projects.

  • External_Input_Box_Dimension

    The 3D dimensions to input to the Mech-Vision project.

    Unit: mm

    Data type: Array[0–2] of Real

  • Set_Box_Dimension

    The trigger signal to input the dimensions. The rising edge does the trigger.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Set_Box_Dimension” in the last scan cycle to prevent unnecessary repetition of triggering.

Data Returned

Returned data from the CameraIO data block FromCamera:

  • Status code

    If there is no error, 1108 will be returned. Otherwise, the corresponding error code will be returned.

Example

In this example, when the parameter “Camera_User”.Set_Box_Dimension has a rising edge, the dimensions read by Step “Read Object Dimensions” will be set to the value of External_Input_Box_Dimension.

../../../../_images/set_dim_example.png

Input TCP to Mech-Viz

This command is for dynamically inputting robot TCP data to Mech-Viz to work with Step “external_move” in Mech-Viz.

Hint

Please deploy the Mech-Viz project based on the template project at xxx\Mech-Mind Software Suite-x.x.x\Mech-Center\tool\viz_project\outer_move, and put the External Move Step to a proper position in the workflow.

../../../../_images/set_tcp.png

Command Sent

  • External_Input_Pose

    The parameter stores the TCP data to be sent to Mech-Viz.

    Data type: Array[0–5] of Real

    Note

    The robot TCP data (unit: mm) needs to be multiplied by 10000 before setting to External_Input_Pose.

    Note

    Here External_Input_Pose and External_Input_Box_Dimension in the function MM_Set_Box_Dimension are of the same EXT_INPUT_DATA variable of the CameraIO data block. If the set values are different, they cannot take effect at the same time.

  • Set_Input_Pose

    The trigger signal for inputting the TCP data. The rising edge does the trigger.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Set_Input_Pose” in the last scan cycle to prevent unnecessary repetition of triggering.

Data Returned

Returned data from the CameraIO data block FromCamera:

  • Status code

    If there is no error, 2107 will be returned. Otherwise, the corresponding error code will be returned.

Example

../../../../_images/set_tcp_example.png

Get Software Status

This command is for obtaining the running status of Mech-Vision, Mech-Viz, Mech-Center (at present, only whether Mech-Vision is ready to start running the project can be checked).

../../../../_images/get_status.png

Command Sent

  • Get_Status

    The trigger signal for checking whether Mech-Vision is ready to start running the project. The rising edge does the trigger.

  • Set_Edge

    This parameter does not need to be set by the user.

    It stores the value of “Get_Status” in the last scan cycle to prevent unnecessary repetition of triggering.

Data Returned

Returned data from the CameraIO data block FromCamera:

  • Status code

    Software status. 1101 means the Mech-Vision project is ready to run. Other codes mean the project is not ready.

Example

In this example, when the parameter “Camera_User”.Get_Status has a rising edge. The software running status will be checked and the result will be stored in the parameter “Status code”.

../../../../_images/get_status_example.png

Clear Target Data

This command is for clearing the obtained data in variables Target_Pose, Target_Label, Speed_Percentage.

../../../../_images/empty_target.png

Command Sent

  • Start_Empty: The trigger signal for clearing the obtained data in variables Target_Pose, Target_Label, Speed_Percentage. The signal takes effect when it is set to high.

  • Target_Pose: Obtained pose data of targets.

  • Target_Label: Obtained label data of targets.

  • Speed_Percentage: Obtained velocity data of targets.

Example

In this example, when variable “Camera_User”.Start_Empty is set to high, the obtained data in variables Target_Pose, Target_Label, Speed_Percentage will be cleared.

../../../../_images/empty_target_example.png