Instruction Manual
121
E SR-750 UM
15-5
Checksum Calculation
Method
• A checksum can be appended to the read data when it is being sent.
* No checksum can be appended to commands or responses.
• The checksum allows you to check if garbled text was caused during the RS-
232C communication.
If the checksum does not match due to concurrent use of the PASS/RTRY and
ACK/NAK protocols, create a program that requests to send again (RTRY or
).
Checksum calculation range and location
The checksum is calculated using all characters that are not a part of the header or
the terminator and 2 characters of ASCII code are appended immediately before
the terminator.
Data format
With appended data
Checksum calculation method
The checksum (cc) is calculated, assuming that the read data is "ABC123".
The characters are converted to ASCII code and the converted codes are
expressed in 8-bit binary numbers as shown below.
A bitwise exclusive OR operation (XOR) is performed on each character.
ASCII code bit
A → 41h → 0100 0001
B → 42h → 0100 0010
C → 43h → 0100 0011
1 → 31h → 0011 0001
2 → 32h → 0011 0010
3 → 33h → 0011 0011
⊕
↓ ↓
0111 0000 → 70h
* The exclusive OR generates 1 when there is an odd number of 1 bit and 0 when
there is an even number of 1 bit.
The checksum is the character representation of the hexadecimal value in 2-digit
ASCII code after the above operation.
Therefore, cc = 70 (37h 30h)
Example:
Reference
Exclusive OR equation
Perform a bitwise operation based on the following equation:
0⊕0 = 0
0⊕1 = 1
1⊕0 = 1
1⊕1 = 0
* ⊕ : Exclusive OR operator
Conversion from hexadecimal number to binary number
Refer to the following chart for converting ASCII code to binary number.
Header
ABC 123 Checksum Terminator
Header
ERROR Checksum Terminator
leads to a cc of 58.
Header
KEYENCE : 100% Checksum Terminator
leads to a cc of 74.
Hexadecimal
number
0 1 2 3 4 5 6 7
Binary number 0000 0001 0010 0011 0100 0101 0110 0111
Hexadecimal
number
8 9 A B C D E F
Binary number 1000 1001 1010 1011 1100 1101 1110 1111
NAK
Header Read data
Checksum
Termi nator
Header Read data
Checksum
Terminator
Data size
Read detailed
error code
:::PMI
15-6
ASCII Code List
High-order 4 bits
Hexadecimal 0 1 2 3 4 5 6 7
Binary 0000 0001 0010 0011 0100 0101 0110 0111
Low-order 4 bits
0 0000 DLE (SP) 0 @ P ‘ p
1 0001 SOH DC1 ! 1 A Q a q
2 0010 STX DC2 “ 2 B R b r
3 0011 ETX DC3 # 3 C S c s
4 0100 EOT DC4 $ 4 D T d t
5 0101 ENQ NAK % 5 E U e u
6 0110 ACK SYN & 6 F V f v
7 0111 BEL ETB ‘ 7 G W g w
8 1000 BS CAN ( 8 H X h x
9 1001 HT EM ) 9 I Y i y
A 1010 LF SUB * : J Z j z
B 1011 VT ESC + ; K [ k {
C 1100 CL FS , < L \ l |
D 1101 CR GS - = M ] m }
E 1110 SO RS . > N ^ n ~
F 1111 SI US / ? O _ o del