TcSafetyPLC en PDF
TcSafetyPLC en PDF
TcSafetyPLC en PDF
Version: 1.2.0
Date: 2017-06-29
Table of contents
Table of contents
1 Foreword .................................................................................................................................................... 5
1.1 Notes on the documentation........................................................................................................... 5
1.2 Safety instructions .......................................................................................................................... 6
1.2.1 Delivery state ..................................................................................................................... 6
1.2.2 Operator's obligation to exercise diligence ........................................................................ 6
1.2.3 Description of safety symbols ............................................................................................ 7
1.3 Documentation issue status............................................................................................................ 7
3 Product description................................................................................................................................. 10
3.1 Intended use ................................................................................................................................. 10
3.2 Technical data .............................................................................................................................. 12
3.3 Safety parameters ........................................................................................................................ 13
3.4 Project design limits...................................................................................................................... 13
4 Operation.................................................................................................................................................. 14
4.1 Installation..................................................................................................................................... 14
4.1.1 Safety instructions............................................................................................................ 14
4.1.2 Specifications for transport and storage .......................................................................... 14
4.1.3 Mechanical installation ..................................................................................................... 14
4.1.4 Electrical installation......................................................................................................... 15
4.1.5 Software installation ......................................................................................................... 15
4.1.6 TwinSAFE reaction times................................................................................................. 15
4.2 Configuration of the TwinCAT Safety PLC in TwinCAT................................................................ 17
4.2.1 Configuration requirements.............................................................................................. 17
4.2.2 Creating a safety project in TwinCAT 3 ........................................................................... 17
4.2.3 CRC distribution ............................................................................................................... 39
4.2.4 Downloading the safety application ................................................................................. 40
4.2.5 Activating the safety application....................................................................................... 41
4.2.6 Safety and CRC toolbars ................................................................................................. 42
4.2.7 Info data ........................................................................................................................... 43
4.2.8 Task settings .................................................................................................................... 48
7 Appendix ................................................................................................................................................ 112
7.1 Support and Service ................................................................................................................... 112
7.2 Certificates.................................................................................................................................. 113
1 Foreword
This description is aimed specifically at trained qualified persons with a control and automation technology
background, who are familiar with the current national and international standards and guidelines.
These persons must be trained in the development, validation and verification of safety-related applications
in a high-level language in accordance with the normative software lifecycle, based on the requirements of
EN 61508.
The following instructions and explanations must be followed during installation and commissioning of the
components.
The qualified personnel must ensure that the application of the described products meets all safety
requirements, including all applicable laws, specifications, regulations and standards.
This documentation was originally written in German. All other languages are derived from the German
original.
Currentness
Please check whether you are using the current and valid version of this document. The current version can
be downloaded from the Beckhoff homepage at http://www.beckhoff.com/english/download/twinsafe.htm.
In case of doubt, please contact Technical Support [} 112].
Product features
Only the product features specified in the current user documentation are valid. Further information given on
the product pages of the Beckhoff homepage, in emails or in other publications is not authoritative.
Disclaimer
The documentation has been prepared with care. The products described are subject to cyclical revision. For
that reason the documentation is not in every case checked for consistency with performance data,
standards or other characteristics. We reserve the right to revise and change the documentation at any time
and without prior announcement. 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®, XFC® and XTS® 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 EtherCAT Technology is covered, including but not limited to the following patent applications and
patents: EP1590927, EP1789857, DE102004044764, DE102007017835 with corresponding applications or
registrations in various other countries.
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.
EtherCAT® is registered trademark and patented technology, licensed by Beckhoff Automation GmbH,
Germany
Copyright
Delivery conditions
In addition, the general delivery conditions of the company Beckhoff Automation GmbH & Co. KG apply.
Risk of injury!
Failure to follow the safety instructions associated with this symbol endangers the life and
health of persons.
WARNING
Personal injuries!
Failure to follow the safety instructions associated with this symbol can lead to injuries to
persons.
CAUTION
Tip or pointer
This symbol indicates information that contributes to better understanding.
Note
2 System description
The TwinCAT Safety PLC meets the requirements of IEC 61508:2010 SIL 3 and EN ISO 13849-1:2015
(Cat 4, PL e).
The TwinCAT Safety PLC realizes a safety-related runtime environment on a standard Industrial PC.
Currently only Beckhoff IPCs can be used. Further information on permitted configurations can be found in
the document “List of approved system configurations” on the Beckhoff website.
The safety-related logic can be created in Safety C, in future also via the graphical TwinSAFE Editor.
The basic rule for a safety system such as TwinSAFE is that failure of a part, a system component or the
overall system must never lead to a dangerous condition. The safe state is always the switched off and
wattless state.
Safe state
For all TwinSAFE components the safe state is always the switched-off, wattless state.
CAUTION
3 Product description
System limits
The TwinCAT Safety PLC is only permitted for hardware platforms that are included in the
"List of approved system configurations".
WARNING The TwinSAFE Editor for engineering and the TwinCAT Safety PLC runtime must be in-
stalled and used on physically different PCs.
Software environment
To have the full functionality of the TwinCAT Safety PLC available, it is necessary to use
Visual Studio 2015 Professional or a later version.
Note
The TwinCAT Safety PLC expands the application area of the Beckhoff I/O system with functions that enable
it to be used for machine safety applications. The TwinCAT Safety PLC is intended for safety functions of
machines and directly related tasks in industrial automation. They are therefore only approved for
applications with a defined fail-safe state. This safe state is the wattless state. Fail-safety according to the
relevant standards is required.
The software part of the TwinCAT Safety PLC is a software-based safety controller, which may only be used
on approved system configurations (consisting of development environment, runtime environment and
hardware platform).
Ensure traceability
The operator must ensure traceability of the equipment via the serial number.
CAUTION
Industrial PC used
Please note the technical data of Industrial PC used and ensure that it is only used as in-
tended.
CAUTION
Security
The TwinCAT Safety PLC is regarded as a self-contained system. Accordingly, the user is
responsible for evaluating and implementing appropriate safety and security measures for
CAUTION the individual components, including the development PC and the runtime environment.
Attention
1. No special proof tests are required during the entire service life of the TwinCAT Safety PLC.
2. Classification according to IEC 61508-2:2010 (see chapters 7.4.4.1.2 and 7.4.4.1.3)
The TwinCAT Safety PLC can be used for safety-related applications as defined in
IEC 62061:2005/A2:2015 SIL3, IEC 61508:2010 to SIL3 and EN ISO 13849-1:2015 to PL e (Cat4).
Further information on calculating or estimating the MTTFD value from the PFHD value can be found in the
TwinSAFE application manual or in EN ISO 13849-1:2015, Table K.1.
4 Operation
Please ensure that the TwinCAT Safety PLC is only transported, supported and operated under the ambient
conditions specified for the respective hardware platform (see technical data for the corresponding hardware
platform).
Risk of injury!
The TwinSAFE components must not be used under the following conditions.
• under the influence of ionizing radiation (exceeding the natural background radiation)
WARNING
• in corrosive environments
• in an environment that leads to unacceptable contamination of the hardware platform
Electromagnetic compatibility
The TwinSAFE components comply with the current standards on electromagnetic compat-
ibility with regard to spurious radiation and immunity to interference in particular.
Attention However, in cases where devices such as mobile phones, radio equipment, transmitters or
high-frequency systems that exceed the interference emissions limits specified in the stan-
dards are operated near TwinSAFE components, the function of the TwinSAFE compo-
nents may be impaired.
4.1 Installation
The typical response time is the time required for transferring a piece of information from the sensor to the
actuator, when the whole system operates normally, without error.
Definition Description
RTSensor Response time of the sensor, until the signal is made available at the interface. Typically
provided by the sensor manufacturer.
RTInput Response time of the safe input, e.g. EL1904 or EP1908. This time can be found in the
technical data. For the EL1904 the time is 4 ms, for example.
RTComm Response time of the communication. This is typically 3 times the EtherCAT cycle time,
since a new Safety-over-EtherCAT telegram has to be generated before new data can be
sent. These times directly depend on the standard control system (cycle time of the PLC/NC/
SafetyTask). Note which task synchronously controls the EtherCAT segment.
RTLogic Response time of the TwinCAT Safety PLC. This is the cycle time of the task in which the
TwinCAT Safety PLC is executed, if no timeout errors occur.
RTOutput Response time of the output terminal. This is typically between 2 and 3 ms.
RTActor Response time of the actuator. This information is typically provided by the actuator
manufacturer
WDComm Watchdog time of the communication
with
The worst-case response time is the maximum time required for switching off the actuator in the event of an
error.
It is assumed that a signal change takes place at the sensor, and that this is passed to the input. A
communication error occurs just at the moment when the signal is to be passed to the communication
interface. This is detected by the logic once the watchdog time of the communication link has elapsed. This
information should then be passed on to the output, resulting in a further communication error. This fault is
detected at the output once the watchdog time has elapsed, resulting in shutdown.
This results in the following formula for the worst-case response time:
with
TwinCAT support
The TwinCAT Safety PLC cannot be used under TwinCAT 2.
Note
The target system is set to TwinCAT Safety PLC in the drop-down list. Use the link button next to Append to
Task to link the target system to the task, with which the TwinCAT Safety PLC is to be executed.
A further group can be created by opening the context menu of the safety project and selecting Add and New
Item....
A group consists of subitems for the group configuration (*.grp), alias devices (*.sds), header files (*.h) and
source files (*.cpp). In addition there are subitems for test and for analysis files.
For each group there is one header file and one source file, which the user can use and adapt for the safety
application. These are the files <GroupName>.h and <GroupName>.cpp.
The test files ModuleTests.cpp and ModuleTests.h can be used for debugging the safety application. In
these files the safe inputs and outputs can be set and remain set if breakpoints are used, without having to
enable the whole configuration. In this state the communication is not safe!
The group configuration is used for the general group settings, including the info data or group ports for error
acknowledge and run/stop.
In addition, there is an option to create an internal process image for the TwinSAFE group. This process
image contains all the signals for use in other TwinSAFE groups. The defined variables are made available
to all other groups in a structure called TSGData in the header file <GroupName>IoData.h.
The connection- and device-specific parameters are set via the alias devices.
If the automatic import is started from the I/O configuration, a selection dialog opens, in which the individual
terminals, which are to be imported automatically, are selected.
The alias devices are created in the safety project when the dialog is closed via OK.
Alternatively, the user can create the alias devices individually. To this end select Add and New item from
the context menu, followed by the required device.
Select Edit in this dialog to adapt the process image and add the SafeTimer.
In addition, tick the checkbox for Use provided Safe Timer as reference under the Connection tab.
For a safety project a specific TwinSAFE component must be selected as provider for a safe time signal, to
ensure that a safety project can be loaded and started successfully. The safety project is only executed if the
provided safe time signal is available (i.e. the corresponding communication link must be in DATA state).
An error in the context of the safe time signal leads to triggering of the safe state for the TwinCAT Safety
PLC.
The Linking tab contains the FSoE address, the checkbox for setting as External Device and the link to the
physical I/O device. If an ADS online connection to the physical I/O device exists, the DIP switch setting is
displayed. Re-reading of the setting can be started via the button . The links to the TwinCAT Safety
PLC process image are displayed under Full Name (input) and Full Name (output).
The TwinCAT Safety PLC supports activation of a ComErrAck for each connection. If this signal is
connected, the respective connection must be reset after a communication error via the signal ComErrAck,
in addition to the ErrAck of the TwinSAFE group. This signal is linked via the link button next to COM
ERR Ack. The following dialog can be used for selecting an alias device. The signal can be canceled via the
Clear button in the link dialog.
The safety parameters matching the device are displayed under the Safety Parameters tab. They have to be
set correctly to match the required performance level. Further information can be found in the TwinSAFE
application manual.
For each alias device an entry with the corresponding FSoE stack is created in the safety PLC. It contains
links to the safe input and output components and also provides the data pointer for access to the safe
inputs and outputs within the safety application.
The data for each individual connection are declared as struct data type in <GroupName>IoData.h and
instantiated in the header file <GroupName>.h.
The user can access a safe input directly via the instance variable, e.g.
sSafetyInputs.EL1904_FSoE_211.InputChannel1.
Creating and opening of an alias device for an AX5805 results in five tabs; the Linking, Connection and
Safety Parameters tabs are identical to other alias devices.
The General AX5805 Settings tab can be used to set the motor string and the SMS and SMA functions for
one or two axes, depending on the added alias device.
The Process Image tab can be used to set the different safety functions for the AX5805.
The parameters under the General AX5805 Settings and Process Image tabs are identical to the parameters
under the Safety Parameters tab. Offers user-friendly display and editing of the parameters. The parameters
under the Safety Parameters tab can also be edited.
The parameters for this function can be set by selecting a function in the inputs or outputs and pressing the
Edit button. New safety functions can be added in the process image by selecting an empty field (---) and
pressing Edit.
The parameter list corresponding to the safety function can be shown; in addition, an optional diagram of the
function can be shown. At present the diagram is still static and does not show the currently selected values.
Before the connection can be used and linked further, the process image size must be parameterized. This
can be set under the Process Image tab. Suitable data types for different numbers of safety data are
provided in the dropdown lists for the input and output parameters.
Once the size is selected, the individual signals within the telegram can be renamed, so that a corresponding
plain text is displayed when these signals are used in the logic. If the signals are not renamed, the default
name is displayed in the editor (Safe Data Byte 0[0], …).
The connection is linked under the Linking tab. The Link button next to Full Name (input) and Full
Name (output) can be used to select the corresponding variable.
This can be a PLC variable, for example, which is then forwarded to the remote device or can be linked
directly with the process image of an EtherCAT Terminal (e.g. EL69x0 or EL6695).
Further information can be found in the TwinCAT documentation for the variable selection dialog.
Detailed information about the individual settings can be found in the following table.
Parameter Description User in-
teraction
required
Conn-No. Connection number: automatically assigned by the TwinCAT system No
Conn-ID Connection ID: pre-allocated by the system; can be changed by the user. A Conn Control
ID must be unique within a configuration. Duplicate connection IDs result in an
error message
Mode FSoE master: TwinCAT Safety PLC is FSoE master for this device. Control
FSoE slave: TwinCAT Safety PLC is FSoE slave for this device. (This option is
not supported in the first version of the TwinCAT Safety PLC).
Type None: Setting for third-party equipment, for which no ESI file is available. Yes
KL6904: Setting for KL6904 (safety parameter inactive)
EL69XX: Setting for EL6900/EL6930/EL6910/EJ6910 (safety parameter inactive)
Watchdog Watchdog time for this connection: A ComError is generated, if the device fails to Yes
return a valid telegram to the TwinCAT Safety PLC within the watchdog time.
Module Fault This checkbox is used to specify the behavior in the event of an error. If the Yes
is ComError checkbox is ticked and a module error occurs on the alias device, this also leads
to a connection error and therefore to disabling of the TwinSAFE group, in which
this connection is defined.
Safe Device-specific parameters: The parameter length is automatically calculated Yes
Parameters from the number of characters that is entered. This information will typically be
(Appl. Param) provided by the device manufacturer.
ComErrAck If ComErrAck is linked to a variable, the connection must be reset via this signal Yes
in the event of a communication error.
Info Data The info data to be shown in the process image of the TwinCAT Safety PLC can Yes
be defined via these checkboxes. Further information can be found in the
documentation for TwinCAT function blocks for TwinSAFE logic terminals.
The header files SafeModuleHelper.h and <GroupName>IoData.h are automatically created by the safety
editor. The files are not write-protected, i.e. the user could modify them, although they are recreated during
the compile process, which means all modifications would be overwritten.
SafeModuleHelper.h contains type definitions, macros and functions created by the safety editor.
<GroupName>IoData.h contains the I/O data structures of the alias devices and the TwinSAFE groups.
The header file <GroupName>.h can be used and expanded by the programmer. Here you can create type
definitions, variables and functions for the safety application module (<GroupName>.cpp).
The file <GroupName>.cpp is split into four parts. Four module functions are pre-defined and cannot be
changed. These include the Init function, which is called when the user application is initialized. The other
functions are InputUpdate, CycleUpdate, OutputUpdate, which are used for integrating the user application
in the cyclic process. Each of these functions is therefore called in each cyclic process (in the order
InputUpdate, CycleUpdate, OutputUpdate). These functions may only be called by the safe runtime
environment.
Module variables
All module variables (i.e. variables defined in file <TwinSAFE GroupName>.h) have to be
initialized as part of the Init function.
Note
Double-click on Target System to open the Target System dialog. In addition to the target system, the CRC
distribution can also be configured here.
The CRC Distribution dialog lists all safe alias devices that can be used for the CRC distribution. The
checkbox next to each entry can be used to specify whether the CRC is to be stored on the component. In
addition, the user can specify how many of the selected components have to return the correct CRC for the
TwinCAT Safety PLC to start. At least one component has to be selected here, in order to enable the safety
project to be downloaded and enabled for the TwinCAT Safety PLC.
environment has to be in Config state). Use the download button in the Safety toolbar, or the menu
item . No user input is required for downloading the safety application. The
project CRC of the safety project to be downloaded is displayed in the Download dialog. Use Finish to
confirm the project CRC and start the actual download.
To this end the current configuration has to be activated first, and TwinCAT has to be started in run mode. If
the safety project is not activated, a corresponding message appears in the TwinCAT 3 output window. Once
the configuration is active, the activation can be started via the unlock button or via the menu.
Confirming the CRC with the Finish button enables and starts the safety application. While the safety
application starts up, the CRC is distributed to the safe communication devices configured as part of the
CRC distribution. When the TwinCAT system is restarted, the safety application starts without having to
activate it again.
After the activation the TwinSAFE CRC toolbar shows the same CRC for online and offline.
The CRC toolbar shows the online and offline CRC. In addition, an icon indicates whether or not they are
identical.
The checkboxes Map Object ID and Map Project CRC can be used to specify that the object ID and the
project CRC should be copied into the process image of the TwinCAT Safety PLC on the target system.
From here, the entries Object Id and Project CRC can be linked to the standard PLC.
Connection Description
Info Data
State • 100 (0x64) Reset
The reset state is used to re-initialize the Safety over EtherCAT connection after the
power-on or a Safety over EtherCAT communication error.
• 101 (0x65) Session
During the transition to or in the Session state a session ID is transferred from the
Safety over EtherCAT master to the Safety over EtherCAT slave, which responds with
its own session ID.
• 102 (0x66) Connection
In Connection state a connection ID is transferred from the Safety over EtherCAT
master to the Safety over EtherCAT slave.
• 103 (0x67) Parameter
In Parameter state safe communication and device-specific application parameters are
transferred.
• 104 (0x68) Data
In Data state Safety over EtherCAT cycles are transferred until either a communication
error occurs or a Safety over EtherCAT node is stopped locally.
Diag • xxxx 0001 - Invalid command
• xxxx 0010 - Unknown command
• xxxx 0011 - Invalid connection ID
• xxxx 0100 - Invalid CRC
• xxxx 0101 - Watchdog expired
• xxxx 0110 - Invalid FSoE address
• xxxx 0111 - Invalid data
• xxxx 1000 - Invalid communication parameter length
• xxxx 1001 - Invalid communication parameters
• xxxx 1010 - Invalid user parameter length
• xxxx 1011 - Invalid user parameters
• xxxx 1100 - FSoE master reset
• xxxx 1101 - Module error detected on slave, with option "Module error is ComError"
activated
• xxxx 1110 - Module error detected on EL290x, with option "Error acknowledge active"
activated
• xxxx 1111 - Slave not yet started, or unexpected error argument
• xxx1 xxxx - FSoE slave error detected
• xx1x xxxx - FSoE slave reports Failsafe Value active
• x1xx xxxx - StartUp
• 1xxx xxxx - FSoE master reports Failsafe Value active
Inputs safe inputs of the connection
Outputs safe outputs of the connection
The Insert Task dialog is used to enter a task name and to specify whether the task is to be created with or
without image. Both options are available for the TwinCAT Safety PLC; in the example With Image is
selected.
Settings
Double-click on the task to open the task settings. Here you can set the cycle time and the priority.
The Online tab for the respective task can be used to check the execution time and the exceed counter.
C++ is essentially an upward compatible extension of C with language support for object orientation and
meta-programming, so that C programs can also be processed by C++ compiler (with some restrictions).
Programming in Safety C therefore also permits limited utilization of object-oriented C++ extensions for data
encapsulation and modularization of program modules by the application developer, although typical C++
concepts such as inheritance, polymorphism and generic template programming are basically not used.
From an application developer perspective, programming in Safety C is therefore closer to the development
procedure in C.
Compared with function block-based programming, high-level languages such as C/C++ enable
programmers much more freedom, although this also creates potential sources of systematic application
errors. In addition, the ISO standards for C/C++ deliberately leave scope for implementing efficient
compilers, so that a standard-compliant C/C++ program may contain undefined or platform-dependent
behavior (e.g. data type widths, division by zero or overflow/underflow of signed integer data types).
The safety standards to be applied for PLC systems therefore require the full scope of C/C++ to be restricted
for the development of safety functions in high-level languages (see IEC 61508-3:2010, for example) through
the application of language subsets with coding rules, in order to avoid programs with ambiguous semantics
and reduce the risk of generating faulty program code or programs with unexpected behavior. Furthermore,
this is intended to facilitate tool-based program analysis and verification, as well as manual analyses through
code inspections.
The permissible language scope of Safety C largely prevents generation of source code with undefined
behavior. At some points alternative helper functions with unambiguous semantics or integrated detection of
undefined behavior are offered, so that the application developer has the option to choose between native
operations and helper functions.
The main restrictions of Safety C compared with C and C++ can be summarized as follows:
• No support (with a few exceptions) for object orientation, meta-programming or other typical C++
extensions (compared with C)
• Limited data types and strong typing of all data types to avoid implicit type conversion effects
• Limitation to simple statements, operators and expressions to avoid unexpected results and side
effects
• Limitation of control flow statements (if-else, for, while, and switch-case) for understandable and
program sequences that can be analyzed
The templates are designed such that programmers can implement modifications and extensions only within
predefined ranges. It is not permissible to create further *.h / *.cpp files within the TwinSAFE group.
Preprocessor defines, type definitions (structs, enums) and module variables can be created in the module
header file (<group name>.h) (enums are not yet supported in V1). Only declaration of the module class with
user-defined module variables and functions is permitted, no implementation.
Once a group has been created, changes to <group name>.h and <group name>.cpp can only be made by
the user. Any changes are immediately secured through checksums (and are thus indirectly indicated to the
user through a change in the project CRC). This means that, if the group name is renamed, the source code
of <group name>.h and <group name>.cpp must be adapted manually. This applies to the name-specific
source code components that are generated at the time of creation (see comments in the source code
template).
Additional header files are dynamically created by the safety editor and cannot be modified by the user. Any
changes the user may have made in these files are overwritten during the compile process!
//\internal////////////////////////////////////////////////////////////////////
//! XML tags <...> enclosed by C style block comment markups are protected for
//! structural and semantic code analysis. Do NOT remove or reorder any of the
//! mandatory markups within the source code template as safe build process may
//! fail otherwise! For further information on how to write compliant Safety C
//! user code please refer to the provided Safety C coding guidelines document!
///////////////////////////////////////////////////////////////////////////////
/*<SafeUserApplicationHFrontend>*/
#pragma once
/*</UserDefinedIncludes>*/
///////////////////////////////////////////////////////////////////////////
//! \class TwinSafeGroup1
//! \brief Declaration of the Safety C user application module class
//! \details Put detailed description of your module functionality here
///////////////////////////////////////////////////////////////////////////
SAFE_MODULE(TwinSafeGroup1) // Rename according to TwinSAFE group name
{
SAFE_MODULE_EXPORT();
};
};
/*</SafeUserApplicationHFrontend>*/
Source code template for implementing a Safety C application module: <TwinSAFE GroupName>.cpp
///////////////////////////////////////////////////////////////////////////////
//! \file TwinSafeGroup1.cpp
//! \brief Source file of the TwinSafeGroup1 application module
//! \ingroup TwinSafeGroup1
//! \authors Administrator
//! \copyright Put affiliation and copyright notice here
//! \version V1.0
//! \date 2016-09-29
//! \details Put detailed description of your module implementation here
///////////////////////////////////////////////////////////////////////////////
///\internal///////////////////////////////////////////////////////////////////
//! XML tags <...> enclosed by C style block comment markups are protected for
//! structural and semantic code analysis. Do NOT remove or reorder any of the
//! mandatory markups within the source code template as safe build process may
//! fail otherwise! For further information on how to write compliant Safety C
//! user code please refer to the provided Safety C coding guidelines document!
///////////////////////////////////////////////////////////////////////////////
/*<SafeUserApplicationCppFrontend>*/
/////////////////////////////////////////////////////////////////////////////
//! \brief Implementation of the safe user module input update function
/////////////////////////////////////////////////////////////////////////////
/*<TcInputUpdate>*/
VOID CSafeModule::InputUpdate()
{
// Put your module input update code here
}
/*</TcInputUpdate>*/
/////////////////////////////////////////////////////////////////////////////
//! \brief Implementation of the safe user module output update function
/////////////////////////////////////////////////////////////////////////////
/*<TcOutputUpdate>*/
VOID CSafeModule::OutputUpdate()
{
// Put your module output update code here
}
/*</TcOutputUpdate>*/
/////////////////////////////////////////////////////////////////////////////
//! \brief Implementation of the safe user module cycle update function
/////////////////////////////////////////////////////////////////////////////
/*<TcCycleUpdate>*/
VOID CSafeModule::CycleUpdate()
{
// Put your cycle update code here
}
/*</TcCycleUpdate>*/
/*</SafeUserApplicationCppFrontend>*/
5.2.1 Definitions
Term Explanation
strict/strong typing Implicit type conversions are not permitted in Safety C. For each operation,
assignment or parameter passing, the data type of all operands must match the
target data type (with few exceptions that are regarded as safe). Any discrepancy
between the data types must be resolved through an explicit conversion. (see
chapter Strong typing [} 58])
pure functions The function always provides the same result, when the same arguments are
transferred to the function. The result of the function does not depend on internal
locals or globals and variables, other internal information or input signals. A pure
function is a function without side effect. All helper functions provided are pure
functions.
non-pure functions / Each function that uses state variables or input/output signals or other internal
impure functions information should be regarded as potentially "impure" or "non-pure", since it may
return different results at different call times. A non-pure / impure function is a
function with side effect. User-defined functions are generally regarded as impure,
even if they meet the criteria of a pure function.
Operator precedence Determines the order to be used for the operators of a programming language,
whereby a composite expression can be transferred to a syntax tree for further
processing by the compiler. In Safety C, the operator precedences are clearly
defined through the derivation from the C/C++ standard.
Operator associativity Determines the order of operators of the same precedence in a composite
expression, unless explicitly given by parentheses. In Safety C, the operator
associativity is clearly defined through the derivation from the C/C++ standard. The
expression (a + b + c) is therefore unambiguously processed through the left
associativity of the addition with the following implicit parentheses: ((a + b) + c)
This effect is particularly important in cases where the order of the operators to be
applied can affect on the overall result. In Safety C the operator associativity must
also be taken into account for compliance with the strong typing.
Evaluation Determines the order to be used when evaluating operands, such as performing
sequence function calls or incrementing a variable as part of a composite expression. The
evaluation sequence can affect the result of an expression if it contains several
mutually dependent side effects. The C/C++ standard does not define a clear
evaluation sequence! For the sake of clarity of Safety C Code, restrictions are
therefore imposed on expressions, in order to avoid the effects of an ambiguous
evaluation sequence.
Recursion A recursion means that a function or procedure calls itself. A distinction is made
between direct and indirect recursion:
direct recursion: A() calls A()
indirect recursion: A() calls B(), B() calls A(), ...
Short circuit evaluation Short circuit evaluation or conditional evaluation refers to a behavior, which for
Boolean operations results in premature abortion of the evaluation. If a result is
unambiguously determined after part of an operation, the following sub-operations
are no longer executed.
Example: c = a&&b;
If a is false, the result c is unambiguously determinable; the operation is therefore
aborted, and c is directly set to false, without evaluation of b.
5.2.2 General
Data types
In the development of the safety application, the user should ensure that a distinction is
made between the data types BOOL and safeBOOL and other safe and non-safe data
Note types. This simplifies the subsequent verification and validation of the realized application.
In V1 safe and non-safe data types are identical from the perspective of the type system.
The user therefore has to assess intermixing of safe and non-safe input signals based on
current standards.
Control structures
For loops are preferable to while loops, since the termination is easier to realize.
Note
The following general rules apply for context-dependent restriction of operators and function calls in
expressions:
• The logic operators &&, || may only be used in conditional expressions of if, for and while statements
(and in the conditional expressions of assert statements).
• The conditional expressions of if, for and while statements must return the result of a comparison
operation (==, !=, <, >, <=, >=). In addition, complex composite operands of this compare operations
should be enclosed in parentheses, e.g.:
while(flag==true) //Statt while(flag)
if (0>(a+b)) //Statt if(0>a+b) oder if(a+b)
• Function calls with potential side effects (so-called "non-pure functions") may only be called as simple
statements, either without assignment of a return value or (if a return value is used) with direct
assignment of the return value to a variable, in order to ensure that the order of evaluation is clearly
determined (i.e. they must not be called as part of a condition or switch expression). Permitted
(example):
INT32 r1 = MyNonPureFunc1();
INT32 r2 = MyNonPureFunc2();
INT32 r = r1 + r2;
Not permitted (example):
INT32 r = MyNonPureFunc1() + MyNonPureFunc2();
• Functions without side effects ("pure functions") may also be used as part of switch or conditional
expressions. Examples of side effect-free functions include helper functions provided by the TwinCAT
Safety PLC, such as mathematical functions or conversion functions. They can be combined with "non-
pure” functions, as long as there is only one call of a "non-pure” function per expression. Permitted
(example):
INT32 r1 = MyPureFunc1() + MyNonPureFunc1(MyPureFunc2());
• It is generally assumed that the predefined module interface functions (Init, InputUpdate, CycleUpdate,
OutputUpdate), user-defined functions and function blocks have potential side effects. For this reason
they may only be called as simple line statements, with or without assignment (see item 3), e.g.:
MyFB1.CycleUpdate();
int y = MyFunction(42, y);
y = MyFunction2();
Calling the interface functions as entry point for the user application is only permitted from the safe
runtime environment. User-defined calls of Init() and CycleUpdate() are only allowed for FB instances
(FBs are not supported in V1).
• The operators post-increment (++) and post-decrement (--) may only be used as simple line statements
(e.g. i++; i--;) (except the third expression of the statement line in a for head of the loop).
• The assignment operator may only be used as part of simple statements with assignment, with the
exception of the first and third expression of the statement line of a for head of the loop (e.g. INT32
i=0;). Multiple assignments are not permitted in a line statement (e.g. a=b=c;), neither are assignments
as default value initialization in function signatures.
• In general, all primitive data types must be strongly typed on assignment and for parameter passing
and function return, in contrast to standard C/C++. Exceptions are combinations of a smaller source
datatype with a larger target datatype with the same signedness (see chapter Strong typing [} 58]).
• To avoid unintentional effects, further combinations of data types and operators are restricted (see
chapter Strong typing [} 58]).
• The use of the explicit type conversion operators requires additional parentheses if the expression to
the right of the transformation operator is a non-bracketed, complex expression:
INT32 i32 = (INT32)u16 * -u16; // Not permitted, since it is not clear which expression is meant as the
operand of the type conversion operator
INT32 i32 = (INT32)(u16) * -u16; // Permitted, since unambiguous
Limitation of complexity
Warnings are issued when a certain complexity is exceeded (known as McCabe index or
zyclomatic complexity). An index of < 10 per function is recommended.
Note
• index > 20 per module function
• index > 50 per module (error for index > 1000)
Explanations for the operator type constraints shown in the following tables:
1. Logic operators (&&, ||, !) may only have variables, literals (true, false) or expressions of type BOOL as
operands.
2. Arithmetic operators (+, -, *, /, %) may only have variables, literals (decimal, hexadecimal, binary) or
expressions of integer arithmetic types (U)INT(8/16/32) as operands.
3. Bitwise operators (&, |, ^, ~, <<, >>) may only have variables, literals (decimal, hexadecimal, binary) or
expressions of integer unsigned arithmetic types UINT(8/16/32) as operands.
4. The comparison operators (<, >, <=, >=) may not have variables, literals (true, false) or expressions of
type BOOL as operands.
5. Binary operators (comparison, arithmetic, bitwise, logic) with left and right operand (+, -, *, /, %, &, |, ^,
<<, >>, ==, !=, <, >, <=, >=) may only contain variables, literals (Boolean, decimal, hexadecimal, bi-
nary) or expressions of the same type (for other restrictions see above).
6. "Integral promotions" (C++ standard conversions to type INT32) of the result expression of operations
with operands of small integer data types (U)INT(8/16) have to be neutralized through an explicit type
conversion, if one of the rules under 1. - 5. is violated,
e.g. in the event of summation of UIN8 expressions in the UINT8 number range:
1: UINT8 z = …; UINT8 a = …;
2: z = (UINT8)(a + (UINT8)(a + a)); //instead of a = a + a + a;
Without type conversion of the INT32 result expression from a+a back to INT8, the type equality rule
for the subsequent addition would be violated. The same applies to the subsequent assignment to the
UINT8 type. Alternatively, all UINT8 expressions can be previously converted to INT32 expressions,
before the summation in the INT32 number range is applied:
3: UINT8 z = …; UINT8 a = …;
4: z = ((INT32)a) + ((INT32)a) + ((INT32)a);
Note, however, that this may lead to a different result. The aim of strong typing is to make the intention
of the application developer regarding type conversion effects explicitly visible.
Permitted (example):
INT16 i16; UINT8 u8; …
INT32 i32 = i16; // Not type-equivalent, but permitted
UINT16 u16 = u8; // Not type-equivalent, but permitted
Further exceptions apply for the initialization of module variables with constant literals. Permitted (ex-
ample):
INT8 i8; // Declaration as module variable
UNT16 u16; // Declaration as module variable
…
i8 = 0; // Permitted, despite the fact that it is a constant literal of type INT32
u16 = 42U; // Permitted, despite the fact that it is a constant literal of type UINT32
7. The explicit type conversion operator () may only be used for conversion of a variable, literal (decimal,
hexadecimal, binary) or expression from one integer arithmetic type (U)INT(8/16/32) to another. The
explicit type conversion operator may lead to loss of data or sign. If this is not desired or if it should be
detected, the helper functions should be used for the conversion.
8. The same source and target types or function signatures must be used for assignment (=), transfer
and return of function parameters and results, or from smaller arithmetic data types to larger data
types without conversion between signed and unsigned data type (safe exception of strong typing).
For initialization statements of type UINT8 a = 10U, the compiler checks whether the literal matches
the declared data type. However, this is only permitted if the declaration and initialization are com-
bined in a simple line statement, or if the initialization applies to a simple module variable.
9. Complex data types (structs) only support assignments for the same type (=), transfer as function pa-
rameter and return through functions, as well as the access operator (.) for data members. The appli-
cation of explicit type conversion to complex data types is generally not forbidden.
Only operator type combinations that have an entry in the following tables are allowed. The type identifier in
the cell is the result type of the operation (taking into account C++ standard type conversions). The right-
hand operand (RHS) is shown in the header, the left-hand operand (LHS) in the first column.
+=, -=, *=, BOOL INT8 UINT8 INT16 UINT16 INT32 UINT32
/=, %=
BOOL
INT8 INT8
UINT8 UINT8
INT16 INT16
UINT16 UINT16
INT32 INT32
UINT32 UINT32
&=, |=, ^=, BOOL INT8 UINT8 INT16 UINT16 INT32 UINT32
<<=, >>=
BOOL
INT8
UINT8 UINT8
INT16
UINT16 UINT16
INT32
UINT32 UINT32
Type rules for assignments, and transfer of function parameters and return of return values
The C/C++ standard stipulates that complex expressions are processed according to a tree structure based
on the implicit operator precedences and operator associativity.
The tree structure is determined by the C/C++ compiler based on the standard and may include implicit type
conversions that are not allowed in Safety C. Apart from a few safe exceptions, in Safety C the permitted
operator type combinations or function signatures have to be considered exactly (strong typing, see matrix
tables)
The implicit operator precedences and the operator associativity can be influenced and the tree structure can
be changed through explicit parentheses.
• Leaf nodes
(these are literals, data references and parameterless function calls)
• Inner nodes
(these are operators or parameterized function calls, which each process one or several sub-
expressions)
• Tree edges
(these are intermediate results of evaluated partial expressions, each with a data type which can be
statically determined at the time of compilation through processing of the nodes according to the tree
structure from the leaf node (at the bottom of the tree structure) to the root node (at the top of the tree
structure))
The evaluation sequence of the leaf nodes is not clearly defined by the C/C++ standard and is specified by
the compiler. In Safety C, expressions with possible side effects have to be restricted, due to the undefined
evaluation sequence (see also Expressions and operators [} 73])
Summation as example
Initial situation: The user wants to program a summation of integer expressions of type UINT8 in Safety C.
The expressions can be literals, variables or function returns, in this case: a, b, c.
Case 1:
Case 2:
If it is clear that the sum cannot exceed the UINT8 number range, or if implicit truncation (modulo arithmetic)
is desired:
UINT8 z = a + b + c;
5.2.3.1.1 Case 1
Sample 1
Sample 2
Sample 3
Sample 4
Sample 5
5.2.3.1.2 Case 2
Sample 1
Sample 2
// Or even that:
UINT8 z = a;
z += b;
z += c; // OK, compact and with clear intention
Data types
INT and UINT are 16-bit types in the TwinCAT Safety PLC, as defined in IEC 61131-3.
In TwinCAT C++, INT and UINT are 32-bit types.
Note
Invalid types
Any C/C++ type identifiers that are not listed, such as unsigned int, char, etc., are not per-
mitted. Pointer types and reference types are also not permitted. All value transfers must
Attention be based on call-by-value.
Specifications
• Local variables must be initialized before they are used and must be used
• Module variables must be initialized in the Init function and read in the code
Note
• Input variables may not be written
• Output variables may not be read
5.3.3.1 Structs
Struct types encapsulate the I/O data (safe/non-safe input/output data and cross-group data). These struct
types are generated as part of <TwinSAFEGroupName>IoData.h from the alias device configuration.
Default variables of this struct types are created in the TwinSAFE group template as module variables with
the name prefix "s".
Furthermore, user-defined struct types can be created in the module header file under
<UserDefinedTypes>…</UserDefinedTypes>; this definition can have an optional leading "typedef". A global
instance variable for a struct type is NOT permitted.
They may be nested hierarchically. Inner struct types of nested struct type definitions MUST have an inner
instance variable for access. Inner struct types are anonymous types and must not be instantiated
independent of their hierarchical parent struct type.
Examples
typedef struct MyData
{
INT32 a;
UINT8 b;
BOOL c;
};
struct MyFunctionInterface
{
struct
{
BOOL a;
BOOL b;
} In;
struct
{
BOOL z;
} Out;
}
Variables of struct instances are accessed via the "." access operator.
User-defined struct types can be used as bidirectional interface for transfer of I/O data for function calls. The
transfer is still based on value transfer ("call-by-value").
Access examples:
MyFunctionInterface callFunc;
callFunc.In.a = true;
callFunc.In.b = false;
callFunc = MyFunction(callFunc);
BOOL result = callFunc.Out.z;
Struct instances must be initialized before they can be used, just like simple variables. Default initialization
within the type definitions are not permitted.
5.3.3.2 Arrays
Not yet supported in V1.
The following types are supported as part of a function body or the body of a control structure block:
Type-0
<expression>;
e.g. function call without return.
Type-1
<type> <identifier>;
e.g. declaration of variables without initialization.
Type-2
<identifier> = <expression>;
e.g. initialization of variables
e.g. operations/function call with result assignment
Type-3
Special cases
Restrictions
e.g. a = b = c;
NOTE: Component 1 and 3 of a for control flow statement (for (<1>; <2>; <3>)) are regarded as simple
instructions, despite the fact that they appear to belong to a line statement.
Special statements
return <expression>;
Break;
Any further C/C++ control flow statements such as goto, continue, throw, etc. are not permitted
5.3.5.1 If-Else
Basic form
if (<COND>)
{
<BLOCK>
}
else
{
<BLOCK>
}
Guidelines
• The else branch is compulsory
(if it is empty, the special comment /*<IntentionallyEmpty/>*/ must be added to avoid a warning)
• No else-if branches are permitted
• Restrictions for the <COND> expression:
◦ Must always be the result of a comparison operation (<,>,<=,>=,==,!=); the left and right sub-
expressions of comparison may have to be enclosed in parentheses (if they do not consist of a
simple literal or identifier)
◦ No function calls with potential side effects
◦ No assignments, no post-/pre-increment/decrement
[CODE SAMPLE]
if ((safeIn1 && safeIn2) == true)
{
sSafeOutputs.EL2904_FSoE_4.OutputChannel1 = true;
sSafeOutputs.EL2904_FSoE_13.OutputChannel4 = true;
}
else
{
sSafeOutputs.EL2904_FSoE_4.OutputChannel1 = false;
sSafeOutputs.EL2904_FSoE_13.OutputChannel4 = false;
}
5.3.5.2 While
Basic form
while (<COND>)
{
<BLOCK>
}
Guidelines
• No break statement allowed
• No continue statement allowed
• Restrictions for the <COND> expression:
◦ Must always be the result of a comparison operation (<,>,<=,>=,==,!=); the left and right sub-
expressions of comparison may have to be enclosed in parentheses (if they do not consist of a
simple literal or identifier)
◦ No function calls with potential side effects
◦ No assignments, no post-/pre-increment/decrement
• Special comment /*<LoopBound max="N"/>*/ must be added at the start of <Block> in order to avoid a
warning; N is the number of expected passes (N>1).
[CODE SAMPLE]
5.3.5.3 For
Basic form
for (<STMT1>; <COND>; <STMT2>)
{
<BLOCK>
}
• No break statement allowed
• No continue statement allowed
• Restriction for <STMT1> expression
◦ Type 3 (see simple statements)
• Restrictions for the <COND> expression
◦ Must always be the result of a comparison operation (<,>,<=,>=,==,!=); the left and right sub-
expressions of comparison may have to be enclosed in parentheses (if they do not consist of a
simple literal or identifier)
◦ No function calls with potential side effects
◦ No assignments, no post-/pre-increment/decrement
• Restriction for <STMT2> expression
◦ Type 2 (see simple statements)
◦ Post-increment/decrement instruction
• The following applies if the for loop is not in a basic form, e.g. for (int i=0; i<10; i++):
Special comment /*<LoopBound max="N"/>*/ must be added at the start of <Block> in order to avoid a
warning; N is the number of expected passes (N>1).
[CODE SAMPLE]
for (INT32 i=N; i >= 0; i-=2)
{
/*<LoopBound max=”42”/>*/
DoSomeComputations();
}
Basic form
switch (<EXPR1>)
{
case <EXPR2>:
<BLOCK>
break;
…
default:
<BLOCK>
break; }
Guidelines
• At least one case block is required
• A default block is mandatory
• The case/default block must end with a break statement
• Restriction for <EXPR1> expression
◦ No function calls with potential side effects
◦ Not a logical expression (no expression of type BOOL)
◦ No assignments, no post-/pre-increment/decrement
• Restriction for <EXPR2> expression
◦ Constant expression (no variables, no function calls)
◦ Not a logical expression (no expression of type BOOL)
Permissible operators
Assignment operators
binary a=b
Restrictions:
• Not permitted as part of conditional expressions, no multiple assignments.
• Operands a and b must be of the same type, or signed/signed or unsigned/unsigned and with bit width
a greater than b.
Arithmetic operators
unary -a
binary a+b, a-b, a*b, a/b, a%b
with assignment a+=b, a-=b, a*=b, a/=b, a%=b
Post-increment/decrement a++, a--
Restrictions:
• Only simple, arithmetic data types are permitted (no BOOL, no structs).
• The operands a, b must be of the same type.
• With assignment only permitted as part of type 2 statements.
• Increment/decrement not permitted as part of expressions (only as simple line statement).
• Overflows/underflows may generate undefined behavior. Carry out appropriate checks or use safe
helper functions!
Bitwise operators
unary ~a
binary a&b, a|b, a^b, a<<b, a>>b
with assignment a&=b, a|=b, a^=b, a<<=b, a>>=b
Restrictions:
• Only simple, unsigned arithmetic data types are permitted (UINT8, UINT16, UINT32).
• The operands a, b must be of the same type.
• With assignment only permitted as part of type 2 statements.
• Shift operations can lead to undefined behavior. Carry out appropriate checks or use safe helper
functions!
Logic operators
unary !a
binary a&&b, a||b, a!=a
Restrictions:
• Only type BOOL permitted.
• Short-circuit operators &&, || are only permitted as part of conditional expressions.
As a substitute, see safe helper functions with complete evaluation: AND(a,b), AND3(a,b,c),
AND4(a,b,c,d) and OR(a,b), OR3(a,b,c), OR4(a,b,c,d).
Comparison operators
binary a==b, a!=b, a<b, a>b, a<=b, a>=b
Restrictions:
• Only simple data types permitted (no structs).
• The operands a, b must be of the same type.
• Comparison of BOOL is only permitted with == and !=.
Restrictions:
• Only simple data types permitted (no structs).
• No explicit type conversion from/to BOOL is permitted.
As a substitute for type conversion from BOOL to arithmetic, see safe helper functions with
unambiguous definition.
• Explicit conversions can lead to sign and data loss. Carry out appropriate checks or use safe helper
functions!
Struct access
binary a.b
Integer literals
The suffix "U" defines literals of type UINT32, even if they can be represented as INT32.
Sign
Literals are specified unsigned, i.e. a minus sign is regarded as an operation. A plus sign is
not permitted, since literals are implicitly regarded as positive.
Note
Boolean literals
Decimal format
Hexadecimal format
Binary format
• false
• 0U
• 987654321
• 0xFF
• 0x0
• 0XFEDCBA98U
• 0b11010100
• 0B0U
Type cast
The type of the captured expression must also be taken into account for the assignment of
literals. For example,
Note INT8 x;
x = 0;
leads to a type error (in this case a type cast through (INT8) is required)
An exception is a declaration statement with combined initialization, provided the literal
matches the target type and the sign suffix is selected correctly, e.g.:
UINT16 x = 65535U;
A further exception is the initialization of simple module variables, which can be assigned
apart from their declaration in the module header through a type 2 statement with suitable
literal, e.g.:
i8ModuleVar = 42;
The keyword "const" is not permitted. Constants have to be defined via a preprocessor "define" (see
dedicated section in the module header file).
A preprocessor directive for defining a constant must have the following form (with optional parenthesis):
Predefined constant
SafeModuleHelper.h defines constants for minimum and maximum values of the permitted data types. Note
that the maximum negative value of INT32 (-2147483648) cannot be used directly as literal:
#define I8_MIN ((INT8) -128 )
#define I8_MAX ((INT8) 127 )
#define I16_MIN ((INT16) -32768 )
#define I16_MAX ((INT16) 32767 )
#define I32_MIN ( -2147483647-1 )
#define I32_MAX 2147483647
#define U8_MAX ((UINT8) 255U )
#define U16_MAX ((UINT16) 65535U )
#define U32_MAX 4294967295U
In addition, the user may declare and define module functions with or without return value. Dedicated
sections are available in the .cpp/.h files for this purpose. Functions with return value must have a final
”return” statement.
User-defined functions can be called from the four interface functions and from the specially defined
functions, provided this does not lead to direct/indirect recursion. In addition, auxiliary functions are available
for application via SafeModuleHelper.h.
5.3.9.1 Asserts
FAILSAFE_ASSERT(<id>, <cond>)
The instruction FAILSAFE_ASSERT() can be used as tool for defensive programming for dealing with
undefined application states at runtime without fallback strategy, e.g. in situations with invalid yet possible
inputs. If a response at application level is possible (e.g. through setting of safe default values), a case
distinction with if-else/switch control structures should be used instead.
It should be able to trigger a FAILSAFE_ASSERT() through a fault test (negative test) at module test level. If
this is not the case, the instruction is presumably unnecessary, since detection of the incorrect execution of
the user code is already ensured through the safe runtime environment. For c=a+b;, for example, it can
therefore be assumed that the statement is executed correctly or any inconsistency is detected. The same
applies to control structures, function calls, etc.
Parameter Description
<id> A short, concise C++ identifier (output as plain text either in the module test output or
via ADS message in the TwinCAT error list window)
<cond> Boolean conditional expression, for which the same restrictions apply as for if(),
while(), etc.
Is triggered if <cond> is FALSE, i.e. <cond> must hold in a valid case!
Triggering in a non-safe module test results in termination of a test case with text output. In the event of a
fault test case, the test case is regarded as passed if the termination with given <ID> and in a given test step
was expected. Otherwise the test case or fault test case is regarded as failed.
FAILSAFE_ASSERT()
The instruction FAILSAFE_ASSERT() sets the safe state of the TwinSAFE group in the
safe runtime environment, if the condition <cond> returns FALSE.
Note
DEBUG_ASSERT(<id>, <cond>)
The instruction DEBUG_ASSERT() can be used for documenting and checking internal assumptions relating
to user-defined program code (preconditions, postconditions, invariants) during the test phase.
Example: Testing of return values or parameters and operands BEFORE a function call or an operation.
Parameter Description
<id> A short, concise C++ identifier (output as plain text either in the module test output or
via ADS message in the TwinCAT error list window)
<cond> Boolean conditional expression, for which the same restrictions apply as for if(),
while(), etc.
Is triggered if <cond> is FALSE, i.e. <cond> must hold in a valid case!
Triggering in a non-safe module test results in termination of a test case with text output and evaluation as
failed.
DEBUG_ASSERT()
In a safe runtime environment the instruction DEBUG_ASSERT() leads to an error or Log-
Window message, if the condition <cond> returns FALSE. Execution of the safety-related
Note application is being continued!
TEST_ASSERT(<cond>)
The instruction TEST_ASSERT() is used to check the assumptions relating to the outputs from a program
module to be tested as part of a module test. Concrete results can be evaluated and general assumptions
can be defined, e.g. to check the relationship between inputs and outputs and internal module variables.
TEST_ASSERT() is the test counterpart to DEBUG_ASSERT() and should therefore ideally be defined by an
independent person.
Parameter Description
<cond> Boolean conditional expression, for which the same restrictions apply as for if(),
while(), etc.
Is triggered if <cond> is FALSE, i.e. <cond> must hold in a valid case!
5.3.9.2 Traces
BRANCH_TRACE()
BRANCH_TRACE() is required for branch coverage measurement in the module test environment, if no
external tool is used for this purpose. A branch ID is automatically numbered according to the document
sequence. The output is generated via ADS by selecting a corresponding log level when the branch is
reached. The output only takes place within the safe runtime environment, not in the module test output.
A BRANCH_TRACE(), if used, must be positioned at the end of a branch, or, if return/break statements are
used, directly before the statement.
A warning is generated if they are set redundantly or are incomplete. The test takes place when a
BRANCH_TRACE() is used only.
Coverage of the branches is indicated in the output at the end of the module test execution. The output IDs
of branches that could not be reached can be assigned to source text lines via the information in
ModuleDatabase.saxml in the TwinSAFE group folder “Analysis Files”. A module test branch coverage of
100% is generally regarded as a minimum criterion for safety-related applications! The special comment
/*<DefensiveBranch/>*/ can be used to exclude branches from the test coverage measurement. This should
only be used in cases where unreachable code is to remain in the source text for a justified reason. This
should not include branches for trapping invalid inputs, since these can be covered by a negative test.
DEBUG_TRACE(<expr>)
The instruction DEBUG_TRACE() can be used for test outputs of local variables and intermediate results for
simple data types, which cannot be output via the process image.
The log output takes place via ADS in TwinCAT if the safe runtime environment is used. Within a module test
a simple text output is used.
Parameter Description
<expr> may be a side effect-free expression of a simple data type, i.e. structs are not
permitted
Complex calculations in control flow statements, particularly function calls and real-valued mathematical
functions (not yet supported in V1), should initially be performed in a line statement, involving assignment to
a local variable. The intermediate result stored in the variable can be incorporated in the condition, e.g. in an
if-else instruction:
For loop conditions, constant sub-expressions that may contain complex sub-calculations should also be
assigned to a variable as provisional result in line statements:
If switch case constructs with many cases are used, the switch expression should also be handled
externally. The following example illustrates in which cases an optimization should be considered (even for a
purely integer based expression):
Standard inputs
//! Struct providing input data of the corresponding standard alias devices
struct StandardInputs
{
//! ..\Alias Devices\ErrAck.sds
struct _ErrAck
{
BOOL In;
} ErrAck;
//! ..\Alias Devices\Run.sds
struct _Run
{
BOOL In;
} Run;
};
Standard outputs
//! Struct storing output data for the corresponding standard alias devices
struct StandardOutputs
{
//! ..\Alias Devices\DiscrepancyError.sds
struct _DiscrepancyError
{
BOOL Out;
} DiscrepancyError;
//! ..\Alias Devices\DiscrepancyCounter.sds
struct _DiscrepancyCounter
{
UINT32 Out;
} DiscrepancyCounter;
};
Safe inputs
//! Struct providing input data of the corresponding safety alias devices
struct SafetyInputs
{
//! ..\Alias Devices\EL1904_FSoE_211.sds
struct _EL1904_FSoE_211
{
safeBOOL InputChannel1;
safeBOOL InputChannel2;
safeBOOL InputChannel3;
safeBOOL InputChannel4;
} EL1904_FSoE_211;
//! ..\Alias Devices\2 safe in 2 safe out.sds
struct __2_safe_in_2_safe_out
{
safeBOOL InputChannel1;
safeBOOL InputChannel2;
} _2_safe_in_2_safe_out;
//! ..\Alias Devices\AX 5805 Drive Option.sds
struct _AX_5805_Drive_Option
{
safeBOOL Axis_1_STO;
safeBOOL Axis_1_SSM1;
safeBOOL Axis_1_SSM2;
safeBOOL Axis_1_SOS1;
safeBOOL Axis_1_SSR1;
safeBOOL Axis_1_SDIp;
safeBOOL Axis_1_SDIn;
safeBOOL Axis_1_Error_Ack;
} AX_5805_Drive_Option;
};
Safe outputs
//! Struct storing output data for the corresponding safety alias devices
struct SafetyOutputs
{
//! ..\Alias Devices\EL2904_FSoE_13.sds
struct _EL2904_FSoE_13
{
safeBOOL OutputChannel1;
safeBOOL OutputChannel2;
safeBOOL OutputChannel3;
safeBOOL OutputChannel4;
} EL2904_FSoE_13;
//! ..\Alias Devices\EL2904_FSoE_4.sds
struct _EL2904_FSoE_4
{
safeBOOL OutputChannel1;
safeBOOL OutputChannel2;
safeBOOL OutputChannel3;
safeBOOL OutputChannel4;
} EL2904_FSoE_4;
//! ..\Alias Devices\2 safe in 2 safe out.sds
struct __2_safe_in_2_safe_out
{
safeBOOL OutputChannel1;
safeBOOL OutputChannel2;
} _2_safe_in_2_safe_out;
//! ..\Alias Devices\AX 5805 Drive Option.sds
struct _AX_5805_Drive_Option
{
safeBOOL Axis_1_STO;
safeBOOL Axis_1_SS11;
safeBOOL Axis_1_SS21;
safeBOOL Axis_1_SOS1;
safeBOOL Axis_1_SSR1;
safeBOOL Axis_1_SDIp;
safeBOOL Axis_1_SDIn;
safeBOOL Axis_1_Error_Ack;
} AX_5805_Drive_Option;
};
The module variables u16SafeTimer can be used to access the safe time signal. This is a 16-bit timer value,
which can be used for time-dependent functionalities within the safety application. This time value may not
be used in the Init function (since it is not yet available at this time). The timer is only suitable for time
measurements across application cycles, since the timer variable remains constant within an application
cycle. Write access to the timer variable is not permitted.
Verification
Confirmation that the requirements are met, based on an examination and provision of evidence.
NOTE
In the context of this standard, verification refers to the process of demonstrating in each phase of the
relevant safety lifecycle (total, E/E/PE system and software) that the results for the special inputs meet the
aims and requirements specified for the phase in every respect, through analysis, mathematical inference
and/or testing.
SAMPLE
Validation
Confirmation that the special requirements for a special application are met, based on an examination and
provision of objective evidence.
NOTE 1
NOTE 2
Validation refers to the process of demonstrating that the safety-relevant system meets the specific safety
specification in every respect, before and after the installation. Validation of the software, for example,
therefore includes examination and provision of evidence that the software meets the safety specification
and requirements.
The developer can test the created safety application via ModuleTests.cpp in standard C++ mode. During
the test the safety application is not compiled and executed in the safety context, but directly within a
standard C++-environment. Also, there is no assignment to the task with which the TwinCAT Safety PLC is
executed in release mode.
The module test can be accessed via MODULE_TEST_BENCH_DEF(<id>), in which the test coverage
measurement is controlled and the test groups are specified via the instruction
MODULE_TEST_GROUP(<id>). Each test group requires a unique ID. A test group consolidates defined
test cases of a group via the instruction MODULE_TEST_CASE(<id>), which was previously defined via
MODULE_TEST_CASE_DEF(<id>). A test case can be subdivided into further logical test steps via the
instruction MODULE_TEST_STEP(<id>). A test case defined with MODULE_TEST_CASE_DEF(<id>) can
be integrated in a test group as fault test/negative test case by calling it via the instruction
MODULE_FIT_CASE(<id>, <step-id>, <asset-id>). It is expected that the test case fails in a given test step
with given assertion ID, in order to be deemed to have passed. This mechanism is used to test
FAILSAFE_ASSERT instructions, e.g. by using invalid input values.
During creation of a TwinSAFE group, a module test bench template with a general test case is created,
which can be used directly for debugging. The interface functions of a TwinSAFE group module are called
periodically.
The module to be tested (TwinSAFE group) is already created and available as a test instance within the
module test via the variable DUT (Device Under Test). All module variables and module functions of a
TwinSAFE group module (including those declared as private) can be accessed via DUT.<variable name/
function name>.
In the example test case DUT.init(); is called once, followed by calls of DUT.Input-, DUT.Cycle- and
DUT.OutputUpdate(); in a For loop.
Before the call the application developer or tester can set the internal variables and analyze the calculation
result after the call via a TEST_ASSERT instruction.
The module test is compiled via the context menu under Test Files (Build) and started in Debug mode. In
future, the test results can be displayed in the safety editor via Run/Analyze (not yet supported in V1).
In addition, the user can open, extend and execute the corresponding Visual Studio project
ModuleTests.vcxproj directly in the TwinSAFE group folder "Test Files". For the source code of the module
tests there are no constraints in terms of coding rules or the implementation of standard libraries.
In Debug mode the usual Visual Studio mechanisms such as breakpoints, step into, step over, etc. can be
used from the TwinCAT Safety Editor.
The variable values can be monitored online via the Locals window or via data tips in Visual Studio. The
output is displayed in the Output window (Debug).
Example
///////////////////////////////////////////////////////////////////////////
//! \brief Implementation of the safe user module input update function
///////////////////////////////////////////////////////////////////////////
/*<TcInputUpdate>*/
VOID CSafeModule::InputUpdate()
{
// Put your module input update code here
BRANCH_TRACE();
}
/*</TcInputUpdate>*/
///////////////////////////////////////////////////////////////////////////
//! \brief Implementation of the safe user module output update function
///////////////////////////////////////////////////////////////////////////
/*<TcOutputUpdate>*/
VOID CSafeModule::OutputUpdate()
{
// Put your module output update code here
BRANCH_TRACE();
}
/*</TcOutputUpdate>*/
///////////////////////////////////////////////////////////////////////////
//! \brief Implementation of the safe user module cycle update function
///////////////////////////////////////////////////////////////////////////
/*<TcCycleUpdate>*/
VOID CSafeModule::CycleUpdate()
{
// Put your cycle update code here
FAILSAFE_ASSERT(DIV_BY_ZERO, b != 0);
z = a / b;
if (z >= 0)
{
neg = false;
BRANCH_TRACE();
}
else
{
neg = true;
BRANCH_TRACE();
}
BRANCH_TRACE();
}
/*</TcCycleUpdate>*/
ModuleTests.cpp
///////////////////////////////////////////////////////////////////////////////
//! \file ModuleTests.cpp
//! \brief Source file with module test definitions for TwinSafeGroup1
//! \authors User01
//! \copyright Put affiliation and copyright notice here
//! \version V1.0
//! \date 2016-10-20
//! \details Put detailed description of your module tests here
///////////////////////////////////////////////////////////////////////////////
#include "TwinSafeGroup1.h"
#include "ModuleTests.h"
//! Definition of test case IDs
#define TC_ID_0 0
#define TC_ID_1 1
///////////////////////////////////////////////////////////////////////////
//! \brief Test bench definition containing testsets triggered by TwinCAT3
///////////////////////////////////////////////////////////////////////////
MODULE_TEST_BENCH_DEF()
{
///////////////////////////////////////////////////////////////////////////
//! \brief TC_ID_0 (put a reference to your test specification here)
//! \test Generic module test sequence calling init and 1000 task cycles
///////////////////////////////////////////////////////////////////////////
MODULE_TEST_CASE_DEF(TC_ID_0)
{
// Test case starts with an initial test step to prepare preconditions
MODULE_TEST_STEP(0);
DUT.Init(); // e.g., call Init() to set state variables to default values
MODULE_TEST_STEP(nCycle);
// Apply test step stimuli to safe and non-safe module inputs here
DUT.u16SafeTimer = (nCycle * 5) % 65536U; // e.g. 5ms task period
// Perform invariant checks on safe and non-safe module outputs and
// also state variables here, e.g., using TEST_ASSERT(<condition>)
// Perform checks on test step response w.r.t. test step stimuli
// here, e.g., using TEST_ASSERT(<condition>) statements
TEST_ASSERT(DUT.z == 2); // As (2*cycle)/cycle is always 2
}
// Perform checks on the final module state w.r.t. test specification
// here, e.g., using TEST_ASSERT(<condition>) statements
}
///////////////////////////////////////////////////////////////////////////
//! \brief TC_ID_1 (put a reference to your test specification here)
//! \test Negative test case for invalid input b=0 (division by zero)
///////////////////////////////////////////////////////////////////////////
MODULE_TEST_CASE_DEF(TC_ID_1)
{
// Test case starts with an initial test step to prepare preconditions
MODULE_TEST_STEP(0);
DUT.Init(); // e.g., call Init() to set state variables to default values
// Apply test step stimuli to safe and non-safe module inputs here
MODULE_TEST_STEP(1);
DUT.a = 1;
DUT.b = 0;
// Perform a single execution cycle
DUT.InputUpdate();
DUT.CycleUpdate();
DUT.OutputUpdate();
// Should not reach here as CycleUpdate is expected to trigger fail safe!
TEST_ASSERT(false);
///////////////////////////////////////////////////////////////////////////
//! \brief Test group TG_ID_0 definition containing a set of test cases
///////////////////////////////////////////////////////////////////////////
MODULE_TEST_GROUP_DEF(TG_ID_0)
{
Helper functions are free from side effects, so that they can be used without restriction in all Safety C
expressions and statements, i.e. the return value of a helper function only depends on the user-defined
function parameters. Furthermore, helper functions do not directly change the module data of a safe
application module or other global application data.
In the event of undefined inputs, helper functions respond by assuming the safe state for the TwinSAFE
group in which they are integrated in the application execution. Undefined inputs are inputs for which a
helper function is unable to generate valid output (referred to as undef. below). However, since function
signatures enable such inputs to be transferred to helper functions as parameters, they are intercepted
internally with a FAILSAFE_ASSERT instruction, thereby programmatically triggering the safe error state of
the TwinSAFE group. The user is notified of this case via a corresponding log message.
5.8.1.1 AND
Executes a safe logical AND for two Boolean expressions.
Functional specification
5.8.1.2 AND3
Executes a safe logical AND for three Boolean expressions.
Functional specification
5.8.1.3 AND4
Executes a safe logical AND for four Boolean expressions.
Functional specification
5.8.1.4 OR
Executes a safe logical OR for two Boolean expressions.
Functional specification
5.8.1.5 OR3
Executes a safe logical OR for three Boolean expressions.
Functional specification
5.8.1.6 OR4
Executes a safe logical OR for four Boolean expressions.
Functional specification
5.8.2.1 ADDI32
Performs a secure addition for the signed 32-bit integer type.
Functional specification
5.8.2.2 SUBI32
Performs a secure subtraction for the signed 32-bit integer type.
Functional specification
5.8.2.3 MULI32
Performs a secure multiplication for the signed 32-bit integer type.
Functional specification
5.8.2.4 DIVI32
Performs a secure division for the signed 32-bit integer type.
Functional specification
5.8.2.5 DIVU32
Performs a secure division for the unsigned 32-bit integer type.
Functional specification
5.8.2.6 MODI32
Performs a secure residual value calculation for the signed 32-bit integer type.
Functional specification
5.8.2.7 MODU32
Performs a secure residual value calculation for the unsigned 32-bit integer type.
Functional specification
5.8.2.8 DIVI16
Performs a secure division for the signed 16-bit integer type.
Functional specification
5.8.2.9 DIVU16
Performs a secure division for the unsigned 16-bit integer type.
Functional specification
5.8.2.10 MODI16
Performs a secure residual value calculation for the signed 16-bit integer type.
Functional specification
5.8.2.11 MODU16
Performs a secure residual value calculation for the unsigned 16-bit integer type.
Functional specification
5.8.2.12 DIVI8
Performs a secure division for the signed 8-bit integer type.
Functional specification
5.8.2.13 DIVU8
Performs a secure division for the unsigned 8-bit integer type.
Functional specification
5.8.2.14 MODI8
Performs a secure residual value calculation for the signed 8-bit integer type.
Functional specification
5.8.2.15 MODU8
Performs a secure residual value calculation for the unsigned 8-bit integer type.
Functional specification
5.8.2.16 NEGI32
Performs a safe arithmetic negation for a signed 32-bit integer type.
Functional specification
5.8.2.17 NEGI16
Performs a safe arithmetic negation for a signed 16-bit integer type.
Functional specification
5.8.2.18 NEGI8
Performs a safe arithmetic negation for a signed 8-bit integer type.
Functional specification
5.8.2.19 ABSI32
Executes a safe absolute value calculation for a signed 32-bit integer type.
Functional specification
5.8.2.20 ABSI16
Executes a safe absolute value calculation for a signed 16-bit integer type.
Functional specification
5.8.2.21 ABSI8
Executes a safe absolute value calculation for a signed 8-bit integer type.
Functional specification
5.8.3.1 SHLU32
Shifts the bits of an unsigned 32-bit value to the left by up to 31 bits.
Functional specification
5.8.3.2 SHLU16
Shifts the bits of an unsigned 16-bit value to the left by up to 15 bits.
Functional specification
5.8.3.3 SHLU8
Shifts the bits of an unsigned 8-bit value to the left by up to 7 bits.
Functional specification
5.8.3.4 SHRU32
Shifts the bits of an unsigned 32-bit value to the right by up to 31 bits.
Functional specification
5.8.3.5 SHRU16
Shifts the bits of an unsigned 16-bit value to the right by up to 15 bits.
Functional specification:
5.8.3.6 SHRU8
Shifts the bits of an unsigned 8-bit value to the right by up to 7 bits.
Functional specification
5.8.4.1 BTOI32
Executes a safe conversion of a Boolean expression to a signed 32-bit integer type.
Functional specification
5.8.4.2 BTOI16
Executes a safe conversion of a Boolean expression to a signed 16-bit integer type.
Functional specification
5.8.4.3 BTOI8
Executes a safe conversion of a Boolean expression to a signed 8-bit integer type.
Functional specification
5.8.4.4 BTOU32
Executes a safe conversion of a Boolean expression to an unsigned 32-bit integer type.
Functional specification
5.8.4.5 BTOU16
Executes a safe conversion of a Boolean expression to an unsigned 16-bit integer type.
Functional specification
5.8.4.6 BTOU8
Executes a safe conversion of a Boolean expression to an unsigned 8-bit integer type.
Functional specification
5.8.5.1 I8TOU8
Executes a safe conversion of the signed 8-bit integer type to the unsigned 8-bit integer type.
Functional specification
5.8.5.2 I8TOU16
Executes a safe conversion of the signed 8-bit integer type to the unsigned 16-bit integer type.
Functional specification
5.8.5.3 I8TOU32
Executes a safe conversion of the signed 8-bit integer type to the unsigned 32-bit integer type.
Functional specification
5.8.5.4 U8TOI8
Executes a safe conversion of the signed 8-bit integer type to the unsigned 8-bit integer type.
Functional specification
5.8.5.5 I16TOI8
Executes a safe conversion of the signed 16-bit integer type to the signed 8-bit integer type.
Functional specification
5.8.5.6 I16TOU8
Executes a safe conversion of the signed 16-bit integer type to the unsigned 8-bit integer type.
Functional specification
5.8.5.7 I16TOU16
Executes a safe conversion of the signed 16-bit integer type to the unsigned 16-bit integer type.
Functional specification
5.8.5.8 I16TOU32
Executes a safe conversion of the signed 16-bit integer type to the unsigned 32-bit integer type.
Functional specification
5.8.5.9 U16TOI8
Executes a safe conversion of the signed 16-bit integer type to the unsigned 8-bit integer type.
Functional specification
5.8.5.10 U16TOU8
Executes a safe conversion of the unsigned 16-bit integer type to the unsigned 8-bit integer type.
Functional specification
5.8.5.11 U16TOI16
Executes a safe conversion of the signed 16-bit integer type to the unsigned 16-bit integer type.
Functional specification
5.8.5.12 I32TOI8
Executes a safe conversion of the signed 32-bit integer type to the signed 8-bit integer type.
Functional specification
5.8.5.13 I32TOU8
Executes a safe conversion of the signed 32-bit integer type to the unsigned 8-bit integer type.
Functional specification
5.8.5.14 I32TOI16
Executes a safe conversion of the signed 32-bit integer type to the signed 16-bit integer type.
Functional specification
5.8.5.15 I32TOU16
Executes a safe conversion of the signed 32-bit integer type to the unsigned 16-bit integer type.
Functional specification
5.8.5.16 I32TOU32
Executes a safe conversion of the signed 32-bit integer type to the unsigned 32-bit integer type.
Functional specification
5.8.5.17 U32TOI8
Executes a safe conversion of the signed 32-bit integer type to the unsigned 8-bit integer type.
Functional specification
5.8.5.18 U32TOU8
Executes a safe conversion of the unsigned 32-bit integer type to the unsigned 8-bit integer type.
Functional specification
5.8.5.19 U32TOI16
Executes a safe conversion of the signed 32-bit integer type to the unsigned 16-bit integer type.
Functional specification
5.8.5.20 U32TOU16
Executes a safe conversion of the unsigned 32-bit integer type to the unsigned 16-bit integer type.
Functional specification
5.8.5.21 U32TOI32
Executes a safe conversion of the signed 32-bit integer type to the unsigned 32-bit integer type.
Functional specification
7 Appendix
Please contact your Beckhoff branch office or representative for local support and service on Beckhoff
products!
The addresses of Beckhoff's branch offices and representatives round the world can be found on her internet
pages:
http://www.beckhoff.com
You will also find further documentation for Beckhoff components there.
Beckhoff Headquarters
Huelshorstweg 20
33415 Verl
Germany
Phone: +49(0)5246/963-0
Fax: +49(0)5246/963-198
e-mail: [email protected]
Beckhoff Support
Support offers you comprehensive technical assistance, helping you not only with the application of
individual Beckhoff products, but also with other, wide-ranging services:
• support
• design, programming and commissioning of complex automation systems
• and extensive training program for Beckhoff system components
Hotline: +49(0)5246/963-157
Fax: +49(0)5246/963-9157
e-mail: [email protected]
Beckhoff Service
The Beckhoff Service Center supports you in all matters of after-sales service:
• on-site service
• repair service
• spare parts service
• hotline service
Hotline: +49(0)5246/963-460
Fax: +49(0)5246/963-479
e-mail: [email protected]
7.2 Certificates
List of figures
Fig. 1 Typical response time.................................................................................................................. 15
Fig. 2 Worst case response time ........................................................................................................... 16
Fig. 3 Creating a safety project - Add New Item .................................................................................... 17
Fig. 4 Creating a safety project - project name and directory ................................................................ 18
Fig. 5 TwinCAT Safety Project Wizard .................................................................................................. 18
Fig. 6 Target system in the Solution Explorer........................................................................................ 19
Fig. 7 Target System Property Page ..................................................................................................... 19
Fig. 8 Creating a TwinSAFE group ........................................................................................................ 20
Fig. 9 TwinSAFE group.......................................................................................................................... 20
Fig. 10 TwinSAFE Group - General Settings........................................................................................... 21
Fig. 11 TwinSAFE Group - Group Ports .................................................................................................. 21
Fig. 12 TwinSAFE group process image ................................................................................................. 21
Fig. 13 TSGData struct ............................................................................................................................ 22
Fig. 14 Starting the automatic import from the I/O configuration ............................................................. 22
Fig. 15 Selection from the I/O tree........................................................................................................... 23
Fig. 16 Creating alias devices by the user............................................................................................... 23
Fig. 17 Alias device - Process Image tab ................................................................................................ 24
Fig. 18 Configuring the I/O elements ....................................................................................................... 24
Fig. 19 Alias device - Connection tab ...................................................................................................... 25
Fig. 20 Alias device in the safety project structure .................................................................................. 25
Fig. 21 Links to the TwinCAT Safety PLC process image ....................................................................... 26
Fig. 22 Connection-specific parameters .................................................................................................. 26
Fig. 23 Selecting an alias device ............................................................................................................. 27
Fig. 24 Safety parameter for the device................................................................................................... 27
Fig. 25 Safety PLC instance - Alias devices ............................................................................................ 28
Fig. 26 Structure of the alias device ........................................................................................................ 28
Fig. 27 AX5000 safety drive functions ..................................................................................................... 29
Fig. 28 AX5000 safety drive options - general AX5805 settings.............................................................. 29
Fig. 29 AX5000 safety drive options - Process Image............................................................................. 30
Fig. 30 AX5000 safety drive options - Function Diagram ........................................................................ 31
Fig. 31 Creating an external connection (Custom FSoE Connection) ..................................................... 32
Fig. 32 Parameterization of the process image size................................................................................ 32
Fig. 33 Renaming the individual signals within the telegram ................................................................... 33
Fig. 34 Selecting the variables................................................................................................................. 33
Fig. 35 Direct linking with the process image of an EtherCAT Terminal.................................................. 34
Fig. 36 Connection-specific parameters .................................................................................................. 34
Fig. 37 TwinSAFE group - Header files ................................................................................................... 36
Fig. 38 TwinSAFE group - Source files.................................................................................................... 37
Fig. 39 Init function .................................................................................................................................. 37
Fig. 40 InputUpdate function.................................................................................................................... 38
Fig. 41 OutputUpdate function................................................................................................................. 38
Fig. 42 CycleUpdate function................................................................................................................... 39
Fig. 43 Target System ............................................................................................................................. 40
Fig. 44 Dialog CRC Distribution............................................................................................................... 40