Barcode Technology

Barcode History

Barcode Label Paper

Barcode Printer

Barcode Application

Inventory Management

AI Barcode QRCode

Barcode Scanner

Barcode Software

Barcode Software B

Barcode Software C

Barcode Software D

Barcode Software E

New Technology A

New Technology B

Robot Technology

Barcode Types

Barcode Types B

Barcode Types C

Barcode Types D

Barcode Types E

Barcode Types F

Electronic Technology

Psychology at Work

Barcode Technology and Barcode Software Related   <<< Back to Directory <<<

Code 128 Barcodes: A Technical Deep Dive and Industry-Wide Integration with ERP Systems (P18)

Chapter 18: Decoding Algorithms - The Pattern Matching Process

Summary of This Chapter

This chapter explains how a barcode scanner or reader actually makes sense of the black and white stripes printed on a label. We focus on the pattern matching process, which is the core of decoding a Code 128 barcode. The reader compares the measured widths of the bars and spaces against a built-in reference table. It uses the special start character at the beginning of the barcode to decide which character set to use initially, and then it watches for special shift and code-change characters to switch sets as needed during the scan. While this sounds like a purely technical topic, we will see that this decoding logic is what makes Code 128 reliable enough to be used in thousands of real-world American businesses, from hospital pharmacies to auto assembly lines. We will explore multiple practical examples across the United States, showing how pattern matching works in shipping, healthcare, retail, manufacturing, and government logistics. By the end, you will understand not only the mechanics of decoding but also why this process is so critical for enterprise resource planning (ERP) systems that run the backbone of American commerce.

Introduction: The Invisible Translation

Every time you buy a product online, pick up a prescription, or receive a package from a courier, there is a good chance that a Code 128 barcode is involved. But have you ever wondered how the scanner turns those varying widths of black ink and white space into a number, a letter, or a commandThe answer lies in a clever but straightforward pattern matching algorithm.

Imagine you are trying to read a foreign language that is written in Morse code, but instead of dots and dashes, you have thick and thin lines. And unlike Morse, which has fixed spacing between letters, this language has eleven different widths for bars and spaces, and they all have to be measured relative to each other. That is the challenge that a decoder faces hundreds of times per second.

The decoder does not 'see' the barcode the way a human sees a word. It sees a stream of electrical signals that rise and fall as the scanner's light beam crosses black bars (which absorb light) and white spaces (which reflect light). The analog signal is converted into digital measurements of time or distance. The decoder then has to decide: is this narrow bar a '1' or a '2' in the Code 128 symbol setIs this wide space a '3' or a '4'And how does it know when one character ends and the next begins

This chapter answers those questions by walking through the pattern matching process step by step. We will pay special attention to the start character, which is like a handshake that tells the decoder which of the three code sets (A, B, or C) to use. Then we will see how shift and code-set characters allow the barcode to switch between numeric, uppercase, and control-character modes on the fly. Finally, we will bring all of this to life with a dozen real-world case studies from American industries, showing how the decoding algorithm performs under different conditions, such as damaged labels, low contrast, high-speed conveyor belts, and handheld scanners in bright sunlight.

The Anatomy of a Code 128 Symbol

Before we dive into the algorithm, let us recall what a Code 128 barcode looks like. It consists of a quiet zone (white margin) on the left, a start character, the encoded data characters, a check character, a stop character, and a final quiet zone on the right. Every character in Code 128, including the start, stop, and check, is represented by a pattern of three bars and three spaces, totaling six elements. Each bar or space has a width of one, two, three, or four modules. The sum of the widths of the three bars is always an odd number, and the sum of the three spaces is always an even number, but the total width of the six elements is always eleven modules. That gives us 107 different possible patterns, but only 103 are used for data and control characters, plus the four start/stop patterns.

The beauty of this design is that the decoder does not need to know the absolute width of a module. It only needs to compare the relative widths of adjacent bars and spaces. For example, if a bar is twice as wide as the narrowest bar in the same symbol, it is a '2'. If it is three times as wide, it is a '3'. The decoder measures each element's duration or pixel count and normalizes them against the narrowest element it has seen so far. This normalization is the first step of pattern matching.

The Reference Table: The Decoder's Dictionary

Every Code 128 decoder has a built-in reference table that maps each valid six-element pattern to a value from 0 to 105, and also indicates which code set (A, B, or C) that value belongs to. For example, the pattern for the digit '0' in Code Set C is different from the pattern for the same digit in Code Set A. The reference table is not a single list but three overlapping lists, one for each code set.

When the decoder starts reading a symbol, it does not know which list to use. That is why the start character is so important. The start character itself is one of three special patterns: Start A, Start B, or Start C. The decoder reads the first character after the quiet zone and compares its measured widths against all possible start patterns. Whichever one matches the best becomes the initial code set. From that point on, the decoder interprets every subsequent character using that code set unless it encounters a shift or a change character.

