MODBUS::Generic
The “MODBUS :: Generic” (Modbus/TCP master) device adapter allows data to be retrieved from most Modbus/TCP enabled devices or platforms. The Modbus/TCP enabled device must be accessible via a public IP address or a VPN connection.
Data will be retrieved from the remote Modbus/TCP enabled device on a periodic basis (i.e., 5 minutes, 30 minutes, 60 minutes, etc).
ip_or_hostname:port:unitId:connectTimeoutMS
ip_or_hostname
- Status= Required.
- Description: The IP address or hostname of the remote Modbus/TCP unit to which to connect.
port
- Status= Optional (but necessary to hold position if other fields past this one are defined).
- The TCP port number to which to connect (502 is default).
unitId
- Status= Optional.
- Defines the slave unit ID number from which to request data.
- When this is specified in the device's unique code value, the field cod's unitId value must be omitted.
- When unitIdunitIdunitId is not specified in the device's unique code value, each field code must contain the unitId value.
connectTimeoutMS
- Status= Optional.
- If there is a reason the default 20 second (20000 ms) timeout is not appropriate, then you can specify a millisecond timeout value here.
Note: It is unlikely you will need to use this setting in the unit's device code.
Device Profile–Naming Conventions of Field Codes
The generic Modbus/TCP device adapter uses the device profile’s field ‘code’ values to build a list of values to retrieve from the remote device.
fieldType
- Status= Required.
- Allowed Values:
- c=Coil
- di=Discrete Input
- ir=Input Register
- hr=Holding Register
unitid
- Status= Required (when unit's unique device code does not specify the unitId value).
- Allowed Values
- Numeric value between 0 and max slave unit id on remote device.
- This value identifies the remote (slave) unit id from which to retrieve the data.
- A device profile may have multiple unitId values present in the device profile.
Note: By allowing the device’s unique code value to specify the unitId, this allows a single device profile to be used for multiple unitIds. This is helpful when the remote units vary the slave unitId value, but not the field mapping definition.
address
- Status = Required.
- Allowed Values
Note: Values vary based on fieldType value
- c = Starts at 1. Modbus function code of 1.
- di= Starts at 10001. Modbus function code of 2.
- ir= Starts at 30001. Modbus function code of 4.
- hr= Starts at 40001. Modbus function code of 3.
numRegs
- Status=Optional
- Default Value =1
- Max Value (currently) = 2
- Description: Defines the number of 16-bit register values to combine into one value.
For example, if a remote system is storing a date timestamp value which requires 32-bits to store that value, you specify the first address via the ‘address’ portion of the field code and specify a 2 for the numRegs value.
dataOrder
- Status = Optional
- Device Value = none
- Applies to “Input Registers” (ir) and “Holding Registers” (hr) data values only when the numRegs value is greater than 1 (2 being the max :: 32-bit value).
The Modbus protocol itself does define how IEEE 754 number values are to be stored or retrieved because the Modbus protocol only deals with Integer values.
Depending on the device that the data is to be retrieved from, you will have to specify the data order so that the Integer register values retrieved will be assembled in the correct order when converting to Number (IEEE 754 float value) fields.
This is also functional for “Integer” fields as well, because there have been instances where devices are not storing/sending Integer values in “Network Order”.
- Valid Values:
- n=Network Order
No change in byte or word ordering.
- sb=Swap Bytes
The bytes within each word will be swapped.
- sw=Swap Words
The word values are swapped but byte order is unchanged.
- s=Swap Words and Swap Bytes
The word values and bytes within each word are swapped.
Device Profile Examples
Here’s an example of retrieving two ir values from two different unitIds in the same device profile. This means the device’s “device code” value does not contain the unitId value so it must be specified in the field code value in the device profile.
Here’s an example where a timestamp is stored in two 16-bit registers and the device adapter combines them into one value by the field code value having _2 for the numRegs value. This is also an example of a device profile where the unitId is not specified in the field code because the device’s code value defines that value.