Acyclic Reading and Writing Using The "IO-Link Library": SIMATIC S7-300/400/1200/1500
Acyclic Reading and Writing Using The "IO-Link Library": SIMATIC S7-300/400/1200/1500
Legal information
Use of application examples
Application examples illustrate the solution of automation tasks through an interaction of several
components in the form of text, graphics and/or software modules. The application examples are
a free service by Siemens AG and/or a subsidiary of Siemens AG (“Siemens”). They are non-
binding and make no claim to completeness or functionality regarding configuration and
equipment. The application examples merely offer help with typical tasks; they do not constitute
customer-specific solutions. You yourself are responsible for the proper and safe operation of the
products in accordance with applicable regulations and must also check the function of the
respective application example and customize it for your system.
Siemens grants you the non-exclusive, non-sublicensable and non-transferable right to have the
application examples used by technically trained personnel. Any change to the application
examples is your responsibility. Sharing the application examples with third parties or copying the
application examples or excerpts thereof is permitted only in combination with your own products.
The application examples are not required to undergo the customary tests and quality inspections
of a chargeable product; they may have functional and performance defects as well as errors. It is
your responsibility to use them in such a manner that any malfunctions that may occur do not
result in property damage or injury to persons.
Disclaimer of liability
Siemens shall not assume any liability, for any legal reason whatsoever, including, without
limitation, liability for the usability, availability, completeness and freedom from defects of the
application examples as well as for related information, configuration and performance data and
any damage caused thereby. This shall not apply in cases of mandatory liability, for example
under the German Product Liability Act, or in cases of intent, gross negligence, or culpable loss of
life, bodily injury or damage to health, non-compliance with a guarantee, fraudulent non disclosure
of a defect, or culpable breach of material contractual obligations. Claims for damages arising
from a breach of material contractual obligations shall however be limited to the foreseeable
damage typical of the type of agreement, unless liability arises from intent or gross negligence or
Siemens AG 2018 All rights reserved
is based on loss of life, bodily injury or damage to health. The foregoing provisions do not imply
any change in the burden of proof to your detriment. You shall indemnify Siemens against existing
or future claims of third parties in this connection except where Siemens is mandatorily liable.
By using the application examples you acknowledge that Siemens cannot be held liable for any
damage beyond the liability provisions described.
Other information
Siemens reserves the right to make changes to the application examples at any time without
notice. In case of discrepancies between the suggestions in the application examples and other
Siemens publications such as catalogs, the content of the other documentation shall have
precedence.
The Siemens terms of use (https://support.industry.siemens.com) shall also apply.
Security information
Siemens provides products and solutions with industrial security functions that support the secure
operation of plants, systems, machines and networks.
In order to protect plants, systems, machines and networks against cyber threats, it is necessary
to implement – and continuously maintain – a holistic, state-of-the-art industrial security concept.
Siemens’ products and solutions constitute one element of such a concept.
Customers are responsible for preventing unauthorized access to their plants, systems, machines
and networks. Such systems, machines and components should only be connected to an
enterprise network or the internet if and to the extent such a connection is necessary and only
when appropriate security measures (e.g. firewalls and/or network segmentation) are in place.
For additional information on industrial security measures that may be implemented, please visit
https://www.siemens.com/industrialsecurity.
Siemens’ products and solutions undergo continuous development to make them more secure.
Siemens strongly recommends that product updates are applied as soon as they are available
and that the latest product versions are used. Use of product versions that are no longer
supported, and failure to apply the latest updates may increase customer’s exposure to cyber
threats.
To stay informed about product updates, subscribe to the Siemens Industrial Security RSS Feed
at: http://www.siemens.com/industrialsecurity.
Table of contents
Legal information ......................................................................................................... 2
1 Library Overview ................................................................................................ 4
1.1 User scenarios ..................................................................................... 5
2 Library Blocks .................................................................................................... 6
2.1 Block list ............................................................................................... 6
2.2 Explanation of IO_LINK_MASTER block ............................................. 7
2.2.1 Description ........................................................................................... 7
2.2.2 Interface and parameter ....................................................................... 8
2.2.3 Mode of operation .............................................................................. 10
2.2.4 Status and error displays.................................................................... 12
2.3 Explanation for the IO_LINK_DEVICE block...................................... 13
2.3.1 Description ......................................................................................... 13
2.3.2 Interface and parameter ..................................................................... 14
2.3.3 Mode of operation .............................................................................. 17
2.3.4 Status and error displays.................................................................... 18
3 Working with the Library in STEP 7 V5.5 ...................................................... 21
3.1 Integrating the library.......................................................................... 21
3.2 Using library blocks ............................................................................ 22
4 Working with the Library in STEP 7 V14 ....................................................... 24
Siemens AG 2018 All rights reserved
1 Library Overview
What will I get?
The present document describes the block libraries for STEP 7 V14 SP1 and
STEP 7 V5.5 SP4 Hotfix 11.
You will receive a tested code with clearly defined interfaces together with these
block libraries. They can be used as a basis for the task you want to implement.
The main focus of this document is to describe
• all blocks belonging to the block library.
• the functionality implemented through these blocks.
Table 1-1
Library Engineering S7-300 S7-400 S7-1200 S7-1500
software
Siemens AG 2018 All rights reserved
IO_LINK_Library_V55 SIMATIC X X
Library-Version: V5.2 Manager STEP
7 ab V5.5 SP4
IO_LINK_Library_V14 TIA Portal X X X X
Library-Version: V5.2 SIMATIC
STEP 7
Professional ab
V14 SP1
TIA Portal X
SIMATIC
STEP 7 Basic
ab V14 SP1
Table 1-2
IO_LINK_MASTER_4 IO_LINK_MASTER_8 IO_LINK_DEVICE
S7-CPU TIA Portal STEP 7 TIA STEP 7 TIA Portal STEP 7
family as of V14 as of Portal as as of as of V14 as of
SP1 V5.5 of V14 V5.5 SP1 V5.5
SP1
S7-1200 V2.0.1 V3.0.3
S7-1500 V3.0.1 V1.0.0 V1.0.0 V3.0.2
S7-300/400 V3.0.1 V3.0.1 V1.0.0 V1.0.0 V3.0.1 V3.1
Based on the different designs and the new requirements, there are now generally
Siemens AG 2018 All rights reserved
Table 1-3
IO-Link block Functionality
IO-Link_Master_4 Using the "IO_LINK_MASTER_4" function block, you can backup or
restore the device parameters and settings of an IO-Link
communication module/IO-Link master with 4 Ports (e.g. ET 200SP
CM 4xIO-Link) using the S7 program to backup and restore.
IO-Link_Master_8 Using the "IO_LINK_MASTER_8" function block, you can backup or
restore the device parameters and settings of an IO-Link
communication module/IO-Link master with 8 Ports (e.g. ET 200MP
CM 8xIO-Link) using the S7 program to backup and restore.
IO-Link device Using this “IO_LINK_DEVICE” function block, you can write device
parameters acyclically to an IO-Link device via the S7 program, or
read parameters, measured values and diagnostic data of an IO-Link
device.
Note:
This block replaces the main function of the previously available
“IO_LINK_CALL” block.
2 Library Blocks
In this chapter all blocks of the IO-Link-Library that are essentially involved in the
implementation of the functionality are explained.
Table 2-1
Blocks TIA Portal Blocks SIMATIC Icon
SIMATIC STEP 7 Manager STEP 7
V14 SP1 V5.5 SP4
FB 50000 FB 5000 IO_LINK_MASTER_4
FB 50002 FB 5002 IO_LINK_MASTER_8
FB 50001 FB 5001 IO_LINK_DEVICE
SFB52 RDREC (system function)
SFB53 WRREC (system function)
SFB3 TP (IEC function)
SFB4 TON (IEC function)
Siemens AG 2018 All rights reserved
2.2.1 Description
By means of this block, you can backup or restore the device parameters and
settings of an IO-Link communication module (e.g. ET 200SP CM 4xIO-Link or ET
200MP CM 8xIO-Link) via the S7 program (Master exchange without engineering
tool).
This block works in the current version of the library with the following IO-Link
communication modules:
Siemens AG 2018 All rights reserved
Table 2-2
IO-Link communication module FW Article number
ET 200SP CM 4xIO-Link As of V2.2 6ES7137-6BD00-0BA0
ET 200AL CM 4xIO-Link As of V1.1 6ES7147-5JD00-0BA0
ET 200pro 4 IO-LINK HF As of V1.0 6ES7147-4JD0-0AB0
ET 200ecoPN IO-Link Master As of V1.0 6ES7148-6JD00-0AB0
S7-1200 SM 1278 4 IO-Link As of V2.0 6ES7278-4BD32-0XB0
ET 200MP CM 8xIO-Link As of V1.0 6ES7547-1JF00-0AB0
Note Please observe that the “Master Backup” function is only available for IO-Link
devices which are specified for the IO-Link standard as of V1.1.
IO-Link communication modules of third-party suppliers are not supported by this
library!
Interface IO_Link_Master_4
Interface IO_Link_Master_8
Siemens AG 2018 All rights reserved
The interface parameters of both variants of IO_LINK_MASTER-blocks are identical, except the
source/target area for the data to be read/written (Parameter "RECORD_DATA").
Input parameters
Table 2-3
Parameter Data type Memory area Description
REQ BOOL I, Q, M, D Positive edge: Triggers data transfer
ID HW_IO I, Q, M, D, L, const For S7-1200/1500
Hardware identifier of the IO-Link communication
module
(for ET200ecoPN the
HW_ID of the IO-Link submodule is to be used)
DWORD For S7-300/400
Logic address of the IO-Link communication
module (module or submodule)
Note: If you are using the IO-Link master
ET200ecoPN IO-Link (6ES7148-6JD00-0AB0),
the diagnostics address of the master has to be
specified here (see chapter 4.3).
RD_WR BOOL I, Q, M, D, L, const Read or write access
0: read
1: write
Siemens AG 2018 All rights reserved
Output parameters
Table 2-4
Parameter Data type Memory area Description
DONE_VALID BOOL I, Q, M, D, L Validity:
0: Data not valid
1: Data valid
BUSY BOOL I, Q, M, D, L Job in progress:
0: Job completed (valid or error)
1: Job in process
ERROR BOOL I, Q, M, D, L Error status:
0: no error
1: Abort with error
STATUS DWORD I, Q, M, D, L Status output:
ERROR flag set = function error
Rest error flag = status of the function
DW#16#000x0000
(x: Process step 0..3)
SF_STATUS DWORD I, Q, M, D, L System error status:
ERROR flag set = Specification to which system
function the status belongs
Error flag reset = DW#16#00000000
LENGTH DINT I, Q, M, D, L Length of the read/written data (net data)
Input/output parameters
IO_LINK_MASTER_4:
Table 2-5
Parameter Data type Memory area Description
RECORD_DATA ARRAY I, Q, M, D, L Source/target area for the data to be
[0..10239] of read/written.
BYTE
IO_LINK_MASTER_8:
Table 2-6
Parameter Data type Memory area Description
RECORD_DATA ARRAY I, Q, M, D, L Source/target area for the data to be
[0..17549] of read/written.
BYTE
As long as no valid response data has arrived, this is signaled via the BUSY =
TRUE parameter.
In this period the STATUS output parameter shows what step (status) the function
is currently in.
The value TRUE of the DONE_VALID output parameter shows that the transfer
was performed successfully and the data is now consistently available on the
RECORD_DATA parameter.
Note The data transfer is in the form of raw date (ARRAY of byte), i. e. the data cannot
be interpreted and must not be changed or manipulated.
Before a data record can be written, it has to be saved first.
If the data has been read successfully, the LENGTH parameter shows the length of
the received or written data. As long as input REQ = TRUE, the output parameters
maintain their value. If input REQ = FALSE before processing of the FB has been
completed, the values of the output parameters are only held for one cycle after
processing the job.
Note If a DPV1 slave is configured via a GSD file (GSD as of rev. 3) and the DP
interface of the DP master is set to “S7 compatible”, the “IO_LINK_MASTER”
block will not function correctly.
Remedy: Reset the interface of the DP master to “DPV1”.
Note The combination with a 1200 CPU and the IO_LINK_MASTER_8 block exceeds
the amount of remanent data which are available in the CPU.
If this combination is used, this leads to data loss, as the data cannot be
completely remanten stored in the CPU.
Siemens AG 2018 All rights reserved
Table 2-7
Status Meaning Explanation
DW#16#0000 0000 No error Function is ready for a new job
DW#16#0000 0230 Type test Function checks module type
Siemens AG 2018 All rights reserved
Note:
Only IO-Link communication modules (master)
of Siemens AG are permitted.
DW#16#00FF 0000 Reset Functional reset of the backup/restore process.
If output ERROR = 1, you are evaluating the
SF_STATUS parameter (status parameter of
WRREC).
DW#16#0001 0xyz Backup Function reads the master parameters.
If ERROR = 1, you are evaluating the
SF_STATUS parameter (status parameter of
RDREC).
Details for the variants xyz:
00010230 = function reads data record ID 230
00010220 = function reads data record ID 220
00010222 = function reads data record ID 222
000100FF = function BACKUP is running (NEW)
DW#16#0002 0xyz Restore Function writes the master parameters.
If ERROR = 1, you are evaluating the
SF_STATUS parameter (status parameter of
WRREC).
Details for the xyz variants:
00020230 = function writes data record ID 230
00020220 = function writes data record ID 220
00020222 = function writes data record ID 222
000200FF = function RESTORE is running(new)
DW#16#000a 1xyz Backup/Restore Only S7-300/400: Copy error, please evaluate
(a = 1 or 2) SF_STATUS (evaluate status information of the
BLKMOV system function).
DW#16#0003 0000 Type test Unknown module type, please evaluate
SF_STATUS (status parameters of the RDREC).
DW#16#0003 0001 Type test Unknown job, not read nor write.
Please observe the notes on the STATUS parameter and read the respective error
information in the help of the respective system function.
2.3.1 Description
The reading and writing of acyclic data enables you to write the device parameters
to an IO-Link device or read parameters, measured values and diagnostics data of
an IO-Link device.
The function block supports you with the following tasks:
• (Re)Configuration of an IO-Link device
• Diagnostics of an IO-Link device
• Executing of IO-Link port functions
• Saving/recovering of IO-Link device parameters
The data on an IO-Link device can be uniquely addressed with index and
subindex. In addition, port functions can also be executed with the
“IO_LINK_DEVICE” function block (e. g. switching the port to the DI mode).
Note The structure of the data objects and the port functions can be found in the
respective documentation of the IO-Link device and the IO-Link master.
Note If a DPV1 slave is configured via a GSD file (GSD as of rev. 3) and the DP
interface of the DP master is set to “S7 compatible”, the block will not function
correctly.
Remedy: Reset the interface of the DP master to “DPV1”.
Siemens AG 2018 All rights reserved
Interface
Figure 2-5 STEP 7 V13 SP1 Figure 2-6 STEP 7 V5.5
Input parameters
Table 2-8
Parameter Data type Memory area Description
REQ BOOL I, Q, M, D Positive edge: Triggers data transfer
ID HW_IO I, Q, M, D, L, const For S7-1200/1500
Hardware identifier of the IO-Link communication
module
(for ET200ecoPN the
HW_ID of the IO-Link submodule is to be used)
DWORD For S7-300/400
Logic address of the IO-Link communication
module (module or submodule)
CAP DINT I, Q, M, D, L, const Access point of the IO_LINK_DEVICE function
(S7- (Siemens AG = 227 decimal)
1200/1500)
INT
(S7-300/400)
RD_WR BOOL I, Q, M, D, L, const Read or write access
0: read
1: write
PORT INT I, Q, M, D, L, const Port number at which the IO-Link device is
Siemens AG 2018 All rights reserved
operated.
Possible values: 0..63
IOL_INDEX INT I, Q, M, D, L, const Parameter index
Possible values: 0..32767
Output parameters
Table 2-9
Parameter Data type Memory area Description
DONE_VALID BOOL I, Q, M, D, L Validity:
0: Data not valid
1: Data valid
BUSY BOOL I, Q, M, D, L Job in progress:
0: Job completed (valid or error)
1: Job in process
ERROR BOOL I, Q, M, D, L Error status:
0: no error
1: Abort with error
STATUS DWORD I, Q, M, D, L Status output:
ERROR flag set = function error
Rest error flag = status of the function
DW#16#000x0000
(x: Process step 0..3)
IOL_STATUS DWORD I, Q, M, D, L IO-Link error status:
ERROR flag set and IO-Link error:
See error information
ERROR flag set and communication error:
Siemens AG 2018 All rights reserved
Input/output parameters
Table 2-10
Parameter Data type Memory area Description
RECORD_IOL_ ARRAY I, Q, M, D, L Source/target area for the data to be read/written
DATA [0..231] of
BYTE
Address assignment
With “IO_LINK_DEVICE”, you read or write (parameter: RD_WR) the data of the
IO-Link peripheral devices which are connected to a port (parameter: PORT) of an
IO-Link communication module (parameter: ID).
The data is uniquely addressed with index/subindex (parameter:
INDEX/SUBINDEX). If data is read, the RD_LEN parameter specifies the length of
the received data in bytes which is located in the target area (parameter:
RECORD_IOL_DATA). In that case the target area also has to be at least RD_LEN
bytes.
When writing data, a (parameter: LEN) specified data volume is transferred to the
IO-Link device.
The source area (parameter: RECORD_IOL_DATA) has to be at least LEN bytes
long. The access point to the IO-Link master is defined via the client access point
(parameter CAP).
As long as no other instructions are made in the manual of the IO-Link master, the
value 227 (valid for all IO-Link communication modules by Siemens AG) can be
used here.
As long as no valid response data has arrived, this is signaled via the BUSY =
TRUE parameter.
In this period the IOL_STATUS output parameter shows in what step (status) the
function is currently in. If this period exceeds the runtime of the IO-Link
communication module or if it takes more than 20s, processing is aborted with a
timeout error (IOL_STATUS).
The value TRUE of the DONE_VALID output parameter shows that the transfer
was performed successfully and the data is now consistently available on the
RECORD_DATA parameter.
Note The data transfer is in the form of raw date (ARRAY of byte), i. e. the data cannot
be interpreted in this form.
It is up to the user, whether to format the data according to the specifications of
the device manufacturer (copy to a data structure or data type).
If data was read, the length of the received data is displayed on the RD_LEN
parameter. As long as REQ = TRUE, the output parameters maintain their value. If
REQ = FALSE, before the processing of the function was completed, the values of
the output parameters are only held for one PLC cycle after processing the job.
Parameter Command
RD_WR Write
IOL_Index 2
IOL_Subindex 0
LEN 1
Data 0x05 ( system command)
Table 2-11
IOL_STATUS = DW#16#00000000
IOL-M Error Code Device Error Code (device specific)
W#16#0000 W#16#0000
B#16#00 B#16#00 B#16#00 B#16#00
Siemens AG 2018 All rights reserved
16#8001 Wrong port address Port address smaller than 0 or larger than 63
16#8002 Wrong index Index smaller than 0 or larger than 32767
16#8003 Wrong subindex Subindex smaller than 0 or larger 255
16#8004 No Device No device connected (however port still in IO-
Link mode)
16#8005 Wrong LEN Invalid length when writing, less than 1 or over
232
16#8006 Wrong LEN Invalid length when reading, less than 0 or over
232
16#8007 DI/DO mode Port in DI or DO mode
16#8008 No SPDU Device in IO-Link mode does not support SPDU
16#8009 - An upload is not possible, since the function is
disabled (data storage).
16#8010 .. 8051 - Reserved
16#8052 RDREC Fault Error occurred when calling RDREC, see
STATUS
16#8053 WRREC Fault Error occurred when calling WRREC, see
STATUS
16#8054 Unexpected Internal error in IO-Link technology (unexpected
acknowledge status during an IO-Link request)
16#8055 Port function failed Only relevant for port functions
16#8056 .. FFFF - Reserved
Note In the following section, it is assumed that a STEP 7 project has been created.
The library is available on the HTML page from which you downloaded this
document. The "82981502_IO_LINK_Library_V5.2.zip” file includes the
STEP 7 V5.5 as well as the STEP 7 V14 SP1 libraries.
Figure 3-1
Figure 3-2
7. Check the consistency of your user program by right-clicking the block folder
Siemens AG 2018 All rights reserved
Figure 3-3
Figure 3-4
8. Create organization block 1 (OB1) and open it. Drag the function block
IO_LINK_MASTER_4, IO_LINK_MASTER_8 or IO_LINK_DEVICE via drag &
drop into any network.
Figure 3-5
9. Enter the data block with the number of the instance data block that you would
like to use. Generate the instance data block if it does not exist.
Figure 3-6
Siemens AG 2018 All rights reserved
10. Assign values of your choice to all formal parameters. The values can be, for
example, stored in any data block.
Save organization block 1 (OB1) and load the STEP 7 project.
Note In the following section it is assumed that a STEP 7 project has been created.
The library is available on the HTML page from which you downloaded this
document.
1. First of all, unzip the "82981502_IO_LINK_Library_V5.2.zip" file on your hard
disk. The library for TIA Portal V14 has the file name
"IO_LINK_Library_V14.zal14".
The library was created with a TIA Portal version V14 SP1, if you have a
TIA Portal version higher as V14 SP1 a message is displayed when opening
Siemens AG 2018 All rights reserved
the library that the library will be upgraded to your TIA Portal version.
Figure 4-1
Figure 4-2
Note Since the library does not only include the blocks for S7-1200 (STEP 7 Basic
V14 license is sufficient) but also assumes STEP 7 Professional V14 for S7-
1500/300/400, you will get the information that you are working with a STEP 7
Siemens AG 2018 All rights reserved
Figure 4-3
Figure 4-4
Example: You want to use the IO_LINK_MASTER_4 block for the S7-1500.
Drag the required “IO_LINK_MASTER_4” block using drag-and-drop to your
user program from the “Types” folder and the subfolder for the "S7-1500
Professional".
5. Open the “Main” OB. Now drag the desired function block using drag-and-drop
into any network.
Figure 4-5
6. Enter the data block with the number of the instance data block you want to
use.
Figure 4-6
Siemens AG 2018 All rights reserved
7. Assign values of your choice to all formal parameters. The values can be e. g.
stored in any data block.
Save the OB1 organization block and load the STEP 7 project into your
S7-CPU.
If you want to use the ET 200ecoPN IO-Link master with article no. 6ES7148-
6JD00-0AB0 together with an S7-300, you have to configure the parameter “ID” of
the “IO_LINK _MASTER_4” or “IO_LINK _MASTER_8” block with the diagnostics
address of the IO-Link master.
To do this, go to the “Device view” and select the ET 200ecoPN IO-Link master.
Refer to the “Device overview” or to the “Properties” to find the corresponding
diagnostics address (in this example: 8182).
Figure 4-7
Siemens AG 2018 All rights reserved
5 Appendix
5.1 Service and Support
Industry Online Support
Do you have any questions or need support?
Siemens Industry Online Support offers access to our entire service and support
know-how as well as to our services.
Siemens Industry Online Support is the central address for information on our
products, solutions and services.
Product information, manuals, downloads, FAQs and application examples – all
information is accessible with just a few mouse clicks at
https://support.industry.siemens.com
Technical Support
Siemens Industry's Technical Support offers quick and competent support
regarding all technical queries with numerous tailor-made offers
– from basic support right up to individual support contracts.
Please address your requests to the Technical Support via the web form:
Siemens AG 2018 All rights reserved
https://support.industry.siemens.com/My/ww/en/requests
Service offer
Our service offer comprises the following services:
• Plant Data Services
• Spare Parts Services
• Repair Services
• On Site and Maintenance Services
• Retrofit and Modernization Services
• Service Programs and Agreements
Detailed information on our service offer is available in the Service Catalog:
https://support.industry.siemens.com/cs/sc