The pattern matching algorithm is essentially a nearest-neighbor search with error tolerance. Because printing and scanning are never perfect, the measured widths will rarely match the ideal widths exactly. A bar that should be two modules wide might measure as 1.9 or 2.1 modules. The decoder calculates a 'distance' between the measured pattern and each entry in the reference table, and it picks the entry with the smallest distance. If that distance is below a certain threshold, the character is accepted. If not, the decoder may try to rescan or signal an error.

The Start Character: Setting the Stage

Let us look at a typical scanning scenario. A warehouse worker in an Amazon fulfillment center in Phoenix, Arizona, picks up a handheld scanner and points it at a Code 128 label on a tote. The scanner emits a red laser line and sweeps across the barcode. The first pattern it encounters after the left quiet zone is the start character. Suppose the start pattern matches Start B. That means the decoder will use Code Set B, which includes uppercase letters, digits, punctuation, and some control characters, but not lowercase letters. The worker is scanning a tote ID that contains letters and numbers, so Code Set B is perfect.

But what if the barcode was generated by a shipping system that uses Code Set C for dense numeric data, like a UPS tracking numberThen the start character would be Start C, and the decoder would expect pairs of digits from that point onward. This is a critical decision because the same six-element pattern can represent different values in different code sets. For example, the pattern that means '65' in Code Set C might mean the letter 'A' in Code Set B or a control character in Code Set A. Without the start character, the decoder would have no way to know.

The decoding algorithm also uses the start character to determine the parity of the check character calculation. The check character is a modulo-103 sum that includes the value of the start character as an initial weight. So the start character is not just a mode selector; it is also a mathematical seed for error detection. If the start character is misread, the entire check character will fail, and the decoder will reject the symbol.

Shifting and Code-Set Switching on the Fly

One of the most powerful features of Code 128 is that it can change code sets in the middle of a barcode. This is done using three special characters: Shift (value 98 in all sets), Code A (value 101), Code B (value 100), and Code C (value 99). The Shift character is a one-time toggle: it tells the decoder to interpret the very next character using a different code set, then revert to the previous set. The Code A, B, and C characters are permanent switches: they change the current code set for all subsequent characters until another switch occurs.

Consider a real example from the healthcare sector. A hospital in Boston uses Code 128 barcodes on patient wristbands. The wristband ID includes a patient's medical record number (all digits), a blood type (one letter), and a date of birth (digits with slashes). To keep the barcode short, the hospital's printer uses Code Set C for the numeric medical record number, then a Code B switch to encode the blood type letter, then a Shift to encode the slash character (which is in Code Set B but not in Code C), and then back to Code C for the date of birth digits. The decoder has to follow these switches precisely. If it misses a Shift character due to a smudge on the wristband, it might interpret the next digit as a completely different character, causing a medication error. That is why the pattern matching algorithm includes a verification step: after decoding each character, it checks the cumulative check character, so a missed shift will almost always cause a check failure.

The pattern matching process for a Shift character is no different from any other character. The decoder measures the six elements, matches them against the reference table, and returns the value 98. But then the decoder's state machine changes its internal mode for the next character only. This state machine is a simple finite automaton that keeps track of the current code set and a 'shift pending' flag. When the next character is decoded, the state machine applies the temporary code set and then clears the flag. This logic is so reliable that it works even on high-speed sorting equipment, where packages travel at 500 feet per minute.

The Role of the Stop Character and Reverse Decoding

The stop character in Code 128 is unique because it has a different structure: it consists of four bars and three spaces (13 elements total) instead of the usual six elements. This asymmetry is intentional. It tells the decoder that the barcode has ended and also provides an extra margin for error detection. The stop pattern is fixed and does not depend on the code set.

Interestingly, many scanners can decode a Code 128 symbol in either direction. If the scanner sweeps from right to left, the decoder sees the stop character first. Because the stop pattern is unique and asymmetrical, the decoder can recognize it and reverse the order of the subsequent characters. This is called reverse decoding or bidirectional decoding. The pattern matching algorithm works the same way in reverse: it compares the widths of bars and spaces against the reference table, but it reads the sequence of elements backwards. This is extremely useful in retail environments, where a cashier might scan an item with a handheld scanner at any angle.

In practice, the decoder does not know whether it is scanning forward or backward until it identifies either a valid start or a valid stop pattern. If it finds a start pattern first, it decodes forward. If it finds a stop pattern first, it decodes backward, reverses the character order, and then applies the same decoding logic. This bidirectional capability is a major reason why Code 128 is preferred over older symbologies like Code 39, which are usually unidirectional.

Normalization and Edge Detection: The Unsung Heroes

