Skip to main content

Adventures with the PLC4X OPCUA Server

· 4 min read

PLC4X OPCUA Server Online

Apache PLC4X is an Apache Software Foundation project. Eclipse Milo is an Eclipse Foundation project. I am a committer to the PLC4X project, this blog is just for me to showcase the project I have been involved in. In no other way is iscito.com associated with the PLC4X or Milo projects.

The PLC4X OPC-UA Server is an integration with the Apache PLC4X stack which allows for communication via a number of industrial protocols, and the Eclipse Milo OPC-UA server stack. This allows you to make available via OPC-UA time series data points using any of these protocols:-

  • Modbus
  • Ethernet/IP (Including Rockwell)
  • ADS (Beckhoff)
  • S7 (Siemens)
  • OPCUA
  • BACNET (Building Automation)
  • Clipsal C-Bus
  • CANOpen
  • KNX (Building Automation)
  • PROFINET (In Development)
  • and a simulation device.

PLC4X is an industrial communication open source package. It has implementations in Java, Go and C (It should be noted that some drivers are still in development. The Java implementations are generally the most complete, with the Go implementation close behind.). The OPC-UA server uses the Java version.

OPC-UA is the next iteration of OPC and has a number of benefits. For me the major points to migrate away from OPC are:-

  • OPC is based on old technology (DCOM/RPC) which is being phased out by Microsoft.
  • DCOM has always been difficult to configure to allow remote communication.
  • OPC is primarily a Microsoft Windows technology.
  • OPC uses any number and random TCP ports making it hard to configure inter-network communication.

OPC-UA has been around for a number of years now and is increasing making it's way into the industrial market. Most SCADA packages now support OPC-UA.

  • OPC-UA uses only one TCP port, which makes firewall configuration simple.
  • It can be run on linux systems allowing for smaller footprint servers. An example would be running the PLC4X OPC-UA server on a docker image.
  • It seems to have a larger code base in the open source community.
  • As opposed to OPC, OPCUA stacks can be run on the same device as the PLC. Allowing for PLCs to support OPCUA natively (Siemens S7-1500).

The Eclipse Milo OPC-UA stack is an open source stack maintained primary by Kevin Herron. I believe it is the OPC-UA stack that the Ignition SCADA package is based on ¹.

To run the PLC4X server, copy the config file from src/main/resources/config.yml and modify it as below. You'll need to build the server from with the plc4j/integrations/opcua-server directory. More information can be found here.

mvn package

run the executable:-

java -jar target/plc4x-opcua-server-0.10.0-SNAPSHOT-uber-jar.jar -c config.yml -i

Once the initial configuration is done via the -i switch, the service can then be run without interaction. This allows it to be run in terminal, wrapped in a service wrapper, GUI link or docker image; however you wish.

An example config file is located in the PLC4X OPC Server Integrations folder.

PLC4X Config file

A directory to store the certificates is the only setting that needs to be specified to run the sample.

The connection string syntax can be found at PLC4X Protocol Syntax, which varies depending on the protocol and parameters available. e.g. modbus://localhost:502

Once the server is running it can be connected to using the opc ua endpoint url

opc.tcp://localhost:53530/plc4x

The hostname can be any resolvable name for the host. In this example I have used the UA Expert Client by Unified Automation, but any client can be used including the PLC4X OPC UA client.

Once connected you're able to browse and subscribe to the available tags.

Tag Browsing

The next steps are to continue the great work that Chris has put into PLC4X's discovery and browse APIs. Integrating this into the OPC-UA server should allow for the automatic population of the device's and addresses.