08-07-2021 02:58 PM
I have an OPC-UA server on Siemens S7-1200 PLC and I'm trying to read the data with the OPC-UA Client Toolkit from LabVIEW 2019
The software UaExpert shows the data without any error (see image below)
But LabVIEW does not show any data and I'm getting the error code:
2155085824 |
BadTypeMismatch |
The value supplied for the attribute is not of the same type as the attribute's value. |
Here's my VI (LabVIEW 2019):
Am I doing something wrong of LabVIEW 2019 (with OPC-UA Toolkit "ni-labview-2019-opcua-toolkit-x86_19.0.0.exe") does not Struct DAta Type?
My VI was created according to the example "OPC UA Demo.lvlib:Data Access Client.vi"
Solved! Go to Solution.
08-08-2021 09:27 AM - edited 08-08-2021 09:30 AM
Hi!
No, you are not doing anything wrong.
OPC UA supports basic datatypes like booleans, integers, floats, strings, timestamps and arrays of these, as well as complex data structures. To my knowledge, the typedefs of those complex data types can also be read from the server. However, LabVIEWs OPC UA toolkit only supports the basic data types.
Most of the nodes shown unter "Server" in UA expert are such complex data types and are not readable by LabVIEW. This is even true for your node, though it is "just" an enum.
But the nodes unter "Server" are not essential. (Though, I understand the idea to start there, since the "Server" node is common to all OPC UA servers.)
Did you try to access the "real data" from the PLC program?
08-09-2021 08:18 AM
Thanks for the answer
I can read data from PLC like bool, float32, int16, int32 and string (valid for scalar and array).
But I can't read any struct data, even if all the elements in the struct are the same time (see fig. below)
Obs.: I can read these data by addressing only one element of the struct at time, e.g., "ServerInterfaces.OPC.Tipo_de_ensaio.Escolhe_FADIGA" (ns=4;i=30) instead of "ServerInterfaces.OPC.Tipo_de_ensaio" (ns=4;i=27)
But read one data at time is much slower than read the whole struct.
Add to this the fact that almost all data from the Siemens libraries are in the "Struct" form (see fig. below)
So, read struct is "must have" in the OPC-UA Toolkit. NI needs to implement this in the new version
08-10-2021 08:32 AM
Hi!
well, this is not really LV related.
Inside the OPC server, a struct is not a data container. It is just a node which contains child nodes.
Also UA expert does not read the struct data, it knows which nodes are inside, reads those, and displays the data just as if it can read the struct directly.
Regarding speed:
Inside OPC, multiple nodes can be read with a single request to the server. While one still has to pass the list of node IDs to be read, only one request is sent to the server, and only one reply with all data is returned.
Further more: You are creating a subscription, that is, you are informed whenever the value changes. If you make a subscription to an entire struct, you would be notified whenever a single value inside changes and get many many many change notifications. This is also not desired.
For your communication with the PLC, you should have a subscription on a nodeId which indicates that data is available, then collect that data via normal read, and maybe write back a value to notify that the data is read from the PLC.
12-02-2021 05:07 PM
Hello Sebastian
I'm here again, now trying to read "real data" and getting the same error 2155085824 (Bad_typeMismatch)
The data that I'm trying to read is the Siemens DTL (Date and time)
According to Siemens: "An operand of data type DTL has a length of 12 bytes and stores date and time information in a predefined structure."
The pdf attached shows details about the DTL
Does LabVIEW OPC-UA supports this data type?
12-03-2021 04:27 AM - edited 12-03-2021 04:32 AM
That's again a structure. And the same thing applies as mentioned before. This is a Siemens specific DateTime element to match their internal DateTime elements. The official OPC UA DateTime datatype is a signed 64-bit integer representing the number of 100ns intervals since midnight January 1, 1601 GMT. This is a base type that the OPC UA Toolkit should be able to handle and convert into a LabVIEW Timestamp.
Your Siemens DataTime struct needs to be handled as individual elements with the OPC UA Toolkit too just as any other struct type. It's not practical to expect the Toolkit to understand the zillions of different complex datatype timestamps that all the different PLCs use.
06-02-2022 04:22 PM
Sorry to resurrect an old thread, but I'm having a similar issue.
I'm not able to read struct members. If a struct is just "a node which contains child nodes", how to I create a NodeID for a child node? I have tried adding a dot and the struct member name (i.e. "ns=4;s=|var|Folder1.Folder2.StructNode.StructMember1"), but I just get Bad_NodeIdUnknown.
Is there some specific syntax for this?
08-07-2023 09:27 AM
Hi,
I'm also having the problem, that I can't read the single values of structures because they have no own ID. Is there a syntax to get the values in a Labview Client.
For example: structure "LocalizedText","ResultDataType","ResultMetaDataType"
Hope anyone here solved the problem and could help
08-08-2023 08:34 AM
As said, it's simply not possible. I'm stuck with LV2017, so may be there's something new in current versions.
I've written this simple tool which allows to browse the OPC node tree in LV similar to UAExpert. Click a node in the tree, and it tries to read it as variant and to browse it for child nodes.
It is simply so that there are nodes which are not accessible by LV. And sometimes, a node itself is a struct, but counts as single node. UAExpert is able to decode and display such structs because the OPC server also provides information on how to do so (See top-level node Types), but LV has no way to do so. There's not much more than reading variables as basic data types / arrays of such or as variant. And if even variant fails, there's no way to read it. So, if this tool cannot read it, LV just can't.
Quite interesting: A LV OPC server also has some special items in its Server node, which are readable by UAExpert, but not LV itself...
I don't know much about the server side, especially about PLCs. Maybe, there is some option to publish the data in an other way?
03-20-2024 01:06 PM
I have seen a similar issue in reading OPC data for booleans that are contained within a struct or within a word in the PLC.
The OPC servers seems to read the first bit of the word correctly, or the first boolean in the struct. Any other booleans don't read correctly in the OPC client. I don't think this has anything to do with LabVIEW, but is within the OPC client itself. Distributed System Manager shows me the same information as the OPC quick client, so it seems the issue relies within OPC.
Oddly enough, if you have multiple numeric values in a struct, that works just fine.