In this post, i will explain how to use Codesys as an OPC-UA Sever with RaspberryPi3. Before starting it, let have a short briefing about OPCUA.
Here is the Description from spotlightmetal.com:
OPC UA (short for Open Platform Communications United Architecture) is a data exchange standard for industrial communication (machine-to-machine or PC-to-machine communication). This open interface standard is independent of the manufacturer or system supplier of the application, of the programming language in which the respective software was programmed, and of the operating system on which the application is running.
The biggest difference to previous versions is that machine data can not only be transported, but also semantically described in a machine-readable way. OPC UA provides access to a wide variety of data in both vertical and horizontal directions. The spectrum ranges from OPC UA components directly integrated on the devices and controllers or machines and systems to so-called gateways and aggregating servers.
Online Help and Google are always your best friends.
Firstly, Create some variables inside Global Variables list.
And Also Create a real array inside the PLC_PRG.
While you want to Configure the OPC-UA Server, Symbol Configuration is necessary to use.
Application>Add Object>Symbol Configuration
Check the Support OPC UA features option and press Add.
you will see the Configuration view.
While pressing “+” inside PLC_PRG, you can see the variables that defined above. But how about my GVL? They are no in the list.
Just make some program inside PLC_PRG that using the GVL Variables.
Go Back again to Symbol Configuration tab then click “Build”. You can see the GVL Variables now. It seems like Codesys will ignore the variables that no using inside the program.
While pressing “+” of GVL, you can see all the variables that defined before.
But after you check the GVL and PLC_PRG, that is a warning message that inform you – some variables are not referenced by the IEC Code. Let’s click Remove Button to see how happen.
Fine,because some variables are not used inside the program, these stuffs may not have the effects. Just press Cancel to ignore it.
Finally, Press F11 to compile the project and Download to your devices.
we will use UaExpert to Testing the OPCUA Function of Codesys. Please register/Login to download the software.
Sure, you can using pure python to make your own opcua client, and i will explain it in the other post.
Custom Discovery>Double click the “+<Double click to Add Server>”.
Enter your Devices IP.
After the server is discovered, there is some options of how to login to server. Security Stuff is supported by Codesys also (Basic256SHA256 something) and i will explain these in the other post also.
Enter your Configuration Name, OK.
if the connection is established, you can see the Addresspace and node behind the sever window.
you can see all the variables inside the GVL.
そしてCodesys上でNodeの値を変わる、UaExpertにもちゃんと数字が反映されていますね。Also, while the node value is changed, you can see the actual value in the UaExpert software.
。ByeBye! And I will write these post in the recently future because Now Japan is in hoilday :)!
- Codesys with OPCUA Security
- Python with OPCUA Client
- Siemens SIOME usage
- Something more aboaut OPCUA