Why does the OPC UA client not receive the data in the order that you specified in STEP 7 (TIA Portal)?
If you change data elements in PLC data types, the configured order of the PLC data type of your STEP 7 (TIA Portal) program does not match the order of the data elements in the type directory of the SIMATIC OPC UA (OPC Unified Architecture). In this way the elements of the PLC data type are transferred via the line between SIMATIC OPC UA server and client differently from the view in STEP 7 (TIA Portal).
With an optimized DB the CPU stores the information so that it can access it in the best possible way. In most cases, this storage structure does not match the structure or configuration of the DB.
If you change the DB in STEP 7 (TIA Portal), you have your view of the DB in STEP 7 (TIA Portal). On the other side, the DB and also the changes in the DB are stored in the CPU ("CPU view of the data") in a different order.
Detailed information about optimized blocks is available in the "Programming Guidelines for S7-1200/1500". Open the PDF document (under "View") and navigates to "2 S7-1200/S7-1500 Innovations > 2.6 Optimized Blocks".
The above-mentioned behavior does not occur in the case of non-optimized data blocks. We recommend however that you continue using the optimized data blocks because with these blocks the file archive is optimized and is independent of the declaration. Access to the data is always performed as quickly as possible.
In the following example a STEP 7 (TIA Portal) program includes the PLC data type "udtCounters" with the data elements configured in Fig. 1.
This PLC data type is used in a global data block. The structure of the data elements of the PLC data type also corresponds to the structure of the SIMATIC S7-1500 OPC UA server.
If, for example, you now change the data type of the data element "intC" from "Int" to "DInt", then this changed data element is automatically shifted down in the SIMATIC S7-1500 OPC UA server or appended as the last variable.
All the data is transferred correctly, only when reading out from the CPU, the order of the data might be different to the order in STEP 7 (TIA Portal).
- Update the firmware version of your CPU S7-1500. With firmware V2.5.2 and higher the behavior described above no longer occurs.
- Program the SIMATIC OPC UA client dynamically so that the client interprets the structures and the order of the elements in them correctly during runtime. More information about this is available in the application "OPC UA .NET Client for the SIMATIC S7-1500 OPC UA Server".
The screens in this FAQ response were created with STEP 7 (TIA Portal) V14.