Before the pattern matching algorithm can compare widths against the reference table, it must first detect the edges of each bar and space. This is done by an analog-to-digital converter that samples the reflected light at a very high frequency. The raw samples form a waveform with peaks (spaces) and valleys (bars). The decoder applies a threshold to convert this waveform into a binary signal: high for white, low for black.

But the widths of the bars and spaces are not measured in absolute time or pixels; they are measured relative to the narrowest element in the entire symbol. The decoder scans the entire barcode to find the minimum width among all bars and spaces. That minimum becomes the 'unit' or 'module' size. Then every other element's width is divided by that unit and rounded to the nearest integer (1, 2, 3, or 4). This normalization compensates for variations in print resolution, scanning distance, and even the curvature of a package.

Here is a practical example from the automotive industry. A Ford assembly plant in Dearborn, Michigan, prints Code 128 labels on engine blocks. The labels are exposed to oil, heat, and abrasion. Some bars become partially smeared, so their measured widths are not exact multiples of the module. The decoder's normalization step uses a statistical method called 'edge-to-edge' measurement: it measures the distance between consecutive rising and falling edges and then clusters those distances into four groups corresponding to widths 1, 2, 3, and 4. Even if one bar is smeared, the cluster analysis helps the decoder infer the intended width. This robust normalization is what allows the pattern matching algorithm to achieve a misread rate of less than one in several million.

Pattern Matching in Action: A Step-by-Step Walkthrough

Let us walk through a concrete example. Suppose we have a Code 128 barcode that encodes the string 'ABC123' using Start B. The scanner captures the following normalized widths for the first character (the start character): bar 1 width = 2, space 1 width = 1, bar 2 width = 2, space 2 width = 1, bar 3 width = 3, space 3 width = 2. The total is 11 modules. The decoder looks up this pattern in the reference table for start patterns. It finds that Start B corresponds to a specific sequence of widths: 2-1-2-1-3-2. Perfect match. So the initial code set is B.

Next, the decoder reads the first data character. The measured widths are 1-2-1-3-2-2. The decoder compares this against all 103 data patterns in Code Set B. It finds that the pattern 1-2-1-3-2-2 maps to the value 33, which is the letter 'A' in Code Set B. The decoder stores 'A'.

The second data character has widths 2-1-3-1-2-2. The reference table says this is value 34, which is 'B'. Third character: 3-1-2-1-2-2 is value 35, which is 'C'. Fourth: 1-2-2-1-3-2 is value 16, which is the digit '1' in Code Set B (since Code Set B includes digits as values 16-25). Fifth: 2-2-1-2-3-1 is value 17, which is '2'. Sixth: 3-2-1-2-1-2 is value 18, which is '3'. The decoder then reads the check character, performs the modulo-103 calculation, and verifies that it matches. Finally, it reads the stop pattern and ends.

But what if the label is slightly damagedSuppose the second bar of the letter 'A' was supposed to be width 2 but is measured as 2.3 due to ink bleeding. The normalizer rounds it to 2. The pattern matching still works. If the rounding is ambiguous (e.g., 2.5 could be 2 or 3), the decoder computes the distance to both possible patterns and picks the one with the smaller total error. This is called maximum likelihood decoding, and it is the standard approach in all commercial scanners.

Real-World American Application 1: United Parcel Service (UPS) Package Tracking

No discussion of Code 128 in the United States would be complete without mentioning UPS. The company uses a variant called Code 128 with a special Application Identifier (AI) format under the GS1 standard. Every package that moves through UPS's global hub in Louisville, Kentucky, bears a Code 128 label that encodes a 1Z tracking number, plus service codes, weight, and destination zip code. The decoding algorithm in UPS's handheld scanners and tunnel scanners must read these labels at a rate of over 100,000 packages per hour.

The pattern matching process here is challenged by labels that are crumpled, partially torn, or covered with dirt. UPS scanners employ multiple redundant scans: each label is read by at least three different laser scanners positioned at different angles. The decoder from each scanner sends its result to a voting system. If two out of three decoders produce the same pattern-matched string, that string is accepted. The start character is always Start C because the 1Z tracking number is numeric, but UPS also encodes letters in the service code, so the label uses a Code C to Code B switch midway. The decoder's state machine handles this switch seamlessly, even when the label is read at an oblique angle. This robust pattern matching is why you can drop off a package at any UPS store and have it tracked accurately from coast to coast.

Real-World American Application 2: Walmart's Supply Chain

Walmart, the largest retailer in the United States, mandates that all suppliers use Code 128 barcodes on cases and pallets. The company operates more than 4,700 stores across the country, each receiving multiple truckloads daily. In Walmart's distribution centers, such as the one in Bentonville, Arkansas, conveyor belts move boxes at high speed past overhead laser scanners. These scanners use the same pattern matching algorithm but with a twist: they run the decoding process on a field-programmable gate array (FPGA) rather than a general-purpose CPU, allowing them to decode up to 2,000 barcodes per second.

