modbus addressing


Recommended Posts

new post:

these work
device.quad.ReadHoldingFloat(100, 28673,1)
device.quad.readHoldingU16(27, 4,1)

then this works
device.quad.readholdingu16(50, 42305,1)

after that, the first one fails
device.quad.readholdingu16(100, 28673,1)
with this error:
P-ModbusRTU 0002: Illegal Data Address: LoopQuadMain Line 220 in PLCSteam
until daqfactory is restarted

I need to be able to read both devices, the read 50002 first trick seems to make no difference.


What should I do?


old post:   So i have read and understand the various permutations on modbus addressing, that is, 0 based, 30-40000, and 50000+ (i am ignoring the 400001 ones).  My system has 5 or 6 modbus devices from different manufacturers, and I have had DAQFactory using some 42006 kinds of addresses, where I think it is subtracting stripping the 4 and subtracting 1 before it sends the address down the wire, and all was well.  Now, I have a device that seems intent on wanting the 0 based addressing, and fails access to any any addresses until I use the "write to a modbus address over 50000" trick to force the scheme back to a 0 index approach...then the new device works fine, but all the other addresses are now off by one.  I really don't want to have to go and find all the locations that specify modbus address constants and subtract one from them, because i will have to go back and test each and every different system to make sure it still works.  Is there an explicit control of the scheme, so that I can specify which address mode to use for a given device access?  What i see now is even for testing, if I read an address over 50000, the mode changes to 0 index, all the prior devices begin to fail, and the only way to change it back is to restart the program.

this fails, until I read an address over 50000, then this works fine, but other addresses like 42006 start failing

P-ModbusRTU 0002: Illegal Data Address

Link to comment
Share on other sites

The thing is, the Modbus driver setting for whether you are using 40,000 notation or 0 indexed is global across all Modbus devices of a particular protocol (i.e. all ModbusTCP devices or all ModbusRTU devices).  So, if you read a value > 50,000 you will lock the entire driver into 0 indexed mode.  That means you have to make sure and use 0 indexed mode on all your Modbus devices.  In your case, it looks like you have a single device that you got working in 40,001 mode, so 28673 was stripped to 8672.  Then you enabled 0 indexed mode, and so 28673 was left at 28673, which apparently on your device is invalid.

So, in general I personally just pretty much always use 0 indexed mode and if I have to work with a device whose manual uses 40,001 notation, I just do the math in my head and translate it to 0 indexed.  Just strip the 10,000's place and subtract one.  So 40,001 becomes 0.  30,503 becomes 502.  28673 isn't in the 40,001 notation space, so would tell me that the manual is already 0 indexed, but often device manufacturers are clueless about this whole thing.  The 40,001 space only includes 1 to 19,999 and 30,001 to 49,999.

BTW: the 40,001 notation is purely a documentation thing.  In the actual protocol, 40,001 is actually sent as 0.  The device itself never sees 40,001.



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.