Function codes

The inverter supports the following function codes:
Function code
Function name
Info
3
0x03
Read Holding Registers
Reading of a single register or a group of several interconnected registers.
6
0x06
Preset Single Register
Writing of a single register.
16
0x10
Preset Multiple Registers
Writing of a single register or a group of several interconnected registers.
23
0x17
Read/Write 4X Registers
Reading and writing within a transaction:
–
Writing of a data block into a group of several interconnected registers.
 
–
Reading from a block of interconnected registers.
 
 
Frame structure
Modbus Application Header (MBAP)
Protocol Data Unit (PDU)
Transaction number
Protocol characters
(always 0x0000)
Number of the bytes still to follow
Unit identifier
Function code
Data / error code
2 bytes
2 bytes
2 bytes
1 byte
1 byte
n byte
Tab. 1: ADU (Application Data Unit)
Communication is established on the basis of the client/server mode. Communication is always started by a client request.
The server (inverter) then either gives a valid response or outputs an error code (provided that the request has been received and evaluated as valid message).
In case of a valid answer, the function code is returned. In the event of an error, a function code assigned to the request is returned.
Error causes can be invalid CRC checksums, non-supported function codes or impermissible data accesses.
Elements of the ADU:
–
MBAP (7 bytes)
 
–
Number of the bytes still to follow in the message.
 
–
Address of the inverter.
 
–
The other bytes of the header are not described here.
 
 
–
Function code
 
–
The function codes exclusively refer to "4X registers", i. e. registers from the address 4000.
 
–
All data in the inverter can only be accessed via these 4X registers, see: Data mapping 
 
–
The 4xxxx reference is implicit, i. e. given by the function code used. In the frame therefore the leading 4 is omitted in the addressing process.
 
–
Lenze supports the basic 1 addressing of Modbus, i.e. the numbering of the registers starts with 1 whereas addressing starts with 0. For example, the address 0 is used in the frame when register 40001 is read.
 
 
–
Data or error code
 
–
Checksum
 
All ADU contents are represented in the Big Endian format (most significant byte first).
 
Error codes
In the event of an error, the server (inverter) responds with a function code associated with the message:
Function code
Associated function code in the event of an error
Supported error codes
0x03
0x83
0x01, 0x02, 0x03, 0x04
0x06
0x86
0x01, 0x02, 0x03, 0x04
0x10
0x90
0x01, 0x02, 0x03, 0x04
0x17
0x97
0x01, 0x02, 0x03, 0x04
Error code
Designation
Cause(s)
0x01
Invalid function code
The function code is not supported by the inverter, or the inverter is in a state in which the request is not permissible or in which it cannot be processed.
0x02
Invalid data address
The combination of a start address and the length of the data to be transmitted is invalid.
Example: If you have a server with 100 registers, the first register has the address 0 and the last register has the address 99. If there is a request of four registers now, from the start address 96, the request can be processed successfully (for registers 96, 97, 98, and 99). If, however, five registers from the start address 96 are queried, this error code is returned, since the server has no register with the address 100.
0x03
Invalid data value
Error in the reset structure of a complex request, e. g. because the data length that has resulted implicitly is not correct.
The cause, however, is not that a (parameter) value is written outside the valid setting range. As a matter of principle, the Modbus protocol has no information on valid setting ranges of single registers or their meaning.
0x04
Server device failure
A non-correctable error has occurred while the request was processed in the inverter.
 
Data transfer with function code 3
Request
Function code
0x03
Start address
0x0000 ... 0xFFFF
Number of registers (n)
0x01 ... 0x7D (1 ... 125)
Response
Function code
0x03
Number of bytes
2 x (number of registers)
Register value
Data in (n) register of 2 bytes each
Error message
Function code in the event of an error
0x83
Error code
01 ... 04
 
Example for data transfer with function code 3
The data from the registers 40108 to 40110 are to be read.
Request
Info
Function code
0x03
Function code 3
Start address (High)
0x00
Start address 107 (0x006B)
Start address (Low)
0x6B
Number of registers (High)
0x00
Number of registers = 3 (0x0003)
Number of registers (Low)
0x03
Response
Info
Function code
0x03
Function code 3
Number of bytes
0x06
6 bytes are read.
Value in registers 40108 (High)
0x02
Data in register 40108: 0x022B (555).
Value in registers 40108 (Low)
0x2B
Value in registers 40109 (High)
0x00
Data in register 40109: 0x0000 (0).
Value in registers 40109 (Low)
0x00
Value in registers 40110 (High)
0x00
Data in register 40110: 0x0064 (100).
Value in registers 40110 (Low)
0x64
 
Data transfer with function code 6
Request
Function code
0x06
Register address
0x0000 ... 0xFFFF
Register value
0x0000 ... 0xFFFF
Response
Function code
0x06
Register address
0x0000 ... 0xFFFF
Register value
0x0000 ... 0xFFFF
Error message
Function code in the event of an error
0x86
Error code
01 ... 04
 