The start character in Walmart's case labels is typically Start B because the case ID includes alphanumeric characters. However, the pallet labels often use Start C for the numeric purchase order number. The decoder's normalization is critical here because the labels are printed on corrugated cardboard, which absorbs ink unevenly. The narrow bars can become fuzzy, and the spaces can fill with dust. Walmart's engineers have tuned the edge detection threshold to be adaptive: the threshold varies dynamically based on the average reflectance of the white spaces. This adaptive thresholding ensures that the pattern matching algorithm sees a clean binary signal even under poor lighting. As a result, Walmart's inventory accuracy exceeds 99.9%, and the decoding algorithm is a key contributor.

Real-World American Application 3: Healthcare - Mayo Clinic Patient Safety

The Mayo Clinic in Rochester, Minnesota, uses Code 128 barcodes on all patient wristbands, medication vials, and lab specimens. The decoding algorithm here must be exceptionally reliable because a misread could lead to a wrong medication or a mismatched blood transfusion. Mayo's scanners use a two-pass decoding method. On the first pass, the decoder performs pattern matching with a tight tolerance (e.g., it requires the measured widths to be within 0.2 modules of the ideal). If the check character passes, the result is accepted. If the check fails, the decoder performs a second pass with a looser tolerance and also attempts to correct common errors, such as a missing space due to a scratch.

One specific example is the administration of heparin, a high-risk blood thinner. The nurse scans the patient's wristband (which has a Code 128 with Start B encoding the patient ID and date of birth) and then scans the heparin vial (which has a Code 128 with Start C encoding the NDC drug code and lot number). The decoder reads the start character of the wristband as Start B, switches to Code C for the numeric NDC, and then uses a Shift character to read the lot number's letters. The pattern matching algorithm correctly handles this series of switches. If any character fails the check, the scanner beeps an error and the nurse rescans. This double-check process, powered by the decoding algorithm, has reduced medication errors at Mayo by over 70% since its implementation.

Real-World American Application 4: US Postal Service (USPS) Intelligent Mail

The United States Postal Service handles over 400 million pieces of mail daily. While USPS uses its own Intelligent Mail barcode for letters, it uses Code 128 for package tracking under the GS1-128 standard. The decoding algorithm in USPS sorting machines, located in facilities like the Chicago International Distribution Center, must read barcodes that are printed on glossy labels, curved envelopes, and even plastic wrap. The pattern matching process is complicated by the fact that the labels are often placed on uneven surfaces, causing the bars to appear distorted in the scanner's field of view.

USPS uses a sophisticated algorithm called 'subpixel interpolation' to measure edge positions with greater accuracy than the pixel grid. Instead of rounding each edge to the nearest pixel, the decoder fits a polynomial curve to the intensity gradient and finds the exact subpixel location of the peak slope. This yields width measurements that are accurate to within 0.05 modules. The reference table comparison then uses these fractional widths directly, computing a correlation score rather than a discrete distance. This approach has increased the first-pass read rate from 92% to 98.5%, allowing USPS to process more packages without manual intervention.

Real-World American Application 5: Boeing Aircraft Parts Traceability

Boeing, the aerospace giant with major facilities in Seattle, Washington, and Charleston, South Carolina, uses Code 128 barcodes to track every single part that goes into an aircraft, from rivets to engine blades. The decoding algorithm here must work under extreme conditions: labels are often laser-etched onto metal surfaces, creating a high-contrast but sometimes reflective barcode. Reflective glare can cause the scanner to see false bars. Boeing's decoders use a polarization filter and a multi-exposure technique: they take multiple images at different exposure levels and combine them to produce a clean width profile.

The pattern matching process then uses a weighted reference table that gives more importance to the wider bars and spaces because they are less affected by speckle noise from the metal surface. The start character is almost always Start B because the part numbers include both letters and numbers. However, Boeing also encodes a serial number using Code Set C for compactness, with a Code B switch for a hyphen. The decoder's state machine handles these switches reliably, even when the label is read by a robotic arm-mounted scanner that moves at non-constant speed. This decoding precision is vital because a misidentified part could ground an entire fleet.

Real-World American Application 6: Amazon Robotics Fulfillment

Amazon's fulfillment centers, such as the massive one in Robbinsville, New Jersey, use thousands of autonomous robots that carry shelving units to human pickers. Each shelf pod has a Code 128 barcode on every side, and each bin has a smaller Code 128 label. The robots have upward-facing cameras that capture these barcodes as they navigate. The decoding algorithm on the robot's onboard computer must perform pattern matching in real time, while the robot is moving and the camera is shaking.

