Modbus device in Domat IDE

What is a prototype

If we want to read and write to a device via Modbus in Domat IDE, it is necessary to have an image of its variables, a so-called prototype, declared in the communication channel. Typically, we have a PLC with a serial channel - e.g. RS485 - and a device connected to it, communicating with the Modbus protocol. Devices are, for example, various I/O modules, UI/UC... room controllers, air conditioners, or solar power plant inverters. Domat IDE needs to know what address the device has and which registers specific data is read and written to. Domat IDE includes a pre-installed Domat device library, which can also be detected automatically. But a prototype needs to be created for third-party devices.

How to create a prototype

In Domat IDE, we add a new channel to the PLC, set the correct port and Modbus protocol.

Then we add the device by clicking on the channel with the right mouse button. We double-click the device, first we need to add a group, so we right-click in the space and select Add group.

The group basically formulates a modbus query. First, we choose whether the group will contain read or write registers. The function we will read or write corresponds to this. You should read what functions your modbus device supports in its modbus table. For example, Domat room controllers of the UI.... series support F03 (Read Holding Register) for reading and F16 (Write Multiple Registers) for writing.

Even if we want to read only one register, it must have its own group. For example, to read the current temperature from the Domat UI010 room controller, we open its modbus table and read that the temperature is in register 17.

This means that for the group we need to set the start element to 17 and the number of elements to 1. We will add a data point and set it to the group it belongs to. The variable type is INT (if you can't read the correct type in the modbus table, you have to try) and the parameter K is 0.01, since it is a value with a resolution of two decimal places. If we want to read the current humidity as well, we can create a new group or add register 19 (where the humidity is) to the existing one. In that case, you need to first adjust the number of elements in the group to 3, then add the humidity data point, assign it to the group and set it to a data offset of 4 (the initial element is 17 + shift by 4 bytes, so 17 LSB, 17 MSB, 18 LSB, 18 MSB) and again choose type INT and K 0.01.

Entry in registers

In the write group, the Write only on change option is available. If we want to use it, we have to create a new group for each register. If there were multiple registers in the group and one changed, the other registers would also be written, which may not be desirable. If we want to overwrite only one bit (coil), but the given device does not support the write function F05 (write single coil) or F15 (write multiple coils), but only the function for working with the entire register, it is necessary to load the entire register, decompose it with the help of a function block Bit Decomposition (BD19), modify the given bit and compose again using Bit Composition (BD18) and then write.

Couple - coupling between hardware I/O points

When deploying UI011 room controllers, UC/FC... controllers, but also third-party integrated protocol devices With Modbus, we often encounter the problem of how to elegantly and satisfactorily solve writing to variables that are also controlled locally - via a rotary knob, display or other manual element. The solution is coupling, see our article

Different versions of devices in the library

If we want to add from the library, for example, a room controller UI010, we have the choice of either using a specific prototype UI010, which contains only temperature and humidity - or we can choose a generic prototype UI0xx, which is common to all room controller UI and contains most of the registers as described in the modbus table. There are really a lot of variables, so if we need to save space on the PLC, unnecessary variables and groups can be deleted, or autogen can be turned off for them (then global variables are not created, but it is possible to create them again at any time by turning on autogen).

How to edit a device from the library

By default, devices from the library cannot be edited. You need to right-click on it and select Create Specific. This separates the prototype from the library and the suffix generic appears at the end of the prototype name.

Export prototype, move to another library

The created or edited prototype can be exported, just right-click and select export item. This will create a .csv file that we can import in another program. If we want to use the prototype in Domat IDE on another computer, or in another version of the IDE, we right-click and select Create library. This function saves the new prototype in the library of the given IDE version (eg c:\Program Files (x86)\Domat\IDE (149126)\HwLibrary\Modbus-Domat\). The resulting file has the extension .hw and we can copy it to the library on another PC or to the library of another IDE version. It will then appear in the list of devices when we select Add device from library.