Part Three: The Codes
The retail sales business in the United States mainly uses the UPC or Uniform Product Code. If you're a manufacturer of retail products you must apply for a UPC barcode for that product by contacting the Uniform Code Council. A normal UPC code contains 12 digits. The first digit tells what type of product the code is on (retail, pharmaceutical, etc.). The next five digits identify the manufacturer of that product. The next five digits identify a specific product produced by that manufacturer. The last digit is a check digit used to tell if the barcode scanner read the first eleven digits correctly. In Europe the EAN or European Article Numbering code is used. It's similar to UPC, but contains an extra digit as part of the identification of the country where the product originated. EAN is also used in some applications in the US, such as Booklan code.
In industrial applications many different types of barcodes are used because the type of information that is contained in the barcode varies considerably. In retail we just want to know the product and manufacturer. In industrial applications we might be barcoding part numbers, serial numbers, lot identification or just about any other piece of information about an object. The characters in the barcode might be numbers, letters or other punctuation marks, in any combination. There might be a limited area to mark the code, requiring the highest density of information possible. In this section we'll discuss the three most common codes used in industrial applications. They are Interleaved 2 of 5, Code 39 and Code 128.
Interleaved 2 of 5 code is designed to encode numbers only. It is a two level code, meaning that the bars and spaces have only two widths. The code is interleaved in that one digit is represented by a series of five bars, two of which are always wide. The next digit is represented by five spaces, two of which are always wide. For this reason an I 2 of 5 code always contains an even number of digits. A leading zero is usually added if an odd number of characters are to be encoded. All codes have unique patterns at the start and end of the code. This tells the barcode reader which direction it is reading the code. Most all codes can be scanned front to back or back to front, as long as the scanner knows which way it's going. Because of the simple start/stop pattern it is possible for a decoder, looking for an I 2 of 5 code, to mistake printing for the code and try and decode it. Many times the decoder will be successful in decoding a two digit code. To avoid potential problems with I 2 of 5 code, always use four digits or more. In addition, always try to use the same number of digits and program your decoder to only accept a code with only that number of digits. You can also use a Modulo 10 Check Character as an extra precaution.
Code 39 is a two level code that is designed to encode both letters and numbers. The standard version encodes upper case letters A-Z, numbers and a few punctuation marks. The asterisk (*) character is always used as a start and a stop character. Extended Code 39 encodes all 128 ASCII characters. Code 39 is the code most often used in industrial applications. Even where only numbers are involved, because it is not subject to the problems outlined above. It is called Code 39 because each character is made up of nine elements, five bars and four spaces, and three of the nine are wide, while the remaining six are narrow. Extended Code 39 uses certain character pairs to represent characters not normally present in Code 39. This works fine but the added characters take the space that would normally yield two characters, so the resulting code is longer than normal Code 39 for a given number of characters.
Code 128 is the best code to use when all 128 ASCII characters are needed. It is a four level code, meaning that bars and spaces can have four different widths. There are actually three versions of Code 128. The A version encodes all upper case alphanumeric characters plus all of the ASCII control characters. The B version encodes all upper and lower case alphanumeric characters. The C version encodes numbers only. It is possible to switch between character sets within the code by using shift characters. The advantage of Code 128 is that it can encode all ASCII characters in the shortest possible code length. The disadvantage is, because it has four different bar and space widths rather than two, more demands are put on printing and decoding technologies.
You can find information on the exact structure of these barcodes and some others at the Barcode Island web site.