Amazon's engineers have developed a 'rolling shutter correction' that adjusts the measured widths based on the known velocity of the robot. Without this correction, a moving barcode would appear stretched or compressed. After correction, the normalization step finds the module size from the entire barcode, but because the barcode might be captured at an angle, the decoder also applies a perspective transformation. The reference table comparison is then performed in a transformed coordinate space. This is a more complex pattern matching process than a typical handheld scanner, but it achieves a decode rate of over 99.5% in the challenging warehouse environment. The start character tells the robot whether the label is a pod ID (Start B, alphanumeric) or a bin ID (Start C, numeric), allowing the robot to route itself correctly.

Real-World American Application 7: FedEx Ground Sorting Hubs

FedEx Ground operates automated sorting hubs in places like Indianapolis, Indiana, where packages travel on high-speed diverters. The barcode labels are printed with thermal transfer printers that produce very sharp edges, but the packages can be crushed or tilted. FedEx uses a bank of six laser scanners that surround the conveyor, each scanning from a different angle. The decoder uses a 'best of six' strategy: each scanner runs the pattern matching algorithm independently, and the results are compared. If at least four scanners agree on the decoded string, the package is routed.

What makes FedEx's application interesting is the use of Code 128 with Application Identifiers for service level (e.g., '2DAY' for two-day delivery). The start character is Start B, and the decoder encounters a series of AIs, each with a variable length. The pattern matching algorithm does not need to know the length of each field because the AI itself tells the decoder how many characters to expect. However, if a character is misread, the length may become ambiguous. FedEx's decoder includes a 'sanity check' on the length of each AI field based on the expected format. For example, if the AI for the zip code is expected to be 5 digits and the decoder reads 6 digits, it flags an error and tries to re-decode that segment using a different segmentation. This extra layer of validation, built on top of the basic pattern matching, ensures that FedEx maintains its industry-leading on-time delivery rate.

Real-World American Application 8: Pharmaceutical Serialization - Purdue Pharma

Purdue Pharma, with manufacturing sites in Connecticut, uses Code 128 barcodes to comply with the Drug Supply Chain Security Act (DSCSA). Each prescription bottle carries a serialized barcode that encodes a product identifier, serial number, lot number, and expiration date. The decoding algorithm here must not only read the barcode but also verify that the serial number is unique and not counterfeit. The scanners in Purdue's packaging line use a high-resolution camera that captures a 2D image, but they decode the Code 128 using a one-dimensional profile extracted from the image.

The pattern matching process includes an additional step: after decoding, the algorithm compares the widths of the decoded characters against the original image to compute a confidence score. If the confidence score is below 95%, the bottle is rejected and re-scanned. This high bar is necessary because a misread serial number could lead to a drug being shipped to the wrong pharmacy. Purdue's implementation also uses the Shift character extensively because the expiration date includes a month letter (e.g., 'J' for June) followed by digits. The decoder's state machine handles these single-character shifts without any performance degradation, scanning over 500 bottles per minute.

Real-World American Application 9: Automotive Supplier - Delphi Technologies

Delphi Technologies, now part of Aptiv, manufactures automotive sensors and connectors in its plants in Michigan and Texas. These parts are shipped to assembly plants like Ford and General Motors. Each component carries a Code 128 label that includes a part number (alphanumeric), a date code (digits), and a plant code (letters). The labels are small, often only 1 inch wide, so the bars are very narrow. The decoder in Delphi's handheld scanners must work with a module width as small as 0.005 inches.

At this small scale, the normalization step becomes extremely sensitive to printer noise. Delphi's decoders use a 'moving average' filter on the measured widths to reduce high-frequency noise before comparing against the reference table. The filter smooths out variations that are smaller than 0.2 modules. This preprocessing is part of the pattern matching process, even though it is not explicitly defined in the Code 128 standard. The start character is Start B, but Delphi also uses Code C for the date code (which is all digits), switching via a Code C character. The decoder's state machine must be fast enough to switch within a single scan, which it does in microseconds. This reliability has earned Delphi a zero-defect rating from its automotive customers.

Real-World American Application 10: Grocery Distribution - Kroger

Kroger, one of the largest supermarket chains in the US, uses Code 128 on all incoming cases from food suppliers. The distribution center in Cincinnati, Ohio, uses voice-picking systems where workers wear headsets and receive instructions via speech synthesis. The worker scans a case barcode to confirm the pick. The decoder in the wearable ring scanner must work in a noisy, refrigerated environment where the labels can be frosty or wet.

