The Checksum - Self-Correction: How the Barcode Checks Its Own Work |
Subtitle: A Deep Dive into Error Detection, the Modulo Algorithms, and the Art of Data Integrity - with Real-World Examples from Symbol, Zebra, Honeywell, Datalogic, Microchip, and NXP |

|
Opening Summary |
The barcode has been scanned. The edges have been counted. The pulse widths have been normalized. The characters have been decoded. But is the data correctHow does the scanner know that the decoded digits are the same digits that were printed on the labelThe answer is the checksum - a mathematical check that is built into the barcode itself. The checksum is a self-correction mechanism that allows the decoder to verify the integrity of the data. |
This article is dedicated to the checksum - the final gatekeeper of the decoding process. We will explore what checksums are, why they are essential, and how they are calculated. We will look at the different checksum algorithms used by the major symbologies: the modulo 10 check of UPC/EAN, the modulo 43 check of Code 39, and the modulo 103 check of Code 128. We will see how major companies have implemented checksum verification in their products. We will examine how Symbol (now Zebra) uses checksums in the LS2208. We will explore Honeywell's and Datalogic's implementation of checksum verification. We will also look at reference designs from Microchip, NXP, and STMicroelectronics. |
By the end of this journey, you will understand that the checksum is not an optional extra but an essential component of any reliable barcode system. You will see how a simple mathematical calculation can prevent a world of errors. |

|
Full Article |
Section 1: The Problem - Data Integrity in a Noisy World |
Imagine you are decoding a barcode, and one of the bars is misread because of a smudge, a scratch, or a momentary glitch in the electronics. The decoder will produce a wrong character, and that wrong character will lead to a wrong product being identified. This could be a minor nuisance in a library, but in a hospital or a warehouse, it could be a catastrophe. |
The checksum is the defense against this. It is a small piece of extra data that is calculated from the main data and encoded into the barcode. The decoder performs the same calculation on the decoded data and compares its result to the checksum that was encoded. If they match, the data is almost certainly correct. If they do not match, the data is rejected. |
Section 2: The Checksum - A Mathematical Summary |
A checksum is a mathematical summary of the data. It is a value that is derived from the data using a specific algorithm. The algorithm is designed so that even a small change in the data produces a different checksum. |
The checksum is typically a single digit or a single character. It is appended to the end of the data. The decoder calculates the checksum from the data and compares it to the appended checksum. |

|
Section 3: Modulo Arithmetic - The Basis of Checksums |
Most barcode checksums are based on modulo arithmetic. Modulo arithmetic is a system of arithmetic where numbers 'wrap around' when they reach a certain value. For example, in modulo 10 arithmetic, the numbers 0-9 are used. 10 is represented as 0, 11 as 1, and so on. |
Modulo arithmetic is used because it is easy to compute and because it provides a good level of error detection. |
Section 4: The UPC/EAN Checksum - Modulo 10 |
The UPC/EAN checksum is a modulo 10 calculation. The UPC/EAN barcode has a single digit checksum at the end. The checksum is calculated from the preceding digits. |
The calculation is a weighted sum. The digits are multiplied by alternating weights (3 and 1), summed, and then divided by 10. The checksum is the value that makes the sum a multiple of 10. For example, if the weighted sum is 42, the checksum is 8 (42 + 8 = 50, which is a multiple of 10). |

|
Section 5: The Code 39 Checksum - Modulo 43 |
The Code 39 checksum is a modulo 43 calculation. It is optional, but highly recommended. The Code 39 barcode can have a single character checksum appended to the data. The checksum is calculated from the data characters. |
The calculation uses a value table. Each character (0-9, A-Z, space, -, ., $, /, +, %) is assigned a value (0-42). The sum of the values is divided by 43. The checksum is the character that corresponds to the remainder. |
Section 6: The Code 128 Checksum - Modulo 103 |
The Code 128 checksum is a modulo 103 calculation. Code 128 is a more complex symbology, and its checksum is calculated using a weighted sum. The weights start at 1 and increase by 1 for each character. The sum is divided by 103. The checksum is the value of the remainder. |
The modulo 103 checksum is mandatory for Code 128. |

