Beckhoff TwinCAT
This driver supports communication over Ip with Beckhoff TwinCAT PLCs.
The Beckhoff software for the TwinCAT (The Windows Control and Automation Technology) system turns any compatible PC into a real-time controller with a multi-PLC system, Numerical Control (NC) axis control, programming environment and operating station. TwinCAT replaces conventional PLC and NC/CNC controllers as well as operating devices.
The TwinCAT software devices can be distributed since TwinCAT PLC programs can run on PCs or on Beckhoff Bus Terminal Controllers. The TwinCAT protocol enables connection to any TwinCAT system whether local or distributed over a TCP/IP network. It uses the AMS Router (message router) provided by Beckhoff to manage and distribute all of the messages, both within the system and via TCP/IP connections. In a distributed architecture, all communication is run over the standard Ethernet network interface of a PC.
In the communication, ADS is the transport layer but the requested TwinCAT device has to support the ADS commands. These are supported by TwinCAT PLCs with version numbers from 2.7 B511, from 2.8 B718 and 2.9
You can configure the TwinCAT driver using the TwinCAT Smart Generator.
Prerequisites
The message router has to be installed on the system that is running PcVue. It comes with any TwinCAT software pack. The earliest version to use is 2.9.
If you do not need a TwinCAT system, install TwinCAT-CP instead.
In a distributed configuration, each PC on the network must have a unique AMS Net Id. To allow two PCs to communicate you need to add the AMS router definition on the remote PC as follows.
- Right-click on the TwinCAT icon and select Properties to open the TwinCAT System Properties dialog.
Show picture
- Select the AMS Router tab.
- Enter the AMS Net Id of your PC in the Local computer field.
- Select Add to open the Add Remote Connection dialog and then enter the parameter for the remote computer.
- Repeat the previous step for each PC that will be communicating and apply the same steps on the remote computer.
- The message router needs to be started for the communication to work. You can do so either manually in the TwinCAT icon's context menu by selecting System.Start, or automatically by selecting Enable in System tab of the System properties dialog.
Network properties
This topic only includes a reference of objects' properties.
See the topic How to configure networks devices and frames for more information about how to configure communication objects.
General properties | |
Name | The name of the network |
Description | The description of the network (optional) |
Protocol specific attributes | Reserved - Do not change |
Activate at start-up | If enabled, the network will start upon Equipment communication start-up |
Advanced properties |
|
Timeout |
Use default value |
Networking |
|
Servers |
The list of PcVue stations where the network will be active |
Protocol Id | Reserved - Do not change |
Device properties
General properties | |
Name | The name of the device |
Description | The description of the device (optional) |
Equipment type | Select the type of equipment that best suits the field device you want communicate with. The list of frame types and address ranges depend on the equipment type. |
Address | The 6-digit AMS Net Id of the remote PC. For example 192 168 0 12 1 1 |
Activate at start-up | If enabled, the device will start upon network start-up |
Advanced properties |
|
Connection |
|
Timeout |
Maximum waiting time between a request and the reply from the equipment |
Port number |
The port number of the field device |
Miscellaneous |
|
Virtual |
Reserved. Do not select. |
Message delay | Reserved. Leave default value 0. |
Port
By default, the driver will access the PLC port of the remote PC. If you wish to specify another port, change the port property as follows.
Port | Value |
Port for PLC | 801 |
Port for PLC (Runtime system 2) | 811 |
Port for PLC (Runtime system 3) | 821 |
Port for PLC (Runtime system 4) | 831 |
Port for logger | 100 |
Port for IO | 300 |
Port for SPS | 400 |
Port for NC | 500 |
Port for ISG | 550 |
Port for PCS | 600 |
Frame addressing
Depending on the equipment type you have selected when configuring the device, you have access to the following type of frames.
The Starting address and Quantity properties define the memory address range for each frame, how it is read from and written to, and how it is interpreted in PcVue.
The start address of the frames and the data type are not used by the driver, only the size is important.
The TwinCAT variable definition for a frame is specified in an ASCII formatted file. The file must be located in the C folder of the project. Its name is made up of the network, device, and frame names (for example MyNet_MyDev_MyFrame.dat).
The format of the file's content is composed of Variable Name which is the name of the variable in the TwinCAT program and Size which is the size of the variable in bytes.
Variable Name,Size
The order in which the variables in TwinCAT program are listed is significant as that is the sequence used for TwinCAT variables onto the frame.
The TwinCAT Smart Generator automates this configuration step.
The Word variable byte offset MUST be a multiple of 2.
Double and Float variable byte offsets MUST be a multiple of 4.
The PLC processes each request before it starts the next PLC cycle. For example, a request with 200,000 TwinCAT variables would cause the PLC to collect and copy 200,000 variables into a single ADS response before starting the next PLC cycle. Such a large number of ADS sub-commands would disrupt the running of the PLCs. We recommend that you do not specify more than 500 TwinCAT variables per frame.
The size of the Word frame defined in PcVue must be greater than or equal to twice the total size of all of the variables defined in the Variable Definition file.
Driver status
The driver status provides driver-specific information to supplement the frame general status. For more information on status in general, refer to the topic General communication status.
Most commonly occurring error codes
Driver status | Description |
0x0007 | Equipment (remote computer) not configured in the AMS Router |
0x0012 | AMS Router not started |
0x1000 | Cannot open the Variable Definition file. Please check that its name is that of a valid frame name. |
0x1001 | Error in allocating the driver's buffer memory |
0x1002 | No variable found in the Write request |
0x1003 |
The total size of the TwinCAT variable definition exceeds 2,097,152 bytes Each variable has an additional 4 bytes for error handling. |
0x2751 | Network cable disconnected |
0x3yyy | Variable not found in the equipment |
xxx is the index (in hexadecimal) of the variable in TwinCAT Variable Definition file | |
0x6yyy | Size of variable mismatched |
yyy is the index (in hexadecimal) of the variable in the TwinCAT Variable Definition file | |
0x6000 | Write request error |
The size of one of the variables written via the variable link differs from the size specified in the TwinCAT Variable Definition file. Write each variable in turn to find out which one is faulty. |
Less usual error codes
Driver status |
Description |
0x0001 | Internal error |
0x0002 | No runtime |
0x0003 | Allocation locked memory error |
0x0004 | Insert mailbox error |
0x0005 | Wrong receive HMSG |
0x0006 | Target port not found |
0x0008 | Unknown command ID |
0x0009 | Incorrect task ID |
0x000A | No I/O |
0x000B | Unknown AMS command |
0x000C | Win32 error |
0x000D | Port not connected |
0x000E | Invalid AMS length |
0x000F | Invalid AMS Net ID |
0x0010 | Low installation level |
0x0011 | No debug available |
0x0013 | Port already connected |
0x0014 | AMS Sync - Win32 error |
0x0015 | AMS Sync - Timeout |
0x0016 | AMS Sync - AMS error |
0x0017 | AMS Sync - no index map |
0x0018 | Invalid AMS port |
0x0019 | No memory |
0x001A | TCP send error |
0x001B | Host unreachable |
0x0500 | Router: no locked memory |
0x0502 | Router: mailbox full |
0x0700 | Error class <device error> |
0x0701 | Server does not support the service |
0x0702 | Invalid index - group |
0x0703 | Invalid index - offset |
0x0704 | Reading/writing not permitted |
0x0705 | Parameter size is incorrect |
0x0706 | Invalid parameter value |
0x0707 | Device is not in a ready state |
0x0708 | Device is busy |
0x0709 | Invalid context (must be in Windows) |
0x070A | Out of memory |
0x070B | Invalid parameter value |
0x070C | Not found (files etc.) |
0x070D | Syntax error in command or file |
0x070E | Objects do not match |
0x070F | Object already exists |
0x0710 | Symbol not found |
0x0711 | Symbol version invalid |
0x0712 | Server is in an invalid state |
0x0713 | AdsTransMode not supported |
0x0714 | Notification handle is invalid |
0x0715 | Notification client not registered |
0x0716 | No more notification handles |
0x0717 | Size for watch too big |
0x0718 | Device not initialized |
0x0719 | Device has a timeout |
0x071A | Query interface failed |
0x071B | Wrong interface required |
0x071C | Class ID is invalid |
0x071D | Object ID is invalid |
0x071E | Request is pending |
0x071F | Request aborted |
0x0720 | Signal warning |
0x0721 | Invalid array index |
0x0740 | Error class <client error> |
0x0741 | Invalid parameter at service |
0x0742 | Polling list is empty |
0x0743 | Var connection already in use |
0x0744 | Invoke ID in use |
0x0745 | Timeout elapsed |
0x0746 | Error in Win32 subsystem |
0x0748 | ADS-port not opened |
0x0750 | Internal error in ADS sync |
0x0751 | Hash table overflow |
0x0752 | Key not found in hash |
0x0753 | No more symbols in cache |
SCADA Basic scripting
You can control communication with this driver in SCADA Basic scripts with the CIMWAY instruction.