The pattern matching algorithm here includes a 'frost compensation' that looks for unusual high-frequency variations in the width profile caused by ice crystals on the label. If the decoder detects such variations, it applies a low-pass filter to the edge positions before normalization. This is an adaptive preprocessing step that is triggered by a statistical test on the widths of the narrow bars. If the narrow bars show more than a certain amount of variance, the decoder assumes frost and applies the filter. This clever adaptation allows Kroger to maintain a 99.8% read rate even in their meat and produce coolers.

Real-World American Application 11: Defense Logistics Agency (DLA) - Military Supply Chains

The US Defense Logistics Agency manages inventory for all military branches. They use Code 128 barcodes on ammunition, spare parts, and food rations. The labels must survive extreme conditions: desert heat, arctic cold, and saltwater spray. The decoding algorithm in DLA's handheld tactical scanners is hardened against a different kind of noise: low battery voltage that can cause the laser diode to flicker. This flicker introduces variations in the measured widths that are systematic (all bars appear slightly wider or narrower).

DLA's decoder uses a 'reference bar' technique: it measures the width of the first bar of the start character and uses that as an internal calibration. If the first bar is measured as 1.8 modules instead of 2.0, the decoder applies a global scaling factor to all subsequent widths. This scaling is applied before the reference table comparison. The start character thus serves double duty: it sets the code set and also calibrates the scanner's gain. This robust design ensures that soldiers in the field can scan supplies even with worn-out equipment.

Real-World American Application 12: E-Commerce Returns - Happy Returns (a PayPal company)

Happy Returns operates return-processing hubs in several US cities, including Dallas, Texas. They process thousands of returned items daily, each with a Code 128 return label. These labels are often printed on home inkjet printers, which have low resolution and uneven ink deposition. The decoder faces a challenge: the bars may have jagged edges and the spaces may have satellite spots of ink.

The pattern matching algorithm here uses a 'majority vote' over multiple scan lines. The camera-based scanner captures a 2D image and extracts 40 different horizontal scan lines across the barcode's height. Each scan line is decoded independently using the standard pattern matching process. The final decoded string is chosen by a majority vote among the 40 lines. If a particular character is decoded differently across lines, the character with the most votes is selected, and the confidence is weighted by the check character of each line. This multi-line decoding has increased the read rate on poor-quality labels from 85% to 96%, allowing Happy Returns to automate the sorting of returns without manual data entry.

The Integration with ERP Systems: From Decoded Data to Business Action

Now that we have seen how the decoder turns stripes into characters, we must ask: what happens nextThe decoded string is almost never the final product. In every one of the examples above, the decoded string is sent to an Enterprise Resource Planning (ERP) system. The ERP system, such as SAP, Oracle, or Microsoft Dynamics, receives the string and matches it against database records. For instance, when UPS scans a package, the decoded tracking number is transmitted via a wireless network to UPS's mainframe, which looks up the destination and updates the package's status. When Walmart scans a case, the decoded case ID triggers an inventory decrement in Walmart's retail ERP, which then generates a replenishment order. When Mayo Clinic scans a vial, the decoded NDC code is checked against the patient's electronic health record in the hospital's ERP, verifying the 'five rights' of medication administration.

The pattern matching algorithm's accuracy directly affects ERP data quality. If the decoder misreads a single character, the ERP system might update the wrong inventory record, send a package to the wrong state, or administer the wrong drug. That is why the decoding process includes not just pattern matching but also a check character validation. The check character is computed based on all the data characters and the start character. The decoder recomputes this check character and compares it with the encoded check character. If they match, the decoded string is considered valid and is passed to the ERP. If they do not match, the decoder discards the result and attempts to re-read. This double layer of validation (pattern matching + check character) is what makes Code 128 so trustworthy for business-critical applications.

Moreover, many ERP systems require the decoded string to be parsed according to GS1 Application Identifier rules. For example, the string may start with '00' for a serial shipping container code, followed by a 18-digit number. The ERP system uses the AI to know exactly how to split the string into fields. The decoder does not perform this parsing; it only outputs the raw character stream. However, the decoder must correctly handle all shift and code-set changes so that the raw stream is an exact representation of the encoded data. If the decoder's state machine fails to handle a shift, the raw stream will have the wrong characters, and the ERP's parser will fail. Therefore, the pattern matching algorithm's state machine is just as important as its width comparison logic.

Challenges and Failure Modes

Even the best pattern matching algorithm can fail. Common failure modes include:

- Low contrast: If the ink is too light or the substrate is too dark, the difference between bars and spaces is small. The edge detection threshold may not be able to reliably separate black from white. In such cases, the decoder may see extra bars or miss real bars, leading to incorrect width measurements.

- Print defects: A missing ink spot can turn a wide bar into two narrow bars. An extra ink spot can bridge a narrow space. These defects cause the decoder to see a different number of edges, so the six-element pattern may become a seven-element or five-element pattern. Most decoders have a 'robust' mode that can tolerate one missing or extra edge, but if there are multiple defects, the pattern matching will produce an invalid character.

