Notes on the documentation

This description is only intended for the use of trained specialists in control and automation engineering who are familiar with the applicable national standards.
It is essential that the following notes and explanations are followed when installing and commissioning these components.

The responsible staff must ensure that the application or use of the products described satisfy all the requirements for safety, including all the relevant laws, regulations, guidelines and standards.

Disclaimer

The documentation has been prepared with care. The products described are, however, constantly under development.
For that reason the documentation is not in every case checked for consistency with performance data, standards or other characteristics.
In the event that it contains technical or editorial errors, we retain the right to make alterations at any time and without warning.
No claims for the modification of products that have already been supplied may be made on the basis of the data, diagrams and descriptions in this documentation.

Trademarks

Beckhoff®, TwinCAT®, EtherCAT®, Safety over EtherCAT®, TwinSAFE® and XFC® are registered trademarks of and licensed by Beckhoff Automation GmbH.
Other designations used in this publication may be trademarks whose use by third parties for their own purposes could violate the rights of the owners.

Patent Pending

The TwinCAT Technology is covered, including but not limited to the following patent applications and patents:
EP0851348, US6167425 with corresponding applications or registrations in various other countries.

Copyright

© Beckhoff Automation GmbH & Co. KG, Germany.
The reproduction, distribution and utilization of this document as well as the communication of its contents to others without express authorization are prohibited.
Offenders will be held liable for the payment of damages. All rights reserved in the event of the grant of a patent, utility model or design.


Übersicht

TwinCAT PLC Library: TwinSAFE

Overview

The TwinSAFE library contains function blocks with which services/functions can be carried out belonging to the TwinSAFE terminals KL1904, KL2904 and KL6904.

TwinSAFE functions

Name | Description
F_GetVersionTcTwinSAFE | Library version number
FB_TwinSAFE_connection | Evaluating the TwinSAFE data which is tranfered from one TwinSAFE terminal to another TwinSAFE terminal, which are inside the same system manager configuration or connected by RT Ethernet.

Example

Name | Description
ExampleTcTwinSAFE.pro | TwinCAT PLC project including the execution of FB instances of the FB FB_TwinSAFE_connection
ExampleTcTwinSAFE.tsm | TwinCAT System Manager configuration which shows the linkage to the TwinSAFE terminals.

PLC Control export file

Name | Description
ST_TWINSAFE_MESSAGE.EXP | TwinCAT PLC Control export file which contains the data type ST_TWINSAFE_MESSAGE. This data type can be used to map TwinSAFE data to a PLC variable of that type. This feature can be used with TwinCAT version 2.10 Build 1334.
FSoE_Types_EL6900.EXP | TwinCAT PLC Control export file, which contains the data types FSoE_xxBytes. These data types can be addressed in the PLC control and then used in the System Manager. The variables of that data type can be used to create a TwinSAFE connection between two EL6900 which contains more than 1 byte of safety data.


F_GetVersionTcTwinSAFE

FUNCTION F_GetVersionTcTwinSAFE

The function returns library version info.

FUNCTION F_GetVersionTcTwinSAFE : UINT

VAR_INPUT
    nVersionElement	: INT;
END_VAR

nVersionElement: Version parameter:

  • 1 : major number;
  • 2 : minor number;
  • 3 : revision number;
Development environment | Target system type | IO-Hardware | PLC libraries to include
TwinCAT v2.10.0 Build > 914 | PC (i386) | --- | TcTwinSAFE.Lib ( Standard.Lib, TcBase.Lib and TcSystem.Lib are included automatically )


FB_TwinSAFE_connection

FUNCTION_BLOCK FB_TwinSAFE_connection

The function block FB_TwinSAFE_connection is made for evaluating the TwinSAFE data which is transfered from one TwinSAFE communication partner to another TwinSAFE communication partner. The input parameters has to be linked to the SafetyQBx or SafetyIn signal of the corresponding TwinSAFE terminal. Please assure that the new linkage does not remove the already existing linkage. When RT Ethernet is used to transfer the TwinSAFE data, one parameter has to be linked to SafetyQBx the other parameter has to be linked to Vardata of the network variable subscriber.

