3.0 Breakdown
In this section, we will break down the standards of UPC-A standards.
3.1 Basics
UPC-A is the world’s most currently used barcode standard. UPC-A barcodes comprise 12 digits, middle and end guards, and safe zones on either side of the barcode. Each digit has a unique pattern of two bars and two spaces. The left and right digits have inverse parity. Scanners can detect whether they scan left-to-right or right-to-left if the barcode is upside-down.
3.2 Digits
As previously mentioned, UPC-A barcodes contain 12 digits. The digits are divided into two halves, L and R. Digits use the schema LLLLLLRRRRRR. L is the number system digit, and R is the check digit. L digits generally contain manufacturer information. R digits typically represent the product code.
3.2 Modules
UPC-A barcodes use modules of bars and spaces. Every module has a uniform width. Height may be variable. Barcodes will scan as so long as the sequence of bars and spaces is valid across a whole horizontal section.
Figure 1 shows the modules and different sections. Two guards border the two halves of the 12-digit code. Three guards (start, middle, and end) tell scanners where the data is. The sequence of bars and spaces has a “safe zone” on either side.
A complete UPC-A barcode contains 113 modules in total. We will cover these in greater detail for the last portion of this section.
Each digit is seven modules wide. The left and right digits have reverse parity. The left and right sides have the same sequence: 3211. However, the bars and spaces invert. The left begins with three spaces, then two bars, and alternates from there, whereas the right starts with three bars, then two spaces, and alternates from there. While this may seem odd at first, it is an ingenious design. Without this reverse parity, numbers would scan incorrectly. For example, the scanner could not detect if it was scanning upside-down or right-side-up.
The start and end guards are three modules in width with the pattern: bar, space, bar. The middle guard is five modules in width. Its pattern is space, bar, space, bar, space. Guards separate the two sides of the data and guide scanners to the data.
Safe zones are nine modules in width. Their job is to prevent interference with the sequence of bars and spaces. The same concept exists in any scannable media, such as QR codes or serial number barcodes.
3.3 Number System Digit
The function of the number system digit is to tell the scanner how to process the following numbers.
0, 1, 6, 7, 8, and 9 are for most products.
2 is reserved for local use for businesses that sell by variable weight.
3 is used for NDC (National Drug Code) numbers.
4 is reserved for local use by businesses using loyalty cards or coupons.
5 is coupons. LLLLL digits are the UPC’s LLLLL digits. The first three R digits are the family code (set by the business), and the following two are the value code that determines the discount amount.
3.4 Check Digit Calculation
The check digit validates barcodes and checks for errors. To calculate the check digit, use the following formula:
Steps:
- Sum all odd digits except the first and last digit
- Multiply the result by 3
- Add the sum of even digits (of all but the first and last digit) to the result
- Find the result modulo 10
- If the result of the modulo operation is 0, the check digit is 0
- Otherwise, the check digit is 10 – result
3.5 Digit values
Figure 2 illustrates the values for each possible digit. The first set of numbers under the bars represents the binary information of each bar. The following four-digit number corresponds to the module width of each bar or space section. We will be using this pattern in our program.