Skip to content

9. Trends and the OPC UA Server

Two ways of getting the numbers out of the session: trends for the trainee's eyes, and an OPC UA server for anything else, from a real HMI package to a PLC test bench.

What you will learn

  • How the trend recorder works and how to read a trend widget
  • Starting the OPC UA server and what it publishes
  • Reading and writing from an OPC UA client
  • Certificates and security policies

Prerequisites

  • Page 6 for trends
  • An OPC UA client for the second half; UaExpert is free, and Opc.Ua.SampleClient.exe ships in DWSIM's plugins\opclibraries folder

The session records every pen that any trend widget on any screen asks for, one sample per step, from the moment the session starts (the last 7200 samples per pen: ten hours at a 5 s step). Opening a screen later shows the history already recorded.

A trend widget draws up to four pens:

  • The first pen is its Target and Property; more pens go in Pens as Tag:Property;Tag:Property.
  • Each pen is scaled to its own range, so PIT-001 in kPa and LIT-001 in metres share one chart without one flattening the other. The value axis is labelled for the first pen; the legend shows each pen's current value and units.
  • WindowSeconds is the width of the time axis. The chart fills from the left, then scrolls.
  • AutoScale off uses Min and Max for the first pen's axis.

Trends are the trainee's best tool for catching a slow malfunction (a ramped valve failure, a drifting sensor) before the alarm. Put one on the home screen.

A trend with the pressure and the level over fifteen minutes

The OPC UA server

The session can publish itself as an OPC UA server. Use it to drive a third-party HMI, to log the exercise in a historian, to connect a PLC emulator running real interlock logic, or simply to watch the plant from UaExpert.

Starting it

OPC UA... on the Instructor Station.

The OPC UA server with one client session

  1. Port 4840 (the OPC UA default) or any free port.
  2. Security: Allow unsecured (None) for a quick connection on a trusted network; Sign and encrypt (Basic256Sha256) for clients with certificates. Both can be offered at once.
  3. Start server. The first start creates a self-signed certificate under %LOCALAPPDATA%\DWSIM\OTS\pki; later starts reuse it. The window shows the endpoint (opc.tcp://<pc>:4840/DWSIM/OTS), the number of tags and connected client sessions.

The server keeps running when the window is closed; Stop ends it, and it stops with DWSIM.

The address space

Under Objects / DWSIM OTS:

Folder Nodes Writable
Session SimTimeSeconds, State, Running, Step, SpeedFactor, ActiveAlarms, UnacknowledgedAlarms, AcknowledgeAll, TrippedInterlocks, ExerciseScore SpeedFactor; AcknowledgeAll (write true)
Interlocks / <name> Tripped, Bypassed, Reset, FirstOut Bypassed; Reset (write true)
Plant / <tag> Per object type, see below See below

Per object:

Object Nodes Writable
PID controller PV, SP, OUT, Manual, Active SP, OUT (manual output), Manual, Active
Gauge, transmitter Value, LL, L, H, HH
Valve Opening, Locked Opening when no controller drives it
Switch On On
Pump DeltaP, Power, Speed, TargetSpeed TargetSpeed
Heater, cooler Duty, OutletT Duty
Separator, tank, CSTR Pressure, Level, Temperature
Compressor, others OutletT, OutletP and type-specific values

Values are in the flowsheet's display units and refresh twice a second. Every write is queued as an operator action, applied at the next step and journaled as OPC UA write: PID-012.SP -> 2.5, so objectives and the report see OPC clients as they see the trainee.

Connecting a client

With UaExpert: Add Server, paste the endpoint, choose the None policy, connect. Accept the server certificate when asked (it is self-signed). Browse to DWSIM OTS / Plant / PID-012 and drag PV and SP into the data access view; write 2.5 to SP and watch the plant respond.

For a secured session, the client presents its own certificate; the server accepts untrusted client certificates and adds them to pki\trusted, so the connection works the first time and can be tightened later by curating that folder.

One server per flowsheet

Each open flowsheet can run its own server on its own port. The node ids are Session.X, Interlocks.<name>.X and Plant.<tag>.X in namespace urn:dwsim:ots, stable across restarts, so a client's subscriptions survive.

The next page separates the instructor and the trainee onto different PCs.