|
Section 7: The Checksum's Purpose - Error Detection |
The checksum is not a correction code. It cannot fix an error; it can only detect one. The purpose of the checksum is to detect errors so that the decoder can reject the scan and ask for a new one. |
The checksum is a form of redundancy. It adds a small amount of extra data that allows the decoder to check the integrity of the main data. |
Section 8: The Checksum's Limitations - What It Cannot Detect |
The checksum is not perfect. It can miss some errors. For example, if two digits are swapped and the checksum calculation is not affected by the order of the digits, the checksum may still match. This is a known limitation of the modulo 10 checksum used in UPC/EAN. |
The checksum is also vulnerable to multiple errors. If two errors cancel each other out, the checksum may still match. However, the probability of this happening is very low. |

|
Section 9: Symbol's LS2208 - Checksum Verification |
Symbol's LS2208 verifies the checksum for all supported symbologies. The LS2208's decoder calculates the checksum from the decoded data and compares it to the checksum that was encoded. If the checksums do not match, the scan is rejected. |
The LS2208's firmware includes the checksum algorithms for Code 39 (modulo 43), UPC/EAN (modulo 10), and Code 128 (modulo 103). |
Section 10: Honeywell's Checksum Implementation |
Honeywell's imagers also verify the checksum. The checksum verification is part of the Adaptus decoding firmware. The checksum verification is performed automatically for all supported symbologies. |
Honeywell's user manuals often mention 'Checksum' as a configurable parameter. For Code 39, the user can enable or disable the checksum verification. |

|
Section 11: Datalogic's Checksum Implementation |
Datalogic's industrial scanners verify the checksum. The checksum verification is part of the Auto-Adaptive Decoding firmware. The checksum verification is performed automatically. |
Datalogic's user manuals also mention 'Check Digit' settings, which allow the user to enable or disable checksum verification for specific symbologies. |
Section 12: The Checksum in Microchip's Reference Design |
Microchip's reference design includes checksum verification for Code 39 (modulo 43), UPC/EAN (modulo 10), and Code 128 (modulo 103). The reference design provides a complete code example. |
Section 13: The Checksum in NXP's Reference Design |
NXP's reference design also includes checksum verification. The reference design uses a DMA engine for edge capture and includes complete code examples for the checksum algorithms. |

|
Section 14: The Checksum in STMicroelectronics' Reference Design |
STMicroelectronics' reference design includes checksum verification. The reference design provides a complete code example for Code 39, UPC, and Code 128. |
Section 15: The Checksum and the User Interface |
The checksum verification is usually transparent to the user. The user only sees the decoded data if the checksum passes. If the checksum fails, the scanner gives an error indication (e.g., a red LED or a different beep). |
The checksum verification is a background process that ensures the data's integrity. |
Section 16: The Checksum and the Decode Security Setting |
The 'Decode Security' setting in Honeywell's scanners is related to the checksum verification. A higher Decode Security setting makes the decoder more strict, which can affect the checksum verification. |
The Decode Security setting does not change the checksum algorithm; it changes the decoder's tolerance for variations in the pulse widths, which can affect the decoded data and, consequently, the checksum. |

|
Section 17: The Checksum and the Minimum Contrast Setting |
The 'Minimum Contrast' setting in Datalogic's scanners is not directly related to the checksum. The Minimum Contrast setting affects the signal amplitude. The checksum verification is performed on the decoded data. |
Section 18: The Checksum and the ROI Threshold |
The 'ROI Threshold' in Datalogic's scanners is not directly related to the checksum. The ROI Threshold affects the image contrast. The checksum verification is performed on the decoded data. |
Section 19: The Checksum and the Start/Stop Characters |
The checksum is not related to the start and stop characters. The start and stop characters are used to locate the barcode and to determine the symbology. The checksum is part of the data. |

|
Section 20: The Checksum and the Quiet Zone |
The checksum is not related to the quiet zone. The quiet zone is used to detect the barcode's presence. The checksum is part of the data. |
Section 21: The Checksum and the Module Width |
The checksum is not directly related to the module width estimation. The module width estimation is used to normalize the pulse widths. The checksum is calculated from the decoded data. |
Section 22: The Checksum and the Scanning Speed |
The checksum is not directly related to the scanning speed. The scanning speed affects the pulse widths, but the module width estimation compensates for this. |
Section 23: The Checksum and the Print Quality |
The checksum is affected by the print quality. A poorly printed barcode may cause decoding errors, which will cause the checksum to fail. The checksum is a good indicator of the print quality. |

