Skip to content
Tech blog

PUT/GET with optimised data blocks of a Siemens S7

Your S7-1200 or S7-1500 returns no values via PUT/GET? Usually optimised data blocks are the reason. We show you two ways to get to your data anyway.

Content overview

Why PUT/GET cannot read optimised data blocks

PUT/GET accesses the controller's memory by absolute address, that is by data block, byte and bit. In an optimised data block the controller arranges the variables itself, so there is no fixed address. This is why a PUT/GET client can neither read nor write optimised data blocks.

For data exchange with an S7-1200 or S7-1500 you therefore have two options:

PUT/GET: The data is stored in non-optimised data blocks, and PUT/GET is permitted in the controller. No additional licence is needed.

OPC UA: The controller provides its data via its OPC UA server. Optimised data blocks stay as they are. This requires an OPC UA runtime licence from Siemens.

“Create new PLC” dialogue in DataSuite with the connection types S7 - Put/Get, S7 - OPC UA and OPC UA
DataSuite connects to each controller via PUT/GET or OPC UA

Which option suits which situation is compared in the article PLC-PC data exchange without an OPC server.

Option 1: PUT/GET with non-optimised data blocks

You need an S7-1200 or S7-1500 with an Ethernet (Profinet) interface, the TIA Portal and DataSuite version 3 or later.

Create a data block for data exchange

A separate, non-optimised data block that DataSuite uses only for data exchange has proven itself. Your existing optimised data blocks then stay unchanged, and the rest of the PLC program does not need to be adapted.

This is how you switch off optimisation for a data block:

  1. In the TIA Portal, right-click the data block under “Program blocks” and choose “Properties”.
  2. Under “Attributes”, clear the option “Optimized block access”.
  3. Compile the project and download it to the controller.

If you convert an existing data block, the addresses of its variables change. In that case, check every part of the program that accesses it.

Permit PUT/GET in the controller

On the S7-1500, and on the S7-1200 from firmware V4.0, PUT/GET is blocked by default.

  1. Open the device configuration of the controller.
  2. In the properties, select “Protection & Security”.
  3. Set the access level to “Full access”.
  4. Under “Connection mechanisms”, enable “Permit access with PUT/GET communication from remote partner”.
  5. Download the configuration to the controller.

Connect DataSuite to the controller

  1. In DataSuite, click “Create new PLC” under “PLCs” and choose the connection type “S7 - Put/Get”.
  2. Enter the IP address of the controller. Rack and slot are usually 0 and 1 on the S7-1200 and S7-1500.
  3. Click “Test connection” to check that the controller responds.

The easiest way to add the variables is from the TIA Portal: export the data block there as a source file and import it into DataSuite. You can also create individual variables by hand.

Jetzt kostenlos beraten lassen

In einem Videocall oder einem Telefonat mit einem unserer Experten werden Ihre Fragen beantwortet. Konkrete Anforderungen und Projekte können direkt besprochen werden.

Die Terminbuchung wird mit Microsoft Bookings durchgeführt, es gilt die Datenschutzerklärung von Microsoft.

Markus Bläser

Option 2: Optimised data blocks via OPC UA

With OPC UA you read and write optimised data blocks directly by variable name. The connection is encrypted, and the controller requires a login. You need an S7-1500 or an S7-1200 with an OPC UA server, a suitable OPC UA runtime licence from Siemens, the TIA Portal and DataSuite version 3 or later. Port 4840 must be open on the network between the PC and the controller.

Activate the OPC UA server in the controller

  1. In the TIA Portal, open the device configuration of the controller and select “OPC UA” in the properties.
  2. Under “Server”, enable “Activate OPC UA server”. The default port is 4840.
  3. Under “Security”, set up at least user name and password authentication. We also recommend an encrypted connection.
  4. Under “Runtime licenses”, select the OPC UA licence you purchased.
  5. Download the configuration to the controller.
TIA Portal, properties of a CPU 1511-1 PN: OPC UA selected, “Activate OPC UA server” enabled, server address opc.tcp://192.168.2.100:4840
Activating the OPC UA server of an S7-1500 in the TIA Portal

For DataSuite to see a variable, it must be marked as “Accessible from HMI/OPC UA” in the data block. This is the default for new variables. On the S7-1200 you also create a server interface and drag the required variables into it. Read more in the article How to use OPC UA with a Windows client.

Connect DataSuite and import data blocks

  1. Click “Create new PLC” under “PLCs” and choose “S7 - OPC UA”.
  2. Enter the IP address and port of the controller.
  3. Choose the security policy that matches the setting in the controller and enter user name and password.
  4. Test the connection and save.
  5. In the data blocks, choose “Import data blocks” and select the blocks you need. DataSuite reads them, including their variables, directly from the controller.
“Add new data block” dialogue in DataSuite with the options “Import data blocks” and “Import objects”
Importing data blocks directly from the controller via OPC UA

If variables are added in the controller later, simply import the data block again.

Writing data to Excel or an SQL database

Once the connection is set up, you work with the variables in the same way, whether they come via PUT/GET or OPC UA. What happens to the data is defined in DataSuite with a trigger: it reacts to a condition, for example every 10 seconds or a bit in the controller, and then runs its actions.

Store data from the controller in Excel

  1. Create a new file under “Excel files” or use a template. Path and file name may contain variables, such as the date.
  2. Choose whether an existing file is overwritten or continued, or whether a new file with a sequential number is created.
  3. Create a trigger with the action “Write data record”, choose the file and sheet and assign the variables to the columns.
Trigger action “Write data record” in DataSuite with file, sheet and the assignment of variables to columns
“Write data record”: each run writes one row to the Excel file

How to prepare the file with headers, logo and formulas is shown in the article Format and use Excel templates. Microsoft Excel does not have to be installed for this.

Write values to the controller

The other direction works the same way: a trigger reads values from an Excel file or database and writes them to a variable in the data block, for example recipes or order data. With PUT/GET, the target variable must be in a non-optimised data block.

SQL database instead of Excel

If the data is to go into a database, create a connection to Microsoft SQL Server, MySQL, MariaDB or PostgreSQL under “Databases”. A trigger then writes the values to a table with an insert or reads them back into the controller with a select. Instructions can be found in the article Connect a PLC to a database in 5 minutes.

Troubleshooting

No connection to the controller

  • Does the controller respond to a ping to its IP address?
  • PUT/GET: Is PUT/GET permitted, the access level set to “Full access”, and are rack and slot correct?
  • OPC UA: Is the server activated and the licence selected? Do security policy, user and password match? Is port 4840 open?

Values do not arrive

  • PUT/GET: Is the data block really non-optimised, and has it been downloaded to the controller after the change?
  • OPC UA: Is the variable marked as “Accessible from HMI/OPC UA”, and has the data block been imported again after changes?
  • Does the variable view in DataSuite show current values? Is the trigger condition met?

If you get stuck, our support team will help you free of charge:
Phone: +49 2742 72927 80
Email: support@mb-datasuite.com

You can test DataSuite free of charge. The manual with detailed instructions is included in the download.

Conclusion

Optimised data blocks cannot be read via PUT/GET. Without an OPC UA licence, create a separate, non-optimised data block for data exchange and permit PUT/GET in the controller. With OPC UA, the data blocks stay optimised and the connection is encrypted. In DataSuite you can use both options side by side and write the data to Excel files or SQL databases.

Download trial software

Test all functions free of charge for 30 days. You will receive an email with a download link for instant use.

Monitor showing “Download DataSuite 3”