Register address issue

Hello. I came across this strange problem. I tried to read data from an energy meter with arduino uno and RS485 to TTL converter and was successful. The adresses I used in the code was 30001,30002... after that I tried to read data from a Diesel Generator. The address was mentioned in the datasheet like 40001,40002... I tried to read the 40070 register according to datasheet. But I didn't get the value. I checked with Modbus software and it was showing value in 40070. But after playing around with the code, I discovered that, when I am writing 40045 in the code, It's actuall showing the output of 40070. I need some clarity on this. Why is this discrepency?
 
Thanks for your reply. I checked the product documentation.It is showing perfectly on modbus software but not in the code. For the code I need to put address 40045. Then only it's showing the correct data.1657288994048.png
 
That documentation seems to be using 5-digit reference notation addressing (i.e. 40070 means Holding Register 70).

What Modbus software are you using? It likely also uses 5-digit reference notation addressing.

Your code may be using 0-based addressing and you may have just stumbled on another register that happens to have the same value as the one you want.

Try using 69 in your code.

Also note that it seems that the Engine Running Time parameter you're trying to read is actually a 32-bit value, so you need to read 2 registers (both 40070 and 40071) and combine those two registers to form the 32-bit value. So your code will need to read starting at register address 69 (assuming your code uses 0-based addressing) and request 2 registers.
 
Register addressing using the leading numeral 4, as in (4)0070 are assumed to be one-based decimal addresses, starting at (4)0001 [5 digit addressing] or (4)00001 [6 digit addressing]. The leading numeral, (4) in this case, is for human beings to recognize that the register is a Holding Register. The leading numeral (4) is not used as part of the Modbus message.

The alternative scheme for register addressing is zero-based addressing, starting at 0000, where addressing is frequently listed in hexadecimal. The actual value for the starting register address used in the Modbus message itself is a zero-based value that does not include the leading numeral. The leading numeral is not needed because the Function Code, which is part of the message, defines which memory area is addressed.

The one-based decimal register address (4)0070 would be converted to one-based hex value of 0x46, but the actual value in the Modbus message is zero-based, so the zero-based hex value is 0x45.

There is confusion somewhere as to which number base (decimal 10 or hex 16) is used for the displaying the register address. I find one-based hex addressing, rare; hex addressing is almost always zero-based.


45 decimal = 0x2D
46 decimal = 0x2E

70 decimal = 0x46
71 decimal = 0x47
 
Register addressing using the leading numeral 4, as in (4)0070 are assumed to be one-based decimal addresses, starting at (4)0001 [5 digit addressing] or (4)00001 [6 digit addressing]. The leading numeral, (4) in this case, is for human beings to recognize that the register is a Holding Register. The leading numeral (4) is not used as part of the Modbus message.

The alternative scheme for register addressing is zero-based addressing, starting at 0000, where addressing is frequently listed in hexadecimal. The actual value for the starting register address used in the Modbus message itself is a zero-based value that does not include the leading numeral. The leading numeral is not needed because the Function Code, which is part of the message, defines which memory area is addressed.

The one-based decimal register address (4)0070 would be converted to one-based hex value of 0x46, but the actual value in the Modbus message is zero-based, so the zero-based hex value is 0x45.

There is confusion somewhere as to which number base (decimal 10 or hex 16) is used for the displaying the register address. I find one-based hex addressing, rare; hex addressing is almost always zero-based.


45 decimal = 0x2D
46 decimal = 0x2E

70 decimal = 0x46
71 decimal = 0x47
Thanks. It worked!
 
Top