Configuring the Data Sources

Selecting the data source variables

Requirement: A data server with one or more data sources is inserted under the application. You have already compiled the applications of the data sources, i.e. created code.

  1. Double-click on the data source object.

    The configuration dialog box with the Data Source Items tab appears.

  2. From the Available Items, select all the variables that you would also like to use in the local application. With the help arrow buttons, move the variables into the Selected Items window. Please note: Only in the case of Structured view do the function blocks and data types also appear and the selection can be reduced to individual components.

  3. If you want to define an application other than the one currently selected as the data source, use the Rebind button.

  4. In order to switch the access right to a variable from “read and write” b90f700902687a3ec0a8640e01ebff96_b21d37321e8f942dc0a8640e01947982 to “read only” b90f700902687a3ec0a8640e01ebff96_2d4bfe7c1e8f9404c0a8640e01947982 or “write only” b90f700902687a3ec0a8640e01ebff96_ff7255fb1e8f9455c0a8640e01947982 , click on the symbol behind the variable.

    Read: whenever the value of the variable in the data source has changed, CODESYS also updates the value in the local application.

    Write: whenever the value of the variable in the local application has changed, CODESYS also updates the value in the data source.

  5. In the Update by Default column, define which variables this should apply to. Update by default means that the DataServer always (!) transfers the variables of the currently active visualization. Note: if a function block instance or a data type instance is activated in this way, the complete instance is transferred! The DataServer transfers variables without the “Update by default” attribute only if they are displayed in a visualization or if you have activated the variables via the DataServer programming interface.

    All variables that the DataServer is to transfer are listed together with the respectively desired update mode in the Selected Items field.

Example

Requirement: The structure created after execution of the example in Adding Data Server and Data Sources in the Project is located in the Device tree of your project. You have compiled App_Dev1 and App_Dev2.

Application App1 below MyPlc wishes to use the following data from device Dev1: PLC_PRG.dev1_iVar, PLC_PRG.showvar and FB1.fb1out. The application should only be able to access showvar for reading. In addition, PLC_PRG.res1 and PLC_PRG.res2 from device Dev2 should be available.

1. Double-click on the object DataSource_Dev1 below App1. Refresh the display of the Available Items in the left window. Activate the option Structured view. The window now contains a tree with all the variables of the application.

2. Select the 3 variables and move them into the right window with the aid of the arrow buttons. Also try the alternative: a double-click on an entry in the left window moves it into the right window. a double-click on an entry in the right window deletes it.

3. Click on the symbol behind showvar and thus switch the variable to b90f700902687a3ec0a8640e01ebff96_2d4bfe7c1e8f9404c0a8640e01947982 “read only”.

4. In the same way, configure DataSource_Dev2 with the variables from App_Dev2.

Attention

Check how many variables can be updated with the setting Update by Default or via the functions of the DataServer interface. Every such update produces data traffic on the communication line between the data source PLC and the DataServer PLC. If too many variables have to be updated in such a way, this can lower the refresh rate of the variables or cause an incomplete transfer!

Caution

Bit accesses used in visualizations that CODESYS executes via a DataServer connection function only if they contain literal offset specifications. CODESYS cannot process an offset specification via defined constants.

Note

If the DataServer is to update variables that do not belong to the currently active visualization, the application must use the functions of the DataServer interface. CODESYS provides this with the Data Server Interfaces library and you can call it in the IEC code via the object g_DataServer.

See also

Configuring the communication with the data source

On the Communication tab of the data source configuration editor you define:

  • the target device with which the data transfer takes place
  • how the update of the values is controlled
  • how the login to the device must take place

If you change nothing here, the data source automatically adopts the communication settings of the device of the active network path.

See also