Data Access
Reading Input Registers / Read Holding Registers (FC03 / FC04)
With this function code one or more 16-bit values can be read. This function can be used with the NanoJ objects (see "NanoJ Objects") or process data objects (minimum 4 byte alignment, see Process data objects (PDO) for details).
Request | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Function code | 1 Byte | 03h |
Starting Address | 2 Bytes | 0000h to FFFFh |
Quantity of Registers | 2 Bytes | 1 to 7Dh (125d) |
CRC | 2 Bytes |
Response ("M" being the number of registers to read) | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Function code | 1 Byte | 03h |
Byte count | 1 Byte | 2 * M |
Register value | 2 Bytes | |
CRC | 2 Bytes |
Error | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Error code | 1 Byte | 83h |
Exception code | 1 Byte | 01, 02, 03 or 04 |
CRC | 2 Bytes |
Example |
|
Here is an example of a request to read register 5000 (1388h) and the following register (=2 registers):
|
Write Single Register (FC06)
With this function code one 16-bit value can be written. This function can be used with the PDO area (see Process data objects (PDO)).
Request | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Function code | 1 Byte | 06h |
Register Address | 2 Bytes | 0000h to FFFFh |
Register Value | 2 Bytes | 0000h to FFFFh |
CRC | 2 Bytes |
Response | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Function code | 1 Byte | 06h |
Register Address | 2 Bytes | 0000h to FFFFh |
Register Value | 2 Bytes | 0000h to FFFFh |
CRC | 2 Bytes |
Error | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Error code | 1 Byte | 86h |
Exception code | 1 Byte | 01, 02, 03 or 04 |
CRC | 2 Bytes |
Example |
|
Here is an example of a request/response to write the value "0001" to register 6000 (1770h):
|
Write Multiple Registers (FC16)
With this function code one or more 16-bit values can be written. This function can be used with the NanoJ objects (see "NanoJ Objects") or process data objects (see Process data objects (PDO) for details).
Request ("N" being the number of registers to write) | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Function code | 1 Byte | 10h |
Starting Address | 2 Bytes | 0000h to FFFFh |
Quantity of Registers | 2 Bytes | 0001h to 007Bh |
Byte Count | 1 Byte | 2 * N |
Registers Value | N * 2 Bytes | |
CRC | 2 Bytes |
Response | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Function code | 1 Byte | 10h |
Starting Address | 2 Bytes | 0000h to FFFFh |
Quantity of Registers | 2 Bytes | 0001h to 007Bh |
CRC | 2 Bytes |
Error | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Error code | 1 Byte | 90h |
Exception code | 1 Byte | 01, 02, 03 or 04 |
CRC | 2 Bytes |
Example |
|
Here is an example of a request to write the values "0102h" and "0304h" starting at the register 6000 (1770h), number of registers is 2, length of the data 4:
|
Report server ID (FC17)
With this function code the description of the type, status and other information of the device can be read.
Request | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Function code | 1 Byte | 11h |
CRC | 2 Bytes |
Response | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Function code | 1 Byte | 03h |
Byte count | 1 Byte | 01h |
Run Indicator Status | 1 Byte | 00h = OFF, FFh = ON |
Additional Data | ||
CRC | 2 Bytes |
Error | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Error code | 1 Byte | 91h |
Exception code | 1 Byte | 01 or 04 |
CRC | 2 Bytes |
Example |
|
Here is an example of a request and response to report the ID and status:
|
Read/Write Multiple registers (FC23)
With this function code one or more 16-bit values can be read and written at the same time. This function can be used with the NanoJ objects (see "NanoJ Objects") or process data objects (see Process data objects (PDO) for details).
Request ("N" being the number of registers to write) | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Function code | 1 Byte | 17h |
Read Starting Address | 2 Bytes | 0000h to FFFFh |
Quantity to Read | 2 Bytes | 0001h to 0079h |
Write Starting Address | 2 Bytes | 0000h to FFFFh |
Quantity to Write | 2 Bytes | 0001h to 0079h |
Write Byte Count | 1 Byte | 2 * N |
Write Registers Value | N * 2 Bytes | |
CRC | 2 Bytes |
Response ("M" being the number of registers to write) | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Function code | 1 Byte | 17h |
Byte count | 1 Byte | 2 * M |
Read Registers value | M * 2 Bytes | |
CRC | 2 Bytes |
Error | ||
---|---|---|
Name | Length | Value |
Slave Address | 1 Byte | |
Error code | 1 Byte | 97h |
Exception code | 1 Byte | 01, 02, 03 or 04 |
CRC | 2 Bytes |
Example |
|
Here is an example of a request to read six registers starting at register 4, and to write three registers starting at register 15: Here is an example of a request to read two registers starting at 5000 (1388h) and a write to two registers at 6000 (1770h) with 4 bytes and the data "0102h" and "0304h":
|