Scott Anderson and Daisy Stanton
THE BARCODE BATTLERS
University of Washington // CSE 370 // Autumn 2001

Introduction

Barcodes were first developed in the fifties to help automate supermarket checkout, and rapidly became the basis for the Universal Product Code system in place today. This standardization is now used on almost all manufactured goods, and ensures that products will be uniformly recognized across the globe. Manufacturers must register their products to get their own proprietary code; in the United States, this process is overseen by the American Manufacturing Association.

Physically, barcodes are made up of a series of lines that vary in width and correspond to various numeric, alphanumeric, or multicode configurations which can then be read in by a laser barcode scanner. On this page we'll introduce the Code 128 barcode standardization to illustrate how encoding works.


Introduction to Code 128

Code 128 is a very effective, high-density symbology which permits the encoding of alphanumeric data. It includes verification protection both via a checksum digit and byte parity checking. This symbology has been widely implemented in many applications where a relatively large amount of data must be encoded in a relatively small amount of space. Its specific structure also allows numeric data to be encoded at, effectively, double-density.


Parts of a Code 128 barcode

A Code 128 barcode consists of a leading "quiet zone", one of three start codes, the data itself, a check character, a stop character, and a trailing quiet zone. 

The quiet zone is the clear area (free from marks) before and after the bars and spaces; its presence allows scanners to establish base values for the color and reflectance of the material they are reading. These numbers are used to dynamically determine what will count as a "space" and what will count as a bar.

The start code is one of three codes that signal the start of the Code 128 barcode. The Code 128 specification defines three "character sets" or "character modes." The different codes, Start-A, Start-B, and Start-C, signal which character set will be used. The character set may also be changed in the middle of the barcode to encode the data more efficiently .

The Code 128 data is encoded in strips of bars and spaces. The table below uses a binary system to represent the encoding, using a "1" for a single-width bar and a "0" for a space.  Note that sequences of zeros or ones simply appear as thicker bars or spaces.

The checksum is included in the barcode, and is a digit that verifies that the data just read in was correct.  The checksum digit is based on a modulo 103 calculation 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 exact steps for calculating the check digit in Code 128 are as follows:

  1. Take the value of the start character (103, 104, or 105) and make that the starting value of the running checksum.
  2. 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.
  3. 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.
  4. Divide the resulting running checksum by 103. The remainder becomes the checksum digit which is added to the end of the message.

The stop code is the bar-and-space sequence that signals the end of the barcode.


The Encoding Process

Each character in Code 128 is encoded using 11 modules, except for the stopcode, which is encoded in 13 modules. The following table lists the encoding scheme for Code 128:

