Method of control via Modbus protocol
−14−
•
Error check
In the Modbus RTU mode, error checks are based on the CRC-16 method. The slave calculates a CRC-16 of each
received message and compares the result against the error check value included in the message. If the calculated
CRC-16 value matches the error check value, the slave determines that the message is normal.
CRC-16 calculation method
1.
Calculate an exclusive-OR (XOR) value of the default value of FFFFh and slave address (8 bits).
2.
Shift the result of step 1 to the right by 1 bit. Repeat this shift until the overflow bit becomes "1."
3.
Upon obtaining "1" as the overflow bit, calculate an XOR of the result of step 2 and A001h.
4.
Repeat steps 2 and 3 until a shift is performed eight times.
5.
Calculate an XOR of the result of step 4 and function code (8 bits).
Repeat steps 2 to 4 for all bytes.
The final result gives the result of CRC-16 calculation.
Response
Slave-returned responses are classified into three types: normal response, no response, and exception response.
The response message structure is the same as the query message structure.
Slave address
Function code
Data
Error check
8 bits
8 bits
3×8 to 33×8 bits
16 bits
•
Normal response
Upon receiving a query from the master, the slave executes the requested process and returns a response.
•
No response
The slave may not return a response to a query sent by the master. This condition is referred to as "No response."
The causes of no response are explained below.
Transmission error
The slave discards the query and does not return a response if any of the following transmission errors is detected.
Cause of transmission error
Description
Framing error
Stop bit 0 was detected.
Parity error
A mismatch with the specified parity was detected.
Mismatched CRC
The calculated value of CRC-16 was found not matching the error check value.
Invalid message length
The message length exceeded 256 bytes.
Other than transmission error
A response may not be returned without any transmission error being detected.
Cause
Description
Broadcast
If the query was broadcast, the slave executes the requested process but does not return
a response.
Mismatched slave address
The slave address in the query was found not matching the slave address of the driver.