====== MODBUS RTU devices configuration file ====== Communication is established with all devices listed in the [[en:ibvunit:ibvunit-config#|]] element during the start of the **ibvunit** program. Devices are identified based on three numerical values: * **HardwareId** (h) – numerical hardware identifier for devices. * **FirmwareId** (f) – numerical firmware identifier. * **FirmwareVersion** (v) – numerical firmware version identifier. Based on the above values, a unique device name is formed, for example, **h3f1v6**. Each device has its individual configuration file. The **ibvunit** program assigns a configuration to a given device, selecting it from the appropriate xml file. The recommended name for the configuration file is the full name of the device, for example, **h3f1v6.xml**. ===== Example Configuration File ===== Below is the syntax of an example configuration file for the **h1021f1v0** device. This example also includes comments that serve as a brief documentation, hints, or an example of alternative configuration, thus making it possible to edit the configuration file intuitively. The main element of the configuration file is **Device**, which among other things has attributes: * **Version** – determines the version of the device configuration file. The proper version of the device configuration file is 1.2 (for ibvunit program in version 2.3.5). * **HardwareId** (h) – numerical hardware identifier for devices * **FirmwareId** (f) – numerical firmware identifier * **FirmwareVersion** (v) – numerical firmware version identifier The remaining elements of the configuration file are described in separate chapters of the documentation. ===== ===== The **HoldingRegisters** element is responsible for defining device registers of the **Holding Registers** type with MODBUS RTU communication, which will be available for the **ibvunit** program. The element can contain multiple [[en:ibvunit:ibvunit-dev-modbus-rtu-config#|]] elements or none at all. The element contains the attributes: * **SetMode** - (mandatory) The attribute value determines whether to use the MODBUS PresetSingleRegister or WriteMultipleRegisters function to set the value of a given register. The attribute can take values: * **Multiple** - means that communication with the MODBUS device allows for bulk writes for Holding Registers. The **Multiple** value should only be set for MODBUS devices correctly implementing the WriteMultipleRegisters function (code 16). * **Single** - means that communication with the MODBUS device only allows for single writes for Holding Registers. The Single value should only be set for MODBUS devices correctly implementing the PresetSingleRegister function (code 6). If the device supports both modes, it is recommended to use **Multiple** for performance reasons. Each device supporting **HoldingRegister** type variables must correctly implement at least one of the above functions to change the value of a given register. Reading **HoldingRegister** type variables is performed by the MODBUS ReadHoldingRegisters function (code 3), which must also be supported by the device. ==== ==== The element located in the [[en:ibvunit:ibvunit-dev-modbus-rtu-config#|]] element. The element is responsible for defining a single register of the **Holding Registers** type with MODBUS RTU communication. The element contains the attributes: * **Addr** – the address of the register in a MODBUS RTU compatible device. * **Name** – the name of the register. Under this name, the register will function as a variable in the **ibvunit** program and throughout the **IB-System**. The name of the parameter is arbitrary, but it is assumed to be intuitive. Therefore, standardizing names according to the [[en:ibprotocol:start|ibprotocol]] documentation is recommended. * **Rd** – a flag (value 0 or 1) indicating whether the register can be read. * **Wr** – a flag (value 0 or 1) indicating whether the register can be written to. * **Min** – the minimum value for the register. * **Max** – the maximum value for the register. * **Presentation** – the way the variable is presented in the **ibvunit** program and throughout the **IB-System**. The permissible attribute values are: * **unsigned** – an unsigned integer value. Value range 0..65535. * **signed** – a signed integer value. Value range -32768..32767. * **hex** – a numerical value in hexadecimal 0x0000. Value range 0x0000..0xffff * **SwappBytes** - (optional) If it's defined and its value is "1", then **ibvunit** switches two bytes of the given register's value, during transmission to and from the device. By default, bytes are not swapped and are transferred according to the MODBUS RTU protocol standard (SwappBytes="0"). ===== ===== The element **InputRegisters** is responsible for defining the device's **Input Registers** with MODBUS RTU communication, which will be available for the **ibvunit** program. The element can contain multiple [[en:ibvunit:ibvunit-dev-modbus-rtu-config#|]] elements or not contain any such element. Each device supporting **InputRegister** type variables must correctly implement the MODBUS ReadInputRegisters function (code 4) in order to read the value of a given input register. **InputRegister** type registers are read-only. ==== ==== An element located in the [[en:ibvunit:ibvunit-dev-modbus-rtu-config#|]] element. The element is responsible for defining a single **Input Registers** device register with MODBUS RTU communication. The element contains attributes: * **Addr** – the address of the register in a MODBUS RTU compatible device. * **Name** – the name of the register. Under this name, the register will function as a variable in the **ibvunit** program and throughout the **IB-System**. The name of the parameter is arbitrary, but it is assumed to be intuitive. Therefore, standardizing names according to the [[en:ibprotocol:start|ibprotocol]] documentation is recommended. * **Presentation** – the way the variable is presented in the **ibvunit** program and throughout the **IB-System**. The permissible attribute values are: * **unsigned** – an unsigned integer value. Value range 0..65535. * **signed** – a signed integer value. Value range -32768..32767. * **hex** – a numerical value in hexadecimal 0x0000. Value range 0x0000..0xffff * **SwappBytes** - (optional) If it's defined and its value is "1", then **ibvunit** switches two bytes of the given register's value, during transmission to and from the device. By default, bytes are not swapped and are transferred according to the MODBUS RTU protocol standard (SwappBytes="0"). ===== ===== The **Coils** element is responsible for defining the two-state outputs of a **Coils** type device with MODBUS RTU communication, which will be available for the **ibvunit** program. The element can contain multiple [[en:ibvunit:ibvunit-dev-modbus-rtu-config#|]] elements or none at all. The element contains attributes: * **SetMode** - (mandatory) The attribute value determines whether to use the MODBUS ForceSingleCoil or WriteMultipleCoils function to set the value of a given register. The attribute can take values: * **Multiple** - means that communication with the MODBUS device allows for bulk writes for Holding Registers. The **Multiple** value should only be set for MODBUS devices correctly implementing the WriteMultipleCoils function (code 15). * **Single** - means that communication with the MODBUS device only allows for single writes for Holding Registers. The Single value should only be set for MODBUS devices correctly implementing the ForceSingleCoil function (code 5). If the device supports both modes, it is recommended to use **Multiple** for performance reasons. Each device supporting Coils type variables must correctly implement at least one of the above functions in order to change the two-state output data. Two-state output reading is performed by the MODBUS ReadCoilStatus function (code 1), which must also be supported by the device. ==== ==== An element located in the [[en:ibvunit:ibvunit-dev-modbus-rtu-config#|]] element. The element is responsible for defining a single two-state output of the **Coils** type with MODBUS RTU communication. The element contains attributes: * **Addr** – the address of the register in a MODBUS RTU compatible device. * **Name** – the name of the register. Under this name, the register will function as a variable in the **ibvunit** program and throughout the **IB-System**. The name of the parameter is arbitrary, but it is assumed to be intuitive. Therefore, standardizing names according to the [[en:ibprotocol:start|ibprotocol]] documentation is recommended. * **Rd** – a flag (value 0 or 1) indicating whether the register can be read. * **Wr** – a flag (value 0 or 1) indicating whether the register can be written to. * **Min** – the minimum value for the register. * **Max** – the maximum value for the register. ===== ===== The **DiscreteInputs** element is responsible for defining the two-state inputs of a **Discrete Inputs** type device with MODBUS RTU communication, which will be available for the **ibvunit** program. The element can contain multiple [[en:ibvunit:ibvunit-dev-modbus-rtu-config#|]] elements or none at all. Each device supporting **DiscreteInputs** type variables must correctly implement the MODBUS ReadInputStatus function (code 2) in order to read the value of a given two-state input. **DiscreteInputs** type registers are read-only. ==== ==== An element located in the [[en:ibvunit:ibvunit-dev-modbus-rtu-config#|]] element. The element is responsible for defining a single two-state input of the **Discrete Inputs** type with MODBUS RTU communication. The element contains attributes: * **Addr** – the address of the register in a MODBUS RTU compatible device. * **Name** – the name of the register. Under this name, the register will function as a variable in the **ibvunit** program and throughout the **IB-System**. The name of the parameter is arbitrary, but it is assumed to be intuitive. Therefore, standardizing names according to the [[en:ibprotocol:start|ibprotocol]] documentation is recommended. * **Rd** – a flag (value 0 or 1) indicating whether the register can be read.