Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
en:mervis-ide:35-help:3-communication-protocols-description:3-modbus_settings [2020/05/05 08:18]
127.0.0.1 external edit
en:mervis-ide:35-help:3-communication-protocols-description:3-modbus_settings [2020/10/13 17:44]
m.chlupac
Line 1: Line 1:
-====== Modbus protocol driver  ======+====== Modbus protocol driver ======
  
-The Modbus protocol driver is probably the most frequently used driver. There are rich possibilities of Modbus datapoints configuration setting in Mervis IDE, and this is why we will have a look on the datapoint definition in more detail.\\ +The Modbus protocol driver is probably the most frequently used driver. There are rich possibilities of Modbus datapoints configuration setting in Mervis IDE, and this is why we will have a look on the datapoint definition in more detail. 
-\\ + 
-A datapoint defined in a Modbus driver is not available in the program, it is just a communication definition. In a program, we need variables to work with. Hence, it is necessary to map (attach) a datapoint to a global variable. This abstract enables the engineer to reconnect easily a variable from one datapoint (input or output) to another, e.g. in case of physical damage of an I/O module. Global variables can be created and attached to datapoints also on an automatic basis, using the Autogen function.\\ +A datapoint defined in a Modbus driver is not available in the program, it is just a communication definition. In a program, we need variables to work with. Hence, it is necessary to map (attach) a datapoint to a global variable. This abstract enables the engineer to reconnect easily a variable from one datapoint (input or output) to another, e.g. in case of physical damage of an I/O module. Global variables can be created and attached to datapoints also on an automatic basis, using the Autogen function. 
-\\ + 
-As a first thing, a communication channel has to be created. This is to specify on which physical port shall the PLC communicate to the Modbus server: a serial line (for Modbus RTU) or the Ethernet interface (for Modbus TCP) can be used.\\ +As a first thing, a communication channel has to be created. This is to specify on which physical port shall the PLC communicate to the Modbus server: a serial line (for Modbus RTU) or the Ethernet interface (for Modbus TCP) can be used. 
-\\ + 
-{{:en:mervis-ide:35-help:modbus_channel.png|Modbus channel}}\\ +{{:en:mervis-ide:35-help:modbus_channel.png|Modbus channel}} 
-\\ + 
-Name - usually named according to the devices which are connected to the channel, or a bus in the project, e.g. "FCU", "Bus1".\\ +Name - usually named according to the devices which are connected to the channel, or a bus in the project, e.g. "FCU", "Bus1".Enable - the channel must be enabled (True) in order to communicate.\\
-Enable - the channel must be enabled (True) in order to communicate.\\+
 Link protocol - Serial for Modbus RTU (over RS232 or RS485, i.e.on the COM... ports), Tcp for Modbus TCP over Ethernet.\\ Link protocol - Serial for Modbus RTU (over RS232 or RS485, i.e.on the COM... ports), Tcp for Modbus TCP over Ethernet.\\
 Integration mode - False: read telegrams are interlaced by write telegrams, launched on change of the written value. True: all data to read are read first, and then all data to write are written. This mode may be more useful for some 3rd party devices.\\ Integration mode - False: read telegrams are interlaced by write telegrams, launched on change of the written value. True: all data to read are read first, and then all data to write are written. This mode may be more useful for some 3rd party devices.\\
 Max. Telegram Duration - also known as Timeout. The Modbus device must respond to a request within this time. The span of 70 ms is OK with a reserve for Domat I/O modules, while for some 3rd party devices like PV inverters, VSDs, etc. a longer time of  about 200...500 ms must be set. A span too long may slow down the whole communication if a device on the bus is offline and does not respond.\\ Max. Telegram Duration - also known as Timeout. The Modbus device must respond to a request within this time. The span of 70 ms is OK with a reserve for Domat I/O modules, while for some 3rd party devices like PV inverters, VSDs, etc. a longer time of  about 200...500 ms must be set. A span too long may slow down the whole communication if a device on the bus is offline and does not respond.\\
