LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

RSLinx/Datasockets block reads and writes

Hello!

I'm trying to perform block reads and writes to an Allen-Bradley PLC-5 using RSLinx and Datasockets. I can do block reads of the integer files (e.g. 'N7') and boolean (B3') files, but I cannot figure out how to perform a block write of booleans. The URLs/code I have tried doesn't generate errors, but doesn't work (story of my life...)

Does anyone have advice on how to do this? What methodology (array of booleans to words, then write to a B3 location, etc...) and how the URL should be formed?

Most examples I have found only show how to write individual elements/bits.

Currently using LV 7.1 and RSLinx 2.4.

Many thanks.

Andrew Russell
Solar Turbines, Inc.
San Diego, CA
Message 1 of 7
(4,785 Views)
Hi,
WHy dont you make use of the OPC VI's for reading data from RS linux from labview,by this you can read and write the whole chunk of data with out any problem.there are many examples for this in this forum it self.
cheers
vicky
0 Kudos
Message 2 of 7
(4,779 Views)
Hello, Vicky

Thanks for the response. I've searched through the forums and the Knowledgebase (and googled this). I have not been able to find any examples of writing whole 'chunks' of data to a PLC data table using Labview/Datasockets/RSLinx. I am going to use this response to document what I have figured out so far.

I'm trying to update a program that uses HighwayVIEW for the PLC communications. A great third party resource (that makes block reads/writes easy), but it hasn't been updated in a while, and my company now have a site license for RSLinx.

With RSLinx,OPC, Datasockets, and Labview, I can READ multiple words (both integer data tables and boolean data tables).

For example, the Datasocket URL for reading 3 integer words from an "N" data table is "opc://localhost/RSLinx OPC Server/[Controller]N7:49,L7" - which means seven words will be read from the N7 file beginning at N7:49 using OPC topic 'Controller'

Similarly for booleans, you can read them in by words - "opc://localhost/RSLinx OPC Server/[Controller]B3:2,L3 - here three 16-bit integers will be read from the PLC starting at B3:2, where the ‘2’ represents the 2nd word in the B3 data table/file.

My remaining problem is how to WRITE blocks of booleans. It looks from the RSLinx documentation ('RSLinx Online Help') that I should be able to create an array of 16 bit words and write them to the PLC with a URL that looks like "opc://localhost/RSLinx OPC Server/[Controller]B3:6,L2" - with two 16 bit words in an array being sent to the PLC starting at B3/6. This *almost* works. I convert (in the Labview code) the array of booleans to an array of 16 bit integers (U16), then write them to the PLC using the above URL syntax. I can set every bit in each word - EXCEPT for bit 15 (the high order bit)- that never gets affected in the PLC. Time to talk to Rockwell/Allen-Bradley, I think.

I can write to the boolean data tables one word at a time (URL = opc://localhost/RSLinx OPC Server/[Controller]B3:6). But this means for the 160 booleans I need to write, I'm going to have to open 10 Datasocket items. Hopefully that will be fast enough for my application.

I'm trying to update a program that uses HighwayVIEW for the PLC communications. A great third party resource (that makes block reads/writes easy), but it hasn't been updated in a while, and my company now have a site license for RSLinx.

Andrew Russell
Solar Turbines, Inc.
San Diego, California
619-544-2349
Message 3 of 7
(4,765 Views)
"This *almost* works. I convert (in the Labview code) the array of booleans to an array of 16 bit integers (U16), then write them to the PLC using the above URL syntax. I can set every bit in each word - EXCEPT for bit 15 (the high order bit)- that never gets affected in the PLC."

It might be worth doing a quick test of typecasting the U16 array to I16 (signed integers) and writing that to the URL that you have working when reading.

I had a problem with the high order bit in some Siemens datatype a few years ago and fixed it by ignoring the available documentation regarding representation. There's also a Knowledge Base item from way back about LabWindows/Datasocket that might also have (or had) bearing for LabView/DS.

Why Does DataSocket Report Different Data Types in Read Mode Than in Write Mode?
=====================================================
Fading out. " ... J. Arthur Rank on gong."
Message 4 of 7
(4,741 Views)
Donald,

That worked! Thanks. I thought I had tried different representations - maybe I missed I16.

So know we know that to write blocks or arrays of booleans, we need to convert to an array of I16, then transmit using a URL like opc://localhost/RSLinx OPC Server/[Controller]B3:13,L2 - where the OPC topic is 'Controller' and in this case, two 16 bit words are written beginning at B3:13.

Getting there, getting there...

Again, thanks.

Andrew Russell
San Diego, CA
Message 5 of 7
(4,728 Views)
Make that "know we know" to "now we know". Sheesh!



@Andrew_Russell wrote:
Donald,

That worked! Thanks. I thought I had tried different representations - maybe I missed I16.

So know we know that to write blocks or arrays of booleans, we need to convert to an array of I16, then transmit using a URL like opc://localhost/RSLinx OPC Server/[Controller]B3:13,L2 - where the OPC topic is 'Controller' and in this case, two 16 bit words are written beginning at B3:13.

Getting there, getting there...

Again, thanks.

Andrew Russell
San Diego, CA

0 Kudos
Message 6 of 7
(4,720 Views)
To add to this research a bit, I've now tried and succeeded in writng an array of floats:

To write an array of floats to sequential address in a float table (“F8”), wire the array (singles or doubles) to the DataSocket Write vi. URL will be similar to: opc://localhost/RSLinx OPC Server/[Controller]F8:0,L2

Testing has shown that for any length parameter “L2” or larger, the entire array is transmitted, regardless of the length parameter setting. Thus opc://localhost/RSLinx OPC Server/[Controller]F8:0,L2 will write a 50 element array as will opc://localhost/RSLinx OPC Server/[Controller]F8:0,L50

Key words: RSLinx OPC Datasocket URL Block Sequential Read Write Allen-Bradley PLC
Message 7 of 7
(4,687 Views)