VALUE WHICH REPRESENTS IN
CHARACTER SET
ENCODING VALUE WHICH REPRESENTS IN
CHARACTER SET
ENCODING
A B C A B C
00 SP SP 00 11011001100 53 U U 53 11011101110
01 ! ! 01 11001101100 54 V V 54 11101011000
02 " " 02 11001100110 55 W W 55 11101000110
03 # # 03 10010011000 56 X X 56 11100010110
04 $ $ 04 10010001100 57 Y Y 57 11101101000
05 % % 05 10001001100 58 Z Z 58 11101100010
06 & & 06 10011001000 59 [ [ 59 11100011010
07 ' ' 07 10011000100 60 \ \ 60 11101111010
08 ( ( 08 10001100100 61 ] ] 61 11001000010
09 ) ) 09 11001001000 62 SPACE SPAE 62 11110001010
10 * * 10 11001000100 63 _ _ 63 10100110000
11 + + 11 11000100100 64 NUL ` 64 10100001100
12 , , 12 10110011100 65 SOH a 65 10010110000
13 - - 13 10011011100 66 STX b 66 10010000110
14 . . 14 10011001110 67 ETX c 67 10000101100
15 / / 15 10111001100 68 EOT d 68 10000100110
16 0 0 16 10011101100 69 ENQ e 69 10110010000
17 1 1 17 10011100110 70 ACK f 70 10110000100
18 2 2 18 11001110010 71 BEL g 71 10011010000
19 3 3 19 11001011100 72 BS h 72 10011000010
20 4 4 20 11001001110 73 HT I 73 10000110100
21 5 5 21 11011100100 74 LF j 74 10000110010
22 6 6 22 11001110100 75 VT k 75 11000010010
23 7 7 23 11101101110 76 FF l 76 11001010000
24 8 8 24 11101001100 77 CR m 77 11110111010
25 9 9 25 11100101100 78 SO n 78 11000010100
26 : : 26 11100100110 79 SI o 79 10001111010
27 ; ; 27 11101100100 80 DLE p 80 10100111100
28 < < 28 11100110100 81 DC1 q 81 10010111100
29 = = 29 11100110010 82 DC2 r 82 10010011110
30 > > 30 11011011000 83 DC3 s 83 10111100100
31 ? ? 31 11011000110 84 DC4 t 84 10011110100
32 @ @ 32 11000110110 85 NAK u 85 10011110010
33 A A 33 10100011000 86 SYN v 86 11110100100
34 B B 34 10001011000 87 ETB w 87 11110010100
35 C C 35 10001000110 88 CAN x 88 11110010010
36 D D 36 10110001000 89 EM y 89 11011011110
37 E E 37 10001101000 90 SUB z 90 11011110110
38 F F 38 10001100010 91 ESC { 91 11110110110
39 G G 39 11010001000 92 FS | 92 10101111000
40 H H 40 11000101000 93 GS } 93 10100011110
41 I I 41 11000100010 94 RS ~ 94 10001011110
42 J J 42 10110111000 95 US DEL 95 10111101000
43 K K 43 10110001110 96 FNC3 FNC3 96 10111100010
44 L L 44 10001101110 97 FNC2 FNC2 97 11110101000
45 M M 45 10111011000 98 SHIFT SHIFT 98 11110100010
46 N N 46 10111000110 99 Code C Code C 99 10111011110
47 O O 47 10001110110 100 Code B FNC4 Code B 10111101110
48 P P 48 11101110110 101 FNC4 Code A Code A 11101011110
49 Q Q 49 11010001110 102 FNC1 FNC1 FNC1 11110101110
50 R R 50 11000101110 103 START A START A START A 11010000100
51 S S 51 11011101000 104 START B START B START B 11010010000
52 T T 52 11011100010 105 START C START C START C 11010011100


CSE 370 Assignment

  1. Original Question: How would the string "CSE370" be represented at the physical level in a bar code?


  2. Our question: Since there are many standards for barcodes, we decided to pick one standard and explain the encoding process for this standard. Thus, specifically we are asking: How would the string "CSE370" be represented at the physical level in a Code 128 standard bar code?


  3. Background and Assumptions: There are many (at least ten) types of barcode standards. Assuming that we were to pick one and represent the string "CSE370" in that format, we knew that we would have to choose a symbology that could encode alphanumeric characters. While Code 39 and Code 128 are both popular formats that support this, we settled on Code 128; it is a more efficient encoding standard and is thus more widely used than Code 39.


  4. The answer: Using the chart from above, the string "CSE370" can be encoded in Code 128 in the following manner:


  5. START A = 11010000100

    C = 35 = 10001000110
    S = 51 = 11011101000
    E = 37 = 10001101000
    3 = 19 = 11001011100
    7 = 23 = 11101101110
    0 = 16 = 10011101100

    CHECKSUM = ( 35+51*2+37*3+19*4+23*5+16*6 ) mod 103 = 20 = 11001001110

    STOPCODE = 1100011101011

    The final encoding, then, is:

    110100001001000100011011011101000100011010001100101110011101101110100111011001100011101011

    which looks like:

  6. Conclusions: Initially assuming there was only one bar code standard, we were surprised to discover the ubiquity of different formats available. We were also surprised to see so many websites devoted to selling bar code fonts, java applets, etc. We concluded that since the computer age is now in full swing, it's very easy for anyone (not just large manufacturers) to use proprietary bar code encoding to automate inventory control. While for Scott, a former Barcode Battler, the utility of the bar code will forever be rooted in its hours of endless gaming entertainment, Daisy's friend spent an hour the other day telling her about his ideas to automate both roommate inventory (scan yourself in, scan yourself out--who really knows when the roommates are there?) and home grocery inventory (scan the new milk as you put it in the fridge, scan the empty carton as you throw it out). Thus we've decided that bar codes can be very, very useful.

References

Primary References
http://www.adams1.com/pub/russadam/128code.html
http://www.idautomation.com/java/
http://www.barcodeisland.com/code128.phtml

Secondary References
http://students.washington.edu/pascalw/barcode/
http://www.lascofittings.com/BarCode-EDI/bc-history.htm
http://retrofuture.web.aol.com/barcode.html