Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Modbusmaster and Input register 0


Automac Jan 23, 2013 07:09 PM

I am using a CR3000/NL115 to poll an instrument using modbusmaster via TCP/IP. I am trying to retrieve 10 IEEE 754 32-bit values starting at Input register 0. So, I am using the instruction like so:

ModBusMaster(resultcode,Socket,9600,70,4,RegNum(1),0,10,1,10)

This returns a result code of -2, indicating that the address is invalid.

If I change the starting address to 2, it retrieves the values as expected with no errors. Except that I am missing the first register.

If I change the starting address to 1, all registers are retrieved without error, although of course, the floating point values are nonsense because I am offset by 16 bits.

Is Modbusmaster not able to address input register 0?

I have tried this with mbpoll in windows and can retrieve all registers no problem so I don't believe this to be a problem with the instrument.

The CR3000 has OS v25.

Thank you for any insight or workarounds anyone can provide. I really want that first register :)


Sam Jan 25, 2013 12:47 PM

ModBusMaster(resultcode,Socket,9600,70,4,RegNum(1),0,10,1,10)

will create an invalid query

ModBusMaster(resultcode,Socket,9600,70,4,RegNum(1),1,10,1,10)

will create a valid query of

[Modbus TCP Header]
46 (address 70)
04 (function 4)
00 (register offset of 0, i.e. start with first register)
00
00 (20 registers, i.e. 40 bytes)
14
[CheckSum]


So there is something else going on. This query is asking for data starting with the first register.

For troubleshooting, limit your query to just 1 value and try to retrieve the first register. If you are not getting the value you expect, make sure that the source really is a floating point number (two registers). Then make sure that your destination is CRBasic is a float and has not been declared/forced to be a LONG. If it still doesn't look right, try using the optional VarDataType parameter of 2. If that still doesn't work then capture the actual data traffic and post it back here.

While you logger is attempting that, use a terminal emulator to bring up the CR3000 prompt, type W [ENTER] [13] [ENTER] [ENTER] N [ENTER]. You will then see the communications over TCP/IP and thus be able to record the modbus traffic in hex.


Automac Jan 25, 2013 10:15 PM

Using a starting register of 1 and setting VarDataType to 2 fixes everything. Thank you very much!

The description in the instrument's manual says:

MODBUS Floating Point Input Registers (32-bit IEEE 754 format; read in high-word, low-word order; read-only)

I guess I never looked at the VarDataType parameter as I was receiving correct data when I used a starting address of 2. Still not sure I understand why this is. I'll work that out another day. It's working now.


Sam Jan 26, 2013 04:02 PM

VarDataType controls how the logger interprets the word order of the data. The help has a few errors, but if VarDataType = 0, the logger expects the word order to be (low/high)(CDAB).If 2, (high/low)(ABCD). Seems to me since that is the standard, we should consider making it the default.

Log in or register to post/reply in the forum.