06-10-2022 01:47 PM
Hi,
Is it possible to start PLC Function, Method, FB or somthing different by DataLayer or OPC UA and wait for response?
In IndraWorks I used SymbolConfiguration option "Support calls to Function, FB..."
But I can't find it in PLC Engineering
What is the best way to achieve this?
Best regards,
Andrey
Solved! Go to Solution.
06-14-2022
02:36 PM
- last edited on
11-21-2022
09:59 AM
by
TheCodeCaptain
Hello Andrey
With the V1.14 we have FBs (CXA_OpcUAClient) that can start methodes at our servers (like XM, MLC, ...)
But our ctrlX CORE OPCserver doesn't support methodes within the PLC (Symbol-Configuration). This will come end of this year.
Regards
Jochen
06-15-2022 01:32 PM
Hello Jochen
And what about DataLayer, is it possible to start PLC method from C++?
I'm working on C++ app and want to process some task on the PLC side and wait for result of this task. To do this I need a way to run Method or Function in the PLC.
Best regards,
Andrey
06-20-2022 07:28 AM
One easy way would be to define an interface like PLCopen. Add start and finish Booleans and an input and output variable to the Data Layer.
06-21-2022 08:36 AM
Hi CodeShepherd
Thanks, I'll try.
11-11-2022 04:03 PM - last edited Friday
When you want to call a method of a PLC FB via Opc UA, there are some restrictions:
Basic example for FB
create object GVL
//Elements are available via OPCUA even when they are not used in program
{attribute 'linkalways'}
//set access rights to read & write for all variables within VAR_GLOBAL
{attribute 'symbol' := 'readwrite'}
VAR_GLOBAL
fbMethodCall: FB_METHOD;
END_VAR
create object Function Block
FUNCTION_BLOCK FB_METHOD
VAR
///counts the number of calls
uliCntMethodCall: ULINT;
END_VAR
Add method to Function Block
METHOD mCallableViaOpcUa : INT
VAR_INPUT
iIn: INT; // currently only 1 input param supported
END_VAR
VAR_OUTPUT
iOut: INT; // currently only 1 output param supported
END_VAR
// Implementation
// counts the number of method call
uliCntMethodCall := uliCntMethodCall + 1;
iOut := iIn + 1; // increase input by 1
mCallableViaOpcUa := iOut; // return iOut
Press “Build” to update the “Symbol Configuration”, than activate the options:
Meaning of access icons:
|
Read only |
|
Read & execute |
|
Write only |
|
Write & execute |
|
Read and write |
|
Read, write and execute |
|
Execute |
|
|
Set access rights (1) for parent fbMethodCall element: “read & write” or more
Click on “…” to open window, for setting access rights of child element method “mCallableViaOpcUa” to “execute”
Click “Online> Login” to PLC with a download. You might have to do a “Build> Clean” before.
Ua Expert is a well-known OpcUA test client. It can be used to verify if the method is correctly written into the symbol configuration. See “chapter Install & Start UaExpert” for installation and first start documenatation.
Ua Expert is a well-known OpcUa testclient. You can download it from: https://www.unified-automation.com/downloads.html
Start the installation program; use the default settings on every page select next installation page until installation is finished.
Starting the UaExpert the first time, a message is shown that a certificate must be created.
Insert your organization in the yellow marked field, keep the other defaults and press “OK”.
Click on Server>Add to open window “Add Server”
HINT: The UA Expert sometimes replaces the IP address with the name of ctrlX, then the communication sometimes could not be established. To check this, right click the server item and select “Properties…”
Replace the name in the Endpoint Url with your IP-address. opc.tcp://192.168.1.1:4840. Press “OK” to close the window. To connect or disconnect select in menu: Server/Connect or Server/Disconnect.
Start ctrlX CORE web page. Login
Goto “Settings/Certificates & Keys/OPC UA Server”. Click on “…” and “Trust” the certificate.
Quit UaExpert (File>Quit) and restart it.
Select “Server>Start”
Select the connection previously defined.
When the connection is successfully established the available OpcUa nodes are displayed in the window “Address Slave”. The screen shoot below shows the location of the PLC symbols. “Root>Objects>datalayer>plc>app>Application>sym”
Tuesday
Hello @HmiGuide ,
thank you for the great documentation on how to call PLC methods via OPC UA.
I created the exact same example as you show us above to see if it´s working. I copied the same FB but the PLC-Programm identify the token METHOD as unexpectedly (see screenshot) which causes errors.
Futhermore (without Method and errors) I can´t find the FB in the symbol configuration. I set the settings as you mentioned and pressed build. I also tried to remove the symnol configuration and insert it new. Unfortunately it didn´t work. Do you have a documentation how to set up a FB with a Method correctly?
I use the CtrlX WORKS Version 1.20.4.
I hope that you have a solution for my problem. Thanks in advance.
Tuesday
I'm currently on a buisiness trip and not able to check your problem. As I not really use the feature daily it will take me some time, to get familiar with it and verify your problem.
Wednesday
Ok, do you know a contact person who is familiar with this feature? This topic is really important for us right know. Thank you!
Thursday - last edited Thursday
Hello,
I tried to reproduce your method on my 1.20 system.
At first I created a new FB called "FB_updateOrder" with an input and output variable.
and added a method named "mCallableViaOpcUa" and impelementet the "output = input +1" logic.
I created a new GVL named "GVL_MethodTest"
and configured the symbol configuration.
After a download I connected to via UA Expert and I was able to call the function/method.
best regards
Christian
Thursday
Hello@E_Stapel
there is a basic misunderstanding from your side. You can't just copy the method code into the declaration part of the FB.
To create a method within a FB right click the FB, "Add object"> "Method."
After adding the method it is visable in the tree (see picture below)
Friday
Hello @NoRisk4Project and @HmiGuide ,
thank you for the great help. In the past I tried already the Method Object in the same way you did it but I couldn´t find the Method in the symbol configuration. Now, I reproduced your example method in the exactly same way. Unfortunately I still can´t find the Method / GVL in the Symbol Configuration (See attachment). I hope you can help me. Thank you so much!
Friday
CoDeSys has changed the display of variable lists in the symbol configuration at some point. In the past everything was always displayed. Meanwhile the GVL's are hidden, which contain the pragma "attribute symbol".
Friday - last edited Friday
Hello,
please clean your application by selecting "Build" and "Clean all". If this is done, rebuild your application with "Generate Code".
Please check the symbol configuration after this sequence again ...