From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

modbus tcp read holding registers not returning requested quantity

Solved!
Go to solution

Background:  I have a customer using an ELAU motion system - they are recording data to Holding Registers that they want to be able to read on a cRIO to match up with some analog data from FPGA (I have digital handshaking happening for that).

 

LabVIEW 2010 SP1

cRIO 9074

 

Using the NI MOdbus.llb VI Library to communicate with the other system.  I can open the TCP communication no problem, and actually get SOME registers, just not ALL of the register data I want to read. 

 

What I want to do is read 330 individual holding registers U16 values.  I know how the data is being split to represent various lengths (i.e. most data items are using 2 registers to represent one 32 bit number).  I just want to read all the individual registers and parse the data in another VI to convert it to the other data types.

 

I provide the MB Ethernet Master Query (poly).vi with the starting address for the first register and then the quantity of 330.  The polymorphic instance selected the is "Read Holding Registers".  The array returned from this VI via "Holding Registers" is only 74 elements and not 330 requested.  I get no exception codes and no LV errors.  Is there some inherent limit on the number of Holding Registers that can be read?

 

I am not using the MBAP Header input (not sure if that is needed).

 

Thank you.

 

 

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
0 Kudos
Message 1 of 7
(4,772 Views)

Just talked to NI Support and it appears that the issue is on the other end at the Slave side - will report what I find.

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
0 Kudos
Message 2 of 7
(4,766 Views)

Changed Length requested to 350 and now it stops at element 93.

 

If I go to 400 I get Exception Code 02.  Address not allowed...

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
0 Kudos
Message 3 of 7
(4,757 Views)
Solution
Accepted by topic author RVallieu

Simple solution once I dug into the MODBUS Serial protocol/TCP protocol documentation available out there via Google.

 

Serial based modbus history is the limitation that carried over to TCP - the maximum amount of bytes in one data pack can only be 256 bytes.  Thus I was limited to around ~125 registers at once.

 

256 bytes = 2048 bits.  Using 16 bit registers that gives 128 registers maximum.  I went with 125 to make keeping track of totals easier.

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
0 Kudos
Message 4 of 7
(4,725 Views)

Hi

 

I do have the same issue, I am not using any instrument but I am transferring data from RT to host using MODBUS TCP lib and at the receiver side I could able to read 125 elements max; But I need to read 3000 elements.

 

Presently I am incrementing the address by 125 and reading in for loop; is there any other effective method to read?

 

Please suggest.

 

Thanks in advance!!!!

0 Kudos
Message 5 of 7
(3,180 Views)

No.  There are no alternatives.  The explanation already given in the post as the solution.

 

!!

0 Kudos
Message 6 of 7
(3,178 Views)

Yes, Thank you for the response.

0 Kudos
Message 7 of 7
(3,160 Views)