VAR_INPUT

VAR_INPUT
    TwinSAFETerminal AT %I* : TwinSAFE_Data; (* Additional link to "SafetyIn" e.g. KL1904, KL2904 or networkvariable subscriber *)
    TwinSAFELogic AT %I* : TwinSAFE_Data; (* Additional link to "SafetyQBx" e.g. KL6904 *)
END_VAR

TwinSAFETerminal: TwinSAFE telegram which is transfered from one TwinSAFE communication partner to another TwinSAFE communication partner. This parameter has to be linked to SafetyIn (output data of a KL1904 or KL2904 or netweork variable subscriber).

TwinSAFELogic: TwinSAFE telegram which is transfered from one TwinSAFE communication partner to another TwinSAFE communication partner. This parameter has to be linked to SafetyQBx (output data of a KL6904).

VAR_OUTPUT

VAR_OUTPUT
    nSafeTerminalData 		: BYTE;
    nSafeLogicData 		: BYTE;
    tCycleTime		: TIME;
    bConnectionInRun 		: BOOL;
    nFirstError		: WORD;
    nLastError		: WORD;
END_VAR

nSafeTerminalData: TwinSAFE data of TwinSAFETerminal.

nSafeTerminalData | description
.0 | Channel 1 of TwinSAFE data (KL1904 Input 1, KL6904 Channel 1)
.1 | Channel 2 of TwinSAFE data (KL1904 Input 2, KL6904 Channel 2)
.2 | Channel 3 of TwinSAFE data (KL1904 Input 3, KL6904 Channel 3)
.3 | Channel 4 of TwinSAFE data (KL1904 Input 4, KL6904 Channel 4)
.4 | Channel 5 of TwinSAFE data (KL6904 Channel 5)
.5 | Channel 6 of TwinSAFE data (KL6904 Channel 6)
.6 | Channel 7 of TwinSAFE data (KL6904 Channel 7)
.7 | Channel 8 of TwinSAFE data (KL6904 Channel 8)

nSafeLogicData: TwinSAFE data of TwinSAFELogic.

nSafeLogicData | description
.0 | Channel 1 of TwinSAFE data (KL2904 Output 1, KL6904 Channel 1)
.1 | Channel 2 of TwinSAFE data (KL2904 Output 2, KL6904 Channel 2)
.2 | Channel 3 of TwinSAFE data (KL2904 Output 3, KL6904 Channel 3)
.3 | Channel 4 of TwinSAFE data (KL2904 Output 4, KL6904 Channel 4)
.4 | Channel 5 of TwinSAFE data (KL6904 Channel 5)
.5 | Channel 6 of TwinSAFE data (KL6904 Channel 6)
.6 | Channel 7 of TwinSAFE data (KL6904 Channel 7)
.7 | Channel 8 of TwinSAFE data (KL6904 Channel 8)

tCycleTime: Cycle time in ms which is needed to exchange the TwinSAFE telegram between the TwinSAFE communication partner of this connection.

bConnectionInRun: When there is no error in the TwinSAFE connection the value is set to TRUE. When the value is FALSE the parameter nSafeTerminalData and nSafeLogicData are set to 0.

nFirstError: Gives an error code for the first error in the connection. The error is resetted as soon as bConnectionInRun is TRUE again.

nLastError: Gives an error code for the last error in the connection. The error is resetted as soon as bConnectionInRun is TRUE again.

errorvalue | description for nFirstError and nLastError
0x0001 | Watchdog in TwinSAFETerminal
0x0002 | Watchdog in TwinSAFELogic
0x0004 | CRC Error in TwinSAFETerminal
0x0008 | CRC Error in TwinSAFELogic
0x0010 | Slave Error in TwinSAFETerminal
0x0020 | Slave Error in TwinSAFELogic
0x4000 | not specified error in TwinSAFETerminal
0x8000 | not specified error in TwinSAFELogic

Example for the FB call in FBD:

PROGRAM MAIN
VAR
    fbTwinSAFE_connection	: FB_TwinSAFE_connection;
    nSafeKL1904_data		: BYTE;
    nSafeKL6904_ata		: BYTE;
    CycleTime			: TIME;
    bConnectioninRun		: BOOL;
    nFirstErr			: WORD;
    nLastErr			: WORD;
    KL1904_input_1		: BOOL;
