Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Talking to a PLC from C#: OPC UA Notifications and Whole-Structure Reads

Use OPC UA subscriptions to monitor PLC values in C#, and read an S7-1500 structure only when the server exposes it and client type mapping is compatible.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For an S7-1500 OPC UA server, a C# application can monitor selected PLC values with subscriptions instead of repeatedly polling them, and it can read a complete structure or UDT when the server exposes that value and the client has a compatible type definition. These are separate choices: subscriptions govern how updates are delivered; structure reads govern how data is grouped and represented.

How OPC UA notifications work

An OPC UA subscription is a server-side mechanism for delivering notifications to a client. The client creates monitored items for selected nodes, and the server samples those values and sends notifications through periodic Publish service requests. This provides a change-monitoring alternative to cyclic reads; it does not mean that every change is delivered instantly. See the OPC Foundation overview of OPC UA.

As an Amazon Associate I earn from qualifying purchases.

Sampling interval and publishing interval are distinct settings. The sampling interval concerns how often the server checks a monitored value; the publishing interval concerns how often notifications are made available to the client. Siemens notes that server minimums and system load constrain useful settings, and that interval choices help limit communication load. A requested interval is not a guaranteed end-to-end response time. For S7-1500-specific configuration, consult Siemens’ Communication Function Manual (11/2024) and STEP 7 V20 subscription settings (11/2024).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to set up a C# subscription

The exact API depends on the OPC UA .NET package and version you choose. Siemens’ S7-1500 example demonstrates subscription and monitored-item services; use its documentation and the API reference for your selected package rather than assuming that sample code transfers unchanged to another library or PLC family. The example is OPC UA .NET Client for the SIMATIC S7-1500 OPC UA Server, V1.5 (09/2022).

#1 Best Overall
PLC HMI All in One Integrated Programmable Logic Controller, 2.8 Inch Touch Screen TFT LCD Display with 7 Input 5 Relay Output, 4 Transistor Output for 2 High-Speed Pulse 100KHz and Direction
  • -- PLC Type: Fully compatible with FX1S, 7 Input 5 Relay Output (24V pulse single). Have additional 4 Transistor Output: 2 for high speed pulse 100KHz & 2 for direction, can drive 2 servos or 2 steppers with pulse
  • -- PLC software: Use GX Workers 2 or Developer (pls download from GX Workers 2 website, we only have Chinese version), support Command + T Ladder Diagram + SFC for programming
  • -- HMI Software: YKBuilder V5.3/7.0 (Pls contact us, we will share it and the video instruction and guidelines). For HMI model: pls choose FE Serial, 280D
  • -- Use the same Cable for download program from PC to PLC/HMI: Use the: mini port – USB cable, pls install HMI & PLC’s USB driver first, which we will share.
  1. Connect: Establish the OPC UA connection and session with the server, using the security and endpoint configuration required by the target installation.
  2. Identify nodes: Obtain the NodeIds for the values the application needs to monitor.
  3. Create monitored items: Add the selected nodes to a subscription and configure sampling and publishing intervals within the server’s supported limits.
  4. Handle notifications: In the monitored-item callback, inspect the returned value and status before passing data into application logic. Treat bad or uncertain status as a data-quality condition, not as a valid process value.
  5. Clean up: Delete or dispose of monitored items and subscriptions when the monitored set changes or the application shuts down. Also plan for connection loss and session recovery according to the client library’s documented lifecycle behavior.

Polling or subscribing?

Neither method is universally better. Polling can suit a simple application that needs values at a fixed cadence and can tolerate repeated reads. A subscription is a natural fit when the application mainly needs to react to changes without continually requesting the same values. Subscriptions add lifecycle and reconnect handling, and neither approach guarantees that an application sees every transient PLC state. Choose and test against the target CPU, firmware, server configuration, client library, and the application’s actual need for samples versus changes.

Decision factor Repeated reads (polling) OPC UA subscription
How updates arrive The client requests values on its own cycle. The server samples monitored values and delivers notifications through publishing.
Load considerations Repeated requests can add client/server communication as the read set or cadence grows. Can avoid repeatedly reading unchanged values, but subscription settings and server capacity still matter.
Application work Manage the polling loop, timing, and read failures. Manage monitored items, callbacks, subscription lifecycle, and connection recovery.
Best fit Fixed periodic snapshots or a simple read workflow. Change-oriented updates when supported and correctly configured.

Reading a whole structure or UDT

