LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Rslinx OPC

I want to read/write blocks of data from an AB PLC5 via RSLinx OPC server.
I've configured the RSLinx server sucessfully and am able to read and write single registers. I also am able to write individual bits.

 

For writes I'm using the URL opc://localhost/RSLinx OPC Server/[NITest]N7:3,L9
with a Boolean array connected to the write datasocket, works fine.

 

For reads I've tried URL opc://localhost/RSLinx OPC Server/[NITest]N7:0,L3.
The VI runs without errors but don't know how to extract individual registers.

Need help reading individual registers

0 Kudos
Message 1 of 10
(6,282 Views)

dpaulovich,

 

How are you reading this data?  Are you using LabVIEW?  If so, are you using Data Sockets or DSC?  What exactly do you mean by "extract individual registers"?

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 2 of 10
(6,251 Views)

- I'm using Labview 9

- I'm using Data Sockets

 

The Data Socket read works with the URL of opc://localhost/RSLinx OPC Server/[NITest]N7:0,L3

From what I've read that should return the values in 3 registers N7:0 to N7:2. Once the Data Socket reads them

how do I look at the individual registers. Do I have to put them in array some how or what?

 

Attached is my VI to do the read/writes from Rslinx

0 Kudos
Message 3 of 10
(6,239 Views)

dpaulovich,

 

What do you mean by "Data Socket read works"?  What results do you currently get?  What results are you expecting?

 

I see that you have a double wired into the type (variant) input on the Data Socket Read.VI is this the type you are expecting from these 3 registers?  It looks like you are then taking that double and converting it to a I16 to display in both the water tank and Deg F indicators.

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 4 of 10
(6,218 Views)

- When I run the VI with the URL of opc://localhost/RSLinx OPC Server/[NITest]N7:0,L3 I get no error.

   It appears like its finding the items, although I have no way of proving it.

 

-  When I run the VI with the URL of opc://localhost/RSLinx OPC Server/[NITest]N7:0

    the VI gets the value from N7:0 and operates the bargraph in the water tank.

 

- The write works as shown. I can set/reset bits in the PLC

 

What I want to do is read a block of registers from a AB PLC5 using the RSLinx OPC server and Labview.

Once the register values are in Labview I need to be able to use the values in individual registers.

0 Kudos
Message 5 of 10
(6,211 Views)

dpaulovich,

 

What do you get when you run the first URL?  Is there anything in the indicator?

 

Is the value you recieve with the second URL what you would expect?  Is that data stored in multiple registers or just one?

 

What happens if the parameter you put into the read is an array of doubles?

 

What is supposed to be in these registers?  It could be that multiple registers are needed to make one value.  You might try changing the constant to something smaller like an I8 or something.

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 6 of 10
(6,189 Views)

Jason

 

Let me start over!!

 

Can you tell me how to read and write blocks of data

from an AB PLC5 using an RSLinx OPC Server and Labview

0 Kudos
Message 7 of 10
(6,183 Views)

dpaulovich,

 

Have you looked through the following DevZone Articles? 

 

http://zone.ni.com/devzone/cda/tut/p/id/4626

http://zone.ni.com/devzone/cda/tut/p/id/3224#toc2

 

The first explains how to set up your RSLinx OPC Server with your AB PLC.  The second one explains how to use DataSockets to read from an OPC server.  You may have to check the documentation of your PLC to get the exact item names and syntax for reading specific registers, but other than that this should pretty much cover everything.  If you are having specific problems after looking at these, fill us in with some more details and maybe someone on here can give some advice.

0 Kudos
Message 8 of 10
(6,169 Views)

David

 

Thanks for the info, I've already looked at these pages.

I'm able to read and write single registers to/from the PLC just fine.

 

What I would like to do is read/write blocks of data.

Can't seem to figure that out.

 

I've attached a Vi that I developed to do the reading and writing to the PLC.

 

Any help will be appreciated.

0 Kudos
Message 9 of 10
(6,162 Views)

dpaulovich,

 

In order to do a block read the best suggestion I can offer you is to place your read in a for loop and pass an array of individual registers paths and use the auto indexing to control how each location is read.

 

You also might want to implement some sort of timing/syncronization between the loops as currently they can run whenever they like.  Making sure they read one after the other might help.

Message Edited by Jason_D on 12-14-2009 03:33 PM
Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 10 of 10
(6,131 Views)