[ Slave ID, Function code, Starting address, No. of registers/coils want to read, Data type, Index]
How to choose function code
It depends on starting address of the register or coil.
Parameter
Register / Coil Address
Function Code
Coil status
00001 on words
1
Input Coil status
10001 on words
2
Holding register
40001 on words
3
Input holding register
30001 on words
4
How to choose starting address & number of registers
For eg: if we want to read the parameters like Watts Total, Watts R phase, Watts Y phase, Watts B phase, and VAR Total from the Elmeasure EN8400 Energy meter then its address is from 40101 to 40110. so now the starting address would be 100 & no. of registers want to read would be 10.
NOTE: The number of register would be 2 in order to read single parameter of data type float, UINT32, INT32 & for rest it would be 1.
How to choose the data type
Supported data types & formats are:
Datatypes case no
Datatype
Remark
0
Float ABCD
1
Float DCBA
2
Float BADC
3
Float CDAB
Generally, the datatype mentioned in the datasheet will be without data format[A, B, C, D sequence], for example, datatype is float. In that case, use this format[default].
4
UINT ABCD
5
UNIT DCBA
6
UINT BADC
7
UINT CDAB
Generally, the datatype mentioned in the datasheet will be without data format[A, B, C, D sequence], for example, datatype is UINT32. In that case, use this format[default].
8
INT ABCD
9
INT DCBA
10
INT BADC
11
INT CDAB
Generally, the datatype mentioned in the datasheet will be without data format[A, B, C, D sequence], for example, datatype is INT32. In that case, use this format[default].
12
INT AB
Generally, the datatype mentioned in the datasheet will be without data format[A, B sequence], for example, datatype is INT16. In that case, use this format[default].
13
INT BA
14
UINT AB
Generally, the datatype mentioned in the datasheet will be without data format[A, B sequence], for example, datatype is UINT16. In that case, use this format[default].
15
UINT BA
In case of Coil status or input Coil status data type is not mandatory, we can choose default data type 0.
Note: In some exceptional cases even after selecting the [default] data format, we will observe that we are not receiving data from the slave in that scenario we have to do a trial & error by selecting a different data format until we will receive the data.
Index
Index number is nothing but a number of queries you have? The first query index is 0.