Difference between revisions of "Modbus RTU Master Read Map Edit"

From Control Solutions IoTServer Documentation
Jump to navigation Jump to search
Line 1: Line 1:
To read Modbus RTU data from a slave device, you need to create a Read map.  There is a form that needs to be filled in. Here is the page for modifying a Read Map.
+
Modbus RTU Master Read Maps are where you configure this device to query other Modbus RTU devices for data, and store that data in local data objects. This page is where you enter the various parameters to make that happen.  
  
 +
[[File:Modbus RTU read map edit 1.jpg]]
  
[[File:Modify RTU Read Map.png]]
+
'''Map Number''' – Used as a reference in the map list for ordering the maps. Polling is done in round robin fashion in the order of map number.
 +
<hr>
 +
The appearance of the following line will vary depending on your user settings. You have the option of displaying Modbus registers as raw address (0-indexed), register number (1-indexed), or Modicon format (e.g. 40001 style).
  
 +
The following variations all refer to exactly the same register:
  
Here is a description for all of the fields that are on this page:
+
[[File:Modbus read map edit 2a.jpg]]
 +
[[File:Modbus read map edit 2a-addr.jpg]]
 +
[[File:Modbus read map edit 2a-modicon.jpg]]
  
[[File:Modify RTU Read Map Type.png]] - Here you select the register type that needs to be read from the slave device.   The Modbus register types supported are: None, Coil, Discrete Input, Input, and Holding registers.
+
Click the Check to validate a Modicon number.
Note: Selecting "None" effectively turns off this read rule, but does not delete it.
+
<hr>
 +
The options available on this line will vary depending on selections made. The following are a few examples.
  
 +
[[File:Modbus read map edit 2a.jpg]]
 +
[[File:Modbus read map edit 2b.jpg]]
 +
[[File:Modbus read map edit 2c.jpg]]
 +
[[File:Modbus read map edit 2d.jpg]]
 +
[[File:Modbus read map edit 2e.jpg]]
  
[[File:Modify RTU Read Map SlvAddrs.png]] - This is the register address / number that is supposed to be read from the slave device. Depending on your user settings, you will either enter the Modbus register address (shown here), Modbus number, or use Modicon notation for this field.
+
'''Register Type''' – Modbus register types available are listed in the following table. These labels are illustrated here as recognized in XML or CSV files, but are further annotated on the web page.  
  
 +
{| class="wikitable"
 +
|-
 +
! Label !! Modbus Register type
 +
|-
 +
| “none” || No register defined
 +
|-
 +
| “Coil” || Coil
 +
|-
 +
| “Disc” || Discrete Input
 +
|-
 +
| “Input” || Input Register
 +
|-
 +
| “Hold” || Holding Register
 +
|}
  
[[File:Modify RTU Read Map Format.png]] - Here you enter the data format and size that should be used for this read.  The valid data types are Signed and Unsigned Integer (int), Floating point IEEE 754 format (Real), Character (Char) and Modd10 (mod10). Some of these data types can of options associated with them.  Int can be signed or unsigned, and can have a length of 1, 2, or 4 registers long.  Real, can be either 2, or 4 registers long.
+
'''Register Number or Address''' – Enter the number (starting at 1) or raw address (starting at 0) as applicable. Do NOT enter 40001 for holding register 1 if you have not selected Modicon as the display format in your User Settings.  
  
Notes:
+
'''Modicon Register''' – Enter numbers like 40001 for the first holding register if you have selected Modicon representation in your User Settings.
- Mod10 has the options of 2, 3, or 4 registers based on the definition of the format, check manufacturer’s documentation if Mod10 is noted. 
 
- Char can be upto 63 registers long.  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.
 
- 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.
 
  
 +
'''Register Format''' – Select the format of the data contained in the Modbus register(s). This is not used by the protocol, but is used by the gateway to interpret what the raw increments of 1 or 16 bits should mean. Select format from the following table.
  
