Modbus RTU Slave CSV Files

From Control Solutions IoTServer Documentation
Jump to navigation Jump to search

Modbus RTU Slave CSV Files

The format of a CSV file is the same for both Modbus RTU Slave and Modbus TCP Server. The term "Server" is synonymous with "Slave".

Modbus Server Example – Primary Server

The following illustrates a CSV file for the primary instance of Modbus Server, which can be assigned to either an RTU or TCP channel. There can be only one instance of a primary server, and this instance establishes the correlation of local objects to Modbus registers. Secondary instances of Modbus servers will refer to the primary server’s mapping of objects to register addresses, optionally with remapping (see below).

Begin,Modbus,ServerMaps
LocalObj,RegAddr,RegFormat,RegSize,Unsigned,LittleEnd
1,0,INT,1,Y,N
2,1,INT,1,N,N
3,2,INT,4,N,Y
4,6,REAL,2,N,Y
5,8,REAL,2,N,Y
6,10,CHAR,10,N,N
7,20,CHAR,10,N,N
End

MODBUS (server/slave) SERVERMAPS Section

LocalObj – Specifies the local object number that contains the data that will be provided to external Modbus clients or masters requesting this Modbus “register”.

RegAddr – Raw 0-indexed address to be assigned to this register.

RegFormat – Format of the data contained in the Modbus register(s), not used by the protocol, but used by the gateway to interpret what the raw increments of 1 or 16 bits should mean. Select format from the following table.

Format Label Format description
“None” No format defined
“Bit” Single bit, used ONLY for RegType Coil or Disc
“Int” Integer (size and whether signed are defined by labels below)
“Real” Floating point (single or double precision)
“Char” Character string with 2 ASCII characters per register
“Mod10” Mod10 format, can be 2, 3, or 4-register, specific to Schneider Electric meters

RegSize – Register size refers to the number of consecutive input or holding registers should be read for a value greater than 16 bits. A 16-bit value would have size of 1, a 32-bit value would have size of 2, and a 64-bit value would have size of 4. Single precision Real (32-bit IEEE 754 floating point) would be size 2, and double precision Real (64-bit IEEE 754 floating point) would be size 4. If format is Mod10, then valid sizes are 2, 3, or 4 – check manufacturer’s documentation if Mod10 is noted. Register “size” for a character string will be character count divided by 2 (plus 1 of string length is an odd number). RegSize is not used for Coil or Disc types.

IMPORTANT: If the register size is more than 1, then the next assigned register address must be incremented by this count.

Unsigned – Indicate “Y” if unsigned, or “N” if signed. Defaults to signed integer. Has no effect on RegFormat other than Int.

LittleEnd – Used when RegSize is greater than 1 to indicate what order the registers should be interpreted in. Enter “Y” to indicate that the lowest numbered register contains the least significant portion of data. Enter “N” or omit to indicate that the lowest numbered register contains the most significant portion of data. Although Modbus protocol itself is not inherently “Little Endian”, many devices operate that way due to Intel processors being inherently Little Endian. Modbus protocol does not stipulate what the register order should be when multiple registers are treated as a single data entity. Therefore, the user is required to pay attention to this.

Modbus Server Example – Secondary Server

The following illustrates the CSV file or section for remapping register addresses in an instance of a Modbus server. The remapping can be optionally included in the primary instance, but is usually more commonly used in a secondary instance of server. The remapping effectively creates a different view of the same set of registers defined by the primary server. For example, in the CSV below, Modbus register 0 is seen at address 100 by any client requesting registers from this instance of the server. Different instances of the server will normally run on different ports in the system.

Begin,Modbus,ServerRemaps
LocalAddr,RemoteAddr
0,100
1,101
2,102
6,106
8,108
10,110
20,120
End

MODBUS (server/slave) SERVERREMAPS Section

LocalAddr – The local Modbus register addressed assigned by the primary server. This address must exist in the register assignments made by the primary server.

RemoteAddr – The remote Modbus register address that this local address should be viewed as.