LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OPC communication help

Hello,

 

I am attempting to connect to RSLinx OPC server in order to read the PLC data into an array and save to spreadsheet.  I have the RSLinx setup i just can't get Labview to see the server.  Are there any examples out there that would work?  I'm running LV2017 on a 64-bit machine.

0 Kudos
Message 1 of 4
(2,891 Views)

Please give more details. Do you get any error message? Is the server on the localhost? Are you trying to read a group of items as an array?

Can you see the server with the "Browse to OPC Item.vi" example?

As far as I know, to read an item you only need to open a Datasocket connection with the proper URL in input. URL prefixes depend on the OPC server.

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 4
(2,851 Views)

Ok, I spent some time playing with the example code I found.

 

I am able to open the URL and see the tags, I can grab one tag at a time and see the data.

What would help out a lot is to be able to put all of the tags of interest into an array to be read and then output an array to be sent to spreadsheet.

 

Seems like there are a few different ways to do this, I would appreciate some ideas on how to do this in the most efficient way possible.  I'm interested in (16) data tags, would it be possible to use base address, since they are all the same, and just run it through a loop to increment the URL by (1) each time it executes?  The data is TC data and does not require high speed read/capture.

 

Any ideas on how to do this would be appreciated.

0 Kudos
Message 3 of 4
(2,841 Views)

Hi there,

 

If you're using datasockets, then follow the screenshot in this KB to read multiple tags and put the data into an array:

 

DataSocket Connections for OPC Items

 

This pretty much does exactly what you said. It opens a datasocket connection to the URL of every tag you want to read and then reads them one at a time in a for loop. Easy peasy!

 

You might also look at the LabVIEW DSC Module, which lets you map OPC tags into LabVIEW shared variables.

 

-Jordan

0 Kudos
Message 4 of 4
(2,834 Views)