FB_TwinSAFE_connection
The function block FB_TwinSAFE_connection is made for evaluating the TwinSAFE data which is transferred from one TwinSAFE communication partner to another TwinSAFE communication partner. The input parameters have 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 must 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 transferred 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 network variable subscriber).
TwinSAFELogic: TwinSAFE telegram which is transferred from one TwinSAFE communication partner to another TwinSAFE communication partner. This parameter must 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 must 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 must be done by marking the parameter TwinSAFELogic and choosing "Change Link..." from the context menu and choosing the correct SafetyQBx variable in the upcoming dialog.

Requirements
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 ) |