MODBUS Address control?


burt4munger
 Share

Recommended Posts

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

?device.plc1.ReadHoldingFloat(17,28673,1)
P-ModbusRTU 0002: Illegal Data Address

Link to comment
Share on other sites

No, there isn't an explicit way of controlling the mode.  This is something I hope will be changed.  

Probably the easiest solution for you is to make a duplicate driver.  So, let's assume you are using the ModbusTCP driver.  RTU is very similar, just different file names.  Do this:

1) copy pModbusTCP.dll and pModbusTCP.dds to, say, pModbusTCP2.dll and pModbusTCP2.dds

2) edit the new pModbusTCP2.dds file with a text editor:  change the first line from:

P,ModbusTCP,PModbusTCP.dll

to:

P,ModbusTCP2,PModbusTCP2.dll

and save.

3) Restart DAQFactory

Now when you go to the device configuration, there will be two protocols, ModbusTCP and ModbusTCP2.  Create a new device with ModbusTCP2 for your new device and leave the old one as is.  By creating a copy, you have two completely separate drivers, which both just happen to talk ModbusTCP.  But one can be setup for 40000 mode, while the other uses 0 indexed.

 

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.

Guest
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.

 Share