Example for data transfer with function code 6
The value "3" (0x0003) is to be written into the register 40002.
Request
Info
Function code
0x06
Function code 6
Register address (High)
0x00
Register address for register 40002: 1 (0x0001)
Register address (Low)
0x01
Register value (High)
0x00
Value to be written into the register: 3 (0x0003)
Register value (Low)
0x03
Response
Info
Function code
0x06
Function code 6
Register address (High)
0x00
Register address: 1 (0x0001)
Register address (Low)
0x01
Register value (High)
0x00
Register value: 3 (0x0003)
Register value (Low)
0x03
 
Data transfer with function code 16
Request
Function code
0x10
Start address
0x0000 ... 0xFFFF
Number of registers (n)
0x0001 ... 0x7D (0d125)
Number of bytes
2 x (number of registers)
Register values
Data in (n) register of 2 bytes each
Response
Function code
0x10
Number of bytes
2 x (number of registers)
Register values
Data in (n) register of 2 bytes each
Error message
Function code in the event of an error
0x90
Error code
01 ... 04
 
Example for data transfer with function code 16
In a transaction, the value "10" is to be written into the register 40002 and the value "258" is to be written into the adjacent register 40003.
Request
Info
Function code
0x10
Function code 16
Start address (High)
0x00
Start address is the register 40002: 1 (0x0001)
Start address (Low)
0x01
Number of registers (High)
0x00
Number of registers: 2 (0x0002)
Number of registers (Low)
0x02
Number of bytes
0x04
4 bytes (0x0004) are to be written.
Register value (High)
0x00
The value "10" (0x000A) is written into the register with the start address 1 (= register 40002).
Register value (Low)
0x0A
Register value (High)
0x01
The value "258" (0x0102) is written into the following register (= register 40003).
Register value (Low)
0x02
Response
Info
Function code
0x10
Function code 16
Start address (High)
0x00
Start address: 1 (0x0001)
Start address (Low)
0x01
Number of registers (High)
0x00
Number of registers: 2 (0x0002)
Number of registers (Low)
0x02
 
Data transfer with function code 23
Request
Function code
0x17
Start address for reading (High)
0x0000 ... 0xFFFF
Start address for reading (Low)
0x0000 ... 0xFFFF
Number of registers for reading (High)
0x00 ... 0xFF
Number of registers for reading (Low)
0x00 ... 0xFF
Start address for writing (High)
0x0000 ... 0xFFFF
Start address for writing (Low)
0x0000 ... 0xFFFF
Number of registers for writing (High)
0x00 ... 0xFF
Number of registers for writing (Low)
0x00 ... 0xFF
Number of bytes for writing
2 x (number of registers)
Written value 1 (High)
0x00 ... 0xFF
Written value 1 (Low)
0x00 ... 0xFF
....
...
Written value n (High)
0x00 ... 0xFF
Written value n (Low)
0x00 ... 0xFF
Response
Function code
0x17
Number of bytes for reading
2 x (number of registers)
Read value 1 (High)
0x00 ... 0xFF
Read value 1 (Low)
0x00 ... 0xFF
...
...
Read value x (High)
0x00 ... 0xFF
Read value x (Low)
0x00 ... 0xFF
Error message
Function code in the event of an error
0x97
Error code
02 ... 04
 
Example for data transfer with function code 23
The following tasks are to be executed with a transaction:
–
The values from six connected registers, starting with register 40005, are to be read.
 
–
The value "255" is to be written into each of three connected registers, starting with register 40016.
 
Request
Info
Function code
0x17
Function code 23
Start address for reading (High)
0x00
Start address for reading is the register 40005: 4 (0x0004)
Start address for reading (Low)
0x04
Number of registers for reading (High)
0x00
Number of registers for reading: 6 (0x0006))
Number of registers for reading (Low)
0x06
Start address for writing (High)
0x00
Start address for writing is the register 40016: 15 (0x000F)
Start address for writing (Low)
0x0F
Number of registers for writing (High)
0x00
Number of registers for writing: 3 (0x0003)
Number of registers for writing (Low)
0x03
Number of bytes for writing
0x06
6 bytes (0x06) must be provided in 3 registers.
Written value 1 (High)
0x00
Data: 255 (0x00FF)
Written value 1 (Low)
0xFF
Written value 2 (High)
0x00
Data: 255 (0x00FF)
Written value 2 (Low)
0xFF
Written value 3 (High)
0x00
Data: 255 (0x00FF)
Written value 3 (Low)
0xFF
Response
Info
Function code
0x17
Function code 23
Number of bytes for reading
0x0C
12 bytes (0x0C) from 6 registers are read.
Read value 1 (High)
0x00
1. written value
Data: 254 (0x00FE)
Read value 1 (Low)
0xFE
Written value 2 (High)
0x0A
2. written value
Data: 2765 (0x0ACD)
Read value 2 (Low)
0xCD
Read value 3 (High)
0x00
3. read value
Data: 1 (0x0001)
Read value 3 (Low)
0x01
Read value 4 (High)
0x00
4. read value
Data: 3 (0x0003)
Read value 4 (Low)
0x03
Read value 5 (High)
0x00
5. read value
Data: 13 (0x000D)
Read value 5 (Low)
0x0D
Read value 6 (High)
0x00
6. read value
Data: 255 (0x00FF)
Read value 6 (Low)
0xFF