-Max. Telegram Duration (Commissioning)- this time, usually longer than the previous one, is used at the commissioning time when it is not necessary to optimize the communication, and  errors caused by too a short timeout shall be avoided.\\+Max. Telegram Duration (Commissioning) - this time, usually longer than the previous one, is used at the commissioning time when it is not necessary to optimize the communication, and  errors caused by too a short timeout shall be avoided.\\
 Pause between telegrams - sometimes used for easier recognition of a telegram start by a 3rd party device. If there are communication dropouts, set this value to about 20...300 ms.\\ Pause between telegrams - sometimes used for easier recognition of a telegram start by a 3rd party device. If there are communication dropouts, set this value to about 20...300 ms.\\
-Port Number - COM port number of the PLC.\\ +Port Number - COM port number of the PLC. 
-The following parameters must be identical both for the channel and for all the Modbus devices connected to this channel. Please follow the 3rd party documentation. If the devices have selectable parameters, check if the settings correspond with the channel settings in the PLC.\\ + 
-Baud Rate- physical communication speed in bit/s.\\+The following parameters must be identical both for the channel and for all the Modbus devices connected to this channel. Please follow the 3rd party documentation. If the devices have selectable parameters, check if the settings correspond with the channel settings in the PLC. 
 + 
 +Baud Rate - physical communication speed in bit/s.\\
 Data Bits - number of data bits in a byte.\\ Data Bits - number of data bits in a byte.\\
 Parity - select communication parity here - None, Odd, or Even.\\ Parity - select communication parity here - None, Odd, or Even.\\
-Stop bits - number of stop bits to indicate end of the transmitted byte.\\ +Stop bits - number of stop bits to indicate end of the transmitted byte. 
-These parameters have no meaning for Modbus TCP communication and are not displayed if Modbus TCP is selected.\\ + 
-\\ +These parameters have no meaning for Modbus TCP communication and are not displayed if Modbus TCP is selected. 
-Right click the channel to add a Modbus slave (Device). A device is a Modbus server (Modbus address) with which we want to communicate, and contains Modbus registers. There may be up to  255 devices on a bus, however, maximum of 60 to 80 devices is used for easier commissioning and service. Now, set the device parameters:\\ + 
-\\ +Right click the channel to add a Modbus slave (Device). A device is a Modbus server (Modbus address) with which we want to communicate, and contains Modbus registers. There may be up to  255 devices on a bus, however, maximum of 60 to 80 devices is used for easier commissioning and service. Now, set the device parameters: 
-{{:en:mervis-ide:35-help:modbus_device.png|Modbus - zařízení}}\\ + 
-\\+{{:en:mervis-ide:35-help:modbus_device.png|Modbus - zařízení}} 
 Device properties\\ Device properties\\
 Name - a device may have a name for easier reference, such as AHU1VSD1.\\ Name - a device may have a name for easier reference, such as AHU1VSD1.\\
 Enable - the device must be enabled to communicate (set to True).\\ Enable - the device must be enabled to communicate (set to True).\\
-Is Custom Box - Custom boxes can be edited. \\ +Is Custom Box - Custom boxes can be edited.  
-\\+
 Modbus Device Parameters\\ Modbus Device Parameters\\
 Device Address - Modbus address 1...255. This address must be set at the device, which is arranged typically by the device hardware supplier.\\ Device Address - Modbus address 1...255. This address must be set at the device, which is arranged typically by the device hardware supplier.\\
-Note - any text\\ +Note - any text 
-\\+
 Prototype Definition\\ Prototype Definition\\
 Lock for link protocol - must be False\\ Lock for link protocol - must be False\\
Line 42: Line 44:
 Model ID - free text, identification of the device type (there may be more device types designed for a single 3rd party hardware, with different variable sets etc.)\\ Model ID - free text, identification of the device type (there may be more device types designed for a single 3rd party hardware, with different variable sets etc.)\\
 Status - selectable, development stage can be entered here (Development, Test, Release, Obsolete, Broken (a branch separated from the main development branch)).\\ Status - selectable, development stage can be entered here (Development, Test, Release, Obsolete, Broken (a branch separated from the main development branch)).\\
-Version ID - free definable, version of the Modbus device in Mervis IDE\\ +Version ID - free definable, version of the Modbus device in Mervis IDE 
-\\ + 
-Device info\\ +Device info 
- Manufacturer - free text, identification of the device manufacturer\\+ 
 +Manufacturer - free text, identification of the device manufacturer\\
 Model - free text, identification of the type of hardware\\ Model - free text, identification of the type of hardware\\
 Version - free text, firmware version of the device (different firmware versions may require different Modbus devices in IDE, based on their Modbus maps)\\ Version - free text, firmware version of the device (different firmware versions may require different Modbus devices in IDE, based on their Modbus maps)\\
