Objective and tools
The goal is to prepare a Siemens PLC to serve variables through OPC UA, simulate it with PLCSIM Advanced and check the connection from UA Expert.
For this example I use a CPU 1515-2 PN, network interface 1 and project IP address 192.168.1.188. The project stays deliberately simple: one DB with variables, one FC that changes the values and the PLC's own OPC UA server publishing that data.
Tools used:
OPC UA Activation
Inside the CPU properties, enable the OPC UA server functionality and assign it to the network interface that will be used. Siemens provides specific documentation for using the S7-1500 as an OPC UA server in TIA Portal. In this case the server runs through interface 1 of the CPU.
This prepares the server entry point. Two important parts are still required before downloading: the OPC UA license and the access permissions.
OPC UA License
This functionality requires the OPC UA license that matches the CPU type. The official Siemens OPC UA page summarizes Siemens' approach to OPC UA communications in industrial automation. In TIA Portal, the license is separated by controller size:
- Small: entry-level CPUs such as 1511, 1512C, 1513 and distributed ET 200SP controllers.
- Medium: mid-range CPUs such as 1515 and 1516. This is the license used in this example.
- Large: higher-performance CPUs such as 1517 and 1518.
User Permissions
When compiling, TIA Portal may warn that user permissions are missing for OPC UA. The fix is to create a specific role, enable the matching Runtime right in the PLC and assign that role to the user that will access the OPC UA server.
First, create the OPC UA role.
Then create the Runtime right in the PLC and make it available for that role.
Finally, assign the role to the required users. In this case we assign it to the admin user, so the OPC UA connection requires a username and password and is protected by credentials.
This user must already exist with a password. That same password will be entered later in the OPC UA client when establishing the connection to the PLC.
Simulation FC and DB
To have changing data in the OPC UA client, I create a small simulation program. The base is a DB with variables and an SCL FC that updates their values.
First, create the variables that will be simulated.
Then enable clock memory bits to use internal pulses and change values easily.
The simulation FC is prepared in SCL with help from Codex, so the test behavior can be generated quickly.
PLC Simulation
With the program ready, enable simulation in the project and prepare the instance in PLCSIM Advanced.
In PLCSIM Advanced I use SingleAdapter and assign the project IP address: 192.168.1.188. This allows the OPC UA client to connect to that address.
OPC UA Server Interface
Once the variables are created, configure an OPC UA server interface in the project.
Then add the variables that should be served. Drag the DB or the variables into the OPC UA interface. When everything is ready, download the simulated PLC.
Check with UA Expert
To validate the server I use UA Expert, the OPC UA client from Unified Automation. The endpoint URL for this test is:
opc.tcp://192.168.1.188:4840
In this article, the OPC UA channel security is left as No security (None). In other words, we use a username and password for access, but message signing and channel encryption are not enabled yet. The authenticated connection with security policies and encryption will be covered in a dedicated article.
After discovering the server and selecting the connection, UA Expert asks for credentials. Here we enter the admin user and the password previously configured in TIA Portal.
After connecting, open the ServerInterfaces folder. The DB published from TIA Portal is available there.
This validates the full path: simulated PLC, active OPC UA server, served variables and an external client reading the published structure.