(Optional) Creating a Modbus Device Interface (XIF) Definition (Release 3.1)
For SmartServer 3.2 and higher, see (Optional) Creating a Modbus Device Interface (XIF) Definition.
You can create a device interface (XIF) definition for a Modbus TCP or Modbus RTU device. To create a Modbus XIF definition, you create a CSV file with a .mod extension that defines the device interface for a Modbus device interface (XIF). The Modbus XIF specifies the Modbus device interface name, program ID, and manufacturer, and lists all the registers to be polled or updated by the SmartServer. To create the file, you will need the manufacturer's documentation for the Modbus device register addresses and contents implemented by the device. Â
This section consists of the following:
Creating a Modbus XIF File
The name of the Modbus XIF file, without the .mod extension, is the name of the Modbus XIF. The extension must be .MOD or .mod. You cannot use a compound extension name such as .mod.csv. Â
A Modbus XIF file has the following three sections.
- A file type specification that identifies the file as a Modbus XIF file.
- A product details section that specifies the program ID, version, product name, and manufacturer for the Modbus device.
- A datapoint list that specifies the datapoints on the device to be available to the SmartServer. The first line of the datapoint list is a header with column headings for a datapoint list.Â
The following figure illustrates the top portion of a Modus XIF file.
The following sections describe the Modbus XIF file sections.
- (Optional) Creating a Modbus Device Interface (XIF) Definition (Release 3.1)#File Type Specification
- (Optional) Creating a Modbus Device Interface (XIF) Definition (Release 3.1)#Product Details
- (Optional) Creating a Modbus Device Interface (XIF) Definition (Release 3.1)#Datapoint List
File Type Specification
The file type specification for a Modbus XIF file is the following:
#filetype,Modbus_xif |
If you open a CSV file with this line in Excel, it is displayed as two cells, one with #filetype and one with Modbus_xif.
Product Details
The product details identify the product specified by the Modbus XIF file. The product details specification has the following contents:
#program_ID,<Program_ID> |
If you open a CSV file with these lines in Excel, each line is displayed as two cells.
Specify the details as follows:
<Program_ID> – (required) a 64-bit hexadecimal number used for identifying resource definitions. An example Modbus RTU program_ID is 9FF4A2150040DB00. The program ID can optionally have colon and hyphen separators. You can create a program ID using the SPIDCalculator as described in Device Type Definition.
- <Version> – (optional) version of the device.
- <Manufacturer> – (optional) manufacturer of the device.
- <Description> – (optional) name of the device. This value can match the name of the .mod file.
Following is an example product details specification for a Schneider PM5563 Modbus meter:
#program_ID,900014153503DB00 |
Following is an example product details specification for an Advantech Adam 4150 DIO module:
#program_ID,9F0096052804DB00 |
Datapoint List
The datapoint list that specifies the datapoints on the device to be available to the SmartServer. The first line of the datapoint list is a header with column headings for a datapoint list. Following is an example datapoint list with a single datapoint defined:
Point Name,Presentation Type,Modbus Datatype,Function Code,Address,Direction,A',B',C',Range Min,Range Max,Block Name,inFeedback,Marker Value,Description (optional) |
The following table describes the column contents for the datapoint list:Â
Parameter | Required/ Optional | Description |
---|---|---|
Point Name | Required | Name of the datapoint. You can provide a descriptive name to identify the datapoint. The name is required, and must be unique for block containing the datapoint (see Block Name below). |
Presentation Type | Required | IAP type that identifies how the data appears in the SmartServer. You can select a data type at www.lonmark.org/nvs/. |
Word Order | Optional | Specifies the 16-bit word ordering within multi-word values. Values can be blank, big, or little. big or blank specify big-endian word ordering. little specifies little-endian, 16-bit word ordering. |
Byte Order | Optional | Specifies the 8-bit byte ordering within multi-byte values. Values can be blank, big, or little. big or blank specifies big-endian ordering. little specifies little-endian ordering.  Byte ordering specification controls the ordering of bytes within the entire value if the Word Order value is blank, and controls byte ordering within each 16-bit word if the Word Order value is specified as big or little. |
Bit Order | Optional | Specifies the bit ordering within each byte. Values can be blank, big, or little. big specifies big-endian bit ordering. little or blank specifies little-endian. |
Modbus Datatype | Required | Specifies how the data is encoded in the Modbus registers. Select a value based on the Modbus register type and encoding as follows:
|
Function Code | Required | Specifies the read function code of the datapoint. Enter one of the following values: Do not specify the FC05, FC06, FC15, and FC16 write function codes. The SmartServer automatically determines the write function code based on the read function code. |
Address | Required | The Modbus register address in the device.  Specify Modbus 0-based addressing without a block number. Some devices specify thei addresses using Modicon addressing with 5 or 6 digits, where the first digit of Modicon addressing represents the memory block, and the remaining digits representing the register address offset by 1. The memory blocks are 0 for coils, 1 for discrete inputs, 3 for input registers, and 4 for holding registers. Do not include the memory block in the address specification, and subtract the offset. For example, if the Modicon register address is 400001, do not include the 4, and subtract 1 from the address of 1. The resulting address is 0. |
Direction | Required | Specifies if a datapoint is read-only (R) or read-write (RW). Datapoints with function codes FC02 and FC04 are required read-only registers and must specify R in this column. Datapoints with function codes FC01 and FC03 are read-write points; however, their writability may be disabled. To do so, fill the column with R, otherwise, enter  RW. |
A', B', C' | Required | Specifies the scaling parameters for a datapoint, such that the scaled value = A' * 10^B' * (raw value + C'). For example, if the the Modbus register value is a UINT16 encoded value with a resolution of .01 and is to be presented as a floating point value, select an IAP type using based on a float base type and use 1,-2, 0 as the scaling values. For this example, if the register value is 6000, the converted value is 60: 1 * 10^-2 *(6000 + 0). If scaling is not required enter 1, 0, 0 as scaling values. |
Range Min | Optional | Specifies the minimum scaled value for the datapoint. If the scaled value of the datapoint is less than the specified value, an error is logged. |
Range Max | Optional | Specifies the maximum scaled value for the datapoint. If the scaled value of the datapoint is greater than the specified value, an error is logged. |
Block Index | Optional | Specifies a numeric block index, starting with index 0. You can use the block index to create multiple blocks of the same type. For example if you have a device with 8 digital outputs, you can define 8 blocks, each named DO, using indexes 0 through 7. Block index 0 is used if you do not specify an index value.  (This is available with SmartServer 2.8 and higher) |
Block Name | Optional | Specifies the block name for the datapoint. You can use blocks to group related datapoints together. You can provide a descriptive name to identify the block. You can specify the same block for multiple datapoints to specify that those datapoints are members of the same block. (This is available with SmartServer 2.8 and higher) |
inFeedback | Required | Specifies whether the block in which the datapoint belongs to must be published on the feedback channel along with a publication of the datapoint to the monitor service. You can specify TRUE or FALSE. This is typically set to FALSE. |
Marker Value | Optional | Supports Modbus device discovery. The Modbus protocol does not support automatic discovery of devices. The SmartServer discovers Modbus devices by probing each Modbus address for marker values that you specify. A marker is a fixed datapoint value that the SmartServer identify the device type for a device. For example, if a device type includes a datapoint with a model name or model number, the datapoint can be used as a marker for the device type. If a Modbus device manufacturer sells a line of devices, Model number 23854, and embeds that number in a datapoint at the same register address in each device, but then also has a datapoint with the number of phases supported by the particular meter, the marker for each meter type can consist of two datapoints, one with the model name and one with the number of phases. Both values must match the marker values in the device interface definition. (This parameter is available with SmartServer 2.8 and higher) |
Description | Optional | Provides a description of the datapoint. |
Defining the Modbus Program ID
Each Modbus device interface definition requires a unique program ID. Create a Modbus program ID for the Modbus XIF as defined in Device Type Definition.
Application Examples
Example 1 -Â EasyIO FC-20 BMS Controller
Following are examples of the manufacturer's documentation for the Modbus registers in an EasyIO FC-20. This example specifies two datapoints per memory block and three for the holding register.
Discrete Input
Coil Output
Input Register
Holding Register
- Point Name = Register Name
- Presentation Type = Select best the IAP type from IzoT Resource Editor standard list that represents the Modbus datatype.
- Modbus Datatype = Type field in Input Register and Holding Register. Coil Output or Discrete Input is always BIT.
- Function Code = Register is clearly labeled for each datapoint in the Easy IO registry map.
- Address = Easy IO documentation specifies it is 1-base addressing, with 5 digits.
If the first digit is:
0 = use FC01
1 = use FC02
3 = use FC04
4 = use FC03
For the next 4 digits, subtract 1 to get register address as shown in the following examples:
40001 in Easy IO = FC03 0000 in MOD file
30001 in Easy IO = FC04 0000 in MOD file
- Direction = Depends on whether registry allows for read/write options, based on the function code for the datapoint, you can use the following direction:
- A`, B`, C` = Refer to the scaling example provided above, and to be used if the way the data is presented needs to be a different resolution.
- Range Min/Max = (Optional) Enter a scaled value that is out-of-range for the datapoint.Â
- Poll Rate (sec) = This value is user-defined.
- Description = Description field in Easy IO register map.
Example 2 -Â Schneider PM5563 Power Meter
Following is an example of the manufacturer's documentation for the Modbus registers in a Schneider PM5563.
- Point Name = Description field
- Presentation Type =Â Select best the IAP type from IzoT Resource Editor standard list that represents the Modbus datatype.
- Modbus Datatype = Data-Type field; Input Register and Holding Register. Coil Output or Discrete Input is always BIT.
- Function Code = Use the function code based on the memory block where the data is located.
- Address = The PM55XX series register index is a spreadsheet with tabs for registers and coils.
The datapoints in the Register List tab will have a function code of FC03 or FC04 depending on the memory block where the data is stored. The datapoints in the Coils tab will have a function code of FC01 or FC02 depending on the coil where the data is stored.
Since the Register column values represent the raw address value, both raw address and raw address minus 1 were tried. It was determined that the raw value minus 1 returned the correct data.- Minute = 1841 = Subtract 1 from the address to convert it to 0-base addressing
- VT_Primary = 2026 = Subtract 1 from the address to convert it to 0-base addressing
- Direction = Access Field. Depending on whether the registry allows for read/write options, based on the function code for the datapoint, use the following direction:
- A`, B`, C` =Â Refer to the scaling example provided above, and to be used if the way the data is presented needs to be a different resolution.
- Range Min/Max = (Optional) Enter a scaled value that is out-of-range for the datapoint.Â
- Poll Rate (sec) = This value is user-defined.
- Description = Description field in register map.
Following is the Modbus XIF file for the PM5563.
#filetype,Modbus_xif |
Example 3 -Â Simpson Amik 201 Power Meter
Following is an example Modbus XIF for a Simpson Amik Power Meter.
#filetype,Modbus_xif |
Example 4 -Â Advantech Adam 4150 DIO Module
Following is an example Modbus XIF for an Advantech Adam 4150.
#filetype,Modbus_xif |