05-16-2018 04:39 AM
Hello,
First of all, I am using Labview 2017 and trying to make a connection to an OPC DA server.
I think one of the standard ways to do this is :
*Create an OPC Client I/O Server at the Project screen or via block diagram interface
*Create shared variables of the tags that you are planning to read at the project screen using "Create bound variables"
OR
*Use Create Shared Variable block diagram from DSC library.
I managed to use the "create bound variables" function and is consistently successful connecting & changing tags of a remote OPC Server with the shared variables. But annoyingly, after creating a shared variable at the block diagram section programmatically (getting a list of the tags at the server and creating shared vars for them) some of the tags get "subnormal" and i can't read or write onto them.
I want to ask 2 questions :
*I can see the tags after creating an OPC Client I/O server at the "Distributed System Manager". Is there a way to getting the list of the tags and read & write on them WITHOUT defining shared variables for each tag?
*What can cause the tags to get subnormal after defining shared variables for them? I need to delete and redefine an OPC Client I/O server when this happens - which fixes the issue.
Thanks for your help.
SG
Solved! Go to Solution.
05-17-2018 01:02 PM
Hi SG,
Can you attach the code that creates the shared variables? When you say the tags become "subnormal", what data do they display when you attempt to read?
LabVIEW uses shared variables to bind to each tag so you can easily access them in the development environment (this is the step where you select "create bound variables" in the LabVIEW Project). You cannot access tags in LabVIEW directly.
Angela L.
05-18-2018
02:00 AM
- last edited on
05-29-2024
11:02 AM
by
Content Cleaner
Hello Angela,
Thanks for the reply. I assumed I had to create shared variables, but needed to make sure.
You can see the attached code. It is a snippet of the code in https://forums.ni.com/t5/Example-Code/Dynamic-OPC-Server-Discovery-and-Connection-Reference-Example/...
You can also see the shared variables / tags with the "subnormal" status (dism.png showing shared variables, dism2.png showing tag values).
You can't read / write them at the "subnormal" status.
05-21-2018
10:31 AM
- last edited on
05-29-2024
11:06 AM
by
Content Cleaner
SG,
The subnormal state indicates that an OPC-bound tag has either received a bad quality from the OPC server, or has failed to write to the OPC tag. What is the source of the OPC server tags (are you communicating with a PLC/other field device, or simulating?) The issue may be due to timing (ex: you're writing to the PLC faster than it allows, so the driver sets a bad quality on its tag in the OPC server). Do the shared variables show up properly in other OPC clients (ex: Quick client?) You can also enable the diagnostic file of the OPC Client I/O server, which will log the OPC communication to see if it provides more information.
Debugging NI OPC Servers with DSC and DataSockets: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019XhySAE&l=en-US
Angela L.
05-22-2018 04:30 AM
Hi Angela,
First of all, I am using Siemens WinCC OPC Server. I have no problems reading / writing to most tags via shared variables. I don't think it's a reading / writing issue. I think there is something buggy about creation / binding of this variables. I know this, because If i create the values directly with "Create bound variables" item, there is absolutely no problems reading them afterwards.
Because of this, I have changed my method to create the variable. I used to create the variables at the I/O server directly by using DSM vi "create shared variable". Now I am trying to create variables at the local library, edit their parameters and publish them. But again, I have been getting different errors.
If I create the local variable and change the variable "network binding" "access type" and "URL" parameters with the program attached, It gives " −1950679007 - A value is missing for the Enable Aliasing option. " error. If I create the variable, click on "Enable Aliasing" checkbox, enter a random url and save / deploy it, even though I change the Aliasing option back to unchecked, the code works. Somehow, someway, clicking on the menu item "enable aliasing" works different than "Network binding".
Is there a direct way to do the exact thing as "Enable Aliasing" checkbox does programmatically? Or is there a way to create a copy of the variable (with the enable aliasing checked) at the same library with a different name? I could just create one working library item and copy it inside the library.
05-24-2018 07:05 PM
@salihgulsen
If I create the variable, click on "Enable Aliasing" checkbox, enter a random url and save / deploy it, even though I change the Aliasing option back to unchecked, the code works. Somehow, someway, clicking on the menu item "enable aliasing" works different than "Network binding".
Do you save and deploy again after you change the Aliasing option back to unchecked? I believe the programmatic options are not exactly the same as the GUI options (since we don't see an enable aliasing method), but I think the end function should be the same.
Also could you attach your program you're using here?
05-27-2018 10:58 AM
Do you save and deploy again after you change the Aliasing option back to unchecked?
* Yes, this is what i do :
If i create the shared var without checking the enable aliasing and then try to attach it to an URL, It gives the "missing access type" or "a value is missing for the enable aliasing option" errors with regards to the selected element sequence in the variable property node as shown in the mat.png and missenable.png .
But if I enable aliasing, deploy and try to run the program, it works.
If i deselect enable aliasing and deploy and run the program it works again! It is very annoying!
I also added the program. Just delete the variable, create a new one under the library without the enable aliasing to see it.
05-31-2018 04:03 AM
I really don't like to bump a topic. But I really need to solve this ASAP.
Is there a way to create a copy of a library variable? I'd just create a manual library - Enable Aliasing checked.
And copy it.
Otherwise I'd create x values beforehand with Enable Aliasing checked and rename / edit the URL of them - which is not a good method.
05-31-2018 11:47 AM
Hi salihgulsen,
Since this issue is fairly in depth and requires a deeper look on our end, please go to ni.com/support and create a service request. If you're not sure how to do this or don't have a service package, please direct message me your contact information and I can do this for you.
Nick
Applications Engineer
National Instruments
06-20-2018 03:35 AM
I have solved my problem! You do not have to use the shared variables to access to OPC Tags!
If you have the DSC package, there is a block called DataSocket Select URL.vi
This block enables you to connect to the OPC tag you selected directly.
There is an example for this in find examples : Monitor OPC Items with Datasocket.vi