10/18/2024

ctrlX Data Layer NRT: read and write basic data using the PLC functions

Disclaimer

We are going to see the basic steps that we need to perform, read and write ctrlX Data Layer NRT variables with the PLC app.

Prerequisites and equipment used

  • Having a ctrlX CORE or ctrlX COREVIRTUAL with version 2.0+
  • PLC app and ctrlX WORKS installed 
  • Basic CODESYS knowledge 

Procedure

Step 1: Open a new PLC project and create some "shared NRT nodes" 

This is pretty standard and has been covered by many guides. The steps are the following: Set up a ctrlX PLC project to publish variables to the ctrlX Data Layer.
Here is the variable which is available in the datalayer and set to number 23 manually.

Easy Variable Datalayer

Step 2: Add the right library, setup the project, see the examples

Just for laziness, I create two new PRGs in order to be able to use the examples without changing the variables names: 

Program Configuration
 

Now we have to add the right library in the system which is really simple. We just need to:

  1. Go to the Library Manager.
  2. Click on "Add Library".
  3. Select the "CXA_Datalayer" library.
  4. Press OK.

Add the library steps

 The library comes with already a lot of examples ready to use. What we need to do is:

  1. Select the library.
  2. Go in "Datalayer_NRT".
  3. Select "_Examples".
  4. Select the needed example and copy the content inside a program to be executed.

Nothing more easy 😎

Find the Examples

Step 3: Read and Write Example

Lets start from the read example. I have manually set my variable to 23 using the front-end, just in order to be able to read something!

23 is the number

 We have to modify some parts:

  1. First we set the right path.
  2. We are reading a Float32  and the "Value" variable should be declared as a REAL;.
  3. The method to be used should be changed accordingly.
  4. We set the execute to true in order to trigger the function any cycle.

Modifications

 The Program, once loaded, is able to read the variable.

Result

The same changes have been made to the Write example. 

Write Example

 

Have Fun 😎

Latest published/updated articles

Types
How-to
Categories
PLC