LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OPC devices - end user adding a new devices

Solved!
Go to solution

I have to create an application that connects to an OPC compatible device and read tags (variables) into my program.  I can do this by creating a shared variable.  What I need to do is add other devices.  It seems apparent that all devices have the same tag names.  When the program runs, my customer wants the ability to select one or multiple devices to read/write data to.  What the program really is meant for is logging data using citadel, setting up alarms, graphing, report generation etc. and will make good use of the DSC module.  The way I envisioned the program to work is that the user pushes a button to add an OPC device to the program, a dialog box comes up with all available OPC devices, the user selects one and hits OK.  At this point the program comes alive, logging and graphing data, generating alarms etc.

 

What I see that needs to happen is that when a device is selected,  a group of arrays is populated. Each element is a separate device and each array is a separate variable.  Ex:

 

 

Array1
bool var 1
[0] = device 1
[1] = device 2
[2] = device 3

 

 

 

Array2
num var 2
[0] = device 1
[1] = device 2
[2] = device 3
This will make it dynamic in size because there is no set number of devices they want connected.  In order to take advantage of the DSC module I need shared variables.  It's almost like I need to dynamically create shared variables as new devices are added.  But then how will I use these shared varaibles in my program if they aren't created until the program runs?  I am stumped.  Any ideas?
Thanks
Matt

 

0 Kudos
Message 1 of 6
(2,500 Views)

Not so simple to do what you want. I already do that in my program, but you need to translate some parts to understand, since it is in Portuguese.

Some features that I use are not documented in LabVIEW.
You will also need some functions of the  OpenG Toolkit  and Database Toolkit installed on your machine.

I'll give you some functions that make it up to you to analyze what is important, because in my case I get the data that comes from the database and recreate the whole structure, since processes, I / O Server, Variable and Alarms

 

The function located in %ProgramFIles%\National Instruments\Shared\System Manager\8.6\vi\vi.lib\variable\tagger\opcClient\SysMan_GetOPCServerList.vi gives to you the OPC list.

0 Kudos
Message 2 of 6
(2,488 Views)

This has been somewhat useful.  Now that I have the OPC server name, how do I read the tags on that server or at least read what the tag names are?Once I have the tag names, I can figure out how to bind shared variables (programmatically created) to these tags.  What functions of the openG toolkit do you use?  What functions of the Database toolkit do you use?

 

Thanks

Matt

0 Kudos
Message 3 of 6
(2,460 Views)

Matt:

 

You can actually create shared variables and processes programmatically using DSC. If you look in the functions palette, you will probably be interested in "DSC Module --> Engine Control." Using the functions in there, you can actually create libraries/processes and variables, as well as list and deploy them.

 

I believe there are several examples for programmatically browsing OPC servers, as well. If you open the example finder in LabVIEW ("Help --> Find Examples"), browse to "Communicating with External Applications --> OLE for Process Control (OPC)."

 

Additionally, if you search for "DSC" in the example finder, you should find many more examples using some of the major features of the DSC module.

 

Hope that helps out a bit!

Caleb Harris

National Instruments | Mechanical Engineer | http://www.ni.com/support
0 Kudos
Message 4 of 6
(2,450 Views)
Solution
Accepted by topic author Mattjk

Hi,

 

To bind variables programatically you will need add the I/O server first on your process the functions srvl_load_db_es.vi and srvl_atualizar_es.vi make it. The function "subCreate and Configure IO Server.vi" creates a new I/O Server and isn't documented by NI.

 

To create add variables programatically on your process the function srvl_atualizar_vm.vi make it. This function makes calls to functions of the DSC and configures all options step by step.

 

To browse for a OPC address you can use the function "Datasocket Select URL.vi" or you can use a tool in the attachment "LogosBrowser.zip" below.

 

Download All
0 Kudos
Message 5 of 6
(2,442 Views)

Thanks for the help, this is useful

0 Kudos
Message 6 of 6
(2,428 Views)