In this article, we will explain from scratch how to use Codesys’ Network Variable List feature to easily exchange data between multiple Codesys Runtimes.Also used in the article will be WAGO’s PFC200 and Berghof’s Raspberry PI Controller.
Come on, let’s enjoy FA.

Foreword
Thank you from the bottom of my heart for visiting my technical blog and YouTube channel.
We are currently running the “Takahashi Chris” radio show with Full-san (full@桜 八重 (@fulhause) / X) which I deliver every Wednesday night.
Sharing, not hoarding, technical knowledge
We publish technical information related to factory production technology and control systems for free, through blogs and videos.
With the belief that “knowledge should be accessible to everyone,” we share practical know-how and real-world troubleshooting cases from our own field experience.
The reason we keep it all free is simple: to help reduce the number of people who struggle because they simply didn’t know.
If you’ve ever thought:
- “Will this PLC and device combination actually work?”
- “I’m having trouble with EtherCAT communication—can someone test it?”
- “I want to try this remote I/O, but we don’t have the testing environment in-house…”
Feel free to reach out!If lending equipment or sharing your configuration is possible, we’re happy to verify it and share the results through articles and videos.
(We can keep company/product names anonymous if requested.)
How can you support us?
Currently, our activities are nearly all unpaid, but creating articles and videos takes time and a proper testing environment.If you’d like to support us in continuing and expanding this content, your kind help would mean a lot.
Membership (Support our radio show)
This support plan is designed to enhance radio with Mr Full.
https://note.com/fulhause/membership/join
Amazon Gift List (equipment & books for content production)
Lists equipment and books required for content creation.
https://www.amazon.co.jp/hz/wishlist/ls/H7W3RRD7C5QG?ref_=wl_share
Patreon (Support articles & video creation)
Your small monthly support will help to improve the environment for writing and verifying articles.
https://www.patreon.com/user?u=84249391
Just trying to share things that could’ve helped someone—if only they’d known.
Your support helps make knowledge sharing more open and sustainable.
Thank you for being with us.
soup01threes*gmail.com
Technical knowledge shouldn’t be kept to ourselves.
Network Variables?
Network Variables can be exchanged between different PLCs in a network. Variables must be defined in a strict and identical list for both sender and receiver, and only one application of the device can define network variables. The list can be included in one or more projects.
Network Variables are also sent as a one-way broadcast only from the sender to the receiver. However, it is possible for a device to contain both sender and recipient lists.
Data exchange via network variables may not be possible in the following cases:
- The device (target system) does not support it.
- If the communication is blocked by a firewall.
- Other clients or applications are using the UDP port set in the properties of the network variable list.
- Multiple applications use the network variable list for each sending and receiving device.
Only arrays with limits defined by literals or constants will be sent via Network Variables.
- “arrVar : ARRAY[0..g_iArraySize-1] OF INT ;” is not sent.
- “arrVar : ARRAY[0..10] OF INT ;” is sent.
Note that the maximum size of a network variable is 255 bytes, but the number of network variables is unlimited; if the size of the GVL exceeds the maximum length of a network telegram, the data is split into multiple telegrams. Depending on the configuration, this may lead to data inconsistencies.
In addition, during data transfer by UDP from the sender to the receiver, data can be lost at the following locations or events during each cycleIn other words, the data received by the receiver in a given cycle may not be up-to-date, but may be out-of-date.
- Sender (network driver, stack)
- Router
- Switches
- Network collision
- (Receiving side network driver, stack)
Implementation
Sender(Wago)
First, create a Network Variable List from the WAGO PFC200 Controller to send data to the Codesys Runtime on the network.
From the WAGO PFC200 Controller project, add a Network Variable List at Application>Add Object>Network Variable List (Sender).
This is the configuration screen for Codesys’ Network Variable List (Sender).
Name
This is the Network Variables List name.
Task
This is the current application task that controls the variables to be sent.
Note that CODESYS always sends variables at the end of the task cycle.
Network Type
Next, set the Network type; data exchange for Network Variables is UDP only.
Setting
Next, click on the Settings button.
Set the Port number or IP address of the data exchange destination for Network Variables.
Port: The number of the port that CODESYS uses to exchange data with other network units, default value is 1202.Note that other nodes in the network must define the same port, and if multiple UDP connections are defined in the project, the port numbers of all configurations should match this value.
Broadcast Adr: The default value is 255.255.255.255, which means that data will be exchanged with all network units.For example, if you want to communicate with all nodes with IP addresses in the range “197.200.100.x”, you should set it to 197.200.100.255.
In the example below, the Codesys Runtime Target can be specified as 192.168.13.40.
You can also set Broadcast as 192.168.13.255.
Listidentifier
This one is used for the network variable list identification ID. When the devices to be exchanged are the sender and receiver, the variable list identifier must be unique to prevent abnormal behavior.Variable List identifiers are defined in the Properties dialog of the GVL object.
This time set the List Identifier for Wago>Berghof to 1.
Interval
Here CODESYS sends variables within the defined cycle.
Done!So the Network Variable List was defined.
Variables
Next, let’s define variables as we always do with the Global Variable List.
Receiver(Berghof)
Next, we want Berghof Controller to receive the data sent by Wago, so we need to add a Network Variable List on the Berghof side as well.
On the Berghof project side, right click>Add Object>Network Variable List (Receiver).
This is the Network Variable List (Receiver) setting screen.
Name
Set the Network Variable List name.
Task
Leave Task as Default.
Sender
The Sender sets where the Network Variable List to be added now will receive the data sent from the Codesys Runtime.In this article, since the two controllers are in the same project, select the WAGO controller in the Sender’s Drop-List.
Result
Done!Codesys IDE automatically synchronizes all data structures on the Network Variable List (Sender) side.
Sender(Berghof)
Next, let’s send data from the Berghof side to WAGO Controller as well.
From Berghof project>Application>Right click>Add Object>Network Variable List(Sender).
The same Network Variable List configuration screen as before will appear.
Listidentifier
Note here that the List Identifier should not overlap with WAGO’s Network Variable List (Sender).
Network Setting
Network settings can be one-to-one or Boardcast settings.
Done!
Variables
そのあとはいつもの通りに変数を定義します。
Wago(Receiver)
The last step is to set up the WAGO side to receive the Network Variable sent from Berghof’s Controller.
Right click on the WAGO Controller side>Add Object>Network Variable List (Receiver).
The same configuration screen as the Network Variable List described earlier will appear.
It was also synchronized to Berghof’s Network Variable List (Sender) variable list.
Program(WAGO)
Writes data from the WAGO side to the Network Variable List.
OutData[0].15:=bPlus; NVL_Sender.SendBytes[0]:=16#AB; NVL_Sender.SendBytes[99]:=16#FD; |
Program(Bergof)
Let’s write the Berghof side data to the Network Variable List.
NVL_Sender.sendData[0]:=1234.5; NVL_Sender.sendData[3]:=5.24521; |
Result
Done!Wago PFC200 and Berghof Controller can now exchange data via Network Variable List.