PROFINET - Siemens SIMATIC S7 PLC Commands¶
The interface files are stored in XXXX/Mech-Center-xxx/Robot_Interface/PROFINET/Programming Samples/Siemens TIA Portal S7-1200 PLC PROFINET (the installation directory of Mech-Center). Please copy the files to the computer with Siemens TIA Portal installed.
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.
Command Sent¶
Vision_Proj_Num
The integer ID number of the Mech-Vision project in Mech-Center, i.e., the number shown on the left of the project path in
in Mech-Center. Range: [1, 99]. The 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 the image-capturing pose of the real robot to input to Mech-Vision.
0
: No robot pose needs to be transmitted by this command. If the project works in the eye-to-hand mode, then image capturing has nothing to do with the robot’s pose, so no robot image-capturing pose is needed by Mech-Vision.
1
: The robot pose transmitted by this command is in JPs.
2
: The robot pose transmitted by this command is a flange pose.Robot_Pose
This parameter is the robot pose needed when the project works in the eye-in-hand mode.
The robot pose is either in JPs or flange pose, according to the setting of the parameter “robot pose type”.
Data format: DINT array of length 6.
Note
The floating point data of JPs and flange pose need to be multiplied by 10000 to convert to 32-bit signed integers before being set to Robot_Pose.
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 to Mech-Center when the Mech-Vision project is started.
Get Vision Target(s)¶
This command gets the vision result, i.e., vision points, after executing command 101.
Command Sent¶
Vision_Proj_Num
The integer ID number of the Mech-Vision project in Mech-Center, i.e., the number shown on the left of the project path in
in Mech-Center. Range: [1, 99]. The 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.
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.
Send_Pose_Num
The number of targets expected to be returned by executing this command once.
0
: Return all the targets.1—20
: Return a specified number of targets.
Note
For using Profinet on Siemens Simatic S7, by default, executing this command once can only fetch at most 20 targets. So this command may need to be executed multiple times to get all the targets wanted.
Data Returned¶
Data_Ready
The signal to indicate the data has newly arrived and can be read.
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.
Target Pose
The robot targets (as TCPs) converted from the vision results 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 targets. The labels are integers.
Data type: UDINT array of length 20.
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.
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.
Command Sent¶
Vision_Proj_Num
The integer ID number of the Mech-Vision project in Mech-Center, i.e., the number shown on the left of the project path in
in Mech-Center. Range: [1, 99]. The 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
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.
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.
For the Mech-Viz project that needs starting, the option Autoload needs to be checked in Mech-Viz’s interface.
Please see Example Mech-Viz Projects for Standard Interface for the description of example Mech-Viz projects.
Command Sent¶
Robot_Pose_Type
0
The current pose of the robot is not needed by Mech-Viz and no pose will be sent.
If the project works in the eye-to-hand mode, no robot image-capturing pose will be needed by the project.
In Mech-Viz, the simulated robot will move from the initial pose JPs = [0, 0, 0, 0, 0, 0] to the first target in the planned path.
1
The robot pose will be sent to Mech-Viz and the pose sent is in JPs.
In Mech-Viz, the simulated robot will move from the input initial pose (i.e., the pose sent by this command) to the first target in the planned path.
TCP is not supported at present.
Note
If in the scene, there are barriers that stand in the way from the initial pose JPs = [0, 0, 0, 0, 0, 0] to the first target in the planned path, the pose type must be set to 1.
Robot_Pose
The current JPs of the real robot (if pose type is set to 1).
Data format: 6 numbers of REAL type.
Note
The floating point data of JPs and flange pose need to be multiplied by 10000 to convert to 32-bit signed integers before being set to Robot_Pose.
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¶
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 JPs of the current robot will be sent to Mech-Center.
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¶
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 JPs of the current robot will be sent to Mech-Center.
Stop Mech-Viz Project¶
This command stops the running of the Mech-Viz project. This command is needed only when the Mech-Viz project fall into an infinite loop or cannot be stopped normally.
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.
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” Task, and this command selects the branch by specifying an exit port of the Task.
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” Task, it will wait for command 203 to specify which exit port of the Task, i.e., the branch, the project should run along.
Command Sent¶
Branch_ID
The Task ID of the branch_by_msg Task.
This parameter is for specifying which branch_by_msg Task the branch selection should apply to.
The Task ID can be read in the Task’s parameters.
Branch_Exit_Port
This parameter is for specifying which exit port of the specified Task, 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 Task. For example, if the specified exit port is the second exit port of the Task 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 Task named 1 when executing the Task.
Set Move Index¶
This command is for setting the index parameter of a Task that involves sequential or separate motions or operations.
Tasks with index parameters include move_list, move_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.
Command Sent¶
Index_Name
The Task ID of the branch_by_msg Task.
This parameter specifies which Task the index setting should apply to.
The Task ID can be read in the Task’s parameters.
Index_Counter
The index value that should be set the next time this Task 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 task 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 Task named “5” will be set to “4”. Later, when the project runs to this Task, the index value will be incremented by 1 to be “5” .
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 targets in the path is not supposed to be sent to the robot, please clear the parameter “Send Target” checkbox of the corresponding move-type Task.
Command Sent¶
Request_Pose_Type
This parameter specifies the type of path targets to return from Mech-Viz.
1
: The targets returned should be in JPs.
2
: The targets returned should be in TCP.Get_VizData
The trigger signal to obtain the planned path from Mech-Viz. 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_VizData” in the last scan cycle to prevent unnecessary repetition of triggering.
Data Returned¶
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.
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.
Send_Pose_Num: The number of targets returned from Mech-Viz by executing this command this time.
Default range: 0—20.
Target_Pose:
Obtained pose data (TCP) of targets.
Data type: DINT array of 20*6.
The data needs to be divided by 10000 before use.
Target_Label:
Obtained label data of targets.
Data type: UDINT array of length 20.
Speed_Percentage:
Obtained velocity data of targets.
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.
Note
When executing this command, if Mech-Viz has not yet had the planned robot motion path (the project is still running), Mech-Center will wait. The default wait time is 10 seconds. If a timeout occurs, a timeout error code will be returned.
Send_Pose_Type: The pose type of targets. Same as Request_Pose_Type.
1
: The targets returned are in JPs.
2
: The targets returned are in TCP.Visual_Point_Index:
The position of the visual_move Task, 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 Tasks move_1, move_2, visual_move, move_3 sequentially, the position of visual_move is 3.
If in the path there is no visual_move Task, 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-Viz, and the targets in the path are in the form of TCP.
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” Task:
Check “StandardInterface” under “Receiver”
Check “Get DO List from VisualMove”
Select a “visual_move” Task that needs the DO signal list at the bottom of the parameter panel
Hint
Please refer to the Mech-Viz template project in XXXX\Mech-Center-xxx\tool\viz_project\suction_zone, and set the corresponding suction cup configuration file in the project before running.
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.
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.
Command Sent¶
Vision_Proj_Num
The integer ID number of the Mech-Vision project in Mech-Center, i.e., the number shown on the left of the project path in
in Mech-Center. Range: [1, 99]. The number can be adjusted by dragging the projects.External_Input_Box_Dimention
The 3D dimensions to input to the Mech-Vision project.
Unit: mm
Data type: Array[0–2] of Real
Set_Box_Dimention
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_Dimention” 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_Dimention has a rising edge, the dimensions read by Step “Read Object Dimensions” will be set to the value of External_Input_Box_Dimention.
Input TCP to Mech-Viz¶
This command is for dynamically inputting robot TCP data to Mech-Viz to work with Task “external_move” in Mech-Viz.
Hint
This function needs to be used with the project at XXXX\Mech-Center-xxx\tool\viz_project\outer_move, for which Task “outer_move” needs to be
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_Dimention in the function MM_Set_Box_Dimention 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¶
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).
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”.
Clear Target Data¶
This command is for clearing the obtained data in variables Target_Pose, Target_Label, Speed_Percentage.
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.