Example: Network Variables
Product: CODESYS Development System
This example shows how to use variables within a network with multiple devices. The example consists of two applications. One application sends the variables and the other receives them.

Description
This example shows how to exchange variables between different devices within a network. One device sends a variable and the other one receives it. To run the example, the applications have to run on different devices because a port can be used only one time on each system.
Additional information
GVL_Send
: Global variable list which also contains the network settings in the global variable properties (see screenshot). Port 1202 and the broadcast address can remain default. With this setting, anyone can receive the variables. Within a project, it is possible that the devices communicate either directly or via a file. If the sender and receiver are in two projects, then it is only possible to communicate via a file.
This example uses a file for communication. Right-click GVL_Send
and on the Link to File
tab set the file that should be used.
NVL
: Global Network Variable List. Here you set the sender application or the imported file.
Main_Receive
: To check the result, the values of the network variables are assigned to local variables. In addition, some diagnostic information is queried.
For the example to work correctly, you need to start the sender application before the receiver application. As a result, the file which should be imported by the receiver can be created first.
If multiple senders are used on one system, then you need to define different ports for correct communication.
System requirements and restrictions
Programming system | CODESYS Development System (version 3.5.16.0 or higher) |
Runtime system | CODESYS Control Win (version 3.5.16.0) |
Add-on components | - |
Note
DOWNLOAD Project