This MecaNetwork example features the Meca500 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.
Meca500 Robot: Go to site
Meca500 Firmware version 8.1.6 or above is required: Go to site
Beckhoff TwinCAT3: Go to site
TwinCAT 3 -SquareMoveDemo: Example Code
User guide: TwinCAT 3 and Mecademic Function Blocks
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:
- 1. Copy the ESI file into the TwinCAT installation directory: \TwinCAT\3.1\Config\Io\OnboardIo.
- 2.Create the folder manually if it doesn't exist.
- 3.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 :
Alternate between 0 and 1
Below are all the commands, their motion command value and their internal FB 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.
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.
This example was developed with a Beckhoff C6015 Industrial PC for the Meca500 v9.1.5 over Ethercat
Was this article helpful?
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
We appreciate your effort and will try to fix the article