First Steps with Ethernet POWERLINK

Understand the fundementals of Ethernet Powerlink protocol
February 15, 2024 by
First Steps with Ethernet POWERLINK
Boot & Work Corp. S.L., Bernat Brunet Pedra

What is POWERLINK used for?

Ethernet POWERLINK is an open, communication protocol in real-time that runs on Ethernet hardware. Developed by B&R, this protocol has gained significant popularity in industrial automation and control systems. Alongside Ethernet POWERLINK, B&R has also worked in the development of openPOWERLINK, an open-source implementation of the POWERLINK protocol. Together, these technologies provide robust and reliable communication solutions, enabling seamless data exchange and synchronization in time-critical applications. With its wide range of applications and the support of an active community, Ethernet POWERLINK and openPOWERLINK continue to drive innovation and efficiency in numerous industries.

In this post, you will learn how to build and test the demo codes and how to adapt them for a simple Raspberry PLC usage.


Installation requirements for Ethernet Powerlink on Raspberry PLC

Implementing Ethernet POWERLINK on a Raspberry PLC requires specific hardware and software components to ensure compatibility and optimal performance. The Open Source PLC Raspberry Pi, a robust and versatile controller, plays a crucial role in this setup, providing the necessary computational power and connectivity options to manage industrial processes efficiently. By leveraging the Raspberry PLC, users can create a reliable and powerful network infrastructure, suitable for a wide range of industrial applications where precision and durability are key.


openPOWERLINK installation

openPOWERLINK must be installed in both computer and Raspberry PLC. Go to this page and download the .tar.gz file. Also, you can clone the openPOWERLINK's Github repository.

After having the openPOWERLINK folder in both devices, follow the instructions:

  • Create debug libraries (OPTIONAL):
cd <openPOWERLINK_dir>/stack/build/linux
cmake -DCMAKE_BUILD_TYPE=Debug ../..
make
make install
  • Create release libraries:
cd <openPOWERLINK_dir>/stack/build/linux
cmake -DCMAKE_BUILD_TYPE=Release ../..
make
make install
  • Build demo application:
cd <openPOWERLINK_dir>/apps/<demo_dir>/build/linux
cmake ../..
make
make install


  • You can now run a demo by calling:
cd <openPOWERLINK_dir>/apps/<demo_dir>/build/linux
sudo ./<demo_exec_file>

The master device (the computer) will run "demo_mn_console" and the slave (Raspberry PLC) will run "demo_cn_console". After choosing the correct interface, you will be able to test the demos and understand the basics of Ethernet POWERLINK.


Setting Up Ethernet POWERLINK Connections for Device Communication


To be able to send and receive Ethernet POWERLINK messages, you will need to connect both devices with an Ethernet cable while being in the same subnet.

To establish a successful Ethernet POWERLINK network, ensuring the proper setup of connections between devices is critical. This involves not only physically connecting the devices using an Ethernet cable but also configuring them to operate within the same subnet. Such a setup is pivotal for the seamless sending and receiving of Ethernet POWERLINK messages, which are essential for the real-time control and monitoring of industrial processes. This precise configuration guarantees high-performance communication, crucial for maintaining efficiency and reliability in automated systems.



Customizing your code for optimal performance on Raspberry PLC


The demo code for Raspberry PLC (demo_cn_console) does not interact with physical IOs at all, so let's get into that. 

  • Install rpiplc library from Industrial Shields.
  • Modify files found in <openPOWERLINK_dir>/apps/demo_cn_console/src like so:
  1. app.c:
#include <rpiplc.h>
static const uint32_t digitalOutputs[] = {Q0_0, Q0_1, Q0_2, Q0_3, Q0_4, Q0_5, Q0_6, Q0_7};
static const int numDigitalOutputs = sizeof(digitalOutputs) / sizeof(uint32_t);
void updateOutputs(void) {
 ​int i;
 ​for (i = 0; i < numDigitalOutputs; i++) {
  ​if (((digitalOut_l >> i) & i) == 1 ) {
   ​digitalWrite(digitalOutputs[i], 1);
  ​} else {
   ​digitalWrite(digitalOutputs[i], 0);
  ​}
 ​}
}

​2. main.c (bold lines):

#include <rpiplc.h>
static void loopMain(void) {​
 ​...
 ​printf("--------------------------------\n\n");
 ​setupInputs();
 initPins();
 
 ​// wait for key hit
 ​while (!fExit) {
  updateOutputs();

​3. In addition, time between polls can be changed in main.c (By default 50 ms):

#define CYCLE_LEN           50000

​4. ../CMakeLists.txt:

TARGET_LINK_DIRECTORIES(demo_cn_console PRIVATE /usr/local/lib)
TARGET_INCLUDE_DIRECTORIES(demo_cn_console PRIVATE /usr/local/include/rpiplc)
TARGET_LINK_LIBRARIES(demo_cn_console ${ARCH_LIBRARIES} rpiplc)
TARGET_COMPILE_DEFINITIONS(demo_cn_console PRIVATE RPIPLC_21) # your model​

Finally, build the demo code again and observe how the outputs change!


Key Takeaways for Successful Ethernet POWERLINK Implementation on Raspberry PLC

To successfully implement Ethernet POWERLINK on Raspberry PLC, it is crucial to focus on precise connections, subnet configurations, and customized code. These steps are foundational for establishing a robust and efficient network, ensuring seamless communication and control in industrial environments. Embracing these practices will enhance automation processes, offering reliability and performance in demanding applications.




​Search in our Blog

First Steps with Ethernet POWERLINK
Boot & Work Corp. S.L., Bernat Brunet Pedra February 15, 2024
Share this post

Looking for your ideal Programmable Logic Controller?

Take a look at this product comparison with other industrial controllers Arduino-based. 

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC comparison >>>