1. Problem Overview: Optimized Data Blocks Are Invisible to Legacy OPC DA
You are integrating a Siemens SIMATIC S7-1200 PLC that was programmed by another party. You receive an address list of data blocks (DBs) you must integrate into a higher-level system through OPC, but the integrator-side documentation only lists symbolic names such as "DB_Motor".Motor1.SpeedActual. There are no absolute offsets like DB1.DBD4. Classic OPC DA servers such as Softing S7/S5 OPC, Matrikon Modbus/TCP OPC, Kepware Siemens TCP/IP Ethernet Driver, and similar products return "address not found" or quality OPC_QUALITY_BAD because the blocks were created with the Optimized block access option in TIA Portal.
This is the single most common dead-end in machine integration projects where the original machine builder never delivered a side-by-side standard DB and the integrator cannot legally or contractually modify the PLC program. The integrator is left with a SCADA system, an OPC tag table, and a hardware inventory that simply cannot see the PLC variables.
This technical reference walks through the four engineering paths that actually work when you cannot modify the PLC program, lists every prerequisite that is silently assumed, and ends with a verification procedure and a troubleshooting matrix you can use on the plant floor.
2. Root Cause: What "Optimized Block Access" Changes Inside the CPU
In TIA Portal, when a DB is created (or when the static section of a function block is generated), the developer can toggle Optimized block access in the DB or FB properties under Attributes. The setting fundamentally changes how the compiler lays out the data in load memory and work memory, and how the runtime publishes it to the outside world.
| Property | Standard (S7-300/400 compatible) | Optimized |
|---|---|---|
| Data layout | Fixed offsets assigned by declaration order; preserved across compiles | Compiler decides offsets; layout can shift with every re-compile |
| Addressability | Absolute: DB1.DBX0.0, DB1.DBD4, DB1.DBW10
|
Symbolic only: "MyDB".MyVariable
|
| OPC DA compatibility | Native — absolute addresses resolve over the S7 protocol | None — no stable offset exists for the client to bind to |
| OPC UA compatibility | Symbolic or absolute browse path | Symbolic browse path only |
| HMI visibility | Always reachable when the DB is reachable | Requires Accessible from HMI attribute per variable |
| Retain / non-retain | Per-variable setting still works | Per-variable setting still works |
| Download behavior | Re-increments the timestamp only on real change | May re-number offsets; any external absolute address becomes stale |
The Siemens S7 communication protocol — used by virtually every classic OPC DA server — exposes memory by absolute byte offset inside the DB. When the block is optimized, the firmware does not publish stable offsets because the symbolic names are resolved dynamically through an internal symbol table. The OPC DA client simply has nothing to put into its tag address field. The protocol is not "broken" — it is doing exactly what the protocol contract specifies, and that contract does not include a way to ask "give me DB1.MyVariable by name."
DB1.DBD4 from an old address list, that offset is invalid after every re-compile of an optimized DB. Treat any printed address list from an optimized DB as stale by definition. The first re-download can renumber every byte.3. Why Classic OPC DA Returns Bad Quality
Classic OPC DA servers all use one of two Siemens transports: ISO-on-TCP (RFC 1006) carrying PUT/GET, or S7 Communication over the same transport. Both transports require one of the following on every read or write request:
- A known absolute address inside a known block:
DB1.DBD0,DB1.DBX4.2,MW10,I0.0,Q0.1. - A known data type length so the server can pack the correct byte count into the request frame.
- A known byte order — the S7 transport is little-endian (Intel byte order) for INT, DINT, REAL, and WORD.
Because optimized DBs do not expose these addresses to the S7 protocol layer, the OPC server cannot resolve the tag. The client receives quality OPC_QUALITY_BAD with sub-status OPC_E_INVALID, or the tag simply does not appear in the server's address space at all. Some servers display the tag with a stub value; others refuse to add it. None of these are bugs — they are the contract of the S7 protocol when faced with optimized blocks.
A second, equally important limitation: classic OPC DA has no concept of a "symbolic browse." The address space is flat and typed, not hierarchical and named. There is no DA service for "list all variables in DB1 by name." Even if the S7 protocol could expose the symbol table, DA clients would have no way to consume it. That is what OPC UA was designed to solve, and why the right long-term path is almost always OPC UA.
4. Critical Configuration: The "Accessible from HMI" Attribute
Before any of the solutions in this article can succeed, every variable you need to read or write must have the Accessible from HMI attribute enabled. Without it, the variable is hidden from every communication layer — S7 protocol, OPC DA, OPC UA, even SIMATIC HMI panels. The attribute is per-variable and defaults to off for safety.
- Open the DB in TIA Portal.
- Select one or more variable rows in the declaration table.
- In the right-hand Properties > Attributes pane, tick the Accessible from HMI checkbox.
- Repeat for every variable you need to expose.
- Compile the project (Ctrl+B or the lightning-bolt icon) and download to the PLC.
For large DBs with hundreds of variables, use the multi-row selection and the right-click context menu to apply the attribute in bulk. Verify in the TIA Portal online view that the attribute was retained across the download — a partial download of just the DB changes the variable list but not always the attributes.
5. Solution 1: Request a Bridge (Mirror) Data Block with Absolute Access
This is the most reliable path when the integrator cannot re-engineer the OPC layer. The PLC programmer creates a single standard (non-optimized) DB that mirrors only the variables you need. You then point your classic OPC DA server at the absolute offsets in that mirror DB. The PLC code copies data into the bridge DB each scan, and copies writes back from the bridge to the source DB.
5.1 What to send to the PLC programmer
Provide an Excel sheet with this column structure to remove ambiguity and prevent back-and-forth emails:
| Symbolic Name | Source DB | Data Type | Direction | Scaling / Units | Update Rate | Notes |
|---|---|---|---|---|---|---|
Motor1.SpeedActual |
DB_Motor |
REAL | Read | rpm | 100 ms | Range 0–3000 |
Line.State |
DB_LineCtrl |
INT | Read | Enum 0=Idle, 1=Run | 100 ms | — |
Recipe.ID |
DB_Recipe |
DINT | Read/Write | — | on change | Valid 1–999 |
Recipe.LoadCmd |
DB_Recipe |
BOOL | Write | Edge-triggered | on demand | Pulse > 200 ms |
5.2 Sample SCL code for the bridge
The PLC programmer drops the following into OB1 (or a faster cyclic OB if scan time allows):
// Mirror optimized source DBs into a single standard-access bridge DB
// Place in OB1 so it runs every scan
// Reads: source -> bridge
"DB_Interface".SpeedActual_R := "DB_Motor".Motor1.SpeedActual;
"DB_Interface".LineState_I := "DB_LineCtrl".Line.State;
"DB_Interface".RecipeID_DI := "DB_Recipe".Recipe.ID;
// Writes: bridge -> source (one-direction per OB1 pass)
"DB_Recipe".Recipe.ID := "DB_Interface".RecipeIDCmd_DI;
// Edge-triggered write commands
IF "DB_Interface".LoadCmd_B AND NOT "DB_Interface".LoadCmdPrev_B THEN
"DB_Recipe".Recipe.LoadCmd := TRUE;
END_IF;
"DB_Interface".LoadCmdPrev_B := "DB_Interface".LoadCmd_B;
5.3 Configure the bridge DB
- In the TIA Portal project tree, right-click Program blocks → Add new block → Data block.
- In block properties, uncheck Optimized block access. The block must be standard for the OPC DA server to address it by offset.
- Add one variable per signal from the integrator sheet, in the order you want the offsets to fall. Group by data type to keep byte alignment clean.
- Tick Accessible from HMI for every variable.
- Compile and download to the PLC. Now
DB_Interface.DBD0,DB_Interface.DBW4,DB_Interface.DBD6,DB_Interface.DBX12.0are stable offsets your OPC server can target.
5.4 OPC DA configuration (example for Softing, Kepware, Matrikon)
Channel name: Siemens TCP/IP Ethernet
Device driver: Siemens S7-1200/1500 (or compatible S7-300/400 fallback)
PLC IP address: 192.168.0.10
Rack / Slot: 0 / 1 (S7-1200 always slot 1)
Tag address examples:
MotorSpeed_r DB100.DBD0 REAL 4 bytes 100 ms
LineState_i DB100.DBW4 INT 2 bytes 100 ms
RecipeID_di DB100.DBD6 DINT 4 bytes on change
LoadCmd_b DB100.DBX12.0 BOOL 1 bit on change
Byte order: Little-endian (Intel)
Scan mode: Polled, 100 ms default
Performance cost is minimal — a single assignment per signal in OB1 runs well under 1 ms even with 200 mirrored tags on a CPU 1214C. The CPU load impact is negligible compared to the savings in OPC debugging time. The downside is that the bridge DB itself becomes a maintenance artifact: every new signal requires a code change in the PLC, a re-download, and an OPC tag database update.
6. Solution 2: Activate the Built-in OPC UA Server on S7-1200
Starting with firmware V4.4 (released 2018), every S7-1200 CPU can act as an OPC UA server directly, with no additional hardware and — on most current models — no extra license. Every variable that has Accessible from HMI set becomes browseable by symbolic name over the OPC UA binary protocol on TCP port 4840 (default). This is the cleanest, most sustainable solution and should be your first choice whenever the PLC programmer is willing to spend ten minutes enabling it.
6.1 Check prerequisites
| Item | Requirement |
|---|---|
| CPU firmware | V4.4 or higher. Check via Online & Diagnostics → CPU Information in TIA Portal, or read MLFB / serial number. |
| TIA Portal version | V15.1 or higher for the OPC UA configuration UI under device properties. |
| CPU model | CPU 1214C, 1215C, 1217C recommended. CPU 1211C / 1212C have reduced OPC UA capability. |
| License | OPC UA option must be activated under CPU properties → Runtime licenses. Some entry-level SKUs ship with OPC UA disabled. |
| Network | TCP port 4840 reachable from the OPC UA client. Default port can be changed if needed. |
| Time sync | PLC real-time clock should be synchronized (NTP or CPU -> PC) for accurate OPC UA timestamps. |
6.2 Activate the server in TIA Portal
- Open the PLC device configuration in the project tree.
- Navigate to Properties → OPC UA → Server.
- Check Activate OPC UA Server.
- Choose the port (default 4840) and at least one endpoint security policy: None for lab testing, Basic128Rsa15 or Basic256Sha256 for production.
- Define the server certificate under Security → Server certificate. Export the certificate and install it in the OPC UA client's trusted store.
- Under Runtime licenses, confirm the OPC UA option is licensed. If not, transfer the license from the license key file.
- Download the hardware configuration to the PLC (not just the program blocks).
6.3 Verify with UA Expert (free OPC Foundation client)
- Install UA Expert from the OPC Foundation downloads page.
- Add a new server:
opc.tcp://192.168.0.10:4840. - Trust the server certificate when prompted.
- Browse to Objects → Server interface → DB_Motor. Variables with Accessible from HMI appear as child nodes.
- Drag a variable onto a DataView panel; the value, data type, source timestamp, and server timestamp should populate.
Once UA Expert confirms the address space, your SCADA or HMI client can connect using the same endpoint URL and certificate. No bridge code, no extra PLC scan time, and no fragile offsets — the symbol table published by the firmware is the source of truth.
7. Solution 3: Symbolic Access During Runtime (S7-1500 Path)
For S7-1500 systems, and for S7-1200 from firmware V4.5 with the S7-1200 symbolic access feature, SCL supports symbolic variable access by string name at runtime. The PLC code registers a DB and looks up a symbol inside it, returning a VARIANT pointer that can be dereferenced. This is documented at the official Siemens TIA Portal help page Symbolic access during runtime (S7-1500).
7.1 When this path makes sense
- You have an S7-1500 (or compatible S7-1200 firmware) and can add code.
- The OPC client can only consume absolute addresses but you need to expose many tags without enumerating each one in source.
- You want to drive a generic tag table from configuration data rather than hand-coded assignments.
- The integrator needs the PLC to compute the absolute address of a symbol whose name is supplied by the SCADA.
7.2 SCL sketch
// Cyclic OB1
// Symbol lookup at runtime — register the DB, then resolve a name string
"dbSymLookup"(req := TRUE,
lookUp := 'MyDB.MyTag',
dataBlock := "DB_Registry",
found => #bFound,
symAddress => #pSymbolAddr);
IF #bFound THEN
// Dereference the VARIANT pointer into the bridge DB
IF IS_REAL(#pSymbolAddr) THEN
"DB_Interface".MirrorReal := #pSymbolAddr^;
ELSIF IS_BOOL(#pSymbolAddr) THEN
"DB_Interface".MirrorBool := #pSymbolAddr^;
END_IF;
END_IF;
8. Solution 4: Third-Party OPC Servers with Symbolic Capability
A small number of OPC vendors implement a Siemens-specific parser that walks the TIA Portal project (offline via exported XML, or online via the OPC UA interface) and rebuilds a symbolic tag namespace that legacy DA clients can consume through a wrapper or DA-to-UA bridge. Products in this category include Softing edgeConnector Siemens, the Siemens SIMATIC NET OPC Server with the S7-1200/1500 symbolic driver, and Prosys OPC UA Gateway. These map the symbolic browser onto legacy DA clients.
8.1 Decision factors
| Server | Supports Optimized DBs | License model | Engineering effort | Notes |
|---|---|---|---|---|
Softing edgeConnector Siemens
|
Yes — symbolic browse, OPC UA only | Per-device, perpetual | Low — discovery auto-imports symbols | Requires OPC UA client; can be wrapped to DA |
Siemens SIMATIC NET OPC Server
|
Yes with PC station + S7-1200/1500 symbolic driver | Bundled with TIA Portal option | Medium — PC station configuration required | Native DA support |
| Prosys OPC UA Gateway | Yes — bridges OPC UA to DA | Per-server subscription | Medium — gateway mapping | Useful for legacy DA SCADA |
| Generic classic OPC DA server (Softing S7/S5, Kepware S7 MPI/TCP, Matrikon) | No | — | N/A — fails on optimized DBs | Confirm S7-1200 OPC UA driver specifically |
When evaluating these, confirm that the vendor specifically supports the S7-1200 OPC UA interface (firmware V4.4+) or the SIMATIC S7-1200/1500 symbolic driver. Generic S7-300/400 drivers will still fail because they bind to absolute addresses only.
9. Verification: Confirming the OPC Path Works End-to-End
9.1 Bridge DB path
- In TIA Portal online view, watch
DB_Interface.DBD0in a VAT — confirm the value updates when you change the sourceDB_Motor.Motor1.SpeedActualin a separate VAT. - From the OPC client, read the same tag and confirm a non-stale timestamp (within your scan rate).
- Force a write from the OPC client; verify the source variable updates in the PLC VAT within one scan.
- Cycle power on the PLC; confirm the bridge DB re-populates from retained source data on the next scan.
- Verify byte order by writing a known pattern (e.g., REAL 1234.5 = 0x449A5000) and reading it back as four bytes.
9.2 OPC UA path
- Browse the server from UA Expert; the address space under your DB must list every variable flagged Accessible from HMI.
- Subscribe to a tag with a 100 ms publishing interval; confirm monitored item notifications arrive without
Bad_CommunicationError. - Check
ServerStatus_State— should reportRunning. - Disconnect and reconnect; verify the session re-establishes without re-importing the certificate.
- Inspect
ServerStatus_StartTime,ServerStatus_CurrentTime, andServerStatus_BuildInfoto confirm the server is the S7-1200 and not a stale cached session.
9.3 Symbolic runtime path
- Force the lookup string to an invalid name; the
foundoutput should goFALSEwithin one scan. - Force a write to the symbol; confirm the OPC client receives the new value.
- Stop and restart the PLC; confirm the registry DB re-populates and the lookups succeed again.
- Monitor the cycle time impact — runtime symbolic lookup is heavier than a direct assignment; budget accordingly.
10. Decision Flowchart
11. Troubleshooting Matrix
| Symptom | Likely Cause | Fix |
|---|---|---|
OPC DA tag quality Bad, address exists in project |
DB is optimized — no absolute offset exposed | Switch to OPC UA or build a bridge DB |
| OPC UA browse shows DB but variable missing | Accessible from HMI not set on that variable | Have programmer enable the attribute, re-download |
| OPC UA client cannot connect | Port 4840 blocked, wrong endpoint URL, certificate not trusted | Open firewall on the path, double-check URL, install the server cert in the client trust store |
OPC UA Bad_SecurityChecksFailed
|
Security policy mismatch between client and server | Match policy (None / Basic128Rsa15 / Basic256Sha256) on both sides |
| Bridge DB value never changes | Assignment in wrong OB, conditional execution, or DB downloaded before code | Place assignments unconditionally in OB1, recompile, download both blocks |
| Values correct but wrong number / wrong sign | Endianness or data type mismatch | Confirm little-endian (Intel) byte order for REAL/INT/DINT; verify DINT vs INT width |
| Write succeeds in client but PLC value unchanged | PLC in Run with read-only access or write-protected via access level | Have programmer set full access level for the OPC connection, or enable PUT/GET permission |
| Variable visible in TIA Portal online but not in OPC | Variable is in Temp or Local scope, or in an FB multi-instance | Move variable to Static of a DB or to the interface DB; re-download |
| Address list from PLC programmer no longer matches | Optimized DB was recompiled, offsets shifted | Stop using absolute addresses; migrate to OPC UA or rebuild the bridge DB |
| OPC UA server unreachable after firmware upgrade | OPC UA option license removed during upgrade | Re-apply license under Runtime licenses; verify V4.4+ is still active |
| Bridge DB values correct in TIA Portal but wrong over OPC | OPC server cache stale after PLC program change | Clear OPC server tag cache; restart DA server; force re-read |
| Reads OK, writes intermittently rejected | PUT/GET access not enabled on CPU, or partner connection limit reached | Enable PUT/GET under CPU properties → Protection & Security; check connection resource count |
12. Standards and Reference Material
The S7-1200 OPC UA server implements the OPC UA Binary protocol as defined in IEC 62541. The S7 transport used by legacy OPC DA servers is the Siemens-proprietary ISO-on-TCP (RFC 1006) carrying the S7 Communication or PUT/GET application layer. Security policies available on the S7-1200 OPC UA endpoint are None, Basic128Rsa15, and Basic256Sha256; the legacy Basic128Rsa15 policy is considered deprecated by the OPC Foundation and should be phased out in favor of Basic256Sha256 for any new integration.
For the runtime symbolic access feature on S7-1500, refer to the official Siemens TIA Portal help topic Symbolic access during runtime (S7-1500). Always confirm the feature set against the specific TIA Portal version and CPU firmware you have installed; some features are gated to specific firmware versions and CPU SKUs.
FAQ
Can classic OPC DA servers (Softing, Matrikon, Kepware) read an optimized S7-1200 data block?
No. Classic OPC DA servers use the S7 ISO-on-TCP protocol and require absolute byte offsets inside the DB. Optimized DBs do not publish stable offsets, so the server returns Bad quality. Use the built-in OPC UA server (firmware V4.4+) or a standard-access bridge DB instead.
What is the minimum firmware version for OPC UA on S7-1200?
Firmware V4.4 (released 2018) is the minimum to enable the integrated OPC UA server. Earlier CPUs cannot act as OPC UA servers and must either be firmware-upgraded or paired with an external OPC UA gateway.
Why does my variable disappear from OPC UA even though it is in the DB?
The Accessible from HMI attribute is not set on that variable. The PLC programmer must tick it in the DB declaration table and download the project again. Variables without this flag are hidden from every communication layer, including OPC UA.
Is there a way to access symbolic names without modifying the PLC program at all?
Not on the S7-1200 side — symbolic resolution happens inside the firmware, and the S7 protocol does not carry symbol names. You must either (a) request that the programmer add a non-optimized mirror DB, (b) ask them to enable the OPC UA server and the HMI-accessible attribute, or (c) insert an external gateway that re-implements symbolic browsing over OPC UA.
What TCP port does the S7-1200 OPC UA server use, and what security policies are supported?
Default TCP port is 4840; configurable under CPU properties → OPC UA → Server. Supported security policies are None, Basic128Rsa15, and Basic256Sha256. Production deployments should use Basic256Sha256 with server certificate installed in the client trust store.
Do I lose data if the bridge DB is not retentive?
Yes — if the PLC powers down and the source variables are retentive but the bridge is not, the bridge loses its values and the OPC client will read stale or zero data until the next OB1 pass repopulates it. Mark the bridge DB as retentive for every variable you need to survive a power cycle.