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: 

Reading Modbus Holding register address not return correct values

Solved!
Go to solution
Hi all Labview developer,
 
We using DSC Modbus Master library to read holding register device modbus address from 49401 to 49415 but the return register values not as we expected compare to value we get from ModScan64 tool (correct value).
It look like we need to offset first address to 49400 to get correct register value.
Anyone can explain why we need to offset the address by 1.
 
Thanks in advance.  
 
 

Modbus read holding register.pngModScan64.PNGModbus read holding register fp.png

0 Kudos
Message 1 of 5
(2,658 Views)

Hi srh1985,

Modscan works on the concept of 1 to n while LabVIEW works on the concept of 0 to n-1.

0 Kudos
Message 2 of 5
(2,639 Views)

Sorry. Can your pls explain more.

0 Kudos
Message 3 of 5
(2,622 Views)
Solution
Accepted by topic author srh1985

Subtract 1 from the register address.

 

When you have an address like 449401, the first 4 indicates it is a holding register.  (It's actually rather unusual to have the rest of the digits as high are they are.)

 

You drop the initial 4, and subtract one.  It is not a "LabVIEW" thing, but an underlying part of the modbus standard.  So when you have list of holding registers, they'll start at 40001  (or in this case 400001), but that is actually address 0.

 

So 449401 is actually addressed as 49400.

 

Think of it as an array being 1st element, 2nd element, 3rd element  (1-based),  but those are index 0, index 1, index 2  (zero-based)

0 Kudos
Message 4 of 5
(2,607 Views)

Thanks.

0 Kudos
Message 5 of 5
(2,601 Views)