-Category path - the path that is displayed in the "Add device from library" dialogue, it is used for better structuring of the device list in IDE.\\ +Category path - the path that is displayed in the "Add device from library" dialogue, it is used for better structuring of the device list in IDE. 
-\\ + 
-Double click the device to open a workspace for Groups and datapoints definition in a device. The Modbus communication follows in groups of datapoints. There are more consecutive registers communicated within a single Group (which is one Modbus request for reading or writing). Group communication optimizes bus traffic and speeds up the data transfer rate. Datapoints are always defined as members of a particular Group.\\ +Double click the device to open a workspace for Groups and datapoints definition in a device. The Modbus communication follows in groups of datapoints. There are more consecutive registers communicated within a single Group (which is one Modbus request for reading or writing). Group communication optimizes bus traffic and speeds up the data transfer rate. Datapoints are always defined as members of a particular Group. 
-\\+
 Firstly, define a Group for reading of registers. This is necessary even if only a single register has to be read.\\ Firstly, define a Group for reading of registers. This is necessary even if only a single register has to be read.\\
 - Right click the workspace with the device name to open the context menu\\ - Right click the workspace with the device name to open the context menu\\
 - Select Add Group\\ - Select Add Group\\
-- Enter the Group parameters:\\ +- Enter the Group parameters: 
-\\ + 
-{{:en:mervis-ide:35-help:modbus_group.png|Skupina}}\\ +{{:en:mervis-ide:35-help:modbus_group.png|Skupina}} 
-\\+
 Name - name of the group, such as "Temperatures_reading". The name should reflect the common properties of the registers which are contained in the Group.\\ Name - name of the group, such as "Temperatures_reading". The name should reflect the common properties of the registers which are contained in the Group.\\
 Read/Write Interval - how often should the Group communicate. Enter 0 ms for communication without gaps.\\ Read/Write Interval - how often should the Group communicate. Enter 0 ms for communication without gaps.\\
 Group Type - select between ReadOnly (a Group which reads data from the device) and WriteOnly (a group which writes data to the device).\\ Group Type - select between ReadOnly (a Group which reads data from the device) and WriteOnly (a group which writes data to the device).\\
-Note- volně definovatelná poznámka.\\ +Note- any text
-\\ + 
-Modbus Group Parameters\\+Modbus Group Parameters 
 Starting Element - number of the first register to read\\ Starting Element - number of the first register to read\\
 Function - Modbus function which must fit with the Group type: for ReadOnly groups choose some of the Modbus Read functions, for WriteOnly groups select some of the writing functions. The function must be supported by the device - check in the Modbus server documentation.\\ Function - Modbus function which must fit with the Group type: for ReadOnly groups choose some of the Modbus Read functions, for WriteOnly groups select some of the writing functions. The function must be supported by the device - check in the Modbus server documentation.\\
-Quantity of Elements- number of registers to be read or written in the Group.\\ +Quantity of Elements - number of registers to be read or written in the Group. 
-\\ + 
- Example: A Group must read Modbus registers 11 to 15. The Group parameters will be set as follows: Starting Element to 11, Quantity of Elements to 5.\\ + Example: A Group must read Modbus registers 11 to 15. The Group parameters will be set as follows: Starting Element to 11, Quantity of Elements to 5. 
-\\ + 
-Secondly, the datapoints will be defined, to which the driver reads values from the Group communication.\\ +Secondly, the datapoints will be defined, to which the driver reads values from the Group communication. 
-\\+
 - Right click the workplace to open the context menu\\ - Right click the workplace to open the context menu\\
 - Select Add Data Point \\ - Select Add Data Point \\
