Skip to main content

OPC UA client

The OPC UA client driver reads and writes values of OPC UA servers: PLCs with an OPC UA server, gateways, other SCADA and MES systems. For what all drivers have in common, see How drivers work.

Protocol and role​

RoleClient. YTCC connects to the OPC UA servers.
TransportOPC UA binary (opc.tcp://)
Default port4840 (part of the endpoint URL)
Devices per driverAny number; each server has its own session and subscription.
Driver typeOPC UA (opc_ua)

Device parameters​

Set these on the device in Drivers → devices (see Add drivers and devices). An empty box uses the default shown in it. The help mark next to each parameter shows a short description.

New device form of an OPC UA device with Device key, Name, Description, Auth, Endpoint URL, Message security mode, Password, Publishing interval (ms), Reconnect, Security policy and Session timeout (ms).

ParameterDefaultMeaning
Endpoint URL— (required)Address of the server, for example opc.tcp://192.168.10.50:4840.
Security policyNoneNone, Basic256Sha256, Aes128Sha256RsaOaep or Aes256Sha256RsaPss.
Message security modeNoneNone, Sign or SignAndEncrypt.
AuthAnonymousAnonymous or Username.
Username, Password—User for Username authentication.
Publishing interval (ms)500How often the server sends changes of the subscription.
Session timeout (ms)60000Session timeout requested from the server.
ReconnectonLeave it on. A broken session is reopened automatically; see Reconnecting.
Set invalid on disconnectonLeave it as it is. What a connection loss does is described in Reconnecting.
Trust server certsoff for a new deviceTrust every server certificate without checking.

The security policy and mode must match an endpoint the server offers, or the connection fails. Changing Publishing interval (ms) rebuilds only the subscription; changing any other parameter reconnects that server. An invalid device does not start and shows the reason; the other servers of the driver keep running.

Certificates and users​

  • Client certificate. The driver creates its own application certificate (YTCC OPC-UA Client) when it first starts. For a secured connection, the server must trust it: after the first attempt, it is usually in the server's rejected list; move it to the trusted list.
  • Server certificate. With Trust server certs off, the server certificate must be in the trusted folder of the driver; the certificate of an unknown server is put in the rejected folder. Move it to the trusted folder after you have checked it. With Security policy None, certificates are not used.
  • User. With Username, create the user on the server and give it read rights on the nodes, and write rights on the nodes YTCC writes. The password is stored in the device settings as text; restrict who may edit the configuration.

Signal address​

Set the address on the Value source tab of the signal, under Address — OPC UA:

FieldMeaning
NamespaceNamespace index, for example 2.
Id types (string) or i (numeric).
IdentifierThe identifier, for example Pump4.Current or 2258.
Queue sizeValues the server keeps between two publishes (default 1: only the latest).
Deadband (abs)Change the server must see before it sends a new value, in the units of the node.

The Scan class of the signal is the sampling interval of the server. In import files, write the node ID as ns=2;s=Pump4.Current or ns=0;i=2258 (see Import and export with Excel or CSV). In a CSV file separated by semicolons, put the address in double quotes, for example "ns=2;s=Pump4.Current".

Copy the node IDs from the server's documentation or from an OPC UA browser tool.

Reading​

The driver uses subscriptions, not polling. Each signal is a monitored item with the sampling interval of its scan class (1 s by default), its queue size and its deadband. The server sends changes at the Publishing interval (ms) of the device. A node the server rejects, for example because it does not exist, is Bad; the others are read normally.

Data types​

OPC UA typeValue in YTCC
BooleanOn or off
SByte, Int16Int16
Byte, UInt16UInt16
Int32, UInt32, Int64, UInt64same
FloatFloat32
DoubleFloat64
StringText

Bind signals to nodes of the types in this table.

Writing​

A signal can be written when its Access is Read / Write or Write only. The value is written to the Value attribute of the node with the type of the signal, so the signal's data type must match the node's type; otherwise the server answers BadTypeMismatch.

Server statusShown as
BadNotWritable, BadWriteNotSupportedSignal is not writable
BadTypeMismatchValue type not suitable
BadOutOfRangeValue out of range
BadUserAccessDeniedDevice does not allow writing
BadNodeIdUnknownSignal not found
BadNotConnectedNo device communication
BadTimeout, BadRequestTimeout, BadConnectionClosedNo response from device
otherDevice returned an error

A command sent while the driver is not connected to the server is rejected with No device communication.

If the signal is set to read back after writing, the driver reads the node again right after a successful write.

Status codes and time stamps​

OPC UA statusQuality in YTCC
GoodGood
UncertainUncertain
BadNotConnectedBad · Not connected
other Bad, or no statusBad

The time of a value is the SourceTimestamp of the server (time source device); the server timestamp is not used. Without a source timestamp, or with one more than 5 minutes ahead or 7 days behind the arrival time, the arrival time is used.

Reconnecting​

If the first connection fails, the driver tries again after 1 second and doubles the wait up to 30 seconds. An open session that breaks is reopened automatically, and the subscription is created again. When the connection is lost, the device shows not connected and the communication alarm comes; the signals keep their last value.

Diagnostics​

Read now on the Value source tab reads the node once through the open session:

TextMeaning
A valueThe server answered
OPC UA BadNodeIdUnknown — ns=2;s=…The node does not exist on the server
OPC UA value type not supported — …The node has a type that is not in Data types
Not connected — … ; … was not readNo session to the server
Invalid node id '…'The address cannot be parsed
SymptomLikely cause
The device never connectsWrong endpoint URL; no endpoint with the chosen policy and mode; firewall
Secure connection refusedThe server does not trust the YTCC certificate, or YTCC does not trust the server certificate
User rejectedWrong user or password, or the server does not allow user name login
One signal BadThe node does not exist, or the user may not read it
A signal never changesThe value does not change, or Deadband (abs) is too large
A signal shows 0 although the node has a valueThe node type is not in Data types

Supported services​

ServiceSupported
Secure channel and session (four policies, three modes)Yes
Anonymous and user name identityYes
ReadYes (Read now, read-back)
Write (Value attribute)Yes
Subscriptions and monitored items, absolute deadbandYes