beautypg.com

G checksum calculation method, Appendix g checksum calculation method – KEYENCE N-400 User Manual

Page 143

background image

135

Appendices

Appendices

Appendix G

Checksum Calculation Method

You can add a checksum to transmitted data. (The checksum cannot be added to a
command or a response to a command.)

Adding a checksum enables incorrect data translation to be detected in the RS-
232C communication. If the checksum does not match when the PASS/RTRY or
ACK/NAK protocol is used, modify the program so that the “Request to resend”
(RTRY or NAK) command is sent to the N-400. To set the checksum, use the
“PROTOCOL SETUP” screen of the N-400 setup software. (The checksum cannot
be added when the PLC link is used.)

Checksum calculation range and the position to add checksum

The checksum calculation is performed with all characters except for the header
and delimiter. The checksum is added immediately before the delimiter.

CC = Checksum (Two ASCII code characters)

Data communication in multi-drop link mode

Data communication in multi-head mode

Checksum calculation method

Example:

Calculate the checksum (CC) in the above example.

Convert each character into the ASCII code as shown below, and express the
result as 8-bit binary numbers.

Calculate the “Exclusive-OR” of the binary numbers of each bit.

Header % P mm

CC

Delimiter

Read Data

Calculation range

Result

Header

CC Delimeter

Read Data

Calculation range

Result

* Based on the “Exclusive OR” logic,

when an odd number of “1”s are
present, the calculation result is “1”,
and when an even number of “1”s
are present, the calculation result is
“0”.

Header % P 01

CC

Delimiter

AB12

%

25h

0010

0101

P

50h

0101

0000

0

30h

0011

0000

1

31h

0011

0001

2Dh

0010

1101

A

41h

0100

0001

B

42h

0100

0010

1

31h

0011

0001

2

32h

0011

0010

0101

1001

59h

+

ASCII code
(Hexadecimal) Binary

Data