In this tutorial I will show you how to establish a OPCUA connection between TwinCAT3 (TF6100 as client)and PLCNEXT AXC F 2152 Controller(OPCUA Server).
Reference Link
PLCNEXT Side
Let’s Configure the OPCUA Server in the PLCNEXT Side.
Go to PLC>OPCUA.
The OPCUA Configuration screen is displayed.
The Server name,security stuff..etc can be configured here.
Variable Visibility
In TwinCAT, we can configure whether each variable is visible or not by the Attribute settings.PLCNext is doing the same thing.Go to Basic Settings>Information Model>Visibility of variables.
- None:Not Visibilily
- Marked:depends on the setting
- All:All nodes are visible.
In this tutorial , Marked is used.
Certificate
In the certification part, Self-signed by controller is used.
Variables Configuration
you can see the OPC rows in the variable define tab.
The variable will be visible if the box is checked.
In this tutorial, The hardware switch on the starter kit is used also. but PLCNEXT can not assign it as a visible node.
Test Code
The Testing Code is very simple – a float variable will plus 1.0 and return to 0.0 if the current value is >=1000.0.
Download
Finally , Please Download it.
UaExpert
UaExeprt and TwinCAT are used for verification in this tutorial.The main reason is UaExpert can be easily tested but can not be implemented in the real-applications.
TwinCAT can be used in the Real-application but you need some know-how to do it.
Because of this, we will use UaExport for verify the connection, then implement it in TwinCAT.
Add the Server
Add the Server and Click the Custom Discovery.
Use the <+Double click to add server> function.
Enter the IP of your PLCNEXT CPU.
Server is found!Double click it.
Yes.
Now you need to authenticate.
Login
Select the Radio box of username.
Enter “admin” as your username>OK.
Connect
Click the Connect server function.
Enter your password.The password is printed on the surfaces of your PLC.(if you did not changed it)
Click Trust server certificate>Accept the server >Continue.
Browse the Node
Server is connected between Server and UaExport.
Browse Root>PLCnext>Arp.Plc.Eclr>NewProgram1 to view the variables that configured in PLCNEXT Engineering before.
Select all these Nodes and drop to the Data Access view.
Verification
Please check if the variables are consistent or not;)!
TwinCAT Side
I will write down some “Main Points’ ‘during the configuration.
Reference Link
Ponit1-Endpoint
The Endpoint URL must be configured correctly.
Enter the IP in the Endpoint URL field.
Username is admin and password is printed on the surface of your PLCNEXT(if you did not change it).
Press Change Endpoint.
Select the Authentication method>OK.
Point2-Add Node
Press “Add Nodes” to insert the OPC UA Nodes.
Save Certificate in Trust List>Trust.
Node can be browsed now.
Select the Nodes that you need to use in your TwinCAT Project.
Check the “Enable Write” box if you need to overwrite the value.
Nodes that you selected are inserted into your project.
Point3-Link the variables
Finally, Do not forget to link these variables into your User program 😉
Verification
Compare the values that are read from UaExpert and TwinCAT and check it.