-- Enter the datapoint parameters:\\ +- Enter the datapoint parameters: 
-\\ + 
-{{:en:mervis-ide:35-help:modbus_datapoint.png|Modbus dat. bod}}\\ +{{:en:mervis-ide:35-help:modbus_datapoint.png|Modbus dat. bod}} 
-\\ + 
-Name -Datapoint name which is used for its identification in Mervis IDE\\+Name - Datapoint name which is used for its identification in Mervis IDE\\
 Assigned HW Properties - special parameters used e.g. at I/O modules. They are not used when integrating 3rd Party devices.\\ Assigned HW Properties - special parameters used e.g. at I/O modules. They are not used when integrating 3rd Party devices.\\
 Group - select a group the data point belongs to.\\ Group - select a group the data point belongs to.\\
Line 85: Line 89:
 Group Type - fills in automatically after a Group is selected (read or write)\\ Group Type - fills in automatically after a Group is selected (read or write)\\
 Comm. Value Mapped Type - select from BuiltIn, Bit and Array.\\ Comm. Value Mapped Type - select from BuiltIn, Bit and Array.\\
-    Bit - select if a bool value has to be read.\\ +Bit - select if a bool value has to be read.\\ 
-    BuiltIn - select if value of any other type has to be read. The type will be specified in the ST Typeparameter.\\ +BuiltIn - select if value of any other type has to be read. The type will be specified in the ST Typeparameter.\\ 
-    Array - select if the values have to be read into an array date type (Array).\\+Array - select if the values have to be read into an array date type (Array).\\
 ST Type - select the data point type. If no transform (see below) is used, the data type must be of the same size as the Modbus table range to read from, specified in the Modbus data point parameters. List of available data types is in the [[:en:mervis-ide:35-help:6-software_basic:6-data-types:0-elementary_data_types|elementary data type table.]]\\ ST Type - select the data point type. If no transform (see below) is used, the data type must be of the same size as the Modbus table range to read from, specified in the Modbus data point parameters. List of available data types is in the [[:en:mervis-ide:35-help:6-software_basic:6-data-types:0-elementary_data_types|elementary data type table.]]\\
-Transform - Between the readout of a register value over Modbus and writing it into a data point it is possible to recalculate, or transform, the value. It is used for example with analogue values in HVAC Integer format, i.e. decimal numbers multiplied by 10 or 100. Example: a temperature measured in the device is 21.5 °C, and the Modbus server transmits it as 2150. This value read from the Modbus register must be transformed back - divided by 100 using a linear transform.\\ +Transform - Between the readout of a register value over Modbus and writing it into a data point it is possible to recalculate, or transform, the value. It is used for example with analogue values in HVAC Integer format, i.e. decimal numbers multiplied by 10 or 100. Example: a temperature measured in the device is 21.5 °C, and the Modbus server transmits it as 2150. This value read from the Modbus register must be transformed back - divided by 100 using a linear transform. 
-\\ + 
-These are the predefined transforms:\\+These are the predefined transforms: 
 identity - the value is not transformed, it is written as is\\ identity - the value is not transformed, it is written as is\\
-\\ 
 Resistance to temperature - linearisation curve for Pt100, Pt500, Pt1000, Ni1000-5000, Ni1000-6180 sensors. The transform has following parameters:\\ Resistance to temperature - linearisation curve for Pt100, Pt500, Pt1000, Ni1000-5000, Ni1000-6180 sensors. The transform has following parameters:\\
-   Kind - sensor type which determines the predefined linearisation curve\\ +Kind - sensor type which determines the predefined linearisation curve\\ 
-   Pre_K - first linear pre-linearisation transform y = Kx + Q coefficient\\ +Pre_K - first linear pre-linearisation transform y = Kx + Q coefficient\\ 
-   Pre_Q - first linear pre-linearisation transform y = Kx + Q coefficient (used for sensor cable resistance compensation)\\ +Pre_Q - first linear pre-linearisation transform y = Kx + Q coefficient (used for sensor cable resistance compensation)\\ 
-   Post_K - second linear post-linearisation transform y = Kx + Q coefficient\\ +Post_K - second linear post-linearisation transform y = Kx + Q coefficient\\ 
-   Post_Q - second linear post-linearisation transform y = Kx + Q coefficient (used for compensation of absolute sensor measuring error in °C)\\ +Post_Q - second linear post-linearisation transform y = Kx + Q coefficient (used for compensation of absolute sensor measuring error in °C) 
-\\+
 Threshold - detector for transform of an anlogue value into binary value (if an AI is used as a DI). The transform has following parameters:\\ Threshold - detector for transform of an anlogue value into binary value (if an AI is used as a DI). The transform has following parameters:\\
