Industrial Communications

cancel
Showing results for 
Search instead for 
Did you mean: 

Modbus 0-indexing

Solved!
Go to solution

Hi all,

 

Got a problem with slave that I want to get data from (holding registers) via modbus TCP/IP

I tested the communication with modpoll and the only way I got data from it was when I used option

-0            First reference is 0 (PDU addressing) instead 1

From this: https://www.ni.com/en-no/innovations/white-papers/14/the-modbus-protocol-in-depth.html

i assume the problem lies in data address start values:

The difference between memory addresses and reference numbers is further complicated by the indexing selected by a given application. As mentioned previously, holding register one is at address zero. Typically, reference numbers are one-indexed, meaning that the start value of a given range is one. Thus, 400,001 translates literally to holding register 00001, which is at address 0. Some implementations choose to start their ranges at zero, meaning that 400,000 translates to the holding register at address zero.

 

Is there an implementation of Modbus protocol in LabView out there that includes this option?

I am using NI Modbus Library 1.2.1.42 and I do not see anything like that in there.

 

Regards

 

0 Kudos
Message 1 of 9
(7,687 Views)

Hi,

 

Common 'problem'

 

In the DCS world the first holding register is 40001 (Not 400001) 

The 4 is indicating Holding registers and the 0001 is the register. 

 

This is translated into the ModBus command 3 with address 0000.

 

In 'my world' this standard and always confusing. 

 

Kees

0 Kudos
Message 2 of 9
(7,644 Views)

Surely this is just a matter of adding or subtracting one from the address?

0 Kudos
Message 3 of 9
(7,638 Views)

The register I am interested is 42048. If you mean simply addressing 42047 then the answer is - no. This does not work.

0 Kudos
Message 4 of 9
(7,632 Views)

If it says 42048 you should use ModBus command 3 and read address 2047.

A lot of devices use command 3 and 4 equally.

0 Kudos
Message 5 of 9
(7,622 Views)

@TheOtherDude wrote:

The register I am interested is 42048. If you mean simply addressing 42047 then the answer is - no. This does not work.


Sounds like your problem if something different then.

0 Kudos
Message 6 of 9
(7,617 Views)

As far as I can see I am currently using 3 (Read Holding registers). Address 2047 contains just FFFF.

When trying to use 4 (reading input registers) an error is generated:

Modbus Error: Illegal Function. This function is not implemented on the server.
Function 4

 

But that was interesting suggestion.

0 Kudos
Message 7 of 9
(7,612 Views)

So your device doesn't support ModBus command 4. 

You read address 2047 with ModBus code 3 (which is for DCS 42048) and you read 0xFFFF

So your device response is correctly !! If the address was not valid you would receive an error code.

Maybe it is not the data you expected but at least this is what your device generates as an answer.

0 Kudos
Message 8 of 9
(7,605 Views)
Solution
Accepted by TheOtherDude

ID1OT

Oh well I was casting everything into DBL and trying to invent new math and apparently 16 + 16 is not 64.

One just has to realize that SGLs want too be useful too...

 

Case closed.

0 Kudos
Message 9 of 9
(7,589 Views)