Reading and Writing RFID Data With SIMATIC S7-1500 Via IO-Link
Reading and Writing RFID Data With SIMATIC S7-1500 Via IO-Link
Reading and Writing RFID Data With SIMATIC S7-1500 Via IO-Link
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
© Siemens AG 2020 All rights reserved
foreseeable damage typical of the type of agreement, unless liability arises from intent or gross
negligence or 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: https://www.siemens.com/industrialsecurity.
Table of Contents
Legal information ......................................................................................................... 2
1 Task ..................................................................................................................... 4
2 Solution............................................................................................................... 6
2.1 Overview............................................................................................... 6
2.2 Description of the core functionality ..................................................... 8
2.2.1 Reading / writing of RFID data from / to a transponder ....................... 9
2.3 Hardware and software components ................................................. 12
2.3.1 Validity ................................................................................................ 12
2.3.2 Components used .............................................................................. 12
3 Mode of Operation ........................................................................................... 14
3.1 General overview ............................................................................... 14
3.2 Functionality ....................................................................................... 17
3.2.1 Program details on FB "IolReadAnt" (FB3) ........................................ 17
3.2.2 Program details on FB "IolWriteAnt" (FB5) ........................................ 18
3.2.3 Error and status display...................................................................... 20
4 Installation and Commissioning .................................................................... 21
4.1 Hardware installation .......................................................................... 21
4.2 Installing the software ......................................................................... 22
4.3 Commissioning ................................................................................... 22
© Siemens AG 2020 All rights reserved
1 Task
Introduction
With RFID, complete tracking and documentation of all delivered, stored and
shipped goods can be performed for intralogistics or in small assembly lines. For
this purpose, a small data medium – referred to as transponder – that stores all
essential information is attached to each product or package. A read/write device
(reader) is used to read from / write to the transponder.
PLC Master
1 2
PROFINET IE
IO-Link Reader
...
Transponder
Problem description
This application should meet the following requirements:
• The connection of the data read by the reader into the S7 station is to be
performed via the IO-Link interface.
• The intention is to show how easily the function blocks of the Library for IO-
Link (LIOLink) can be used for this task.
• The following RFID functions are to be implemented in the user program:
– Switching on an integrated antenna of the RF220R reader
("LIOLink_RF200_SwitchAntenna")
– Reading RFID data from transponders ("LIOLink_RF200_ReadTag") and
writing RFID data to transponders ("LIOLink_RF200_WriteTag")
– Switching off integrated antenna after a successful read/write process or
after an error in order to prevent possible interferences with other read
devices.
• The read/write process shall be controlled and visualized via a panel.
• Integration of simple functions to monitor the implemented processes
• Error handling
To realize the application, a SIMATIC RF220R IO-Link reader (version 1.1) with a
SIMATIC S7-1513-1 PN CPU should be used.
© Siemens AG 2020 All rights reserved
Further informations
You can download the Library for IO-Link (LIOLink) separately in the Siemens
Industry Online Support:
https://support.industry.siemens.com/cs/ww/en/view/82981502
2 Solution
2.1 Overview
Schematic layout
The figure below shows a schematic overview of the most important components of
the solution:
Figure 2-1
2
User program of the
S7-1500 CPU: PG/PC
IOL_READ_WRITE_ 3
DATA
S7-1500
1
PROFINET IE
© Siemens AG 2020 All rights reserved
5 4
Components included
Table 2-1
No. Component Description
1. S7-1500 CPU Any S7-1500 CPU can be used
2. User program " IOL_READ_WRITE_DATA" with:
• "IolReadAnt"
• "IolWriteAnt"
• "LIOLink_RF200_ReadTag"
• "LIOLink_RF200_WriteTag"
• "LIOLink_RF200_SwitchAntenna"
3. PG/PC Programming device on which the RT
Simulator of the panel is operated
4. MDS Dxx Transponder
5. SIMATIC RF220R with IO-Link interface Reader. Any RF200 IO-Link reader V1.1
V1.1 release can be used
Structure
The integration of the RF220R via IO-Link to the S7-1500 is performed via the
IO-Link Master ET 200SP/ CM 4xIO-Link, to which the RF220R is connected via its
IO link interface
The user blocks FB IolReadAnt and FB IolWriteAnt have been created with the
function blocks from the Library for IO-Link (LIOLink). In these blocks the following
is realized:
• the interconnection of the RFID functions
• the monitoring functions and
• the error handling.
Advantages
This application example
• already includes the above-described functions on a fully implemented basis
• can be easily customized for extensions
© Siemens AG 2020 All rights reserved
Delimitation
This application does not include a basic description of
• SIMATIC RF200 IO-Link Reader. Please refer to document /6/.
• SIMATIC ET 200SP. Please refer to document /7/.
• the LAD/ FBD/ STL/ SCL programming languages.
• SIMATIC HMI control panels Basic Panels. Please refer to document /8/.
Basic knowledge of these topics is assumed.
Note For a more detailed description of these functions, please refer to chapter 3 and
the following chapters.
Read/write function:
The entire process for reading/writing the RFID data including switching on and
off of the integrated antenna of the reader, read/write job and monitoring
function.
3
© Siemens AG 2020 All rights reserved
4 6
Table 2-2
No. Description
1. Entry of the time for the "Watchdog timers", the length, and the offset with the data to
be read.
2. Display whether a transponder is located in the detection area of the reader.
No. Description
3. "ERROR" indicates whether an error has occurred. "STATUS" gives an indication of
which error has happened (see Chapter 3.2.3).
4. "READ" starts a read job.
5. "DONE" indicates whether the last job has been processed without errors.
6. Outputs up to 24 bytes of the read data after a job has been executed without errors.
1
© Siemens AG 2020 All rights reserved
4 6
Table 2-3
No. Description
1. Entry of the time for the "Watchdog timers", the length, and the offset with the data to
be written.
2. Display whether a transponder is located in the write area of the reader.
3. "ERROR" indicates whether an error has occurred. "STATUS" gives an indication of
which error has happened (see Chapter 3.2.3).
4. "WRITE" starts a write job.
5. "DONE" indicates whether the last job has been processed without errors.
6. 24 bytes of the data to be written can be entered here. The data entered here is
directly written to data block "Data_Buffer" (DB1).
Wait for
trigger
1 Start
Switching on Error
2
IOL Reader
Finished
No transponder
detected
Watchdog timer Error and
3
5s status output
Transponder
detected
© Siemens AG 2020 All rights reserved
4
Read/write
function Error
Finished
Switching off
5
IOL Reader
Table 2-4
No. Action Note
1. Job triggered by the user. With watch table, user program or HMI.
2. Switch on IOL reader by selecting the
"LIOLink_RF299_SwitchAntenna"
block.
3. Start the watchdog timer. The watchdog timer monitors whether a
transponder is located within the detection
area within a monitoring time of 5 seconds.
4. Read the transponder with the
"LIOLink_RF200_ReadTag" block.
5. Switch off IOL reader by selecting the Executed if the read job has been
"LIOLink_RF200_SwitchAntenna" executed successfully or an error has
block. occurred during the read job.
Switching off the antenna field terminates
the read function.
Hardware components
Table 2-5
Component No. Article number Note
SIMATIC S7-1500 1 6ES7 513-1AL01-0AB0 Alternatively, any other
CPU 1513-1PN SIMATIC S7-1500 with PN
interface compatible with the
CP can also be used.
© Siemens AG 2020 All rights reserved
Note A SIMATIC Basic Panel KTP1000 is not absolutely necessary. For simulating the
user interface, the PC runtime of STEP 7 V16 will be used.
Software components
Table 2-6
Component No. Article number Note
TIA Portal V16 1 6ES7822-1A.06-..
S7-PCT-Port 1 Available for download in the
Configuration Tool Online Support \3\
(as of V3.4 HF2)
IODD file RF220R 1 Available for download in the
for IO Link V1.1 Online Support \4\
3 Mode of Operation
3.1 General overview
Figure 3-1
1 Start
2
LIOLink_RF200_ Error
SwitchAntenna
No transponder
Watchdog timer detected Error and
3
5s status output
Transponder
detected
© Siemens AG 2020 All rights reserved
4
LIOLink_RF200_ Error
ReadTag/WriteTag
Done
5
LIOLink_RF200_
SwitchAntenna
The table below shows the individual steps of the read/write function
(reading/writing RFID data from/to the transponder).
Table 3-1
No. Description
1. Use the "READ"/"WRITE" button on the user interface of the SIMATIC Panel
(HMI) to start the read/write function. The two functions can also be started via a
watch table.
2. The " LIOLink_RF200_SwitchAntenna" library block switches on the antenna
field at the reader.
3. The "TONR" watchdog timer monitors whether a transponder is located in the
detection/write area within the monitoring time of 5 s.
4. If a transponder is detected in the reader’s field within the 5 seconds, the "
LIOLink_RF200_ReadTag" / "LIOLink_RF200_WriteTag" library block will
read/write the RFID data from/to the transponder.
5. The " LIOLink_RF200_SwitchAntenna" library block switches off the antenna
field at the reader when:
• the read/write job has been successfully completed
• an error has occurred while processing the read/write job
• no transponder was detected in the reader’s field within the specified time.
Turning off the antenna field terminates the read/write function.
Program overview
Figure 3-2
Main
IolReadAnt IolWriteAnt
User program
Lxx_ Lxx_
Lxx_ Lxx_
Switch Switch
ReadTag WriteTag
Antenna Antenna
Library blocks
Inst Inst
DataBuffer IolWriteAnt
IolReadAnt
© Siemens AG 2020 All rights reserved
Hmi
Interface
Data blocks
Program blocks
Table 3-2
Element Symbolic name Description
OB1 Main Cyclic OB:
Calling the blocks for both functions.
FB3 IolReadAnt FB "IolReadAnt" includes the described functions
(Chapter 3.1) on an already fully implemented
basis. In this block, the blocks are called from the
"LIOLink_RF200_V31" library and the "TONR"
monitoring function.
FB5. IolWriteAnt FB "IolWriteAnt" includes the described functions
(Chapter 3.1) on an already fully implemented
basis. In this block, the blocks are called from
the "LIOLink_RF200_V31" library and the
"TONR" monitoring function.
FB1 LIOLink_RF200_ Function block for switching the antenna of an
SwitchAntenna RF200 IO-Link reader on/off.
FB2 LIOLink_RF200_ReadTag Function block for reading the transponder.
FB3 LIOLink_RF200_WriteTag Function block for writing to the transponder.
DB1 DataBuffer Global data block for saving the RFID data
DB2 HmiInterface Global data block for the tags that are integrated
in WinCC and that form the HMI interface.
Note For a more detailed description of the library blocks, refer to the library
documentation:
https://support.industry.siemens.com/cs/ww/en/view/82981502
sdsafasdfsa
"Main"
OB 1 calls the following blocks:
• FB3: "IolReadAnt" contains the flowchart for a read job from switching the
reader on, via the read function, to switching the reader off.
• FB5: "IolWriteAnt" contains the sequence for a write job from switching the
reader on, via the read function, to switching the reader off.
"HmiInterface"
The "HmiInterface" data block (DB2) includes the data for the visualization in tags.
© Siemens AG 2020 All rights reserved
These tags are integrated into WinCC Basic V16 and form the HMI interface.
Table 3-3
Name Data type Description
read Bool Read job triggered at positive edge.
addrTagRead Word Offset of the data to be read on the transponder
lengthRead Time Length of the data read during the read job.
doneRead Bool True, if write job completed without error.
errorRead Bool True, if read job has failed.
statusRead Bool Read job status in Hex code.
presenceRead Word Presence of a transponder in the detection area.
write DWord Write job triggered at positive edge
addrTagWrite Bool Offset where the data is written to the transponder.
lengthWrite DWord Length of the data written during the write job.
doneWrite Bool True, if write job completed without error.
errorWrite Bool True, if read job has failed.
statusWrite Bool Write job status in Hex code.
presenceWrite Word Presence of a transponder in the write area.
"DataBuffer"
In data block "DataBuffer" (DB1), the RFID data to be read from or written to the
transponder is stored.
Table 3-4
Name Data type Description
readData Array[0..1999] of byte Data read from the transponder after a read job.
writeData Array[0..1999] of byte Data, to be written to a transponder during a
write process.
3.2 Functionality
3.2.1 Program details on FB "IolReadAnt" (FB3)
The following figures and tables show the call interface of user block FB
"IolReadAnt" (FB3).
Figure 3-3
© Siemens AG 2020 All rights reserved
Input Output
For a S7-300 CPU, the input "hwId" must be set to the IO start address of the IO-
Link master.
NOTE
For a ET 200eco PN Master, the input "portAddr" must be set to "0".
The following figure and table show the call interface of user block FB "IolWriteAnt"
(FB5).
Figure 3-4
Input Output
For a S7-300 CPU, the input "hwId" must be set to the IO start address of the IO-
Link master.
NOTE
For a ET 200eco PN Master, the input "portAddr" must be set to "0".
For error diagnostics, the function blocks "IolReadAnt" (FB3) and "IolWriteAnt"
(FB5) have one STATUS output each. By reading the STATUS output of the
function block you receive information on
• Error messages of the IolReadAnt function block (FB3) and the function blocks
of the library
• Error messages of the connected RF200 IO-Link reader.
read process.
16#00018102 The previous job has not been completed yet. Restart process
The job is finished at the next possible time.
16#00018103 No transponder was detected in the reader’s Restart process
field within the specified time.
16#00018104 The given length is smaller than 28. Specify a length of a
minimum of 28.
16#000180xy Error messages of the extended instructions Online help in STEP 7
16#000187xy "BLKMOV", "DPRD_DAT" and "DPWR_DAT".
16#000185xy
16#00018xyy
16#001100xx Error messages of the connected reader See below.
NOTICE Before you switch on the power supply, complete and check the
installation!
24 V
230 V
PROFINET IE
MDS Dxx
24 V RF220R
(V1.0)
24 V
ET 200SP CM 4xIO-Link
Table 4-1
No. Action Remarks
1. Connect the individual modules to a suitable
module rack.
2. Connect the PM 1507 with the power supply When wiring the 24V, make sure that the
system (230 V alternating current). polarity is correct.
3. Interconnect the following devices:
• PROFINET interface of the PG/PC to the PROFINET interface of the S7 CPU
• PROFINET interface of the S7-CPU with the PROFINET interface of ET 200SP
• Reader cable with the CM 4xIO link (see \9\, Chapter 3.1)
4.3 Commissioning
4.3.1 Restore S7-1500 CPU factory setting
Before you begin with the commissioning of the application, the S7-1500 CPU must
have the factory settings (see \8\, Chapter 13.5).
Under the following circumstances you can reset the S7-1500 to the original factory
settings:
• No memory card has been inserted in the CPU.
• The CPU is in STOP mode.
Result:
The CPU then performs a "Reset to factory settings" whilst the RUN/STOP LED
flashes yellow. If the RUN/STOP LED lights up yellow, the CPU has been reset to
factory settings and is in STOP mode. The "Reset to factory settings" event is
entered in the diagnostic buffer.
NOTICE When assigning the IP addresses of your devices please ensure that they
are all located in the same subnet and each IP is only assigned once
across the subnets.
The table below shows the network setting to which you have to change the
PC/PG:
Table 4-4
No. Action
1. Open the Internet Protocol (TCP/IP) Properties by selecting
"Start > Settings > Network Connections > Local Connections".
2. In the open window, select Internet Protocol (TCP/IP) and open Properties.
3. Select the option box "Use following IP address" and fill in the box as shown in
the picture. Close the dialog boxes with "OK".
Before you start operating the application, the following steps are necessary to
commission the RF200 IO-Link reader.
Table 4-5
No. Action
1. In the TIA Portal, open the Device configuration of the PLC_S7_1500 station.
2. Open the properties of the CM 4xIO-Link module and activate a new potential
group.
"Properties" > "Potential group"
© Siemens AG 2020 All rights reserved
No. Action
4. In PCT (S7 Port Configuration Tool) go to the Ports tab, open the product catalog
in PCT and select an IO-Link device V1.1. Drag this device to the desired port of
the master module. In this example an RF200 IO-Link reader is inserted.
Note The start addresses have to be within the I/O addresses of the 4SI IO-Link
module.
Before the STEP 7 project can be loaded into the CPU, the IP address of the S7-
1500 CPU with which you can load the project into the CPU, must be changed.
Note The IP address configured in STEP 7 V16 (TIA Portal) for the S7-1500 CPU
must be located in the same subnet as the IP address set in Windows.
Table 4-6
No. Action
1. Navigate to the "IP address" option via the display of your S7-1500 CPU.
Settings > Addresses >X1 (IE/PN) > IP Address
2. Set the IP address used in the example project of the S7-1500 (192.168.0.1).
Table 4-7
No. Action
© Siemens AG 2020 All rights reserved
1. Start the TIA Portal V16 in the project view. Search for "Nodes accessible online".
To this end, navigate to "Project Tree> Online Access> [Your_Ethernet_Adapter]>
Update accessible devices".
Your stations are now recognized.
2. The procedure is identical for all CPUs: Now you navigate to "[Your_S7CPU]>
Online&Diagnostics".
In the graphical area of "Online & diagnostics", select "Functions> Assign IP
address".
3. Assign the IP address used in the Assign the IP address used in the
project for the ET 200SP (see inspector project for the ET 200SP (see inspector
window of the device view). window of the device view).
Confirm the action with "Assign IP Confirm the action with "Assign IP
address". address".
Requirement:
• The STEP 7 V16 project has already been installed and retrieved (see Chapter
4.3).
• The IO-Link master has already been configured (see Chapter 5.4).
Proceed as follows:
• Start the TIA Portal.
• Open the project view.
• Open the "IOL_READ_WRITE_DATA" project.
• In the project navigation:
– Select "PLC_S7_1500 [CPU 1513-1 PN]"
– Right-click and select:
"Download to device > Hardware and software"
• Select the suitable PG/PC interface in the "Extended download to device"
dialog window. As soon as loading is possible, the "Download" button will be
enabled.
• Click the "Download" button.
• Check the messages in the "Load preview" dialog and if required, enable the
© Siemens AG 2020 All rights reserved
READ WRITE
Note In the user interface of the HMI you can change the display language of each
screen from German to English and vice versa by clicking on the flag icons.
The application example can be opened via the main menu and continuing
information be called up via the online support.
In the application example you can toggle between scenario 1 and 2.
The scenarios can be controlled via the respective operator windows.
3. The read RFID data is available to you in the Read Data area.
3. If the write job has been completed successfully, this is indicated by the green
"DONE" signal.
No. Action
5. Place a transponder in the reader’s field and once again click on the "READ" button.
The error was cleared.
6. The read RFID data is available to you in the "Read Data" area.
© Siemens AG 2020 All rights reserved
6 Appendix
6.1 Service and support
Industry Online Support
Do you have any questions or need assistance?
Siemens Industry Online Support offers round the clock access to our entire
service and support know-how and portfolio.
The Industry Online Support is the central address for information about our
products, solutions and services.
Product information, manuals, downloads, FAQs, application examples and videos
– all information is accessible with just a few mouse clicks:
support.industry.siemens.com
Technical Support
The Technical Support of Siemens Industry provides you fast and competent
support regarding all technical queries with numerous tailor-made offers
– ranging from basic support to individual support contracts. Please send queries
to Technical Support via Web form:
www.siemens.com/industry/supportrequest
© Siemens AG 2020 All rights reserved
Service offer
Our range of services includes the following:
• Plant data services
• Spare parts services
• Repair services
• On-site and maintenance services
• Retrofitting and modernization services
• Service programs and contracts
You can find detailed information on our range of services in the service catalog
web page:
support.industry.siemens.com/cs/sc
The Siemens Industry Mall is the platform on which the entire siemens Industry
product portfolio is accessible. From the selection of products to the order and the
delivery tracking, the Industry Mall enables the complete purchasing processing –
directly and independently of time and location:
https://mall.industry.siemens.com