Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I communicate with FP-1601 via .NET?

I have a VI which talks with a FP-1601, telling it to send an analog output through one of the connected modules. The VI determines what values should be output based upon a text file, which is the output of another application, which is not a VI, and not developed using any NI equipment. This works, but there are issues with the text file being left open by users, etc., which make it a non-ideal solution.

We would like to stop using the VI to parse the file and communicate, and instead, modify the application to talk directly with the FP-1601. At first, I thought this would be a simple matter of using sockets in .NET and sending the proper commands to the 1601, but from what I've been able to find on the site, the ethernet protocol used to communicate with the 1601 is un-documented and private, so we will have to go through some other route to accomplish this.

I have a fair amount of experience coding in VB, and VB.net, and some small experience using LabView Express. I have no other experience in tying the two together, or using NI's other APIs, etc. Can someone direct me as to how to send the commands to the analog out module through the FP-1601 using an application developed in Visual Studio .NET?

Thanks for your help in this,

Spencer
0 Kudos
Message 1 of 7
(4,257 Views)
FieldPoint includes an OPC server. You could use a .NET OPC client library to send data to your analog output FieldPoint module. National Instruments DataSocket supports OPC. So, one option for a .NET OPC client library is the Measurement Studio DataSocket .NET class library. The DataSocket .NET class library is available with the Professional and Enterprise versions of Measurement Studio. If you have NI Developer Suite, you have a license for Measurement Studio Enterprise.

If you do not have NI Developer Suite and you have no need for any Measurement Studio components other than DataSocket, it would probably be more cost effective for you to create your own .NET OPC client library or find one from another vendor.
0 Kudos
Message 2 of 7
(4,252 Views)
Thank you, I had not known about the OPC server or protocol.

We have the developer suite, though I had never installed the Measurement Studio. I installed it, and was able to get a project going that linked to the NI libraries, and was able to construct a NationalInstruments.Net.DataSocket object with no problems. I'm still not clear on how to actually use the OPC protocol however.

Do I need to configure the FP-1601 module at all, or is the OPC server on by default? I've had a very difficult time finding information on enabling this feature on NI's website.

Once the server is on, given a knwon IP and module, is it relatively simple to use the DataSocket class to update the module? Do I need additional classes as data wrappers, or do I pretty much write the values directly out to a specific address, and that's it, just like using a file?

Thanks for your help, this is unlike anything I've done with Labview before, so I'm not 100% confident at this point.
0 Kudos
Message 3 of 7
(4,241 Views)
I feel like I'm making headway here, so anyone who would like to clear up a few things might finish this up fairly quickly.

The only code I could find on the NI site that is close to what I need is something developed in VB6. After reviewing that, I was able to get the following code fragments, which should be able to display where I'm stumbling, and perhaps can help with what I should do.

The Code:



Dim ds As NationalInstruments.Net.DataSocket = New NationalInstruments.Net.DataSocket

'FP module doesn't have a name, but has a static IP address:
ds.SelectUrl("opc://192.168.6.64/", "Select the module to read from.") ' Refer to as line A

ds.Connect()

Dim v = ds.Data.Value
System.Console.WriteLine("Read data value: " & v)

ds.Disconnect()




Now, my questions:

When the selectUrl in line A runs, it brings up a window that shows the FP module correctly. But when I select any of the sub-nodes, the Url that gets assigned is along the lines of: lookout:\\192.168.6.64\FP\1AO\03. Is that an acceptable Url to use when I try to write out to the module? What is the difference between the opc: and lookout: protocols?

The reading code does not give any errors, but seems to always return 0. Does that code look correct to anyone who has done this before?

And finally, when I do the same procedure, but want to write a value to a given address, how would the above code change? Do I simply assign the value ala: ds.Data.Value = v, and it updates automagically, or is there some other command I am missing?

I don't see any documentation for any of the NI.Net classes, which is making this a bit harder. It seems as though anyone who has managed this once will have no problem with these issues, however.

Thanks in advance for any help you can provide.
0 Kudos
Message 4 of 7
(4,236 Views)
I'm not sure why browsing via an OPC URL yields a lookout URL. I'll look into this.

You can use either the OPC protocol or the lookout protocol over DataSocket to communicate with FieldPoint. In general, the lookout protocol is lower level and is necessary only if you need to programmatically configure your FieldPoint modules. The OPC protocol should be good enough (and easier to use) if you just need to transfer data.

The format of OPC URLs is documented in chapter 3 of the FieldPoint 1601 User Manual.

If you are interested in additional information about using the lookout protocol to communicate with FieldPoint over DataSocket, check out Using Advanced DataSocket Commands with FieldPoint Ethernet Network Modules.

The easiest way to access Measurement Studio for Visual Studio .NET 2003 library documentation is directly through the Visual Studio .NET 2003 Combined Help Collection. This means you can access it through Help>>Contents or Help>>Index, directly from within the Visual Studio .NET 2003 environment. Alternatively, you can access it standalone from the Start menu - Start>>Programs>>National Instruments>>Measurement Studio 7.1 for VS.NET 2003>>Measurement Studio Documentation. Are you able to find the help there?

Exactly how you values are sent through DataSocket depends on how you have configured the connection. You can configure the connection to AutoUpdate, which sends values as soon as you assign them to the DataSocketData object. Alternatively, you can configure for manual update, which requires that you call DataSocket.Update before the values are sent. This information is covered in the help topic Using the Measurement Studio DataSocket .NET Library. You also might want to check out the Visual Basic .NET example program, which shows how you read and write via DataSocket over dstp - \Program Files\National Instruments\MeasurementStudioVS2003\DotNET\Examples\DataSocket\ReaderWriter.
0 Kudos
Message 5 of 7
(4,231 Views)
You are getting lookout URLs because you are directly browsing the FieldPoint network module. To access the FieldPoint module through the National Instruments OPC client, you need to configure your modules in MAX on a host PC, save the configuration, and browse to the NationalInstruments.OPCFieldPoint data item on the host PC.

In your case, after saving the FieldPoint configuration on the host PC, you would change your SelectURL parameter to "opc://localhost/National Instruments.OPCFieldPoint/FP @ 192_168_6_64" to browse your network module through the OPC client software.
0 Kudos
Message 6 of 7
(4,211 Views)
Thank you for all your help. I've been able to get enough of a start that I should be able to finish this once the other developer that I am working with finishes providing me with his changes. The help documents were where you stated, but for whatever reason did not pull up automatically when I F1'ed the class name in VS, the way all the other class documentation does. But they are there, and between those, and what you've told me, I think we've got a good start.

Thanks again.
0 Kudos
Message 7 of 7
(4,202 Views)