A complete structure read is possible when the S7-1500 OPC UA server exposes the value as a structure or UDT and the client has matching type information. Siemens’ .NET example includes a workflow for browsing to a node whose type definition indicates a structure/UDT, copying its NodeId, and reading it through a dedicated view. This is a Siemens example workflow, not a universal feature guarantee for every PLC, OPC UA server, or C# library.

Before relying on a whole-structure read, compare the client’s expected structure with the server’s type definition and layout. Siemens warns that its documented access rules include limited structural checks: a configuration mismatch may not be caught at compile time or runtime. Validate field ordering, assigned data types, the server’s type definitions, and the exact PLC and client versions. See Siemens’ STEP 7 V20 rules for access to structures (11/2024).

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Whole structure or individual fields?

Reading a structure can reduce the number of separate client requests in a design that otherwise reads many fields individually, but it also transfers a grouped payload and depends on type mapping. There is no universal performance winner established for all tag sets or PLCs. Choose based on the data the application actually needs and the maintenance cost of keeping client and server layouts aligned.

Rank #4
3.8 Inch PLC HMI All in One Integrated Programmable Logic Controller, 10 Input 7 Relay Output, 2 High-Speed Pulse 100KHz for Sevor or Stepper, 2 Input 100KHz for Encoder (17MR-FE380-FX-A)
  • -- PLC Type: Fully compatible with FX1S, 10 Input 7 Relay Output (5V pulse single). Have additional 4 Transistor Output: 2 for high speed pulse 100KHz & 2 for direction, can drive 2 servos or 2 steppers with pulse; have 2 high speed input 100KHz X0 X1 to control encoder also
  • -- PLC software: Use GX Workers 2 or Developer (pls download from GX Workers 2 website, we only have Chinese version), support Command + T Ladder Diagram + SFC for programming
  • -- HMI Software: YKBuilder (Pls dowload from link or contact us, we will share it and the video instruction and guidelines), very easy to use, just create the buttun and set the address
  • -- Use the same Cable for download program from PC to PLC/HMI: Use the: mini port – USB cable, pls install HMI & PLC’s USB driver first, which we shared from link
Rank #3
3.8 Inch PLC HMI All in One Integrated Programmable Logic Controller, 10 Input 7 Relay Output, Built-in Analog 2AD & 2DA, 2NTC10K, 2 High-Speed Pulse 100KHz for Sevor or Stepper (17MR-FE380-FX-B)
  • -- PLC Type: Fully compatible with FX1S, 10 Transistor Input (NPN Type), 7 Relay Output. Have additional 4 Transistor Output: 2 for high speed pulse 100KHz & 2 for direction, can drive 2 servos or 2 steppers with pulse, built-in 2AD(0-10V) and 2DA(0-10V), also 2 NTC10K B3435 probe. Just read the address of AD DA NTC's will ok, 2 high speed input 100KHz X0 X1 to control encoder
  • -- PLC software: Use GX Workers 2 or Developer (pls download from GX Workers 2 website, we only have Chinese version), support Command + T Ladder Diagram + SFC for programming
  • -- HMI Software: YKBuilder V5.3 and Choose FE serial 380 model in HMI software. (Pls contact us, we will share it and the video instruction and guidelines), very easy to use, just create the buttun and set the address
  • -- Use the same Cable for download program from PC to PLC/HMI: Use the: mini port – USB cable, pls install HMI & PLC’s USB driver first, which we will share.
Consideration Whole-structure read Individual-field reads
Request pattern Can group fields into fewer client requests in some designs. May require separate requests for separate fields, depending on the client and read operation.
Data transferred Includes the grouped structure value, which may contain fields the application does not need. Can target only the fields the application needs.
Type requirements Requires compatible structure layout and type information. Requires correct node identification and value-type handling for each field.
Schema changes Changes to field order or types can invalidate client mapping. Changes can affect individual fields and their application logic, but do not require mapping the entire structure as one value.

What to verify on the target PLC

  • Confirm the target S7-1500 model, firmware, OPC UA server configuration, and client library version support the required subscription and structure behavior.
  • Use the server’s accepted sampling and publishing settings; do not interpret either interval as guaranteed application-visible latency.
  • Test callback status handling, connection loss, resubscription, and shutdown cleanup under the conditions the application must survive.
  • For structure reads, verify field order, data types, and server/client type definitions rather than relying on a matching structure name.
  • Measure request volume and application response under the actual workload before deciding that grouping values or changing intervals improves performance.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.