Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Read and Write OPC UA variables on a remote Siemens S7 PLC server
Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1786912] Tue, 15 May 2018 12:39 Go to next message
Daniel Ng is currently offline Daniel NgFriend
Messages: 19
Registered: October 2017
Junior Member
Dear all,

I've gone through the entire OPC-UA tutorial under the documentation and was successful in reading and writing the variables created with a forte OPC-UA server locally on Windows 10.

However, I am trying to interface with a Siemens S7-1500 PLC which has its OPC-UA server enabled. The difference between the forte's server version and Siemens's that I can tell is that the NodeIds have been declared differently. Forte's is a numeric id while Siemens's is a string.
index.php/fa/32826/0/
index.php/fa/32829/0/

How should I declare the endpoint url on the Client's FB ID to connect this variable on the Siemens?

Endpoint Url used:
opc_ua[opc.tcp://172.21.5.1:4840#/Objects/3:plcMagazineBack/Outputs/xG1_MB20]

Siemens server URL: 172.21.5.1
Variable node: xG1_MB20 that is under Objects/plcMagazineBack/Outputs/
index.php/fa/32828/0/

I've attached some pictures to show more details on the variable node from UA Expert and how I had tried to connect initially. I've played around with various versions for the endpoint url but was always hit with the error message "Could not find the method node on the server.."
index.php/fa/32827/0/

Any help is greatly appreciated!

Thanks!

Regards,
Daniel
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1786956 is a reply to message #1786912] Wed, 16 May 2018 11:20 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
opc_ua[opc.tcp://172.21.5.1:4840#/Objects/3:plcMagazineBack/Outputs/xG1_MB20]


Hi Daniel,
my first guess would be that you should edit your browsePath for FB ID input. You should specify the namespace index for each node in the path. From the screenshot attached you should at least use 3:xG1_MB20 as it is in the namespace 3. When you just write the variable name without a namespace index, forte uses namespace index 1 and, i suppose, fails to find the corresponding node.

Cheers,
kirill
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1786958 is a reply to message #1786956] Wed, 16 May 2018 11:50 Go to previous messageGo to next message
Daniel Ng is currently offline Daniel NgFriend
Messages: 19
Registered: October 2017
Junior Member
Hi Kirill,

I had already added the namespace index in the beginning. It's there after the root folder /Objects/ and before plcMagazineBack. Should I also be putting it before the String variable name xG1_MB20?

Thanks.

Regards,
Daniel
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1786961 is a reply to message #1786958] Wed, 16 May 2018 12:49 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
You need to specify it for each node (except /Objects node), which is outside namespace 1. Supposing everything in your BrowsePath is in namespace 3 your ID should look as follows:

opc_ua[opc.tcp://172.21.5.1:4840#/Objects/3:plcMagazineBack/3:Outputs/3:xG1_MB20]
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1787023 is a reply to message #1786961] Thu, 17 May 2018 12:11 Go to previous messageGo to next message
Daniel Ng is currently offline Daniel NgFriend
Messages: 19
Registered: October 2017
Junior Member
Hi Kirill,

Thanks the for advice, I've checked and indeed the namespace for all the objects in the BrowsePath is indeed 3.

My problem is that Siemens has the nodeIDs for the objects and variables classified as strings and I guess I would need to add double quotes for the variable name "xG1_MB20"? Like so?

 opc_ua[opc.tcp://172.21.5.1:4840#/Objects/3:"plcMagazineBack"/3:"Outputs"/"xG1_MB20"]


However, simply adding quotes in the ID field doesn't work with 4diac as it would misinterpret the double quotes throwing an error Element type must be followed by either attribute specifications, ">" or "/>". Is there a escape character I could use to include the quotes? I've tried backslash and " since it seems to be reading in XML but to no success.

Thanks again.

Regards,
Daniel
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1787025 is a reply to message #1787023] Thu, 17 May 2018 12:23 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 634
Registered: January 2014
Senior Member
Hi,

I'm not sure how to provide strings to the siemens opc ua server but if you want to have quotes in IEC 61131-3 string literals you need to escape them with a $ sing. 4diac should be capable of handling this.

Alois
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1787029 is a reply to message #1787025] Thu, 17 May 2018 12:50 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
Hi,
no, you shouldn't use the quotes. You specify the browse path, not the nodeId, so it's no matter if your NodeId's are Numeric or Strings - both should work.. you specify the browse path without the quotes like that:
opc_ua[opc.tcp://172.21.5.1:4840#/Objects/3:plcMagazineBack/3:Outputs/3:xG1_MB20]
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1787036 is a reply to message #1787029] Thu, 17 May 2018 14:03 Go to previous messageGo to next message
Daniel Ng is currently offline Daniel NgFriend
Messages: 19
Registered: October 2017
Junior Member
Dear all,

Unfortunately, for some unknown reason, I've tried the browse path as suggested
opc_ua[opc.tcp://172.21.5.1:4840#/Objects/3:plcMagazineBack/3:Outputs/3:xG1_MB20]
but the error OPC UA: Could not find the method node on the server still persists.

Also, trying to escape with the $ sign wasn't recognised either.

Thanks alot.

Regards,
Daniel
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1787037 is a reply to message #1787036] Thu, 17 May 2018 14:09 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 634
Registered: January 2014
Senior Member
My question espcially to the opc ua experts would be: as Daniel tries to read a remote variable, is the error message he is getting a real error or only the process of determining if a method or a variable node should be handled?
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1787040 is a reply to message #1787037] Thu, 17 May 2018 14:49 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
@Daniel: in these cases, I normally try to to add the nodes one by one and look at which node it fails. So, for example if you try to add
/Objects/3:plcMagazineBack

and trigger the client block. If forte finds the node then it'll output an error message like "the node should be VARIABLE or METHOD", then you can add the next node in your path and see (an error message on this step is ok, as it means that forte found a node but it's of ObjectType, not a varible or method). If you, however get OPC UA: Could not find the method node on the server it means forte wasn't able to find the node in the namespace. Then double-check the BrowseName in OPC UA Expert.

@Alois: not sure if I understand your concern correctly, but from my point of view it's the real error. Just the more appropriate text for an error message would be OPC UA: Could not find the method/variable node on the server

[Updated on: Thu, 17 May 2018 14:50]

Report message to a moderator

Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1787049 is a reply to message #1787040] Thu, 17 May 2018 20:01 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 634
Registered: January 2014
Senior Member
Quote:
@Alois: not sure if I understand your concern correctly, but from my point of view it's the real error. Just the more appropriate text for an error message would be OPC UA: Could not find the method/variable node on the server

My question was more as the client automatically detects if its a method or a variable node. It could be that it first checks if it is a method node. as it is no method node it outputs an error and tries if it is a variable node and my succeed. Therefore no further output. But I must confess I haven't looked into the implementation and I don't know how the identification of the node type is done in OPC Ua.
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1787055 is a reply to message #1787040] Fri, 18 May 2018 02:32 Go to previous messageGo to next message
Daniel Ng is currently offline Daniel NgFriend
Messages: 19
Registered: October 2017
Junior Member
Dear Kirill and Alois,

I believe the Client FB is working as it should be and you are right. I've tried both

opc_ua[opc.tcp://172.21.5.1:4840#/Objects/3:plcMagazineBack/]


opc_ua[opc.tcp://172.21.5.1:4840#/Objects/3:plcMagazineBack/3:Outputs/]


and got the Remote node class for client needs to be of class VARIABLE or METHOD. error that you mentioned which means that it managed to browse to those nodes.

I'm quite sure now that the only thing missing is to add the double quotes and 4DIAC needs to parse it as part of the variable name. It keeps giving the error that it cannot be found because all of the variable names Siemens created has double quotes enclosed within.

index.php/fa/32846/0/

@Alois, is there any other way to add the " as part of the ID input of the Client FB apart from $?
index.php/fa/32847/0/

Thanks!

Regards,
Daniel
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1787118 is a reply to message #1787055] Sat, 19 May 2018 06:00 Go to previous messageGo to next message
Daniel Ng is currently offline Daniel NgFriend
Messages: 19
Registered: October 2017
Junior Member
So I went to modify the opcua_layer.cpp file to allow me to add the double quotes to the variable name but I still cannot access that variable. ><

index.php/fa/32860/0/

Btw, BG20 is just another variable i tried to access.

[Updated on: Sat, 19 May 2018 06:01]

Report message to a moderator

Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1787142 is a reply to message #1787118] Sat, 19 May 2018 16:15 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
hi,

i still don't think you need to specify those quotes for the browse path. If you look at this example

https://www.eclipse.org/forums/index.php/fa/32829/0/

you access the Incrementer/Incremented/OUT variable via the browse path without any quotes, while in uaExpert its browse path is 1,"OUT" with quotes. What I'd look at further is what Siemens server returns after UA_Client_readNodeClassAttribute, recently have some problems with another servers calling this method. It could be that it doesn't get the nodeClass correctly and then the forte won't call the method, as the node class will be unspecified. If possible, we can have a quick chat on that next week, I'd be really interested in finding out what's going on.
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1793912 is a reply to message #1787142] Mon, 20 August 2018 10:38 Go to previous messageGo to next message
Ahsan Zia is currently offline Ahsan ZiaFriend
Messages: 26
Registered: July 2018
Junior Member
Dear all,
I am working on similar kind of problem.

I am attaching snapshot of my Forte, UA Expert, Server.
It looks like the client (4diac) is connected to the server (JS).
The Forte window is not giving me any message regarding the connection.
Please check my files and let me know that I am on the right path for my server/client connection.

opc_ua[opc.tcp://130.230.16.25:8088#/Objects/1:eq_states/2:EQ_V101]
localhost:8088

thanks.
BR,
Ahsan
  • Attachment: Forte.JPG
    (Size: 53.81KB, Downloaded 20 times)
  • Attachment: 4diac.JPG
    (Size: 149.82KB, Downloaded 27 times)
  • Attachment: node.JPG
    (Size: 68.28KB, Downloaded 15 times)
  • Attachment: UA expert.JPG
    (Size: 169.76KB, Downloaded 23 times)
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1793917 is a reply to message #1793912] Mon, 20 August 2018 13:08 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
Hi Ahsan,

one thing that i can see from the screenshots provided is that ID field in your FB is configured wrong.

Quote:
opc_ua[opc.tcp://130.230.16.25:8088#/Objects/1:eq_states/2:EQ_V101]


you miss PLC1 Object here, which is a part of your browse path.

Second thing that I'd check is why the monitoring in 4diac is not working. Do you run your forte locally on your pc?

BR,
Kirill
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1793921 is a reply to message #1793917] Mon, 20 August 2018 14:01 Go to previous messageGo to next message
Ahsan Zia is currently offline Ahsan ZiaFriend
Messages: 26
Registered: July 2018
Junior Member
Dear Kirill,
Yes, you have understand my problem now.
I am using.
opc_ua[opc.tcp://130.230.16.25:8088#/Objects/1:PLC1/2:eq_states/2:EQ_V201]
As the browser path, but nothing changed.

Yes, I am running it locally.
My JS server runs at
localhost:8088. Also give me the simulator on the same address in the browser.


Thanks for your support, I am waiting for your update.

BR,
Ahsan
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1793932 is a reply to message #1793921] Mon, 20 August 2018 16:34 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
Your forte output contains no opc ua errors so far. I'd say, you need to find out why your monitoring is not working first. For doing so, please look into <your 4 diac workspace foder>/.metadata/.log that will give you a hint, what could be wrong with your monitoring. Or simply post your .log file here.

[Updated on: Mon, 20 August 2018 16:53]

Report message to a moderator

Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1793934 is a reply to message #1793932] Mon, 20 August 2018 17:00 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 634
Registered: January 2014
Senior Member
Regarding your monitor error. Could you be so kind and also post a screenshot of your system configuration. Do you have several devices there with the same MGR_ID? If this is the case 4diac-ide has issues with monitoring. You should only have one device per MGR_ID.
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1793936 is a reply to message #1793934] Mon, 20 August 2018 19:07 Go to previous messageGo to next message
Ahsan Zia is currently offline Ahsan ZiaFriend
Messages: 26
Registered: July 2018
Junior Member
Dear All,

I have one device per MGR_ID.

index.php/fa/33666/0/

Please check the screenshots below, and log file.

opc_ua[opc.tcp://130.230.16.25:8088#/Objects/1:PLC1/2:eq_states/2:EQ_V201]

Thanks for your support, I am waiting for your update.

BR,
Ahsan Zia



  • Attachment: SysConf.JPG
    (Size: 188.01KB, Downloaded 174 times)
  • Attachment: sys.JPG
    (Size: 99.00KB, Downloaded 13 times)
  • Attachment: UA expert.JPG
    (Size: 206.66KB, Downloaded 11 times)
  • Attachment: .log
    (Size: 294.43KB, Downloaded 19 times)
  • Attachment: forte3.JPG
    (Size: 52.87KB, Downloaded 17 times)
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1793954 is a reply to message #1793936] Tue, 21 August 2018 07:20 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 634
Registered: January 2014
Senior Member
thanks for all this information. There are a few questions that are coming up:
1. how many fortes are you running? I see the output in the 4diac-ide and I see the console where you separately start forte. Could it be that you are deploying to the wrong one?
2. I see several rather strange issues in your log. could you be so kind and activate automatic error reporting. You can find it under Windows -> Preferences -> General -> Error Reporting. With this we would get these issues in a data base where we can anaylze it and make the next 4diac version even more stable and you don't have to manually report each issue.

Cheers,
Alois
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1793956 is a reply to message #1793954] Tue, 21 August 2018 07:32 Go to previous messageGo to next message
Ahsan Zia is currently offline Ahsan ZiaFriend
Messages: 26
Registered: July 2018
Junior Member
Dear All,
I am deploying only one forte at a time.
Forte is deploying fine for the example under the OPC UA tutorial section.
what are the prime problems by looking at my log files? Can you propose an idea quickly how to fix my problem? I want solve this soon.
I have done the error reporting.


Thanks.
BR,
Ahsan Zia
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1794007 is a reply to message #1793956] Wed, 22 August 2018 09:47 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 101
Registered: February 2016
Senior Member
Some ideas and questions after reading the thread:

1- Regarding monitoniring, did you actually enable monitoring on the system by Right Click on it -> Monitor System or did you just try to watch directly?
2- How do you trigger ARG1.REQ?
3- Do you want to read and write thevariable? You're using a client with one input and one output. Try using a CLIENT_0_1 which have not data input, and would be enough to read the variable.
4- In a different test, use a PUBLISH_1 to write to the variable.

Jose
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1794010 is a reply to message #1794007] Wed, 22 August 2018 10:14 Go to previous messageGo to next message
Ahsan Zia is currently offline Ahsan ZiaFriend
Messages: 26
Registered: July 2018
Junior Member
Hi,
I tried to monitor application by using the enable monitoring tool. "Could not find the method node on the server 'opc.tcp://130.230.16.25:8087"
Right Click >Arg1 >trigger event.
I have only CLIENT_1 & CLIENT_2_1 in my 4Diac, Using 1.9.1 4Diac, no CLIENT_0_1 FB,
will using an older version of 4diac solve my problem?

Thank you.
Br,
Ahsan
  • Attachment: Screen.png
    (Size: 266.43KB, Downloaded 19 times)
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1794012 is a reply to message #1794010] Wed, 22 August 2018 11:59 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 634
Registered: January 2014
Senior Member
Unfortunately I didn't see anything specific to your problem in the logs. But there are some issues that need some investigation. Older versions of 4diac will not change this. I would see they would make it worse. It is very strange that monitoring is not working for you. Never saw this in that way.

Regarding your problem. If you have a look at the OPC UA docs there are two kinds of Client FBs used there. One with inputs and outputs and one with only one single output (CLIENT_0_1). The first is used to call a method on a server. Therefore you also get this error message. As far as I understan dyou would like t read a value from your server. For that you need to use the CLIENT_0_1. For writing a publish_1 has to be used.
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1794080 is a reply to message #1794012] Thu, 23 August 2018 09:44 Go to previous messageGo to next message
Ahsan Zia is currently offline Ahsan ZiaFriend
Messages: 26
Registered: July 2018
Junior Member
Dear All,
I have tried with different setups and client FB combos but still getting "Could not find the method node on the server " error message.
Are there any configuration issues of 4Diac, when trying connecting to a remote server, like i am trying to do?
Because it (Client/server method) works fine when implementing examples in 4Diac documentation,
There are a few people having the same issues on this forum but no concrete solutions to solve this issue.

Thank you
BR,
Ahsan
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1794186 is a reply to message #1794080] Mon, 27 August 2018 06:19 Go to previous messageGo to next message
Jose Maria Jesus Cabral Lassalle is currently offline Jose Maria Jesus Cabral LassalleFriend
Messages: 101
Registered: February 2016
Senior Member
hi,

did you try with PUBLISH_1 to write the variable?

If you don't have CLIENT_0_1, you could create one. These networking FBs are generics, meaning that forte will know how to handle them, so you could create a Service FUnction Block called CLIENT_0_1 and use the same names and types of another CLIENT FB, but only provide RD_1 and not SD.

Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1794204 is a reply to message #1794186] Mon, 27 August 2018 13:17 Go to previous messageGo to next message
Ahsan Zia is currently offline Ahsan ZiaFriend
Messages: 26
Registered: July 2018
Junior Member
Hi,
Yes, I have tried PUBLISH_1 to write data but it is unable to connect to my serve.

Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1794629 is a reply to message #1786912] Tue, 04 September 2018 08:10 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
One important thing to note here is, as we're using translateBrowsePathToNodeId method, to address a NodeId you need to specify the path via BrowseName. It happens that NodeId and BrowseName have different namespace indices. In that case, one need to pick the namespace index of the BrowseName (see pic, highlighted).
  • Attachment: Capture.PNG
    (Size: 61.10KB, Downloaded 7 times)
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1794944 is a reply to message #1794629] Tue, 11 September 2018 12:55 Go to previous messageGo to next message
Ahsan Zia is currently offline Ahsan ZiaFriend
Messages: 26
Registered: July 2018
Junior Member
Dear All ,
I am trying to develop composite FBs for my application.
Initially, I was thinking to make composite blocks for each of the nodes, to read and write the values, but I guess that is not possible?
If I go by the procedure by implementing the same logic for each nodes, it will be quite messy, there will be dozens of tabs at the same time to operate the application.
Please suggest me some ideas..

Thank you

BR,
Ahsan
  • Attachment: NwBlck.JPG
    (Size: 208.80KB, Downloaded 6 times)
  • Attachment: app.JPG
    (Size: 232.57KB, Downloaded 8 times)
  • Attachment: compo.JPG
    (Size: 193.12KB, Downloaded 4 times)
Re: Read and Write OPC UA variables on a remote Siemens S7 PLC server [message #1794952 is a reply to message #1794944] Tue, 11 September 2018 14:15 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 634
Registered: January 2014
Senior Member
Dear Ahsan,

Composite Blocks should be possible. Also if you you specify the datatype for you in and outputs (in your example. BOOL) you don't need the BOOL2BOOL blocks.

Alois
Previous Topic:Build Forte error
Next Topic:Help needed Traffic Light Tutorial
Goto Forum:
  


Current Time: Fri Sep 21 11:28:05 GMT 2018

Powered by FUDForum. Page generated in 0.03213 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top