[[File:Modify RTU Read Map Slave.png]] - This is the slave / unit number of the device you want to retrieve the data from.
+
{| class="wikitable"
 +
|-
 +
! Format Label !! Format description
 +
|-
 +
| “None” || No format defined
 +
|-
 +
| “Bit” || Single bit, used ONLY for Register Type 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
 +
|}
  
When you select a size grater than 1, another drop box will show up and the choices are high and low - [[File:Modify RTU Read Map RegOrder.png]] - This determines the order of how the data should be read.
+
'''Register Size''' – Register size refers to the number of consecutive input or holding registers that 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). Register Size is not used for Coil or Disc types.  
  
 +
'''Unsigned''' – Select signed or unsigned. Defaults to signed integer. Has no effect on Register Format other than Int.
  
Once a register has been read, additional items, can be performed on the value read.  This can be to: extract out a bit, or portion of the data, apply a scale factor, or apply an offset value to the value read, if needed.
+
[[File:Modbus read map edit 3a.jpg]]
  
 +
'''Endian Selection''' – Used when Register Size is greater than 1 to indicate what order the registers should be interpreted in. Select "low" to indicate that the lowest numbered register contains the least significant portion of data. Select "high" 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.
  
[[File:Modify RTU Read Map Mask1.png]] - Is used to extract our data from the register.  When the Modbus register is read, its data is bit-wise ANDed with the Mask, then right justified so that the least significant mask bit becomes the least significant data bit. The result is then placed in the local data object selected by the read map.  This can be a single bit, all the way up to the entire register.  The data entered here needs to be entered in Hexadecimal format.  Often Modbus may have each bit in an Unsigned Integer value represent a single status bit.  This allows one register to contain sixteen individual values.  Another usage of this would be if the 16-bit register actually contained two 8-bit values.  One in the lower half of the register, the other in the upper half of the register.  '''See appendix ???? for additional information on bit mask and extracting portions of a register.'''
+
[[File:Modbus RTU read map edit 3.jpg]]
Note: Mask operation skipped if mask value is zero, or register format is not Int
 
  
 +
'''Device''' – Select a device from the TCP Device list that should be accessed for this read attempt on a TCP network.
  
[[File:Modify RTU Read Map ScaleOffset.png]] - From that point you can perform scaling and apply an offset to the result if necessary.  Scaling applies the formula y=mx+b.  When reading from the slave, the raw data is multiplied by the scale factor, then the offset is added to produce the resulting present value. When writing to the slave, the offset is first subtracted from the present value, and that result is divided by the scale factor to produce the raw data actually written to the slave device.
+
'''Unit''' – Unit number to be included in the TCP request, will default to 1 if not given or is set to zero. Web page will force it to default to 1, but is optional for CSV or XML import.  
NOTE: If a scale factor is not given (zero is entered), no scaling will be performed, as if slope=1 and intercept=0.
 
  
 +
[[File:Modbus read map edit 4.jpg]]
  
[[File:Modify_RTU_Poll_Period.png]] - This sets the rate the point is to be polled from the slave device.  Polltime is defined in seconds (can be fractional). Polling is done in round-robin fashion. In a very busy system, more than this time may expire before the next poll. If less than this time has expired, then the system will wait this amount of time until polling again.
+
'''Mask''' – A bit mask given as an 8-digit hexadecimal value, if non-zero. The mask operation is skipped if mask value is zero, or register format is not Int (integer). When the data of interest is a single bit, or bit field less than the full register width, the Mask is used. When the Modbus register is read, its data is bit-wise ANDed with the Mask, then right justified so that the least significant mask bit becomes the least significant data bit. The result is then placed in the local data object selected by the read map.  
  
 +
[[File:Modbus read map edit 5.jpg]]
  
[[File:Modify RTU SaveLocal.png]] location in this gateway where this data is to be saved (Local Object).
+
'''Scale''' – Register content is multiplied by this value, if non-zero, before being placed into the local object. Scale is treated mathematically as 1 if omitted (set to zero).  
  
 +
'''Offset''' – This value is added to the register content (after being multiplied by scale) before being placed into the local object.
  
