8-4
Chapter 8. Modbus Communication Function
• Checksum (LRC)
This value is for checking whether something abnormal (e.g., electromagnetic
noise) has caused the message content to change during transmission. The
checksum is expressed as a 2-digit hexadecimal character code. The procedure for
calculating the checksum is as follows.
(1) Add from the start of the station address to immediately before the
checksum. Note that the values to be added are not the ASCII character
values in the instruction message but the one-byte binary data converted
from two ASCII characters.
(2) Take the two's complement of the sum.
(3) Convert the low-order one byte of the sum to a 2-digit hexadecimal
character code.
The following is a sample checksum calculation:
Sample message
: : 3AH (start of the message)
0: 30H (1st byte of the station address)
A: 41H (2nd byte of the station address)
0: 30H (1st byte of the read command)
3: 33H (2nd byte of the read command)
0: 30H (1st byte of the starting word address)
3: 33H (2nd byte of the starting word address)
E: 45H (3rd byte of the starting word address)
9: 39H (4th byte of the starting word address)
0: 30H (1st byte of the read count)
0: 30H (2nd byte of the read count)
0: 30H (3rd byte of the read count)
2: 32H (4th byte of the read count)
(1) Add from the start of the station address to immediately before the
checksum. The addition calculation is as follows:
0AH + 03H + 03H + E9H + 00H + 02H
The result is FBH.
(2) The low-order byte of FBH is FBH. It remains unchanged. The two's
complement of FBH is 05H.
(3) Convert the obtained 05H to a two-byte ASCII code.
The result is:
0 : 30H
5 : 35H
The two bytes, 0 (30H) and 5 (35H), are the checksum.
• Delimiter (CR/LF)
This indicates the end of the message. Immediately after LF is received, the device
enters a state allowed to process the received message.