micrologix 1400 and modbus rtu woes.

B

Thread Starter

blackj

I need to communicate with a micrologix 1400. When i attempt to do so, I get error code 3.

I am new to modbus messaging and haven't had alot of experience with it, so thank you in advance for any help you can give me.

I am trying to poll 1 analog value in register 40001.

Comms are at 9600, 8N1.

Byte order is Bigendian, type is r4 (is this correct for the micrologix 1400?) As for the request, im using function code 3 with a byte length of 2.

Modbus rtu message that goes out to the device is:
01 03 9C 41 00 01 FA 4E

response from device is:
01 83 03 01 31

any help would be appreciated.
 
J

Jerry Miille

The response you are getting is an error response (the most significant bit of the function code is ON), that is your transmitted function code was a hex 03 and the response function code is a hex 83. The following byte is the error code and it is 03 hex that means a data value is incorrect. That is not exactly correct because it is the address that is incorrect. You are asking for register 40001 but the 40000 part of this address is implied by the function code (03 Read Holding Registers).

Just change your address to 1 and you should be good to go!

Jerry Miille

Miille Applied Research Co., Inc.
http://www.miille.com/
 
Is the register really 40001, or is it actually holding register 1? Some people like to use numeric prefixes to indicate the address type, where "4" stands for holding register. It's like using "I" for inputs and "Q" for outputs on IEC style PLCs.

The prefix isn't actually part of the address though. It also isn't actually part of Modbus as there is nothing in the specification that allows it. It's just something that some people unfortunately like to do when writing documentation, and it has probably caused more confusion than anything else.

An exception code of "3" should indicate an incorrect number of registers. However, you are only asking for 1 register. I suspect that the AB PLC is returning an incorrect error code where it should be returning a "2" for an address error.

With Modbus, the type of register is selected by using the correct function code, and function code 3 is for reading holding registers. I would suggest trying it again with register address 1 instead of 40001.
 
One other point to add to this is the register may be "0" rather than "1". According to the Modbus protocol, the first register is register "0". However, some people like to call the first register "1".

What this means is that you may need either register "0" or register "1" depending upon whether the documentation follows the numbering system used by the Modbus protocol, or whether someone just happened to prefer counting from "1".
 
Top