Before a Code 128 symbol may be encoded, the software must compute the correct checksum digit which will be included in the bar code. The checksum digit is based on Modulus 103 Checksum based on the weighted sum of the values of each of the digits in the message that is being encoded, including the start character.
The steps for calculating the check digit are as follows:
- Take the value of the start character ("START A"=103, or "START B"=104, or "START C"=105) and make that the starting value of the running checksum.
- Starting with the first data character following the start character, take the value of the character (between 0 and 102, inclusive) multiply it by its character position (1) and add that to the running checksum.
- Take each additional character in the message, take its value, and multiply it by its character position, and add the total to the running checksum
- use the resulting to MOD 13, that is divide the resulting running checksum by 103, then the remainder is the checksum digit, which is added to the end of the message
- The stop character is appended after the checksum digit.
This is easier to understand with an example.
Let's calculate the checksum digit for the sample bar code above, "HI345678".
The checksum digit is included in all Code 128 bar codes, but it isn't printed as part of the text below the bar code symbol (as is the case with UPC and EAN symbols).
Table 2.1. Calculate checksum digit of "HI345678"
Barcode | START-A | H | I | CODE C | 34 | 56 | 78 |
---|---|---|---|---|---|---|---|
Character Value | 103 | 40 | 41 | 99 | 34 | 56 | 78 |
Character Position | - | 1 | 2 | 3 | 4 | 5 | 6 |
Calculation | 103 | 40 * 1 | 41 * 2 | 99 * 3 | 34 * 4 | 56 * 5 | 78 * 6 |
Weighted Sum | 103 | 40 | 82 | 297 | 136 | 280 | 468 |
Summing up the running checksum for each digit, we get:
103 + 40 + 82 + 297 + 136 + 280 + 468 = 1406
Then,
1046 MOD 13 = the remainder of 1406 / 103 = 67
Thus the checksum digit is the character which has a value of 67.
Note | |
---|---|
|