-   Threshold - a limit to switch from True to False and back\\ +Threshold - a limit to switch from True to False and back\\ 
-   Invert - inverts the function: if Invert = True, the transform output is False if the input value is higher than the Threshold.\\ +Invert - inverts the function: if Invert = True, the transform output is False if the input value is higher than the Threshold. 
-\\+
 Window - if the input value is between predefined limits, the output is True, otherwise False. Example: damaged sensor detection - if the measured value is lower than -40 °C or higher than 150 °C, the sensor is damaged and the output value is True (using the Invert function)\\ Window - if the input value is between predefined limits, the output is True, otherwise False. Example: damaged sensor detection - if the measured value is lower than -40 °C or higher than 150 °C, the sensor is damaged and the output value is True (using the Invert function)\\
-   Low - lower limit\\ +Low - lower limit\\ 
-   High - higher limit\\ +High - higher limit\\ 
-   Invert - inverts the function: if Invert = True then if the value is within limits, the output is False, otherwise is True.\\ +Invert - inverts the function: if Invert = True then if the value is within limits, the output is False, otherwise is True. 
-\\+
 LinearByTable- linearisaton curve with max. 8 points. The curve is defined using pairs of values - coordinates of the points in X and Y vectors.\\ LinearByTable- linearisaton curve with max. 8 points. The curve is defined using pairs of values - coordinates of the points in X and Y vectors.\\
-   XValues - vector with X coordinates of the linearisation curve points\\ +XValues - vector with X coordinates of the linearisation curve points\\ 
-   YValues - vector with Y coordinates of the linearisation curve points\\ +YValues - vector with Y coordinates of the linearisation curve points\\ 
-   Active points - number of points used, max. 8, taken from the left of the vector\\ +Active points - number of points used, max. 8, taken from the left of the vector\\ 
-   Pre_K - first linear pre-linearisation transform y = Kx + Q coefficient\\ +Pre_K - first linear pre-linearisation transform y = Kx + Q coefficient\\ 
-   Pre_Q - first linear pre-linearisation transform y = Kx + Q coefficient\\ +Pre_Q - first linear pre-linearisation transform y = Kx + Q coefficient\\ 
-   Post_K - second linear post-linearisation transform y = Kx + Q coefficient\\ +Post_K - second linear post-linearisation transform y = Kx + Q coefficient\\ 
-   Post_Q - second linear post-linearisation transform y = Kx + Q coefficient\\ +Post_Q - second linear post-linearisation transform y = Kx + Q coefficient 
-\\+
 Negate - for bool type values, negates the input value\\ Negate - for bool type values, negates the input value\\
 \\ \\
Line 141: Line 145:
 Definition of from which register and how the data point will be read. The main data, which is Modbus function and starting, are defined in the Group which the data point is assigned to. All other settings are related to the first register of the Group. As an example, a group of registers is defined which starts with Modbus register 2064 and contains a total of 8 registers:\\ Definition of from which register and how the data point will be read. The main data, which is Modbus function and starting, are defined in the Group which the data point is assigned to. All other settings are related to the first register of the Group. As an example, a group of registers is defined which starts with Modbus register 2064 and contains a total of 8 registers:\\
 \\ \\
