58
IND100077-259
Calculating Checksums (IDCHK, IHCHK)
Here is a simplified method to calculating checksum. The example is using decimal numbers, for explanation purposes
only. The actual values are in hexadecimal throughout the user manual.
Visual representation of the byte:
Attention
Address
CMD
CMD
CMD
Length
IHCHK
DATA
IDCHK
Header
Number Base Systems mentioned in this section.
Binary
2
7
2
6
2
5
2
4
2
3
2
2
2
1
2
0
Decimal
128
64
16
16
8
4
2
1
Hex
80
40
20
10
8
4
2
1
The total value of a byte is represented by 8 bits, all bits have the value of either 0 or 1. One byte can represent a
decimal number between 0 and 255 (256 different combinations).
For example: let us convert 55 from decimal to binary. We place in the table below (marked in green) 1 or 0 for the
highest available decimal number in that cell and subtract until we reach 0.
So in the case of 55, it is: 55 -
32 - 16 - 4 - 2 - 1
= 0
1 or 0
0
0
1
1
0
1
1
1
Binary
2
7
2
6
2
5
2
4
2
3
2
2
2
1
2
0
Decimal
128
64
32
16
8
4
2
1
This results in binary value 0011 0111 based on the input in the table, which in decimal are 55, and HEX 0x37.
IDCHK
Calculating IDCHK require us to find the inverted value of the sum of all data bits. We send a data package with the
data value as 55, which we know is 0011 0111. The inverted data value is the inverted of 0011 0111 (55 converted to
binary), which is 1100 1000.
If we then convert 1100 1000 to decimal using the conversion table above, we get
200
In simpler terms, you could say we are doing 55 - 255 = -200. Ignore the fact that it is a negative number.
Attention
Address
CMD
CMD
CMD
Length
IHCHK
55
200