Data Modelling with the OPC UA Information Model and Companion Specifications

How an OPC UA information model is built in the field: address space, node classes, ObjectTypes, references, Companion Specifications, NodeSets and common mistakes.
Technical summary
Technology
OPC UA, NodeSet2 XML, OPC UA for Machinery, OPC UA DI, EUROMAP, PackML
Topic
Designing a type-based data model in OPC UA
Level
Intermediate–advanced
Prerequisites
  • Basic OPC UA client/server concepts
  • Knowledge of PLC data block and tag structure
In this article8 sections

The OPC UA server is commissioned, the certificates are in place and the connection is green. But the client is still reading hundreds of flat tags one by one: DB10.Speed, DB10.Temperature_1, Line3_Count. In this state, OPC UA’s type and information model capabilities go unused. What makes the protocol valuable is the information model, which also carries the meaning and structure of the data. Below, using a filling machine model as an example, we describe how we build the address space, node classes, type definitions and Companion Specifications in the field.

Why a tag list gets stuck at some point

In a flat tag list, meaning lives in two places: in the naming convention and in an Excel file on someone’s desktop. If there are ten machines of the same type in the OT infrastructure, ten separate mappings are made on the client side. A sensor is added to a machine; the mappings on the SCADA, historian and MES side are all updated by hand, and one can be forgotten. In an information model, on the other hand, “filling machine” is defined once as a type, each machine becomes an instance of this type, and the client finds all instances of the same type itself by browsing the structure.

Topic Flat tag list Type-based information model
Meaning In the name and in external documentation In types, references and properties
Unit, range In a separate table EngineeringUnits, EURange properties
Adding a new machine New mapping on every client New instance; the client recognises it from the type
Vendor independence Each vendor uses its own names A common structure with Companion Specifications
Initial cost Low Requires model design and tools

The cost of a model is the design time up front. If you are going to read three to five values from a single machine, flat variables are enough, and nobody should claim otherwise. If there are many pieces of equipment of the same type, several consuming systems and a production data collection infrastructure that will live for years, the calculation changes. The design work pays for itself. If the protocol decision has not been made yet, first take a look at the comparison of OPC UA and MQTT.

Address space, nodes and references

Everything the server shows the client is a node in the AddressSpace. Each node has a NodeId, a BrowseName, a DisplayName and a NodeClass. The specification defines eight node classes:

  • Object: A container representing an asset such as a machine, line or motor.
  • Variable: A node carrying a value. There are two kinds: data variables (DataVariable) and properties (Property).
  • Method: A function the client can call; for example, loading a recipe.
  • ObjectType and VariableType: Type definitions for objects and variables.
  • ReferenceType: The meaning of the relationship between nodes.
  • DataType: The data type of the value, including structure and enum definitions.
  • View: A view presenting a subset of the address space.

References are the skeleton of the model. The ones we use most are: Organizes (folder structure, i=35), HasComponent (a variable, object or method that is part of the object, i=47), HasProperty (fixed or slowly changing information qualifying the node, i=46), HasTypeDefinition (which type an instance comes from, i=40) and HasSubtype (type inheritance, i=45). We see the distinction between variables and properties as the most confused point in the field. A temperature measurement is a component variable. Its unit and measurement range are properties of that variable.

A NodeId consists of a namespace index and an identifier, such as ns=2;s=Filler01.Speed. The index can change by server, and even with a reconfiguration of the server; what is permanent is the namespace URI. Teams that write ns=2 into the client configuration and move on find that all reads fail the day a new NodeSet is loaded onto the server. The right way is to resolve the index from the server’s NamespaceArray via the URI. A hard-coded index is a deferred fault.

ObjectTypes and type definitions

The centre of a type-based model is the ObjectType. You derive your own type from BaseObjectType (i=58) or from a more specific type in a Companion Specification. Each component under the type carries a ModellingRule: a Mandatory component must exist in every instance, an Optional component may exist. This rule determines what the client can rely on with certainty.

