ContentHub
20251119-OPC-UA#1-Server-EN.mp4
74 views
View transcript
Hello, in this WAGO tutorial we’ll show you how to configure an OPC UA server in CODESYS 3.5 so that a client can establish a connection to it. For this demonstration, we’re using a PFC200 with firmware 30, which will act as our OPC UA server. The client will be simulated using the software tool UaExpert. First, we open the Web-Based Management of the controller. Since, in this video, we’re working exclusively with unencrypted and anonymous OPC UA communication – meaning without certificates, usernames, or passwords – we need to enable this in the Web-Based Management of the controller. Under the Fieldbus tab, in the OPC UA menu, you’ll find the section OPC UA Server Security Settings. Here, you need to tick the box for Anonymous Access. There’s also a note stating that, for this to work, the Port Authentication of the runtime must be disabled. You’ll find this under Configuration → Ports and Services, in the PLC Runtime Services section. Remove the tick and confirm with Submit. Next, we start in CODESYS 3.5 with a new standard project. The connection to the controller has been established, and the modules on the K-Bus have been scanned and added. In OPC UA, there are two types of communication: either via the Communication Manager or via the Symbol Configuration. Both are defined and configured on the server. We’ll begin with the Communication Manager, which is the more modern communication method. Later in the tutorial, we’ll also demonstrate the Symbol Configuration approach. Right-click on the application, select Add Object, and choose Communication Manager. Then, in the right-click menu of the Communication Manager, select Add Object again and choose OPC UA Server. This sets up the server. As long as we only want to read and write variables, as in this tutorial, this option is sufficient. Since OPC UA is not just a protocol but also a modelling standard, there’s an additional option: OPC UA Information Model, which allows you to integrate predefined or custom information models. This is typically used when industry-specific requirements go beyond simply providing variables – for example, hierarchical object structures, method calls, or type definitions. For now, we’ll stick with the OPC UA Server. The OPC UA Server has been added, and within the server, we find the Symbol Set. Here, we can add the variables that will be provided as OPC UA tags. We don’t have any variables in our project yet, so let’s quickly create some. First, a simple Bool variable assigned to Digital Input 1. To ensure it appears later, we’ll reference it once in the program window. Then, an Integer variable that we’ll increment by 1 in each cycle so that it continuously counts up. We load the program into the controller and start it. The Integer variable is counting up as expected, and when we apply 24V to the first digital input, xDI1 becomes TRUE. Back in the Symbol Set of the OPC UA Server, we refresh the view at the top and now see the two variables under Application: PLC PRG. Simply drag and drop these into the Symbol Set – and done. On the right-hand side, you can define access rights for each variable. The default setting is Read and Write, but for the digital input variable, write access doesn’t make much sense in our setup, so we’ll set it to Read only. Once we load the program into the controller and start it, the variables will be provided by the controller via OPC UA. Now, we want to read the values using UA Expert. Click the Plus icon to add a new server. The Add Server window opens, and under Custom Discovery, double-click to enter the server URL. It’s important that the URL starts with opc.tcp, followed by the controller’s IP address, and then the OPC UA standard port: 4840. If DNS resolution is available in the network, you can also enter the hostname. The server is found, and the MAC address is displayed. Expand the entry, and you’ll see two server connections. Select the lower one with the IP address, as we don’t have a DNS server in our small test network. In the Address Space section, under Objects, you’ll find the Symbol Set folder containing the two variables. Drag and drop these into the Data Access View - the Integer variable counts up, with a slight delay, and when we apply 24V to the digital input on the controller, xDI1 becomes TRUE. That was the method using the Communication Manager. Now, let’s do the same using the Symbol Configuration. Both methods can even run in parallel for a test setup. So, we’ll simply add the Symbol Configuration to our existing project under Application. For a real system, however, we strongly recommend choosing one method only, as running both may compromise stability and unnecessarily complicates the project. In the pop-up window, make sure the tick for OPC UA functionality is set – this is the default setting. In the Symbol Configuration window, click 'Build', and you can now select which variables should be provided via Symbol Configuration. You can also select all variables, but be careful, especially in large projects, not to accidentally enable thousands of variables at once. OPC UA is a powerful communication method, but it does have its limits. That’s all there is to it – and we can now read the values in UaExpert. The variables from the Symbol Configuration appear in the server tree under our WAGO controller, Application - Programs - PLC PRG. Drag them into the Data Access View, and we receive the values via Symbol Configuration – in parallel with the Communication Manager. The Integer variable counts up, and xDI1 becomes TRUE when we activate the first digital input. If we enlarge the Node ID column, you’ll notice a key difference between the two communication methods. With Symbol Configuration, the Node ID is displayed in plain text. With the Communication Manager, the Node ID is generated as opaque, meaning a binary-coded format without semantic information. Opaque is part of the OPC UA standard and ensures stability and uniqueness, as the Node ID is independent of symbolic names that may change. It also improves performance, as long strings don’t need to be transmitted. If you want the Communication Manager to provide the Node ID as a string instead of opaque, that’s possible. The displayed Node ID remains the same, only the type changes. To do this, simply tick Write Node IDs as base 64-encoded strings at the top of the Symbol Set. After restarting the controller and communication, and dragging the updated variables into the Data Access View, we receive the Node ID as a string in UaExpert via both communication methods. And that brings us to the end of this tutorial on configuring an OPC UA server in CODESYS 3.5 so that a client can connect to it. If this video was helpful, give us a thumbs up, subscribe to the channel, and contact the WAGO Support Centre if you have any further questions.