- Curvature and perspective: When a barcode is wrapped around a cylindrical object, the bars near the edges appear narrower than those in the center. The decoder must correct this using a known cylinder radius or by using an adaptive normalization that considers the local magnification. Not all scanners have this capability, so some curved labels are difficult to decode.

- Specular reflection: Glossy labels can produce a mirror-like reflection that overwhelms the sensor, causing a bright spot that is interpreted as a wide space. Polarization filters and multiple angles help, but in extreme cases, the decoder may need to interpolate over the glint.

- Motion blur: On high-speed conveyors, the scanner's integration time may be too long relative to the barcode's movement, causing the bars to appear smeared. The decoder's edge detection will see a gradual slope instead of a sharp step, making it hard to determine the exact width. Some decoders use deconvolution to reverse the blur, but this is computationally expensive.

In all these cases, the decoder's pattern matching algorithm falls back to a 'rescan' or 'read failure' signal, which prompts the operator or the automated system to take corrective action. The beauty of Code 128 is that its design allows for graceful degradation: even if a few characters are ambiguous, the check character will usually catch the error, so the system rarely produces a false positive.

Advancements in Decoding Algorithms

While the basic pattern matching process has remained unchanged for decades, modern decoders have added several enhancements:

- Machine learning classifiers: Instead of using a fixed distance metric, some decoders train a neural network on thousands of labeled width vectors. The network learns to classify a measured pattern into one of the 103 character classes, even in the presence of noise. This has improved read rates on low-quality labels by 10-15%.

- Dynamic reference tables: The reference table is not static; it can be adapted to the specific printer and substrate. Some scanners perform a calibration scan on a known test symbol and then adjust the reference widths to match the printer's characteristics. This is especially useful in manufacturing environments where the same printer is used for months.

- Real-time feedback: Some decoders can output not only the decoded string but also a confidence value per character. The ERP system can use this confidence to decide whether to accept the scan or ask for a rescan. For example, if the check character passes but one character has a confidence below 80%, the system might flag the scan for manual verification.

- Parallel decoding: With multi-core processors, a decoder can run multiple pattern matching instances in parallel, each with a different normalization assumption (e.g., different module size estimates). The instance that produces a valid check character first is selected. This reduces decode time for difficult labels.

These advancements are all built upon the fundamental reference-table comparison that we described at the beginning. The core idea remains the same: measure widths, normalize, compare, and verify.

Summary of This Chapter

In this extensive chapter, we have taken a deep dive into the pattern matching process that lies at the heart of Code 128 decoding. We began by understanding that every Code 128 character is a sequence of six bars and spaces with widths of 1 to 4 modules, totaling 11 modules. The decoder's primary task is to measure these widths, normalize them against the narrowest element, and then find the closest match in a reference table that contains all valid patterns for Code Sets A, B, and C.

The start character is the critical entry point: it tells the decoder which code set to use initially, and it also participates in the check character calculation. The decoder then reads each subsequent character, using a finite state machine to handle Shift (one-time) and Code-set (permanent) changes. The stop character, with its unique 13-element structure, signals the end and allows bidirectional reading.

We then explored how this seemingly simple algorithm is implemented in a wide range of American industries. From UPS's high-speed tunnel scanners in Louisville to Boeing's laser-etched aerospace parts, from Walmart's dusty distribution centers to Mayo Clinic's sterile pharmacies, from Amazon's robot-mounted cameras to FedEx's multi-scanner sorting hubs, from Purdue's pharmaceutical serialization to Kroger's frosty coolers, from the Defense Logistics Agency's tactical scanners to Happy Returns' multi-line camera systems - in each case, the pattern matching algorithm is tuned and adapted to the specific challenges of the environment. Yet the core logic remains consistent: measure, normalize, compare, and verify.

We also examined the integration with ERP systems, emphasizing that decoding is not an end in itself but the first step in a chain of business processes. The accuracy of pattern matching directly impacts inventory management, order fulfillment, patient safety, and supply chain visibility. The check character provides a mathematical guarantee that the decoded string is internally consistent, while the state machine ensures that shift and code-set switches are faithfully reproduced.

Finally, we discussed failure modes and modern advancements. Even with all the challenges - low contrast, print defects, curvature, specular reflection, and motion blur - the pattern matching algorithm, combined with the check character, achieves error rates that are remarkably low. New techniques like machine learning, dynamic reference tables, and parallel decoding continue to improve performance, but they all rest on the same foundational principle: that a barcode is a sequence of widths, and the decoder's job is to match those widths to a known dictionary.

