These examples features Mecademic robots being used with Beckhoff TwinCAT 3 over EtherCAT.
This can be used with different Beckhoff IPCs or other EtherCAT-based PCs.
This example features a simple Square Move pattern that runs in a loop.
TABLE OF CONTENTS
Components
Meca500 Robot: Go to site
MCS500 Robot: Go to site
Meca500 Firmware version 8.1.6 or above is required: Go to site
Beckhoff TwinCAT3: Go to site
Attachments
MCS500
MCS500 Firmware 10.2.x
MCS500 Firmware 10.1.x
Meca500
Meca500 Firmware 10.2.x
Meca500 Firmware 10.1.x
Meca500 Firmware 9.1.5
Meca500 v9.1.5 TwinCAT 3 SquareMoveDemo
User guide: TwinCAT 3 and Mecademic Function Blocks
Software
The purpose of this document is to guide the user in integrating a Mecademic Robot with TwinCAT. This guide and the examples that are in it were done with version 15.0.
Installing the ESI file
Proceed as follows:
- Copy the ESI file into the TwinCAT installation directory: \TwinCAT\3.1\Config\Io\OnboardIo.
- Create the folder manually if it doesn't exist.
- Open TwinCAT and click in the menu under TwinCAT > EtherCAT Devices on Reload Device Description.
Prior to scanning your network in the TwinCAT environment, the following command must be sent to the robot in the web interface to change the network configuration from TCP/IP to EtherCAT.
If the previous steps were done correctly, upon scanning your network, you should see the Meca500.
Double-clicking on the robot in the Device tree will bring this configuration window.
In the EtherCAT tab, you will find the robot's EtherCAT address.
In this example, the address is 1001.
To obtain the SmPdo variables to communicate with the robot, go into the Advanced Settings menu.
And Enable the Create SM/PDO Variables checkbox.
The variables are now created and you will find them in the Device Tree.
If you double-click on the variables (Meca500_SM_2 & Meca500_SM_3), you will find the Data type created by TwinCAT. These can be used in your PLC Project.
This Data Type number may change depending on the firmware that you use and should correspond to the Data Type used in the MecaSmPdo Structure.
You can then associate the corresponding Robot Input/Outputs to your code using the Linked to.. button in the Variable Tab of the SmPdo variable.
Using the function blocks
The following function blocks are provided by Mecademic to simplify the usage of the Meca500 with Beckhoff PLCs.
These instructions will be mirroring the commands present in the TCP/IP interface to enable ease of use and standardize the programming structure between the Web Interface and PLC programs.
Follow the steps below to use the Add-On Instructions in TwinCAT.
First, select the block that represents the command you want to send to your robot.
Populate the argument(s) field with the values you want to send for the selected command. The command will be sent to the robot on the first scan of the block or when one of the argument(s) values is modified.
If real-time updates are required, sending these instructions by updating the values should be the preferred method. However, it is recommended to update the values before enabling the blocks as this might give better control and prevent multiple instructions from being sent too rapidly if they are not all updated in the same scan.
Once the command has been sent, the sent bit from the block will become true and stay true until one of the arguments is modified or until the block is no longer enabled.
The buffered bit will become true when the MoveID (Internal or External) of the last command received by the robot equals the MoveID of the command sent by the block. When the Buffered bit becomes True it is an acknowledgment from the robot controller that it has received the command and added it to the FIFO command buffer queue.
At the end of the Case..Of in the example, you will find this code.
This code reset the Buffered and Sent Flag to False and then allows the sequence to go to the next step when the Robot has acknowledged the command sent.
To prevent communication problems, it is imperative to send one instruction at a time to a given robot.
We recommend using a Grafcet-like structure, where each step can only execute one instruction.
It is also recommended to only have one instance of an instruction per robot, this facilitates future program debugging.
Motion Commands and MoveID
The way that robot can identify all of the different commands with the motion command number. Each command has its own unique number. The internal MoveID values of the FBs are closely related to the motion command values. Since the MoveID needs to be changed every time a new command is sent to the robot, the function block will alternate between two MoveIDs.
These two numbers will be constructed as such :
32
|
xx | 0/1 |
Prefix | Motion command | Alternate between 0 and 1 |
Below are all the commands, their motion command value and their internal FB MoveID:
Commands |
Motion Command value |
AOI MoveID |
MoveJoints | 1 |
32010-32011 |
MovePose | 2 |
32020-32021 |
MoveLin | 3 |
32030-32031 |
MoveLinRelTRF | 4 |
32040-32041 |
MoveLinRelWRF | 5 |
32050-32051 |
Delay | 6 |
32060-32061 |
SetBlending | 7 |
32070-32071 |
SetJointVel | 8 |
32080-32081 |
SetJointAcc | 9 |
32090-32091 |
SetCartAngVel | 10 |
32100-32101 |
SetCartLinVel | 11 |
32110-32111 |
SetCartAcc |
12 |
32120-32121 |
SetTRF | 13 |
32130-32131 |
SetWRF | 14 |
32140-32141 |
SetConf | 15 |
32150-32151 |
SetAutoConf | 16 |
32160-32161 |
SetCheckpoint | 17 |
32170-32171 |
Gripper | 18 |
32180-32181 |
Gripper | 19 |
32190-32191 |
GripperForce | 20 |
32200-32201 |
MoveJointsVel | 21 |
32210-32211 |
MoveLinVelWRF | 22 |
32220-32221 |
MoveLinVelTRF | 23 |
32230-32231 |
VelCtrlTimeout | 24 |
32240-32241 |
SetConfTurn | 25 | 32250-32251 |
SetAutoConfTurn | 26 | 32260-32261 |
SetTorqueLimits | 27 | 32270-32271 |
SetTorqueLimitsCfg | 28 | 32280-32281 |
MoveJointsRel | 29 | 32290-32291 |
SetValveState | 30 | 32300-32301 |
SetGripperRange | 31 | 32310-32311 |
MoveGripper | 32 | 32320-32321 |
SetJointVelLimit | 33 | 32330-32331 |
SetOutputState | 34 | 32340-32331 |
SetOutputState_Immediate | 35 | 32350-32351 |
SetIoSim | 36 | 32360-32361 |
VacuumGrip | 37 | 32370-32371 |
VacuumGrip_Immediate | 38 | 32380-32381 |
VacuumRelease | 39 | 32390-32391 |
VacuumRelease_Immediate | 40 | 32400-32401 |
SetVacuumThreshold | 41 | 32410-32411 |
SetVacuumThreshold_Immediate | 42 | 32420-32421 |
SetVacuumPurgeDuration | 43 | 32430-32431 |
SetVacuumPurgeDuration_Immediate | 44 | 32440-32441 |
MoveJump | 45 | 32450-32451 |
SetMoveJumpHeight | 46 | 32460-32461 |
SetMoveJumpApproachVel | 47 | 32470-32471 |
SetTimeScaling | 48 | 32480-32481 |
StartOfflineProgram | 100 | 31900-31901 |
These unique MoveIDs are useful for troubleshooting and knowing which commands were received or not by the robot. It is also important to not use these internal MoveID when using the external MoveID feature of the Function Blocks.
External MoveID
The external MoveID feature can be activated by setting the ExternalStateControl value to 1. When this is enabled, the user will need to input their own MoveID in the FB. The commands will be sent only when the external MoveID value is updated to a new value as with the internal MoveID. This feature can be useful for users who want more in-depth control of their sequence and who want to monitor the commands sent and received by the robot more closely.
It should be noted that this approach needs a careful and thorough understanding of how MoveID is being used in the robot controller and should only be used by more advanced users. It is also important to note that the values of the external MoveID should never be the same as the internal values of FB. If the user tries to input the same value as an internal value the error bit will become true on the FB.
Control Block (Example v9.1)
In firmware v10, the control block is no longer required to manage the EtherCAT connection to Mecademic robot as a DisconnectFromEtherCAT bit as been added in the Output PDOs
The Meca500Control Function Block helps manage the connection of the robot to the PLC.
The block handles the change of state of the robot slave from the Init state to the Operational State using the Meca500.Connect variable. It can also be used to change back the network configuration from EtherCAT to TCP/IP using the Meca500.DisconnectFromEthercat variable.
Its last functionality is to automatically handle the Activation, Homing, and reset Paused state & Errors of the robot.
This functionality might not be wanted and should be removed from the function block if not desired.
The sNetID can be found in the configuration of the EtherCAT device.
Please note that these examples are provided as-is by either Mecademic or it's Partners. These can be used as starting point for development and testing but Mecademic or it's partners are not under obligation to provide support and are not liable for any errors or unintended behavior caused by the examples. These examples could be updated over time.