END_VAR

In the above example data of a TwinSAFE connection are written to the connected variables. When the output bConnectionInRun is FALSE the outputs nSafeTerminalData and nSafeLogicData are set to 0.

The linkage of the input data of the connection has to be done by marking the parameter TwinSAFETerminal and chossing "Change Link..." from the context menu

and choosing the correct SafetyIn variable in the upcoming dialog.

When using RT Ethernet for the TwinSAFE communication please choose the corresponding subscriber variable.

The linkage of the output data of the connection has to be done by marking the parameter TwinSAFELogic and chossing "Change Link..." from the context menu and choosing the correct SafetyQBx variable in the upcoming dialog.

Development environment | Target system type | IO-Hardware | PLC libraries to include
TwinCAT v2.10.0 Build > 914 | PC (i386) | KLx904 | TcTwinSAFE.Lib ( Standard.Lib, TcBase.Lib and TcSystem.Lib are included automatically )


ITcUserManager:CreateProcessAsUserDlg

TYPE ST_FSoE_xxBytes

TYPE ST_FSoE_xxBytes :
STRUCT
    CMD : BYTE;
    SafeData1 : WORD;
    CRC1 : WORD;
    SafeData2 : WORD;
    CRC2 : WORD;
    ...
    SafeData7 : WORD;
    CRC7 : WORD;
    ConnID : WORD;
END_STRUCT

ST_FSoE_xxBytes: Contains the Safety-over-EtherCAT telegram with the length of safe data of 2, 4, 6, 8, 10, 12 or 14 bytes (xx has to be replaced by 02 to 14).

Strukturelement | Beschreibung
CMD | Command ID. A detailed description can be found in the Safety-over-EtherCAT specification
SafeData1 | Safe data. A detailed description can be found in the Safety-over-EtherCAT specification
CRC1 | CRC checksum. A detailed description can be found in the Safety-over-EtherCAT specification
SafeData2 | Safe data. A detailed description can be found in the Safety-over-EtherCAT specification
CRC2 | CRC checksum. A detailed description can be found in the Safety-over-EtherCAT specification
... |
SafeData7 | Safe data. A detailed description can be found in the Safety-over-EtherCAT specification
CRC7 | CRC checksum. A detailed description can be found in the Safety-over-EtherCAT specification
ConnID | ID of the TwinSAFE connection. A detailed description can be found in the Safety-over-EtherCAT specification


ITcUserManager:CreateProcessAsUserDlg

TYPE ST_TWINSAFE_MESSAGE

TYPE ST_TWINSAFE_MESSAGE :
STRUCT
    Data: ARRAY[0..5] OF BYTE;
END_STRUCT

ST_TWINSAFE_MESSAGE: Contains the TwinSAFE telegram with a length of 6 bytes.

Bytenummer | Beschreibung
0 | A detailed description can be found in the Safety-over-EtherCAT specification
1 | A detailed description can be found in the Safety-over-EtherCAT specification
2 | A detailed description can be found in the Safety-over-EtherCAT specification
3 | A detailed description can be found in the Safety-over-EtherCAT specification
4 | A detailed description can be found in the Safety-over-EtherCAT specification
5 | A detailed description can be found in the Safety-over-EtherCAT specification


ITcUserManager:CreateProcessAsUserDlg

TYPE TwinSAFE_Data

TYPE TwinSAFE_Data :
    ARRAY[0..5] OF BYTE;
END_TYPE

TwinSAFE_Data : Contains the TwinSAFE telegram with a length of 6 bytes.

Bytenumber | Description
0 | A detailed description can be found in the Safety-over-EtherCAT specification
1 | A detailed description can be found in the Safety-over-EtherCAT specification
2 | A detailed description can be found in the Safety-over-EtherCAT specification
3 | A detailed description can be found in the Safety-over-EtherCAT specification
4 | A detailed description can be found in the Safety-over-EtherCAT specification
5 | A detailed description can be found in the Safety-over-EtherCAT specification