As we close this chapter, it is worth reflecting on the elegance of Code 128. It is a symbology that was designed in the early 1980s, yet it remains one of the most widely used barcodes in the world, precisely because its decoding algorithm is both simple and robust. The pattern matching process is not magic; it is a systematic comparison of measured widths against an ideal table. But when this process is executed millions of times a day across the United States, it becomes the invisible glue that holds modern logistics, healthcare, retail, manufacturing, and defense together. Whether you are a warehouse worker, a nurse, a pilot, or a soldier, the barcodes you scan are decoded by this same algorithmic dance of bars and spaces, and the data they produce flows into ERP systems that run the American economy.

In the next chapter, we will look at how these decoded strings are formatted and transmitted over networks to ERP databases, but for now, we hope you have gained a thorough appreciation for the humble but mighty pattern matching process. It is, in many ways, the unsung hero of automatic identification and data capture - a silent translator that turns physical ink into digital action, one character at a time.

 

EasierSoft Barcode Label Design & Bulk Printing Software

---- Use Excel Data to Batch Print Barcodes on Label Sheets or Roll Labels  

---- How to use this barcode software

Download:  Free Barcode Software + Barcode Label Designer

Download Free Barcode Software at Softonic

     Download at CNET

Once you obtain a GS1/UPC/EAN barcode, or other barcode type and QR code, you can use our free software to batch print barcode labels onto Roll label paper using a professional label printer, or to batch print barcodes onto Avery 5160 label sheets using a regular laser or inkjet printer. Our software has free and paid versions.

The free version fully meets your needs for batch printing GS1/UPC/EAN barcodes. The paid version can import data from Excel and databases to batch print barcode labels with different values.

How to Start

Input Data

Import Excel Data

Print Barcode

Barcode Format

Label Designer

All Screen Shot

Export Barcode Image

Save Template

Output Word Excel

How to Use & FAQ:

Example: Print barcodes to 5161 label

Example: Print barcodes to 5162 label

Example: Print barcodes to 5163 label

Example: Print barcodes to 5164 label

Example: Print portrait orientation 5164

Example: Print barcodes to 5167 label

Example: Print barcodes to 5168 label

Example: Print portrait orientation 5168

Example: Print barcodes to 5169 label

Example: Print barcodes to 5660 label

Example: Print barcodes to 5661 label

Example: Print barcodes to 5662 label

Example: Print barcodes to 5663 label

Example: Print barcodes to 5664 label

Example: Print portrait orientation 5664

Example: Print barcodes to 5873 label

Example: Print barcodes to 5874 label

Two ways to import Excel data

Import Excel Data - Pro Edition

Import Excel Data - Std Edition

Import Data from Excel - Detail

Load Data From Excel File

Data Editing Table

Copy Data From Excel

Four ways to input barcode data

Add ASCII Key E

Input Multiple Lines of Text for Barcodes

Generates Sequential Serial Numbers

Import or copy data from Excel sheets

Special sequence number generation

Std Details: Simple Input Form

Std Details: Multiple Line Text Input

Details: Sequence Barcode Generator

Examples: Sequence Barcode Generator

Import Data From Excel Spreadsheet

Barcode Data Correspondence Diagram

Data Editor

Editing a Single Row Data in Form

Batch Editing Multiple Rows of Data

Batch Data Editing - Example 2

Design & print complex barcode labels

Configuring Text Elements on Label

Configuring Barcode Elements on Label

Configuring Image Elements on Label

Setting Line Elements on Label

Designing Labels for 5164 Sheet

Advanced Page Layout Settings

Add Barcode Elements to a Label

Configuring Parameters of a Barcode

Entering Multiple Values for a Barcode

Highlights

Excel integration: Import data directly from Excel to generate and print barcodes in bulk.

Label designer: Create complex labels with multiple barcodes, text, logos, and shapes.

Batch printing: Print thousands of barcodes at once using standard inkjet/laser printers or professional barcode printers.


Flexible editions:

Standard Edition: Simple batch printing with Excel data.

Professional Edition: Adds command-line automation for workflow integration.

Label Designer Edition: Advanced design features for complex labels.


Why Choose Our Barcode Solutions?

Cost-effective: Free online generator and permanent free desktop version available.

Easy to use: No technical expertise required—just input data and print.

Versatile: Supports nearly all 1D and 2D barcode types, including QR codes.

Trusted: Recommended by CNET and widely downloaded by users worldwide.


Suitable Use Cases

Small businesses and startups needing quick barcode labels for products.

Retailers and online sellers managing inventory with batch barcode printing.

Manufacturers requiring sequential or custom barcode labels for packaging.

Educational and testing environments where barcodes are used for tracking.

 

 

CONTACT

cs@easiersoft.com

If you have any question, please feel free to email us.

 

https://free-barcode.com

 

<<< Back to Directory <<<     Barcode Generator     Barcode Freeware     Privacy Policy