最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

Code 128 Symbology Introduction

Symbology_Barcode crifan 2295浏览 0评论

 

Code 128 Symbology Introduction

Version: 2010-12-20

Author: green-waste(at) 163.com

 recommand to see this article of PDF version, go to this page to download:

Code 128 Symbology Introduction v20101220.pdf

http://download.csdn.net/source/2924661

 

1       Glossary
1.1     Value
For the value column in Encoding Code Table, the “value” is also called code, or character, or digit.

 So actually:

Start code = start character

Check character = check digit

Function code = function character

…..

1.2     Variant
The variant is just the character set, so variant A/B/C is just the Character Set A/B/C

2       Code 128 Definition
2.1     Symbology

Code 128 is a variable length, high density, alphanumeric symbology.

It is a very effective, high-density symbology which encoding of alphanumeric data.
2.2     Checksum digit

Code 128 also employs a check digit for data security.

Code 128 symbology must include a checksum digit.
2.3     Character set

Code 128 has three characters Set: A, B, C.

Code 128 has 106 different bar and space patterns and each pattern can have one of three different meanings, depending on which of three different character sets (characters Set  A/B/ C) is employed.

Three different start characters tell the reader the character set used in the following encoding, and three shift codes permits changing character set inside the symbol.

 
3       Code 128 Characteristics
3.1     Start character

As you can see in Encoding Code Table,

The three start characters are:

“START A“=103, “START B”=104,  “START C”=105
3.2     Shift code

As you can see in Encoding Code Table, three shift codes are:

For character set A: change to character set B is “Code B=100”, to character set C is “Code C=99”

For character set B: change to character set A is “Code A=101”, to character set C is “Code A=99”

For character set C: change to character set A is “Code B=101”, to character set C is “Code B=100”

Note:

But the shift work only with Code A or Code B characters.
3.3     Character set usage domain
Generally:

Character Set A: encodes all upper case (‘A=33’ to ‘Z=58’) and ASCII control characters (‘NUL=64’ to ‘US=95’);

Character Set B: encodes all upper (‘A=33’ to ‘Z=58’) and lower (‘a=65’ to ‘z=90’) case characters;

Character Set C: encodes numeric digit pairs 00 through 99 (‘00=00’ to ‘99=99’).

 

Character Set A and B: used to encode alpha-numeric information

Character Set C : offers double density when being used to encode numeric data, which means use a single value/code, decoded as two digital value/data, that is  one value = two data.

 

This third character set – Character Set C, effectively doubles the code density when printing numeric data.
3.4     Function Code

In addition to ASCII characters, Code 128 also allows encoding of four special function codes (FNC1 – FNC4), which are listed in Encoding Code Table.

The meaning of function code FNC1 and FNC4 were originally left open for application specific purposes. Recently an agreement was made by the Automatic Identification Manufacturers Assoc. (AIM) and the European Article Numbering Assoc. (EAN) to reserve FNC1 for use in EAN applications.

FNC4 remains available for use in closed system applications.

FNC2 is used to instruct a bar code reader to concatenate the message in a bar code symbol with the message in the next symbol.

FNC3 is used to instruct a bar code reader to perform a reset. When FNC3 is encoded anywhere in a symbol, any data also contained in the symbol is discarded.
3.5     Calculate the Check/Checksum Digit

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:

1.      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.

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.      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.

5.      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 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:

1. Note that the checksum starts with the first Start Character, with a weight of 1, and that the first data character also has a weight of 1.

2. In my understanding, the above “CODE-C=99” is the generated barcode, but not displayed/printed, just like the check digit.

 
3.6     Structure / Composition of Code 128

Table 2 Structure of Code 128

one of three start codes

(“START A“=103, or

 “START B”=104,  or “START C”=105)

the data itself

a check character

a stop character

Termination bar of 11

We will now code the above example, HI345678, in Code 128. As we calculated in the Checksum Digit Calculation section, the checksum digit is 67. So we must also code the checksum digit at the end of the message.

We encode each digit using the encoding table above.
The START-A character: 11010000100.
The digit “H” encoded as: 11000101000.
The digit “I” encoded as: 11000100010.
The “CODE-C” character: 10111011110.
The digits “34” encoded as: 10001011000.
The digits “56” encoded as: 11100010110.
The digits “78” encoded as: 11000010100.
The checksum digit of 67 encoded as: 10000101100.
The STOP character: 11000111010.
The termination bar: 11.