-{{:en:mervis-ide:35-help:input registers are read, it has to be specified where to start within a group and how many bytes to read. the group is always defined by its starting register and number of elements. these numbers represent modbus registers and length of the telegram.\\ +{{:en:mervis-ide:35-help:modbus_telegram.png}}\\ 
-after a new data point has been created, it has to be assigned to a group, and its data type must be specified. the data type must match the read value and it is important that it has equal number of bits. the data types description is listed in the [[:en:mervis-ide:35-help:6-software_basic:6-data-types:0-elementary_data_types|elementary data type table.]]\\+\\ 
 +The byte order (MSB, LSB) is the same as in the Modbus telegram. The driver reads the Group data in this order, and this must be taken into account when parsing the Group into the data points.\\ 
 +\\ 
 +Write offset gap\\ 
 +Interface number of the offset where the writing data ends (if the data point is writable). Counted in bytes. Example: to write to register 2068 the Write offset gap would be 10. Please check that Write offset gap = Data offset + Multibyte length.\\ 
 +\\ 
 +Data offset (Parser)\\ 
 +Starts from 0; specifies on which byte (not register!) the data of a datapoint start. Example: when reading from register 2068 the Data offset would be 8. Maximum value is 2 * Quantity of Elements - 1, which would read the last byte in the group. Note that in a Modbus telegram the higher byte (MSB) is transmitted as first, and the lower byte (LSB) as second; when mapping into byte-based data point types (BYTE, SINT, USINT) the higher (more significant) byte of a Modbus register has lower value of the Data offset.\\ 
 +\\ 
 +Bit offset (Parser)\\ 
 +Moving in a byte between single bits - for bit-based datapoints read by functions F01 Read Coils, F02 Read Discrete Inputs or written by functions F05 Write Single Coil, F06 Write Single Register. Starts at 0, so to read the 4. bit (bit 3) in a byte (note - not necessarilly in a register!) the Bit offset = 3. The settable range is 0 to 7.\\ 
 +\\ 
 +Multibyte length (Parser)\\ 
 +Number of bytes (not registers!) to be read into a data point or to be written into the Modbus table. It is mostly 2, as one Modbus register has 16 bits = 2 bytes. In special applications as e.g. cumulated values in energy meters, which use 4 bytes, the Multibyte Length may be higher. For bit-oriented data points the Multibyte Length = 1 (1 byte is enough - the one which contains the required bit).\\ 
 +\\ 
 +Multibyte Order (Parser)\\ 
 +In this string it is possible to change the byte order in which the values from the telegram will be mapped on the data type of the data point. Changing the order is used to fix problems with variable formatting, such as "rotate", "non-rotate", "byte swap", "word swap", "Intel byte order". Default value is "12345678", and usually it is not necessary to change it.\\ 
 +\\ 
 +Note\\ 
 +Free field for a note to explain the mapping of a part of the telegram to the data point. For engineering notes.\\ 
 +\\ 
 +The rules described above can be summed up into four paragraphs:\\ 
 +\\ 
 +1. Reading of holding / input registers\\ 
 +If the holding/input registers are read, it has to be specified where to start within a group and how many bytes to read. The group is always defined by its starting register and number of elements. These numbers represent Modbus registers and length of the telegram.\\ 
 +After a new data point has been created, it has to be assigned to a group, and its data type must be specified. The data type must match the read value and it is important that it has equal number of bits. The data types description is listed in the [[:en:mervis-ide:35-help:6-software_basic:6-data-types:0-elementary_data_types|elementary data type table.]]\\
 \\ \\
 The data point setting specifies which and how large part of the whole group telegram belongs to this data point.\\ The data point setting specifies which and how large part of the whole group telegram belongs to this data point.\\
Line 184: Line 213:
 ===== Optimizing the Modbus mapping engineering ===== ===== Optimizing the Modbus mapping engineering =====
  
-To map the Modbus parameters more efficiently and faster, they can be edited right from the communication channel editor. The edisor is displayed by double click on the communication channel or right click to the communication channel + Open editor. \\ +To map the Modbus parameters more efficiently and faster, they can be edited right from the communication channel editor. The edisor is displayed by double click on the communication channel or right click to the communication channel + Open editor.
  
 The "Data Offset", "Bit offset", "MultiByte Length" and "Write offset gap" allow faster editing of Modbus parameters. The "Data Offset", "Bit offset", "MultiByte Length" and "Write offset gap" allow faster editing of Modbus parameters.
  
-{{:img/modbus_mapping.png|Mapování modbusových parametrů}}\\ +{{:en:mervis-ide:35-help:modbus_mapping.png|Mapování modbusových parametrů}}
  
 ===== Modbus device export ===== ===== Modbus device export =====
Line 196: Line 223:
 To export a Modbus device to a CSV file, right click the Device - Export device. To export a Modbus device to a CSV file, right click the Device - Export device.
  
-{{:en:mervis-ide:35-help:export_modbus_device.png|Export zařízení}}\\ +{{:en:mervis-ide:35-help:export_modbus_device.png|Export zařízení}} 
-\\+
 Output Path - The target file path for export\\ Output Path - The target file path for export\\
 Overwrite existing - Replace an existing file if present\\ Overwrite existing - Replace an existing file if present\\