Function Code supported by Modbus

Source: Internet
Author: User

Function Code supported by Modbus:

The following table lists the function codes supported by Modbus:

Function Code

Name

Function

01

Read coil status

Obtains the current status (ON/OFF) of a set of logical coils)

02

Read input status

Obtains the current status (ON/OFF) of a set of switch inputs)

03

Read holding register

Obtains the current binary value in one or more keep registers.

04

Read input registers

Obtains the current binary value in one or more input registers.

05

Strong single coil

Strong the disconnection status of a logic Coil

06

Preset Single Register

Load the binary value into a holding register

07

Read exception status

Obtains the breaking status of eight internal coils. The address of these eight coils is determined by the Controller.

08

Delivery diagnosis and Verification

Send the diagnostic verification message to the slave to evaluate the communication processing

09

Programming (for 484 only)

Allows the host to simulate the function of the programmer and modify the logic of the PC slave.

10

Consultation (only for 484)

Allows the host to communicate with a slave machine that is executing program tasks and to check whether the slave machine has completed its operation tasks. This function code is sent only after messages containing Function Code 9 are sent.

11

Read event count

Allows the host to issue a ticket and then determine whether the operation is successful, especially when the command or other responses generate a communication error.

12

Read communication event records

However, the host retrieves the Modbus transaction communication event records of each slave. If a transaction is processed successfully, the related error is returned.

13

Programming (184/384 484 584)

Allows the host to simulate the programmer function to modify the PC slave Logic

14

Inquiry (184/384 484 584)

Allows the host to communicate with the slave that is executing the task and regularly checks whether the slave has completed program operations. This function code is sent only after messages containing function 13 are sent.

15

Strong multi-Coil

Enable the disconnection of a series of continuous logic Coils

16

Preset multi-register

Load the specific binary value into a series of continuous holding registers.

17

Report slave ID

Allows the host to determine the type of the addressing slave and the status of the slave running indicator.

18

(884 and micro 84)

Allows the host to simulate programming and modify the PC status logic.

19

Reset communication link

After a non-modifiable error occurs, it indicates that the slave machine is reset to a known state and the sequential bytes can be reset.

20

Read common parameters (584l)

Display the data information in the extended storage file

21

Write common parameters (584l)

Write or modify common parameters to an extended storage file

22 ~ 64

Reserved for extended feature backup

 

65 ~ 72

Reserved for user functions

Reserved as extended encoding of user functions

73 ~ 119

Invalid Function

 

120 ~ 127

Retained

Reserved for internal functions

128 ~ 255

Retained

Used for exception response

In these function codes, the numbers 1, 2, 3, 4, 5, and 6 are used for a long time to read and write the numbers and analog numbers of the lower computer.

1. read-write number register (coil status ):

The computer sends the command: [Device address] [command no. 01] [Starting Register address high 8 bits] [low 8 bits] [number of read registers high 8 bits] [low 8 bits] [CRC verification low 8-bit] [High 8-bit CRC verification]

Example: [11] [01] [00] [13] [00] [25] [low CRC] [High CRC]

Meaning:

<1> device address: you can mount multiple devices on the 485 bus. The device Address indicates the device you want to communicate. In this example, we want to communicate with number 17 (decimal 17 is hexadecimal 11.

<2> command number 01: The command number for reading numbers is fixed to 01.

<3> 8-bit high and 8-bit low starting address: indicates the starting address of the switch type to be read (the starting address is 0 ). For example, the starting address in the example is 19.

<4> 8-bit high registers and 8-bit low registers: Number of switches read from the starting address. In this example, there are 37 switches.

<5> CRC verification: The CRC verification starts from the beginning. At the end of this agreement, I will introduce it again. Note that the order of high and low bytes in the CRC check command is the opposite of that in other commands.

Device response: [device address] [command no. 01] [number of returned bytes] [data 1] [data 2]... [data N] [8-bit low CRC verification] [8-bit high CRC verification]

Example: [11] [01] [05] [cd] [6B] [B2] [0e] [1b] [low CRC] [High CRC]

Meaning:

<1> the device address and command number are the same as those above.

<2> Number of returned bytes: the number of bytes of data, that is, the value of N in data 1, 2... n.

<3> data 1... n: because each data is an 8-digit number, each data indicates the value of 8 switches, and each digit is 0, indicating that the corresponding switch is disconnected. The value of 1 indicates that the switch is closed. In the example, the switch is closed, the switch is closed on the 21st, the switch is closed on the 22nd, the switch is closed on the 23rd, the switch is closed on the 24, the switch is closed on the 25, the switch is closed on the 26, and the switch is closed on the 27... if the requested switch quantity is not an integer multiple of 8, the high part of the last byte is meaningless and set to 0.

<4> CRC verification is the same as above.

2. Read-only numeric registers (input status ):

Similar to reading the coil, the command number of the second byte is not 1 but 2.

3. Write number (coil status ):

The computer sends the command: [Device address] [command no. 05] [the Register address to be deprecated is 8 bits in height] [8 bits in height] [8 bits in height] [low 8-bit CRC verification] [High 8-bit CRC verification]

Example: [11] [05] [00] [AC] [ff] [00] [low CRC] [High CRC]

Meaning:

<1> the device address is the same as the above.

<2> command number: the command number for writing numbers is fixed to 05.

<3> the Register address to be placed down is 8 bits in height and 8 bits in height: indicates the address of the switch to be set down.

<4> 8-bit/8-Bit Data Height: indicates the status of the switch to be switched. In this example, the switch is closed. Note: Here, only [ff] [00] indicates that [00] [00] indicates that the disk is closed, and other values are invalid.

<5> note that only one switch value can be set for one command.

Device response: If the command sent by the computer is returned as is, otherwise no response is returned.

4. Read and Write analog registers (keep registers ):

The computer sends the command: [Device address] [command no. 03] [Starting Register address high 8 bits] [low 8 bits] [number of read registers high 8 bits] [low 8 bits] [CRC verification low 8-bit] [High 8-bit CRC verification]

Example: [11] [03] [00] [6B] [00] [03] [low CRC] [High CRC]

Meaning:

<1> the device address is the same as the above.

<2> command number: the command number for reading analog data is fixed to 03.

<3> 8-bit high and 8-bit low starting address: indicates the starting address of the analog quantity to be read (the starting address is 0 ). For example, the starting address is 107.

<4> 8-bit high registers and 8-bit low registers: Number of analog reads starting from the starting address. In this example, three analog numbers are used. Note that two bytes must be returned for an analog value in the returned information.

Device response: [device address] [command no. 03] [number of returned bytes] [data 1] [data 2]... [data N] [8-bit low CRC verification] [8-bit high CRC verification]

Example: [11] [03] [06] [02] [2B] [00] [00] [00] [64] [low CRC] [High CRC]

Meaning:

<1> the device address and command number are the same as those above.

<2> Number of returned bytes: the number of bytes of data, that is, the value of N in data 1, 2... n. In this example, three analog data are returned. Because an analog data requires two bytes, a total of six bytes are returned.

<3> data 1... n: [data 1] [data 2] is the 8-bit high and 8-bit low of 1st analog data, [data 3] [data 4] is the 8-bit high and 8-bit low of 2nd analog numbers, and so on. The values returned in this example are 100, and respectively.

<4> CRC verification is the same as above.

5. Read-Only analog registers (input registers ):

Similar to reading the storage register, the command number of the second byte is no longer 2 but 4.

6. Write a single analog register (keep register ):

The computer sends the command: [Device address] [command No. 06] [the Register address to be placed down is 8 bits in height] [8 bits in height] [8 bits in height] [8 bits in height] [low 8-bit CRC verification] [High 8-bit CRC verification]

Example: [11] [06] [00] [01] [00] [03] [low CRC] [High CRC]

Meaning:

<1> the device address is the same as the above.

<2> command number: the command number for writing analog data is fixed to 06.

<3> the Register address to be deprecated is 8 bits and 8 bits: the address of the analog register to be deprecated.

<4> the data in the lower part is 8 bits in height and 8 bits in height. This indicates that the data in the lower part is required. For example, set the value of register 1 to 3.

<5> note that only one analog value can be placed under one command.

Device response: If the command sent by the computer is returned as is, otherwise no response is returned.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.