PLCnext Lesson 13- Interfacing Raspberry pi with PLCnext via OPCUA
By Rajvir Singh
Key Concepts
- Raspberry Pi and PLCnext communication
- OPC UA server and client
- Node-RED for data acquisition and transfer
- Humidity and temperature sensor data
- IP addressing and subnet configuration
- Data type definition (float) in OPC UA communication
- PLCnext local variables with OPC UA access
- UaExpert for OPC UA data monitoring
Raspberry Pi and PLCnext Communication via OPC UA
The video demonstrates how to establish communication between a Raspberry Pi and a PLCnext controller using OPC UA. The goal is to transfer sensor data (humidity and temperature) from a sensor connected to the Raspberry Pi to the PLCnext controller.
Project Setup
- A Raspberry Pi is connected to a humidity and temperature sensor.
- Node-RED is running on the Raspberry Pi to read the sensor data.
- A PLCnext controller with a built-in OPC UA server is used.
- The Raspberry Pi and PLCnext are connected to the same network switch and are on the same subnet (e.g., 192.168.0.x with the same subnet mask). The Raspberry Pi's IP address is 192.168.0.88, and the PLCnext's IP address is 192.168.0.210.
PLCnext Configuration
- Two local variables, "humidity" and "temperature," of type REAL are created in the PLCnext's main logic.
- The "OPC" attribute is enabled for these variables, making them accessible via the OPC UA server.
Node-RED Configuration on Raspberry Pi
- An OPC UA client node is used in Node-RED to push data to the PLCnext's OPC UA server.
- The OPC UA client node is configured with the PLCnext's IP address (192.168.0.210) and the OPC UA port.
- A function node is used to define the "topic" for the OPC UA write operation. The topic specifies the address of the PLCnext variable to which the data will be written.
- The message payload contains the sensor data (humidity and temperature).
Step-by-Step Process
- Read Sensor Data: The Raspberry Pi reads humidity and temperature values from the connected sensor using Node-RED.
- Prepare Data for OPC UA: In Node-RED, a function node is used to create the "topic" for the OPC UA write operation. The topic is the address of the PLCnext variable (e.g., "ns=4;s=|var|Local.Humidity"). The payload is the sensor value.
- Configure OPC UA Client: The OPC UA client node is configured with the PLCnext's IP address and port.
- Write Data to PLCnext: The OPC UA client node sends the sensor data to the PLCnext's OPC UA server, writing the values to the specified variables.
- Verify Data Transfer: The UaExpert OPC UA client is used to verify that the humidity and temperature values are being correctly written to the PLCnext variables. The values can also be observed directly in the PLCnext programming environment.
Example: Writing Humidity Value
- The humidity value is read from the sensor and passed to a link node in Node-RED.
- A function node is used to define the topic:
msg.topic = "ns=4;s=|var|Local.Humidity";
and the data type is defined as float. - The OPC UA client node is configured to write to the PLCnext's OPC UA server.
- The humidity value is sent to the PLCnext and written to the "Humidity" variable.
Key Arguments and Perspectives
- OPC UA provides a standardized way to communicate between different controllers, such as Raspberry Pi and PLCnext.
- Using OPC UA, sensor data from a Raspberry Pi can be easily integrated into a PLCnext-based control system.
- This approach eliminates the need to directly wire sensors to the PLC, allowing for more flexible and distributed sensor deployments.
Notable Quotes
- "So I'm basically trying to build a communication between that and how it is possible."
- "So this way I can read the sensor which are connected to a different controller."
Technical Terms and Concepts
- OPC UA (OLE for Process Control Unified Architecture): A platform-independent standard for industrial communication.
- Node-RED: A flow-based programming tool for wiring together hardware devices, APIs, and online services.
- PLCnext: A programmable logic controller platform from Phoenix Contact.
- UaExpert: An OPC UA client application for testing and monitoring OPC UA servers.
- Topic: In the context of OPC UA, the address of a variable or data item on the server.
- Payload: The data being sent in an OPC UA message.
- Data Type: The format of the data being transferred (e.g., REAL or float).
Logical Connections
The video logically connects the steps required to establish OPC UA communication between a Raspberry Pi and a PLCnext. It starts with the hardware setup, then moves to the software configuration on both devices, and finally demonstrates the data transfer and verification process.
Synthesis/Conclusion
The video provides a practical demonstration of how to use OPC UA to communicate between a Raspberry Pi and a PLCnext controller. By using Node-RED on the Raspberry Pi as an OPC UA client, sensor data can be easily transferred to the PLCnext's OPC UA server, enabling integration of distributed sensors into a PLC-based control system. The next video will explore an easier method for communication.
Chat with this Video
AI-PoweredHi! I can answer questions about this video "PLCnext Lesson 13- Interfacing Raspberry pi with PLCnext via OPCUA". What would you like to know?