<ins>Value updated can be conditionally controlled by another local register.</ins>
+
NOTE: The order of operation is as follows: (1) read Modbus register; (2) apply mask if applicable; (3) apply scale if non-zero; (4) apply offset. Result is then placed in local object.  
  
[[File:Modify RTU Read Map LocCompReg.png]] is provided, and its value matches the value entered
+
[[File:Modbus read map edit 6.jpg]]
[[File:Modify RTU Read Map LocCompCond.png]] the will the read happen. If not, it is skipped.
+
 
 +
'''Poll Time''' – Poll time in seconds (can be fractional). The sets the rate at which the remote Modbus register will be read. This poll time is not guaranteed to be met. Polling is done in round-robin fashion. In a very busy system, more than this time may expire before the next poll. If less than this time has expired, then the system will wait this amount of time until polling again.
 +
 
 +
[[File:Modbus read map edit 7.jpg]]
 +
 
 +
'''Local Object''' – Local object number that the result of the Modbus read operation should be placed into.
 +
 
 +
[[File:Modbus read map edit 8.jpg]]
 +
 
 +
'''Default Value''' – Provides the default value that the local object should be set to in the event the FailCount is exceeded.
 +
 
 +
'''Fail Count''' – Optional, provides a count of read failures, if non-zero, that can occur before the local object will be set to the default value given in this map. If zero, the default value will never be applied. If 1, then the default value will be applied upon the first failure (probably not recommended), and so on. The count is reset by a successful read.
 +
 
 +
[[File:Modbus read map edit 9.jpg]]
 +
 
 +
'''Index Object''' – Optional, allows for selectively enabling this read operation. If an index object (local object number) is given, and its value matches the index value, then this read operation will take place. If an index object is given but the local object’s value does not match the index value, then this read operation will be skipped.
 +
 
 +
'''Index Value''' – Optional, used in conjunction with Index Object (see note above).
 +
<hr>
 +
To illustrate the use of Mask, consider the two following read maps. Note that they are reading the same register from the remote Modbus device. But the mask value is different.
 +
 
 +
[[File:Modbus read map group 1.jpg]]
 +
[[File:Modbus read map group 2.jpg]]
 +
 
 +
The value derived from the first read map will be an 8-bit value taken from the low order byte of the 16-bit holding register. The value derived from the second read map will be an 8-bit value taken from the high order byte of the 16-bit holding register. This is how you "unpack" values from a packed Modbus register.
 +
 
 +
Another common requirement is to pick single bits out of a holding register. For a single bit, the Mask value will be a single bit like 00000001, 00000002, 00000004, 00000008, etc.  
 +
 
 +
If the maps such as the two illustrated above are placed in sequential order in the read map list, they will result in only a single Modbus read request, and the data will be shared with all sequential maps requesting the same register from the same device.

Revision as of 15:57, 2 May 2019

Modbus RTU Master Read Maps are where you configure this device to query other Modbus RTU devices for data, and store that data in local data objects. This page is where you enter the various parameters to make that happen.

File:Modbus RTU read map edit 1.jpg

Map Number – Used as a reference in the map list for ordering the maps. Polling is done in round robin fashion in the order of map number.


The appearance of the following line will vary depending on your user settings. You have the option of displaying Modbus registers as raw address (0-indexed), register number (1-indexed), or Modicon format (e.g. 40001 style).

The following variations all refer to exactly the same register:

Modbus read map edit 2a.jpg Modbus read map edit 2a-addr.jpg Modbus read map edit 2a-modicon.jpg

Click the Check to validate a Modicon number.


The options available on this line will vary depending on selections made. The following are a few examples.

Modbus read map edit 2a.jpg Modbus read map edit 2b.jpg Modbus read map edit 2c.jpg Modbus read map edit 2d.jpg Modbus read map edit 2e.jpg

Register Type – Modbus register types available are listed in the following table. These labels are illustrated here as recognized in XML or CSV files, but are further annotated on the web page.

