Modbus Function Code

3

Thread Starter

386956599

Hi,

I am using citectSCADA to read current/voltage value from power meter via Modbus TCP/IP protocol.

I figured out Modbus function 03 shall be used to get the reading.

Things I do not understand is:
function code 03 shall be used to read holding register (analog out)
function code 04 shall be used to read input register (analog input)
In my case, I am trying to read analog input.

Can anyone explain why code 03 shall be used rather than 04?

Thanks,
Jason
 
W

www.colwaysolutions.com

Holding registers are the most universal 16-bit register, may be used to read or write, and can be used for a variety of things including configuration data, inputs, outputs, or any other usage for 'holding' data.

On the other hand Input registers are read only. You can't write to the input registers.

For your application Input register does the job.
 
Function Code 4 is used to read analog inputs that come from an analog to digital converter and represent an analog input wired to the slave device. You cannot write to these input registers.

Function Code 3 is used to read general purpose "holding" registers that are not derived from analog inputs.

Function Code 16 is used to write values to these general purpose "holding" registers.
 
Thanks for your reply.

But how come current/voltage of the power meter (other example is the speed reference of VSD) is not analog input?
 
C

Colway_Solutions

Current/voltage of the power meter is Obviously analog input, where you're just reading the current/voltage values, and hence, you're not doing any writing operation back to the power meter. So obviously you can use input register to read the values.

It is always a good practice to verify communication of the MODBUS TCP over MODBUS via a 3rd party MODBUS master application. You can use Modbus protocol tester which is available for free of download from here:

http://www.colwaysolutions.com/modbus-protocol-tester.php
 
>But how come current/voltage of the power meter (other
>example is the speed reference of VSD) is not analog input?

It is logical that the data ought to be an analog input. however if you've found that it works with function code 3, reading Holding Registers, the missing link here is that is how the firmware in the drives was implemented. Someone decided that was the thing to do, even though it is a writeable modbus memory type (holding registers).

I've seen devices where they would do this, but not implement the function codes to write to holding registers, OR, fail the write if you tried to write to certain holding registers and not to others.

Sometimes its done by the h/w mfg to simplify - just stuff everything that isn't a bit into holding registers.

One of those things that as long as you've successfully obtained the data you need, best to just keep moving as you'll probably run into this again somewhere else. Hope this helps clarify.

John
 
Hi Jason,

Modbus function code 4 (read input register) will read the input data values that are present at the analog inputs of the IO module. It is a read only register because it is only written to by the internal circuitry of the IO module.

Modbus function code 3 (read holding registers) reads and writes the output holding register value (i.e. the value that is being written to the analog output of the IO module). It is a read/write register because you write to it to change the output value, and you can read it to verify it's contents.
 
Top