Configuring a Network Variable Exchange

The following steps are necessary for exchanging network variables between the sender device and receiver device.

1. Creating a network variable list in the sender device and generating an export file

Requirements: An application is inserted in the device tree of the controller that has been employed as the sender device.

  1. Select the application and insert a Network Variable List (Sender) object. Make the following settings in the Add Network Variable List (Sender) dialog box: Network type: UDP (for example, NVL_Sender”).

  2. Double-click the NVL object to open the respective editor and type the declarations of the network variables. Example:

    VAR_GLOBAL

    iglobvar:INT;

    bglobvar:BOOL;

    strglobvar:STRING;

    END_VAR

  3. Right-click the NVL object in the device tree to open the Properties. In the Properties dialog box, click the Network Variables tab to show the following settings: Network type: UDP; List identifier: 1; Pack variables; Cyclictransmission: every 50 ms.

  4. Please note: You can also convert an existing GVL into a network variable list by configuring its network variable properties.

  5. Click the Link To File tab.in the Properties dialog box of the NVL_Sender. Define a file name <export>.gvl and a save location in the file system for the export file of the GVL. Select the Export before compile check box.

  6. Click Build ‣ Build to compile the application.

The export file for the network variable list is now located in the defined folder.

See also

2. Creating an associated network variable list in the receiver device

Requirements: There is a sender device and a receiver device in the device tree. An application with a task configuration is inserted below the device. An NVL or a GVL is created below the sender device as network variable list to be sent.

  1. Select the application of the receiver in the device tree and click Add Object ‣ Network Variable List (Receiver) .

    ⇒ The Add Network Variable List (Receiver) opens.

  2. In the dialog box, select the previously created NVL of the sender device and type a name (for example, “NVL_Receiver”). CODESYS populates this recipient list automatically with the variable declarations from the sender list.

    Please note: As an alternative, you can check the Import from file check box and load the export file that was generated previously from the sender list.

3. Testing the network variable exchange

Requirements: There is a network variable list (sender) in the sender device and a network variable list (receiver) in the receiver device and both lists have identical variable declarations.

  1. Below the application in the sender device, create a program that increments a network variable (for example, iglobvar:=iglobvar+1;).

  2. Configure the application task so that this program calls it.

  3. Below the application in the receiver device, create a program that writes the value of this network variable to a local variable (for example, ilocalvar:=iglobvar;).

  4. Configure the application task so that this program calls it.

  5. Download both applications to the controllers and start them (set application active, log in, download, start).

  6. In the online views of the editors of both programs, check whether the values of iglobvar match in the receiver and the sender.

Configuring network variable communication between V2.3 and V3 controllers

Requirements: A global variable list exists in a V2.3 project with network variables that you want to read into your V3 project. In the V3 project in the device tree below the controller, there is an application with a program that uses the variables.

  1. Open the Properties dialog box of the GVL in the V2.3 project (sender).

  2. Insert another controller into the project as a dummy with an application and a task. Then create the V2.3 GVL below it as follows:

  3. Below the dummy application, insert a Network Variable List (Sender) object named “dummy23”.

  4. Right-click dummy23 to open the Properties dialog box. Click the Network properties tab. Type the same network properties as the GVL in the V2.3 project.

  5. Fill dummy23 with the same variable declarations as in the V2.3 GVL.

  6. Define a save location for an export file “dummy23.gvl” in the Link To File tab of the Properties for dummy23.

  7. Set the application of the dummy controller as active and press F11 to compile. CODESYS creates the export file.

  8. Set the application of the physical controller as active and right-click to open the Add Object dialog box.

  9. Select Network Variable List (Receiver) and type a name (for example, “NVL_from_23”).

  10. Select the Import from file check box and select dummy23.gvl, which was generated previously.

  11. Check NVL_from_23, which has just been created. You must receive the same variable declarations as those in the sender GVL in the V2.3 project.

See also