|
Section 24: The Checksum and the Noise |
The checksum is affected by the noise. Noise can cause decoding errors, which will cause the checksum to fail. The checksum is a good indicator of the noise level. |
Section 25: The Checksum and the Jitter |
The checksum is affected by the jitter. Jitter can cause decoding errors, which will cause the checksum to fail. |
Section 26: The Checksum and the Distortion |
The checksum is affected by the distortion. Distortion can cause decoding errors, which will cause the checksum to fail. |

|
Section 27: The Checksum and the Symbology |
The checksum algorithm is specific to the symbology. Code 39 uses modulo 43; UPC/EAN uses modulo 10; Code 128 uses modulo 103. |
Section 28: The Modulo 10 Checksum - A Detailed Example |
The modulo 10 checksum is used in UPC/EAN. The calculation uses alternating weights of 3 and 1, starting from the rightmost digit (excluding the checksum). The weighted sum is calculated. The checksum is the value that makes the sum a multiple of 10. |
Section 29: The Modulo 43 Checksum - A Detailed Example |
The modulo 43 checksum is used in Code 39. The calculation uses a value table. The values are summed. The checksum is the remainder when the sum is divided by 43. The checksum is the character that corresponds to the remainder. |

|
Section 30: The Modulo 103 Checksum - A Detailed Example |
The modulo 103 checksum is used in Code 128. The calculation uses a weighted sum, starting with a weight of 1 for the first character. The weights increase by 1 for each subsequent character. The sum is divided by 103. The checksum is the value of the remainder. |
Section 31: The Checksum and the Decoder's Reject Rate |
The checksum affects the decoder's reject rate. If the checksum fails, the scan is rejected. A high reject rate can be caused by a poorly printed barcode, a noisy environment, or a malfunctioning scanner. |
The reject rate is a useful diagnostic tool. It can indicate problems with the barcode quality or the scanner. |
Section 32: The Checksum and the Decoder's False Read Rate |
The checksum reduces the decoder's false read rate. A false read is when the decoder outputs a wrong barcode. The checksum makes it very unlikely that a wrong barcode will pass the checksum. |
The false read rate is a critical performance metric for barcode scanners. |

|
Section 33: The Checksum and the Decoder's Accuracy |
The checksum improves the decoder's accuracy. The checksum ensures that the decoded data is correct. The checksum is the final check. |
Section 34: The Checksum and the Decoder's Reliability |
The checksum improves the decoder's reliability. The checksum ensures that the decoded data is reliable. The checksum is an essential part of the decoder. |
Section 35: The Future of Checksums - More Sophisticated Error Correction |
While checksums are simple and effective, some advanced barcodes, like 2D codes, use more sophisticated error correction, like Reed-Solomon codes. Reed-Solomon codes can not only detect errors but also correct them. This is important for 2D codes, which can be partially damaged. |

|
Section 36: The Checksum - A Summary of Best Practices |
Based on our exploration, let us summarize the best practices for checksum verification in a barcode scanner: |
1. Always Verify the Checksum: The checksum is an essential error-checking mechanism. Always verify it. |
2. Use the Correct Algorithm: Each symbology has its own checksum algorithm. Use the correct algorithm for the symbology. |
3. Enable the Checksum (if optional): For symbologies like Code 39, the checksum is optional. Always enable it. |
4. Handle the Errors: If the checksum fails, reject the scan and notify the user. |
5. Test the Checksum: The checksum verification must be tested with a variety of barcodes to ensure it is working correctly. |

|
Final Summary |
The checksum is the final gatekeeper of the decoding process. It is a mathematical summary of the data that allows the decoder to verify the integrity of the decoded data. The checksum is a simple but essential error-checking mechanism that prevents incorrect data from being output. |
We have seen how major companies implement checksum verification. Symbol's LS2208 verifies the checksum for all supported symbologies. Honeywell's and Datalogic's scanners also verify the checksum. Microchip, NXP, and STMicroelectronics provide reference designs with complete checksum verification examples. |
The checksum is not an optional extra. It is an essential component of any reliable barcode system. The checksum is the final check that ensures the data's integrity. |