For measured values, use AnalogItemType from the Data Access part instead of BaseDataVariableType. This type makes the EURange property mandatory and brings EngineeringUnits and InstrumentRange as optional properties. The unit is carried with the value. The question “is this pressure in bar or kPa?” is answered in the model, not during commissioning.

Use inheritance deliberately. If FillerType and CapperType are derived from a common PackagingMachineType, the state, counter and alarm structure is defined in one place; the client queries “all packaging machines” via the parent type. Inheritance chains five or six levels deep, on the other hand, cause headaches in maintenance and tool compatibility. Two or three levels are usually enough.

What Companion Specifications bring

A Companion Specification is a standard information model published jointly by the OPC Foundation and the relevant industry organisation for a specific industry or device class. The aim is for different vendors to present the same kind of machine with the same structure. The ones we encounter most in the field:

Specification Scope Typical use
OPC UA DI (Devices) Device identification, manufacturer, serial number, software version The basis of many other specifications
OPC UA for Machinery Common building blocks for machine identity, state and operating mode Machine inventory and basic state monitoring
EUROMAP 77 / 83 Data between plastic injection moulding machines and MES Mould, cycle and work order information
PackML (based on ISA-TR88.00.02) Packaging machine state machine and counters Line coordination, OEE data

The practical gain is on the client side: once the MES has learned the EUROMAP 77 structure, it reads machines from different vendors that support the same specification in the same way. The problem is that which part and which version of the specification vendors support varies. If you only write “OPC UA capable” in the specification, you may be faced with a flat tag list when the machine arrives. State explicitly in the specification the Companion Specification to be supported, its version and the expected optional components. The current list of specifications and documents is on the OPC Foundation Online Reference site.

NodeSet files and modelling tools

Information models are distributed using the UANodeSet XML schema defined in Part 6 of the OPC UA specification; in the field it is called a NodeSet2 file. Companion Specifications also come with their own NodeSet files, and when loaded onto the server, their types are added to the address space. Below is how a simple type defined in your own namespace and its component look inside a NodeSet (simplified: the Aliases section and AnalogItemType’s mandatory EURange property are not shown):

<UAObjectType NodeId="ns=1;i=1001" BrowseName="1:FillerType">
  <DisplayName>FillerType</DisplayName>
  <References>
    <Reference ReferenceType="HasSubtype" IsForward="false">i=58</Reference>
    <Reference ReferenceType="HasComponent">ns=1;i=6001</Reference>
  </References>
</UAObjectType>
<UAVariable NodeId="ns=1;i=6001" BrowseName="1:FillSpeed"
            ParentNodeId="ns=1;i=1001" DataType="Double">
  <DisplayName>FillSpeed</DisplayName>
  <References>
    <Reference ReferenceType="HasTypeDefinition">i=2368</Reference>
    <Reference ReferenceType="HasModellingRule">i=78</Reference>
  </References>
</UAVariable>

i=58 denotes BaseObjectType, i=2368 AnalogItemType and i=78 the Mandatory modelling rule. Do not write this XML by hand. A single wrong ParentNodeId is enough for the server to load the model silently incomplete. Use a graphical modelling tool: the OPC Foundation’s open-source UA-ModelCompiler, Siemens’ SiOME editor and Unified Automation’s UaModeler are common options. On the S7-1500 side, a NodeSet prepared with SiOME can be imported into TIA Portal as a server interface and mapped to PLC variables; other vendors offer similar import functions.

Manage the NodeSet file like source code. Keep it in version control, update the Version and PublicationDate values in the Model element with every change, and state the specification versions it depends on explicitly with RequiredModel. A NodeSet that exists as a single copy on an engineer’s laptop is lost at the first laptop replacement.

An example model for a filling machine

The goal: to gather the machine’s identity, current state, production counters and process measurements under a single type. The structure below is based on the identity and state approach of OPC UA for Machinery and defines the process part in its own namespace. The representation has been simplified; in the Machinery specification, the state and mode building blocks may also be located under a separate building blocks folder:

