Tietokoneiden näyttöjä, joissa näkyy kuvaa automaatiolaboratorion laitteistosta. Monitoreiden takana näkyy sama laitteisto kuin kuvissa.

timohei.net / My Courses / ???/ T115303 Communications for Automation / OPC UA /
OPC UA

To connect two Siemens S7-1200 PLCs to communicate with each other as a server and client using OPC UA, you need to follow these general steps:

  1. Configure the network communication between the two PLCs: Ensure that the two S7-1200 PLCs are connected to the same network and that the network settings are properly configured on each PLC, including assigning unique IP addresses to each PLC, configuring the subnet mask and gateway, and setting up any necessary port forwarding or firewalls.
  2. Configure the OPC UA server on one of the PLCs: One of the PLCs will act as the OPC UA server, which will provide access to the data stored in its memory. To configure the OPC UA server, you can use the TIA Portal software to create a new OPC UA server object, define the data types and variables to be exposed, and specify the security settings.
  3. Configure the OPC UA client on the other PLC: The second PLC will act as the OPC UA client, which will connect to the server and retrieve data. To configure the OPC UA client, you can use the TIA Portal software to create a new OPC UA client object, specify the IP address and other connection parameters of the server, and define the variables to be read or written.
  4. Establish the OPC UA connection between the two PLCs: To establish the OPC UA connection, you need to configure the client to connect to the server using the appropriate security settings and authentication credentials, and then test the connection by reading or writing data from one PLC to the other.

Here are some more detailed steps for configuring the OPC UA server and client on the S7-1200 PLCs:

Setting up the OPC UA Server

  1. Open the TIA Portal software and create a new project.
  2. Create a new PLC program for the S7-1200 that will act as the OPC UA server.
  3. In the TIA Portal software, go to the "Devices & Networks" view, and right-click on the server PLC and select "Insert new object".
  4. Select "OPC UA Server" and click "OK".
  5. In the "OPC UA Server" properties dialog, configure the security settings, the authentication credentials, and the endpoints (i.e. the network addresses on which the server will listen for client connections).
  6. Add the variables that you want to expose to the OPC UA client, including their data types and addresses in the PLC memory.
  7. Download the program to the server PLC and start it.

Setting up the OPC UA Client

  1. Open a new project in the TIA Portal software.
  2. Create a new PLC program for the S7-1200 that will act as the OPC UA client.
  3. In the "Devices & Networks" view, right-click on the client PLC and select "Insert new object".
  4. Select "OPC UA Client" and click "OK".
  5. In the "OPC UA Client" properties dialog, configure the connection parameters, including the IP address of the server PLC, the security settings, and the authentication credentials.
  6. Add the variables that you want to read or write from the server, including their data types and addresses in the PLC memory.
  7. Download the program to the client PLC and start it.

Establishing the Connection

  1. In the TIA Portal software, go to the "Devices & Networks" view, and select the OPC UA client object that you just created.
  2. Right-click on the client object and select "Connect to Server".
  3. If the connection is successful, you should be able to see the available variables on the server in the "Data Blocks" view of the TIA Portal software.
  4. Test the connection by reading or writing data from the server: Once the connection is established, you can test it by reading or writing data from the client PLC to the server PLC. This can be done using the "Data Blocks" view in the TIA Portal software, where you can select the variables you want to read or write, and observe their values.
  5. Monitor and troubleshoot the connection: During operation, it is important to monitor the OPC UA connection and ensure that it is working as expected. This can be done using the diagnostic tools provided by the TIA Portal software, which allow you to view the connection status, the data traffic, and any errors or warnings that occur.

Some additional considerations to keep in mind when working with OPC UA on S7-1200 PLCs:

Updated 16.2.2023

© Timo Heikkinen | timo piste heikkinen at oamk piste fi