Problem Overview
Engineers commissioning SIMOTION SCOUT V4.1 with SINAMICS SM150 drives on SIMOTION D445 controllers frequently encounter compiler warning 16013: Data type "DT" is not portably convertible when a global device variable of type DATE_AND_TIME (DT) is added to the project and then read from the add_on source file. The warning is non-fatal — the source generates successfully, the project builds, and the controller goes online — but it indicates a real portability hazard: a DT variable cannot be reliably serialized across the SIMOTION runtime boundary when consumed by a non-SIMOTION HMI such as SIMATIC WinCC V7.x via OPC.
The reported project in this case study contains six D445 stands (N1_A_D445_Stand_1 through N6_A_D445_Stand_5/6) driving SINAMICS SM150 sections, with a custom add_on ST source file at line 138 that surfaces the warning. This reference documents the root cause, the accepted Siemens remediation patterns, the migration to the IEC 61131-3 DTL type where required, and the end-to-end OPC publishing workflow for delivering those global device variables into WinCC.
System Environment and Topology
The reference configuration that produced the warning is summarised in the table below. Values are derived from the project header in SCOUT V4.1 and from the official SIMOTION V4.1 SPx compatibility matrix.
| Component | Identifier / Version | Notes |
|---|---|---|
| Engineering tool | SIMOTION SCOUT V4.1 (with TIA Portal integration) | Standalone SCOUT or SCOUT TIA |
| Controller | SIMOTION D445-1 DP/PN (6 stands) | Stands labelled N1_A..N6_A |
| Drive | SINAMICS SM150 (6 units) | Direct integration via DRIVE-CLiQ |
| Compiled sources | n1auxcu, n1auxop, n1input, n1panel, add_on, redwri, n1cpu, n1dopar, sysflt, n1drvmg | Auto-generated + user add_on |
| HMI | SIMATIC WinCC V7.0 | OPC Data Access client |
| OPC server | SIMOTION OPC server (built on SIMOTION runtime symbol interface) | DCOM / OPC DA 2.0 / 3.0 |
| Compiler warning | 16013, add_on(138) | DT not portably convertible |
add_on source does not block the project — but each stand inherits the same compiled image, so the fix must be applied at the project level (preferably in a shared library) and recompiled on all six targets.
Compiler Warning 16013: Root Cause
Warning 16013 is emitted by the ST (Structured Text) compiler in SCOUT when a variable is declared with the legacy data type DATE_AND_TIME (DT) and that variable is referenced in a context that SCOUT has classified as a portability boundary. Portability boundaries are code constructs that may be regenerated, exchanged with another SIMOTION device, or — most importantly — exported to an OPC namespace where the consumer is a Windows application (WinCC, third-party SCADA, or an OPC bridge).
The exact compiler output from the reported project is:
Information: START of compilation of 'add_on' at 15:10:33
Warning: add_on(138) : 16013 : Data type "DT" is not portably convertible
Information: END of compilation of 'add_on' at 15:10:33
Information: Compilation of add_on: 0 Error(s), 1 Warning(s)
The warning refers to a specific declaration at add_on.st line 138. Typical offending declarations look like the samples below:
// Offending declaration (warning 16013)
VAR_GLOBAL
g_stTimestamp : DATE_AND_TIME; // DT - 64-bit, BCD-encoded, non-portable
g_dtSample : DT; // alias form, same warning
END_VAR
Why DT Fails the Portability Check
The DT type is a 64-bit BCD-encoded structure that was specified in IEC 61131-3 first edition. Its byte layout depends on the SIMOTION runtime implementation and is not aligned with the OPC DA standard binary representations used by WinCC. The SCOUT compiler therefore flags any DT value that may be transported outside the SIMOTION process image as not portably convertible. The runtime will still hold the value correctly inside the device, but external tooling that tries to read the symbol will receive an opaque BCD blob.
This is distinct from error 16012 (not convertible at all); 16013 means the value can technically be moved, but it cannot be interpreted by a non-SIMOTION consumer without a custom conversion block.
Data Type Comparison: DT vs DTL vs STRING vs DWORD
The remediation strategy is to substitute DT with a type that is natively representable in OPC. The table below compares the four practical options for storing a timestamp in a SIMOTION global device variable intended for HMI consumption.
| Attribute | DATE_AND_TIME (DT) | DTL (IEC 61131-3 2nd ed.) | STRING (ISO 8601) | DWORD (Unix time, sec since 1970) |
|---|---|---|---|---|
| Size | 8 bytes | 12 bytes (struct of 6 WORDs) | 20–32 bytes typical | 4 bytes |
| Encoding | BCD, runtime-specific | Binary, BCD-free | ASCII | Binary unsigned 32-bit |
| OPC portability | Not portable (warning 16013) | Portable as opaque struct; OPC clients need mapping | Portable as plain string | Portable as 32-bit unsigned |
| WinCC display | Requires custom DLL / conversion block | Requires custom conversion block | Direct string tag | Direct numeric tag, format in WinCC |
| Resolution | 1 second | 1 ns | 1 s (string) | 1 s |
| Range | 1970-01-01 to 2554-12-31 | 1970-01-01 to 2554-12-31 | Depends on writer | 1970-01-01 to 2106-02-07 (unsigned overflow) |
| SCOUT warning | 16013 | None (when declared inside SIMOTION) | None | None |
Recommendation: For new code in SCOUT V4.1, declare the timestamp as DTL inside the SIMOTION program and expose a derived STRING or DWORD representation as the OPC-visible global device variable. The internal DTL value preserves nanosecond resolution for control loops; the OPC value delivers a clean WinCC tag.
Resolution Path A — Convert DT to STRING
The fastest path when the HMI only needs a human-readable timestamp is to convert the DT to STRING before the OPC export. This eliminates warning 16013 because STRING is a portable type for OPC.
- Open the
add_onsource in the SCOUT program editor. - Locate line 138 (or the line reported by the compiler). Replace the DT declaration with a STRING buffer.
- Add a conversion at every write site using the SIMOTION system function
DT_TO_STRINGorDTL_TO_STRINGif you migrate to DTL.
VAR_GLOBAL
// Replaces the DT that triggered warning 16013
g_sTimestamp : STRING[19]; // YYYY-MM-DD HH:MM:SS\0
END_VAR
// Conversion example
g_sTimestamp := DT_TO_STRING(g_dtInternalTimestamp);
Resolution Path B — Use DTL Internally, Expose DWORD Seconds
Path B is the preferred pattern when the timestamp participates in control logic (interlocks, sequence timing, motion gating) where nanosecond resolution matters. DTL is the IEC 61131-3 second-edition type and is fully supported by SCOUT V4.1.
VAR_GLOBAL
g_stTimestamp : DTL; // nanosecond resolution, portable
g_dwUnixTime : DWORD; // OPC-visible, 32-bit seconds since epoch
END_VAR
// Update once per scan
g_stTimestamp := CURRENT_DTL;
g_dwUnixTime := DTL_TO_DWORD(g_stTimestamp);
The g_dwUnixTime tag is the OPC-published symbol. In WinCC, format it with a dynamic text or a C script that converts the DWORD back into a date string using the WinCC standard function FormatDateTime.
Resolution Path C — Restrict DT to SIMOTION-to-SIMOTION Boundaries
If the DT variable will only be consumed by another SIMOTION device on the same project (for example a peer D445 exchanging tags via the _exchangeVars mechanism), warning 16013 is informational rather than critical. SCOUT will still generate the OPC symbol, but downstream SIMOTION devices read it as a DT and convert internally with no loss of fidelity.
To make the intent explicit and silence the warning without changing the wire format, add a comment block and a pragma at the declaration:
VAR_GLOBAL // pragma(off, "16013") // DT is intentional, used SIMOTION-side only
g_dtPeerSync : DATE_AND_TIME; // consumed by peer D445 via _exchangeVars
END_VAR
Publishing Global Device Variables to WinCC V7.0 via OPC
Once the DT warning is resolved, the global device variable can be exposed to WinCC. The OPC server in SIMOTION is built into the runtime and surfaces every exported symbol under the SIMOTION device name. WinCC V7.0 acts as an OPC DA client.
High-Level Data Flow
Configuration Steps in SCOUT
- Open the project, navigate to the affected SIMOTION device (e.g.
N1_A_D445_Stand_1) and double-click Symbol browser in the detail view. - Confirm you are in offline mode (the symbol browser tab is editable only offline in SCOUT V4.1).
- Right-click the table and choose Add new symbol. Assign a name (for example
g_sTimestamp) and select the corresponding global device variable as the data source. - Set the OPC attribute for the symbol to accessible / writable as required.
- Save and recompile the project (Save and compile shortcut). Verify that warning 16013 no longer appears in the add_on source.
- Download the project to the D445 (all six stands if the global is shared).
Detailed, version-pinned instructions for creating and exporting global device variables are documented in the official Siemens documentation:
- Use of global device variables in SIMOTION SCOUT (Structured Text)
- Creating global device variables in the symbol browser
Configuration Steps in WinCC V7.0
- Open the WinCC Explorer on the HMI station.
- Right-click Tag Management > OPC > OPC Groups and select System Parameters. Add the SIMOTION OPC server as a remote server. The ProgID is
Siemens.SIMOTION.OPCServer.1. - Configure DCOM on the WinCC station and on the SIMOTION PC (or CX/IBN-PN station) to allow anonymous launch and access for the SIMOTION service account.
- In the tag management, browse the OPC namespace. The SIMOTION OPC server exposes tags under
SIMOTION.<DeviceName>.<SymbolName>, for exampleSIMOTION.N1_A_D445_Stand_1.g_sTimestamp. - Add the tag to a WinCC internal tag group. Recommended update cycle: 1000 ms for status, 250 ms for control interlocks.
- In the Graphics Designer, bind the tag to an I/O field for display or to a Status display for indication.
Verification and Acceptance Test
Acceptance is a three-stage check. All three must pass before the project is signed off.
| Stage | Tool | Pass criterion |
|---|---|---|
| Compile cleanliness | SCOUT V4.1 Build Output | Zero entries matching 16013 in any compiled source |
| Runtime symbol presence | SCOUT Symbol Browser (online) |
g_sTimestamp or g_dwUnixTime shows current value, quality = GOOD |
| HMI tag update | WinCC Graphics Designer (Runtime) | Tag value updates within one configured cycle; no OPC quality BAD in the diagnostics view |
- Trigger a forced refresh in SCOUT (Project > Save and compile all). Confirm 0 Error(s), 0 Warning(s) in the output pane for every stand.
- Go online to
N1_A_D445_Stand_1. Open the symbol browser and confirm the OPC attribute is set and the current value is non-zero. - In WinCC, open the diagnostics overview (Tools > Status of Driver Connections) and confirm the OPC channel reports OK.
- Force a write from WinCC (set the tag to a known string). Verify in SCOUT that the runtime value follows within the cycle window.
Common Pitfalls and Field-Proven Caveats
- STRING length mismatch. SCOUT STRING[n] allocates n+1 bytes. If WinCC allocates a buffer of length n, the trailing null terminator is dropped and the next byte leaks into the next tag. Always size WinCC string tags to n+1.
- Stand-specific recompile. In multi-stand projects, fixing the warning on one stand does not propagate automatically. Use Save and compile all rather than Compile add_on on the stand.
-
Pragmas in HF levels prior to HF5.
pragma(off, "16013")is not always honoured. Verify on a test stand before relying on it for production sign-off. - OPC tag polling vs subscription. WinCC V7.0 defaults to subscription (advise loop). On a heavily loaded network this can be starved by PROFINET I/O. Move high-priority tags to a separate group with a 250 ms cycle.
-
SM150 regeneration. When the SINAMICS SM150 is auto-recommissioned by the add_on source after a CU replacement, the timestamp variable is reinitialised. Verify the conversion block runs in
_initializeso the OPC tag stays valid. - Multi-language WinCC projects. STRING values are not auto-localised. If the HMI needs regional date formats, perform the conversion on the HMI side (WinCC C script with locale lookup) rather than baking the format into the SIMOTION STRING.
Troubleshooting Matrix
| Symptom | Likely cause | First check | Resolution |
|---|---|---|---|
| Warning 16013 on add_on.st line 138 | DT declaration at OPC-boundary line | Inspect line 138 declaration | Convert to STRING / DTL / DWORD per paths above |
| OPC tag shows quality BAD in WinCC | DCOM permissions or ProgID mismatch | WinCC > Tools > Status of Driver Connections | Reconfigure DCOM, verify ProgID Siemens.SIMOTION.OPCServer.1
|
| WinCC shows garbage characters | STRING length mismatch or wrong code page | Compare SCOUT STRING[n] with WinCC buffer length | Resize WinCC buffer to n+1, set code page to Windows-1252 or UTF-8 |
| Symbol not visible in OPC browser | OPC attribute not set or not yet downloaded | SCOUT Symbol Browser (offline vs online) | Set OPC accessible, recompile, download project to controller |
| Warning persists after conversion | Stale .awl / .h file from previous compile | Check file timestamp in project folder | Project > Clean then recompile |
| Conversion function not found | Library version mismatch in SCOUT | Library list in offline project | Update to the SCOUT V4.1 SPx compatible library set |
| Peer D445 reads zero | DT to DTL migration broke the peer mapping | _exchangeVars configuration | Update peer device to expect DTL or re-export as DT for that channel only |
| SM150 reset clears the timestamp | add_on does not reinitialise after CU replacement | _initialize task configuration | Move conversion call to background task that runs unconditionally |
Multi-Stand Rollout Checklist
- Apply the chosen remediation (A, B, or C above) to the shared library that contains the
add_onsource. - Increment the library version (e.g. from V1.2 to V1.3) so the consuming projects pick up the change.
- Open each of the six stand projects and accept the library update.
- Run Save and compile all. Confirm zero warnings matching 16013 in every stand.
- Download to each stand in turn; verify online symbol presence.
- In WinCC, replicate the OPC tag configuration across the six device folders.
- Run the acceptance test per stand before re-enabling production.
Reference: SCOUT V4.1 Compiler Warning 16013 Summary
| Field | Value |
|---|---|
| Warning number | 16013 |
| Severity | Warning (non-fatal) |
| Message text | Data type "DT" is not portably convertible |
| Typical source |
add_on, user_lib, auxcu
|
| Introduced in | SCOUT V4.0 onwards |
| Affected data type | DATE_AND_TIME (DT) |
| Underlying standard | IEC 61131-3 first edition (BCD encoding) |
| Recommended replacement | DTL (binary), STRING (ISO 8601), DWORD (Unix seconds) |
| Suppression mechanism |
pragma(off, "16013") (HF5+) |
What does warning 16013 "Data type DT is not portably convertible" mean in SCOUT V4.1?
It means a variable declared as DATE_AND_TIME (DT) is being exposed at a runtime boundary (peer device, OPC namespace, or export interface). Because DT uses a 64-bit BCD layout specific to SIMOTION, the SCOUT compiler warns that downstream consumers cannot interpret the value without a custom conversion. The build still succeeds — 0 errors, 1 warning — but the OPC tag will appear as an opaque blob in WinCC.
How do I resolve warning 16013 without losing the timestamp?
Migrate the global device variable to DTL for in-controller logic and expose either a derived STRING (for direct display) or DWORD (for Unix-seconds) as the OPC-visible tag. Both STRING and DWORD are portable through the SIMOTION OPC server without further conversion. See Resolution Paths A and B above.
Can I use SIMOTION global device variables with WinCC V7.0 through OPC?
Yes. Configure the SIMOTION OPC server (ProgID Siemens.SIMOTION.OPCServer.1) as a remote OPC DA server in WinCC Explorer, configure DCOM launch and access permissions for the WinCC user, then browse the namespace at SIMOTION.<DeviceName>.<SymbolName> and bind the tag to a WinCC internal variable. Update cycles of 1000 ms for status and 250 ms for control interlocks are typical.
Does pragma(off, "16013") silence the warning?
Yes, but only in SCOUT V4.1 HF5 or later. Older HF levels emit the warning regardless of the pragma. Pragma suppression should be reserved for variables that genuinely stay SIMOTION-side (peer-device exchange only); it does not fix the OPC portability issue if the tag is later exposed to WinCC.
Why does the warning point at add_on(138) specifically when there are six stands?
Each stand has its own copy of the auto-generated sources plus the shared add_on source. Line 138 is the location in the shared source file, so every stand recompiles the same declaration. Fixing line 138 in the source library once clears the warning from all six stands after a Save and compile all.