Label Modbus Register type
“none” No register defined
“Coil” Coil
“Disc” Discrete Input
“Input” Input Register
“Hold” Holding Register

Register Number or Address – Enter the number (starting at 1) or raw address (starting at 0) as applicable. Do NOT enter 40001 for holding register 1 if you have not selected Modicon as the display format in your User Settings.

Modicon Register – Enter numbers like 40001 for the first holding register if you have selected Modicon representation in your User Settings.

Register Format – Select the format of the data contained in the Modbus register(s). This is not used by the protocol, but is 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 Register Type 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

Register Size – Register size refers to the number of consecutive input or holding registers that 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). Register Size is not used for Coil or Disc types.

Unsigned – Select signed or unsigned. Defaults to signed integer. Has no effect on Register Format other than Int.

Modbus read map edit 3a.jpg

Endian Selection – Used when Register Size is greater than 1 to indicate what order the registers should be interpreted in. Select "low" to indicate that the lowest numbered register contains the least significant portion of data. Select "high" 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.

File:Modbus RTU read map edit 3.jpg

Device – Select a device from the TCP Device list that should be accessed for this read attempt on a TCP network.

Unit – Unit number to be included in the TCP request, will default to 1 if not given or is set to zero. Web page will force it to default to 1, but is optional for CSV or XML import.

Modbus read map edit 4.jpg

Mask – A bit mask given as an 8-digit hexadecimal value, if non-zero. The mask operation is skipped if mask value is zero, or register format is not Int (integer). When the data of interest is a single bit, or bit field less than the full register width, the Mask is used. When the Modbus register is read, its data is bit-wise ANDed with the Mask, then right justified so that the least significant mask bit becomes the least significant data bit. The result is then placed in the local data object selected by the read map.

Modbus read map edit 5.jpg

Scale – Register content is multiplied by this value, if non-zero, before being placed into the local object. Scale is treated mathematically as 1 if omitted (set to zero).

Offset – This value is added to the register content (after being multiplied by scale) before being placed into the local object.

NOTE: The order of operation is as follows: (1) read Modbus register; (2) apply mask if applicable; (3) apply scale if non-zero; (4) apply offset. Result is then placed in local object.

Modbus read map edit 6.jpg

Poll Time – Poll time in seconds (can be fractional). The sets the rate at which the remote Modbus register will be read. This poll time is not guaranteed to be met. Polling is done in round-robin fashion. In a very busy system, more than this time may expire before the next poll. If less than this time has expired, then the system will wait this amount of time until polling again.

Modbus read map edit 7.jpg

Local Object – Local object number that the result of the Modbus read operation should be placed into.

Modbus read map edit 8.jpg

Default Value – Provides the default value that the local object should be set to in the event the FailCount is exceeded.

Fail Count – Optional, provides a count of read failures, if non-zero, that can occur before the local object will be set to the default value given in this map. If zero, the default value will never be applied. If 1, then the default value will be applied upon the first failure (probably not recommended), and so on. The count is reset by a successful read.

Modbus read map edit 9.jpg

Index Object – Optional, allows for selectively enabling this read operation. If an index object (local object number) is given, and its value matches the index value, then this read operation will take place. If an index object is given but the local object’s value does not match the index value, then this read operation will be skipped.

Index Value – Optional, used in conjunction with Index Object (see note above).


To illustrate the use of Mask, consider the two following read maps. Note that they are reading the same register from the remote Modbus device. But the mask value is different.

Modbus read map group 1.jpg Modbus read map group 2.jpg

The value derived from the first read map will be an 8-bit value taken from the low order byte of the 16-bit holding register. The value derived from the second read map will be an 8-bit value taken from the high order byte of the 16-bit holding register. This is how you "unpack" values from a packed Modbus register.

Another common requirement is to pick single bits out of a holding register. For a single bit, the Mask value will be a single bit like 00000001, 00000002, 00000004, 00000008, etc.

If the maps such as the two illustrated above are placed in sequential order in the read map list, they will result in only a single Modbus read request, and the data will be shared with all sequential maps requesting the same register from the same device.