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 CORE VIRTUAL 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:
Go to the Library Manager.
Click on "Add Library".
Select the "CXA_Datalayer" library.
Press OK.
Add the library steps
The library comes with already a lot of examples ready to use. What we need to do is:
Select the library.
Go in "Datalayer_NRT".
Select "_Examples".
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:
First we set the right path.
We are reading a Float32 and the "Value" variable should be declared as a REAL;.
The method to be used should be changed accordingly.
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 😎
... View more