Barcode, 2D code or OCR? Choosing part identification for traceability

Compare 1D barcodes, 2D Data Matrix codes and OCR for part traceability: data capacity, size, read reliability, direct part marking and when to use each.

A 2D Data Matrix code, a 1D barcode and a printed lot number, the three main part identification methods

Traceability means being able to answer, for any part, "where did this come from and what happened to it?" That depends on reliably identifying each part or batch as it moves through production. Machine vision does this by reading codes and text, but the method you choose has a big effect on how reliable, compact and future-proof your traceability will be.

Here's how the three main options compare: 1D barcodes, 2D codes and OCR.

1D barcodes

The familiar striped barcode, in common symbologies such as Code 128 and EAN/UPC, encodes data in the widths of bars and spaces.

  • Strengths: universally supported, cheap to print, and easy to read with image-based readers at any orientation.
  • Limitations: relatively little data for the space they take, and a scratch or smudge across the bars can make the code unreadable. They also need a clean, high-contrast print, which usually means a label.

1D barcodes remain a good fit for labels, packaging and anywhere the code has to work with existing scanners and systems.

2D codes (Data Matrix and QR)

2D codes store data in a grid of dark and light cells. Data Matrix is the most common choice for industrial part marking; QR codes are more familiar from consumer use.

  • More data in less space. A Data Matrix just a few millimetres across can hold a full serial number, part number and date.
  • Built-in error correction. Data Matrix (ECC 200) uses Reed-Solomon error correction, so a code can often still be read even when part of it is damaged or dirty.
  • Direct part marking. 2D codes can be laser-etched, dot-peened or inkjet-printed straight onto metal, plastic or ceramic parts, so the ID stays with the part for life without needing a label.

The trade-off is that they aren't human-readable, and directly marked codes can be much harder to read than printed labels. More on that below.

OCR and OCV

Optical character recognition (OCR) reads human-readable text such as serial numbers, lot codes and expiry dates. Optical character verification (OCV) goes one step further: it checks that the printed text matches what was expected and that it's printed well enough to be read.

  • Strengths: people can read it too, which matters for operators, service engineers and end customers. Often it's also required by the customer or regulations.
  • Limitations: text carries no error correction, so reliability depends heavily on print quality, font and background. Characters that look alike, such as O and 0 or I and 1, need careful handling.

OCV is closely related to mark inspection on semiconductor packages, where every character of the marking has to be present, correct and legible.

Side-by-side comparison

1D barcode2D codeOCR / OCV
Data per areaLowHighMedium
Tolerance to damageLowHigh (error correction)Low
Human-readableNoNoYes
Direct part markingRarelyYes, very commonYes
Typical useLabels, packagingPart-level traceabilityLot codes, dates, serials

Direct part marking needs the right lighting

A laser-etched or dot-peened code on a machined metal part can have very little contrast against the surface around it, and the surface itself may be shiny, curved or textured. Reading these codes reliably is much more about lighting than about the decoder.

Dot-peened codes often read best under low-angle (dark-field) lighting, which makes each dot catch the light. Laser marks on flat, shiny surfaces often read best under coaxial or dome lighting. Our machine vision lighting guide explains why.

Reading is not the same as grading

A reader that decodes a code today doesn't guarantee that the next scanner downstream, perhaps at your customer's site, will manage it too. That's why many manufacturers also grade their codes against print-quality standards: ISO/IEC 15416 for 1D barcodes, ISO/IEC 15415 for printed 2D codes, and ISO/IEC TR 29158 (AIM DPM) for directly marked parts. Grading catches a slowly degrading printer or laser before codes start failing in the field.

Which should you choose?

  • Use a 2D Data Matrix for part-level traceability, especially when space is tight or the code must survive the life of the part.
  • Use a 1D barcode on labels and packaging that must work with existing scanners.
  • Use OCR / OCV when people need to read the information, or when the text itself must be verified.
  • Often the best answer is a combination: a 2D code for machines and human-readable text for people, both checked by the same vision identification system.

If you're planning a traceability project, or struggling with read rates on an existing one, talk to us. We'll help you choose the marking, lighting and reading approach that works for your parts.

Keep reading

All articles