Understanding Modbus Registers
Modbus registers or addresses have two key distinctions: read operations and write operations. Modbus read operations correspond to function codes FC1, FC2, FC3, and FC4. Write operations, used for sending commands to devices, are associated with function codes FC5, FC6, FC15, and FC16. This distinction is crucial when adding Modbus registers to the device address map.Please note that for most devices, the most commonly used function codes are FC3, FC6, and FC16. However, it is important to know that the PPL controller supports all Modbus function codes, despite the frequent use of these particular ones.
Naming Conventions
While not mandatory, it is recommended to adopt the following naming conventions for clarity and usability:- Write Operations: Prefix register names with
control.to indicate that the register is used for controlling the device. - Read Operations: Prefix register names with
measure.to signify that the register is used for measurement purposes. - Fault and Warning Registers: Use the prefixes “fault.” or “warning.” for registers that monitor faults or warnings. This helps in generating appropriate Telegram notifications and alerts for the system.
Required Parameters
Each register in the address map must include the following parameters, regardless of whether it is for reading or writing Modbus registers:The Modbus device address from which to read a register or to which to write a value.Example:
0Specifies the number of registers to read or write. This should be 1 for (u)int16 data types and 2 for (u)int32, float32 or string32 data types and 4 for (u)int64 or float64 data types.Example:
1A unique name for the register, representing the measurement point read from or written to the Modbus device.Example:
measure.ports.port1.voltageThe data type of the value.Options:
int16 | uint16 | int32 | uint32 | float32 | string32 | int64 | uint64 | float64The Modbus function code required to read from or write to the device.Options:
1 | 2 | 3 | 4 | 5 | 6 | 15 | 16Optional Parameters
These parameters are not necessary for every register but can be included as needed:The scaling factor to apply to the Modbus register’s return value or the value being written.Example:
0.1The offset to apply to the Modbus register’s return value or the value being written.Example:
10The direction of the power or current flow on a port of the device. When the direction is set to
output,
the register value will be inverted.Options: input | outputThe minimum value of the register. For write register, setting the minimum value prevents you from
writing a value lower than the minimum value. The control command will be blocked by the Power Platform.Example:
0The maximum value of the register. For write register, setting the maximum value prevents you from
writing a value higher than the maximum value. The control command will be blocked by the Power Platform.Example:
10Indicates if mapping should be applied to the return value or the value being written.Example:
Indicates if the register is a multi-read register.
Specifies the word order notation.Options:
littleEndian | bigEndianSpecifies the byte order notation.Options:
littleEndian | bigEndianRequired Register communicationCheck
There is a specific register that must be included in every Modbus address map, known as communicationCheck. This register allows the PPL controller to verify communication with the Modbus device. The controller pings the device and attempts to read the value from the register specified as communicationCheck. A successful read confirms the connection between the PPL controller and the Modbus device.
This register only needs the required parameters to be filled in; optional parameters are not necessary. However, the register must be a valid Modbus register on the device. Therefore, it can be a duplicate of another Modbus register in your address map, but with a different name. For example:
.json extension. For example, cet_30C3_address_map.json.
Example
modbus_address_map.json