Modbus rtu communication protocol pdf




















The data bytes contain the datacollected by the slave, such as register values or status. If an error occurs,the function code is modified to indicate that the response is an errorresponse, and the data bytes contain a code that describes the error. The errorcheck field allows the master to confirm that the message contents are valid. The main advantage of this mode isthat it allows time intervals of up to one second to occur between characterswithout causing an error.

The main advantage of this mode is that its greatercharacter density allows better data throughput than ASCII for the same baudrate. Each message must be transmitted in a continuous stream. Coding System Eight-bit binary, hexadecimal The allowable characters transmitted for all other fields are hexadecimal Networked devices monitor the network bus continuously for the coloncharacter. When one is received, each device decodes the next field the addressfield to find out if it is the addressed device.

Intervals of up to one second can elapse between characters within the message. If a greater interval occurs, the receiving device assumes an error hasoccurred. A typical message frame is shown below. This is most easily implemented as a multiple of character times at thebaud rate that is being used on the network shown as T1-T2-T3-T4 in the figurebelow.

The first field then transmitted is the device address. The allowable characters transmitted for all fields are hexadecimal Networked devices monitor the network bus continuously, including duringthe silent intervals.

When the first field the address field is received, eachdevice decodes it to find out if it is the addressed device.

Following the last transmitted character, a similar interval of at least 3. A new message can begin after thisinterval. The entire message frame must be transmitted as a continuous stream. If a silentinterval of more than 1.

Similarly, if a new message begins earlier than 3. This will set an error, as the value in the final CRC fieldwill not be valid for the combined messages. A typical message frame is shownbelow. The individual slave devices are assigned addresses in the range of The Function Code field tells the addressed slave what function to perform.

The following functions are supported by Modbus poll. Contents of the Error Checking Field Two kinds of error-checking methods are used for standard Modbus networks. Theerror checking field contents depend upon the method that is being used. The error check characters are the result of aLongitudinal Redundancy Check LRC calculation that is performed on the messagecontents, exclusive of the beginning colon and terminating CRLF characters.

LRC Example Code. RTU When RTU mode is used for character framing, the error-checking field contains abit value implemented as two eight-bit bytes. The error check value is theresult of a Cyclical Redundancy Check calculation performed on the messagecontents. The CRC field is appended to the message as the last field in the message. Whenthis is done, the low-order byte of the field is appended first, followed by thehigh-order byte. The CRC high-order byte is the last byte to be sent in themessage.

CRC Example Code. Request The request message specifies the starting coil and quantity of coils to be read. Response The coil status response message is packed as one coil per bit of the data field. The LSB of the first data byte contains the coil addressed in therequest.

The other coils follow toward the high-order end of this byte and from low order to high order in subsequent bytes. If the returned coil quantity is not a multiple of eight, the remaining bits in the final data byte will be padded with zeroes toward the high-order end of the byte.

The byte count field specifies the quantity of complete bytes of data. Request The request message specifies the starting input and quantity of inputs to be read. Response The input status response message is packed as one input per bit of the data field.

The LSB of the first data byte contains the input addressed in therequest. The other inputs follow toward the high-order end of this byte and from low order to high order in subsequent bytes. If the returned input quantity is not a multiple of eight, the remaining bits in the final data byte will be padded with zeroes toward the high-order end of the byte.

Request The request message specifies the starting register and quantity of registers to be read. Response The register data in the response message are packed as two bytes per register, with the binary contents right justified within each byte. For each register the first byte contains the high-order bits, and the second contains the low-order bits. Request The request message specifies the coil reference to be written. Coils are addressed starting at zero-coil 1 is addressed as 0.

A value of FF 00 hex requests the coil to be ON. A value of 00 00 requests it to be OFF. All other values are illegal and will not affect the coil. Response The normal response is an echo of the request, returned after the coil state has been written. If a silentinterval of more than 1. Similarly, if a new message begins earlier than 3. This will set an error, as the value in the final CRC fieldwill not be valid for the combined messages.

A typical message frame is shownbelow. The individual slave devices are assigned addresses in the range of The Function Code field tells the addressed slave what function to perform. The following functions are supported by Modbus poll. Contents of the Error Checking Field Two kinds of error-checking methods are used for standard Modbus networks.

Theerror checking field contents depend upon the method that is being used. The error check characters are the result of aLongitudinal Redundancy Check LRC calculation that is performed on the messagecontents, exclusive of the beginning colon and terminating CRLF characters. LRC Example Code. RTU When RTU mode is used for character framing, the error-checking field contains abit value implemented as two eight-bit bytes.

The error check value is theresult of a Cyclical Redundancy Check calculation performed on the messagecontents. The CRC field is appended to the message as the last field in the message. Whenthis is done, the low-order byte of the field is appended first, followed by thehigh-order byte. The CRC high-order byte is the last byte to be sent in themessage.

CRC Example Code. Request The request message specifies the starting coil and quantity of coils to be read. Response The coil status response message is packed as one coil per bit of the data field. The LSB of the first data byte contains the coil addressed in therequest. The other coils follow toward the high-order end of this byte and from low order to high order in subsequent bytes. If the returned coil quantity is not a multiple of eight, the remaining bits in the final data byte will be padded with zeroes toward the high-order end of the byte.

The byte count field specifies the quantity of complete bytes of data. Request The request message specifies the starting input and quantity of inputs to be read. Response The input status response message is packed as one input per bit of the data field. The LSB of the first data byte contains the input addressed in therequest. The other inputs follow toward the high-order end of this byte and from low order to high order in subsequent bytes.

If the returned input quantity is not a multiple of eight, the remaining bits in the final data byte will be padded with zeroes toward the high-order end of the byte. Request The request message specifies the starting register and quantity of registers to be read.

Response The register data in the response message are packed as two bytes per register, with the binary contents right justified within each byte. For each register the first byte contains the high-order bits, and the second contains the low-order bits. Request The request message specifies the coil reference to be written.

Coils are addressed starting at zero-coil 1 is addressed as 0. A value of FF 00 hex requests the coil to be ON. A value of 00 00 requests it to be OFF.

All other values are illegal and will not affect the coil. Response The normal response is an echo of the request, returned after the coil state has been written. Example of a response to the request:. Request The request message specifies the register reference to be Written. Registers are addressed starting at zero-register 1 is addressed as 0. The requested Write value is specified in the request data field. Here is an example of a request to Write register to 00 03 hex in slave device Response The normal response is an echo of the request, returned after the register contents have been written.

Request The request message specifies the coil references to be written. A logical 1 in a bit position of the field requests the corresponding coils to be ON. A logical 0 requests it to be OFF. Below is an example of a request to write a series of ten coils starting at coil 20 addressed as 19, or 13 hex in slave device



0コメント

  • 1000 / 1000