Codesys
Three correct!
OPC UA is regarded as "the" communication standard in the Industry 4.0 era. However, many automation specialists are asking themselves: How complex will this be for me? This question is answered using the example of the use of OPC UA Server, Client and PubSub on Codesys-compatible platforms.
In the world of automation, Codesys is known and established as the IEC 61131-3 platform. Hundreds of different industrial control systems are configured with the tool or its derivatives. The extensive communication features of the software play an important role here, making it possible, for example, to load created PLC applications onto a device, debug them in online mode, read and write I/O data via fieldbus or proprietary protocols. Secure data exchange with other devices or units via OPC UA is also an essential feature of the platform.
OPC UA Server - Publish application data
The original aim of OPC and OPC UA is to make controller data accessible to other participants. This is done via a corresponding server, either as additional software for a controller or - in the case of Codesys-compatible controllers - integrated in the PLC runtime system. If a user wants to make the current PLC values known to other devices, he inserts the 'Symbol configuration' object in the Codesys project and specifies which variables are to be published. Publishing can be done object by object, in data structures or individually. If required, the data can be structured in different symbol groups and the access rights of individual variables or complete groups can be defined in fine granularity. A valid X.509 certificate is also required on the controller for secure communication. It can either be issued by a certification authority and imported to the control unit or created directly in the device itself.
Figure 2: Information models in XML format become instantiable data structures in Codesys Development.
© CodesysBut that's only half the battle. In order for the published data to be used and utilized correctly on the other side, you need to know what it means. In recent years, numerous companies from different industries have come together under the umbrella of the OPC Foundation and jointly defined standardized information models for data exchange. In the XML files of the OPC UA Companion Specifications, the data structures are provided with context information so that the transmitted data can be interpreted and used correctly straight away. Bilateral agreements are therefore unnecessary. Such information models can be used quite conveniently in the Codesys project: The XML files are first imported into a repository, a type of database in the development interface. Using the 'Communication manager' object, the user can insert these information models into the project and freely decide which of the available data structures or types should be used. IEC 61131-3 function blocks are created at the touch of a button and instantiated either manually or automatically by command. Variables created in this way can be used in the PLC code as before and published via the OPC UA server. If an information model contains OPC UA methods, the user can encode their function in the generated block themselves. Connected OPC UA clients can call these methods and thus functions of the server - "on demand", so to speak. This dynamic usability of information models for very different industrial and application areas makes it very easy for application developers to react flexibly to changing tasks or to reuse code that has already been created.
OPC UA Client - various use cases
Figure 3: In the data source manager, the OPC UA client enables the insertion and use of PLC data from a connected controller.
© CodesysThe client is the remote station to the server: It searches the data structures provided and enables their use. In the past, as today, machines and systems are visualized using the PLC data via the client. With the visualization integrated in Codesys, users create suitable user interfaces in the development system parallel to the development of the PLC application - or completely independently of it. Almost all users use such visualizations to operate machine units, systems or as a convenient tool for debugging or commissioning the application on compatible controllers. By integrating an OPC UA client into the visualization runtime under Windows and Linux, such user interfaces can be used to visualize any controllers with OPC UA servers. To do this, the visualization user connects the data source manager in the project with the server URL of the OPC UA server on the controller. The client displays the published data and enables visualization or animation.
In addition to the original use case of visualization, OPC UA communication via server client is suitable for data exchange between devices. The data source manager in Codesys can also be integrated into "normal" PLC applications in the same way. Once the connection has been established from the client to a controller with OPC UA Server, its variables are available in the development system in exactly the same way as if they had been declared locally in the project - regardless of the manufacturer of the connected controller. For standardized data exchange, it is therefore advisable to implement OPC UA server and client functionality in pairs on suitable controllers.
The data source manager is automatically based on a library whose blocks can also be called and used directly to implement the client connection within the application. This gives experienced developers of PLC applications additional degrees of freedom when implementing their logic functions.
OPC UA PubSub - for real-time communication
As convenient as client-server communication is, there is a catch: the server in particular requires a considerable amount of CPU power and memory. This is not a problem for most of the now "very well motorized" industrial controllers with Windows or Linux as the operating system. However, if data exchange is to be realized with low-cost field devices, this protocol is no longer suitable. To remedy this, the OPC Foundation has defined PubSub, a lean alternative that enables communication via different protocols: Codesys users simply use an available library for communication. To send and receive messages, the object-oriented blocks are called cyclically within the PLC application. Data is currently exchanged on the basis of UDP (User Datagram Protocol). However, the library is designed in such a way that time-synchronized communication protocols can be added at any time. The future implementation of a real-time-capable OPC UA-based fieldbus system is thus prepared. This makes OPC UA PubSub suitable not only as an alternative for communication between less performant devices, but also in future for data exchange between controllers in real time via protocols such as TSN or even with cloud systems.
Codesys users can therefore use the OPC variant best suited to their application. This is possible thanks to the seamless integration into the IEC 61131-3 development system. After a simple configuration, integrated data is available just as if it had been declared in the local controller. Whether OPC UA Server, OPC UA Client, OPC UA PubSub or all three variants simultaneously on a compatible device.



