Objects
└── Machines                          (Organizes)
    └── Filler01 : FillerType
        ├── Identification            (Manufacturer, Model, SerialNumber,
        │                              YearOfConstruction, SoftwareRevision)
        ├── MachineryItemState        (Executing / NotExecuting / OutOfService ...)
        ├── MachineryOperationMode    (Processing / Maintenance / Setup)
        ├── Production
        │   ├── GoodCount       : BaseDataVariableType (UInt32)
        │   ├── RejectCount     : BaseDataVariableType (UInt32)
        │   └── CurrentOrderId  : BaseDataVariableType (String)
        ├── Process
        │   ├── FillSpeed       : AnalogItemType (Double, EURange, EngineeringUnits)
        │   └── ProductTemp     : AnalogItemType (Double, EURange, EngineeringUnits)
        └── Methods
            └── LoadRecipe(RecipeId) 

The order we follow in the field:

  1. List the consumers: Work out which data SCADA, the historian, MES and maintenance systems want, and how often. Data with no consumer does not go into the model.
  2. Choose the standard parts: Use existing specification types for identity and state; define only the missing process part yourself.
  3. Separate type from instance: First define FillerType, then create each machine as an instance of this type. Add instance-specific extra components to the type with the Optional rule.
  4. Fix data types and units: Unsigned integers for counters, Double for measurements; give units with UNECE codes in EngineeringUnits.
  5. Define access rights: Tie which variables are writable and who can call methods to server roles.
  6. Verify with a client: Browse with a general-purpose OPC UA client; check references, type definitions and properties one by one. A model you can’t see in the browser doesn’t exist for the client.

The connection security of the server publishing the model is a separate topic; for the certificate and security policy side, see the article OPC UA security settings. If the model is to be transferred to a plant-wide data layer, building the structure from the start to be compatible with Unified Namespace topic design significantly reduces the mapping work in the next step.

Common modelling mistakes

  • Copying the PLC data block one-to-one: The DB structure is the PLC programmer’s internal layout. Helper bits, intermediate calculations and edge detection flags do not go into the model. The model is built around what the consumer needs.
  • Making everything a Property: A continuously changing measurement should be a component variable; a property is information qualifying the variable. Some clients do not open subscriptions on properties, and the value appears frozen on screen.
  • Creating instances by hand independently of the type: If the type is in one place and the instances are drawn by hand elsewhere, the two drift apart over time. Use the tool function that derives instances from the type.
  • Renaming in a string NodeId: The NodeId is the clients’ permanent reference. If you need to change the visible name, touch the DisplayName, not the NodeId.
  • Not owning the namespace URI: For your own model, use a URI your company controls (such as http://company.example/UA/Filler/) and do not change it between versions.
  • Not versioning: Removing a mandatory component is a backward-incompatible change. Add new components as optional; if removal is essential, publish a new model version.

The model places work on the server side; as the number of clients reading the same model grows, that work pays back. For an inventory of which Companion Specifications your existing machines support and for model design, see our OPC UA, MQTT and data integration page.

Frequently asked questions

Does an OPC UA information model require a special PLC feature?

If the PLC’s built-in OPC UA server supports custom type definitions and NodeSet import, the model is published directly on the PLC. If not, the model is built on an external OPC UA server or edge gateway that reads data from the PLC.

Can we also use our own model on a machine that supports a Companion Specification?

Yes. The standard types cover the machine’s identity, state and industry-specific parts; you add the remaining process data with components you define in your own namespace. The rule is simple: don’t modify the standard type; derive a subtype.

If the NodeSet file and the server’s address space differ, which one applies?

For the client, the address space of the running server applies. The NodeSet is the source of the design. To prevent differences, always generate the server configuration from the NodeSet in version control and verify it after commissioning by browsing with a client.

How does an existing SCADA working with a tag list benefit from the information model?

If the SCADA does not support browsing, it still reads the variables in the model one by one by NodeId; existing operation is not disrupted. The gain from type-based discovery shows when MES, historian or data platform clients that can browse are connected.

Support

Contact us for support or a discovery session on this topic.

Contact form
[email protected]

Eretek Industrial

PLC, PROFINET/PROFIBUS and SCADA communication, IT/OT network segmentation and industrial field connectivity. We install and monitor without stopping the production line.

Knowledge Center

Other articles