This is shown in the following graphical representation where the bar code has been sectioned-off into areas that reflect each of the 10 components just mentioned.

 
3.7     Compare to Other symbology

For Code 39, Code 93, Code 128, EAN-UCC 128:

There are all variable length alphanumeric symbology.

And their “Data Capacity” – the practical upper limit, dependent on the scanner and is typically between 20 and 40 characters.

Code 128 is more efficient at encoding data than Code 39 or Code 93.

Code 128 is the best choice for most general bar code applications.

Code 39 and Code 128 are both very widely used while Code 93 is rarely used.

 
4       Append
4.1     Encoding Code Table

 This table indicates how to encode each digit of a Code 128 bar code.

Note that it is easiest to think of each character as a value between 0 and 105, inclusive, rather than thinking of them as characters.

The character that a value represents depends on what mode (or character set) you’re in-so rather than thinking of a character as “A” or “B”, etc. it is more appropriate to think of it as 33, 34, etc.

 

Note:

For easy to identify that special value, I color some of them like this:

Shift Code of Character Set

Start character

Function Code

 

Table 3 Encoding Code Table

VALUEWHICH REPRESENTS IN
CHARACTER SET
ENCODINGVALUEWHICH REPRESENTS IN
CHARACTER SET
ENCODING
ABCABC
00SPSP001101100110053UU5311011101110
01!!011100110110054VV5411101011000
02021100110011055WW5511101000110
03##031001001100056XX5611100010110
04$$041001000110057YY5711101101000
05%%051000100110058ZZ5811101100010
06&&061001100100059[[5911100011010
070710011000100606011101111010
08((081000110010061]]6111001000010
09))091100100100062^^6211110001010
10**101100100010063__6310100110000
11++111100010010064NUL`6410100001100
12,,121011001110065SOHa6510010110000
13131001101110066STXb6610010000110
14..141001100111067ETXc6710000101100
15//151011100110068EOTd6810000100110
1600161001110110069ENQe6910110010000
1711171001110011070ACKf7010110000100
1822181100111001071BELg7110011010000
1933191100101110072BSh7210011000010
2044201100100111073HTi7310000110100
2155211101110010074LFj7410000110010
2266221100111010075VTk7511000010010
2377231110110111076FFl7611001010000
2488241110100110077CRm7711110111010
2599251110010110078SOn7811000010100
26::261110010011079SIo7910001111010
27;;271110110010080DLEp8010100111100
28<<281110011010081DC1q8110010111100
29==291110011001082DC2r8210010011110
30>>301101101100083DC3s8310111100100
31??311101100011084DC4t8410011110100
32@@321100011011085NAKu8510011110010
33AA331010001100086SYNv8611110100100
34BB341000101100087ETBw8711110010100
35CC351000100011088CANx8811110010010
36DD361011000100089EMy8911011011110
37EE371000110100090SUBz9011011110110
38FF381000110001091ESC{9111110110110
39GG391101000100092FS|9210101111000
40HH401100010100093GS}9310100011110
41II411100010001094RS~9410001011110
42JJ421011011100095USDEL9510111101000
43KK431011000111096FNC3FNC39610111100010
44LL441000110111097FNC2FNC29711110101000
45MM451011101100098SHIFTSHIFT9811110100010
46NN461011100011099Code CCode C9910111011110
47OO4710001110110100Code BFNC4Code B10111101110
48PP4811101110110101FNC4Code ACode A11101011110
49QQ4911010001110102FNC1FNC1FNC111110101110
50RR5011000101110103START ASTART ASTART A11010000100
51SS5111011101000104START BSTART BSTART B11010010000
52TT5211011100010105START CSTART CSTART C11010011100
  STOPSTOPSTOP11000111010

 
5       Reference

1. CODE 128 SYMBOLOGY

http://www.barcodeisland.com/code128.phtml

2. Bar Code Symbologies

http://www.taltech.com/resources/intro_to_bc/bcsymbol.htm

3. Bar Coding Basics

http://www.taltech.com/resources/intro_to_bc/bcbascs.htm

转载请注明:在路上 » Code 128 Symbology Introduction

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
81 queries in 0.179 seconds, using 22.24MB memory