Code readingGuide

Code 128 barcode module size, reading angle and reader distance

Yes: a Code 128 barcode reading at any angle works when the module size is resolved at the distance — width math, pixels per module and tilt limits.

LumaSpec Vision9 min read Share on LinkedIn

On this page 10 sections
  1. 01The decision first
  2. 02How wide the code really is
  3. 03Pixels per module: the number that gates the read
  4. 04Worked example: 20 characters at any rotation
  5. 05Roll is free; tilt is paid for
  6. 06Read only your code: length and symbology filtering
  7. 07Which reader for which station
  8. 08Checks before you mount it
  9. 09When the usual answer is wrong
  10. 10Questions

You are mounting a fixed reader over a line, and the label is a Code 128 with 0.381 mm modules carrying 17 to 20 data characters, arriving at whatever angle the part presents. Is any-angle reading realistic, and what does it cost in resolution and mounting distance? Yes on both counts: this is a large module by industrial standards, and image-based readers decode a 1D code from scan lines traced at many angles in one frame. The limit is pixels per module at the code, not the symbology and not the data length. This guide works the width math, sets the pixels-per-module budget, converts it into field of view and working distance, and marks where tilt, glare and filtering change the decision.

The decision first

A Code 128 of this module size with 17 to 20 data characters reads at any rotation angle. Image-based readers — fixed-mount, smart camera or handheld — trace scan lines in many directions across the frame, so a code lying anywhere between 0° and 360° in the label plane is just another orientation to the decoder.

The budget to hold: one pixel covering no more than half a module at the code. For this module that is 7.5 mil (0.19 mm) per pixel — 2 pixels per module, the decode floor. Design at 3 pixels per module, 5 mil (0.127 mm) per pixel, and print gain, placement wander and moderate tilt still leave margin. Module size drives reader sizing the same way in document work; see barcode module width for document scanning for that case.

How wide the code really is

Code 128 encodes each data character in 11 modules; start, check and stop patterns add a fixed overhead. A supplier sizing formula for code sets A and B:

modules = 11 × data_characters + 25 symbol_width = modules × X quiet_zone = 10 × X, each side

X is the module width: 15 mil = 0.015 in = 0.381 mm.

  • 17 characters: 11 × 17 + 25 = 212 modules → 212 × 0.381 mm = 80.8 mm (3.2 in)
  • 20 characters: 11 × 20 + 25 = 245 modules → 245 × 0.381 mm = 93.3 mm (3.7 in)

Quiet zones are 10 modules on each side, so add 20 × 0.381 mm = 7.6 mm: the full footprint is 88 mm (3.5 in) at 17 characters and 101 mm (4.0 in) at 20. Height is the printer's choice; a 10 mm high symbol puts the diagonal at 101.5 mm, so width sizes your field of view. Keep both quiet zones inside the frame at the worst placement — a clipped quiet zone fails reads that have resolution to spare.

Pixels per module: the number that gates the read

ppm = sensor_pixels_across × module_width / field_of_view max_field_of_view = sensor_pixels_across × module_width / ppm_target

Two pixels per module decodes; three is the design target. Below two, print spread starts merging the narrow light bars and the decode rate falls away fast. Tilt is what consumes the budget, because the apparent module foreshortens with the cosine of the tilt angle:

Tilt off the label plane Apparent module Pixels per module to hold 2 px
0° full width 2.0
30° 13 mil 2.3
45° 10.6 mil 2.8
60° 7.5 mil 4.0

A 3-pixel design budget keeps the 2-pixel floor down to about 48° of tilt, since 3 × cos 48° = 2.0.

Worked example: 20 characters at any rotation

Take an example station: the 101 mm footprint plus 29 mm of placement wander, so a 130 mm field of view. Take an example sensor 1280 pixels across with 3.8 µm pixels (sensor width 1280 × 0.0038 mm = 4.86 mm) behind a 12 mm lens.

Pixel size on target = 130 mm ÷ 1280 = 0.102 mm, which is 4.0 mil. Pixels per module = 0.381 ÷ 0.102 = 3.7 — above the 3-pixel target, so every rotation angle decodes with margin.

The widest field this sensor allows: 1280 × 0.381 ÷ 3 = 163 mm at the design target, and 1280 × 0.381 ÷ 2 = 244 mm at the floor.

Working distance: magnification m = 4.86 ÷ 130 = 0.037, so WD = f × (1 + m) ÷ m = 12 mm × 1.037 ÷ 0.037 ≈ 333 mm. Mount near 330 mm, and check your own lens with the lens focal length calculator.

Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

How sensor width, working distance and field of view set the focal length Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.CameraField of view (FOV)Working distance (WD)≈ fsensor width slensm = s / FOVf = WD × m / (1 + m)
How sensor width, working distance and field of view set the focal length. Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.

For a wider scene, step up to a 5 MP class fixed reader.

Fixed code readers2560 x 2048 fixed code reader, 30 fps, 60 codes/s, 8 mm lens (LS-CRD-0028)LS-CRD-0028
Interface
Fast Ethernet
Resolution
5 MP
Sensor format
1/1.7"
Shutter
Global
$920.00View part

The LS-CRD-0028 gives 2560 × 2048 pixels, 60 codes per second and an 8 mm lens. Across a 300 mm field of view that is 2560 × 0.381 ÷ 300 = 3.3 pixels per module, and the 2-pixel floor stretches to 2560 × 0.381 ÷ 2 = 488 mm — field enough for several codes or generous placement wander.

Roll is free; tilt is paid for

Rotation in the label plane costs nothing: the module pitch along the code's own axis is unchanged, and the decoder finds that axis. What you pay for is tilt out of the plane.

At 45° of tilt the example's 3.7 pixels per module drops to 3.7 × cos 45° = 2.6 — still decoding. At 60° it is 1.9, below the floor. Tilt also adds depth: a 101 mm symbol tilted 45° spans 101 × sin 45° ≈ 71 mm from near edge to far edge, and the lens must hold focus over all of it. Depth of field scales roughly with f-number, so stopping from f/2.8 to f/8 buys close to three times the depth at one-eighth of the light — plan a stronger light, or a longer exposure on static parts.

Tilt on a shiny label also swings the specular reflection toward the lens. Polarization answers that at the lens.

Fixed code readersHikrobot MV-IDB005EXI-05NRP Fully isolated version, 1.3 MP resolution, 4.63 mm focal length, 70 mm focus distance, Polarized industrial code readerMV-IDB005EXI-05NRP
Interface
Fast Ethernet
Resolution
Up to 3 MP
Shutter
Global
Lens mount
M5.8
$719.00 · quotedView and quote

The MV-IDB005EXI-05NRP pairs a 1.3 MP sensor with a 4.63 mm focal length, a 70 mm focus distance and a polarized light path. For glare combined with curvature, the techniques in reading QR codes on reflective and curved surfaces carry over to Code 128.

Read only your code: length and symbology filtering

When several labels can be in frame, set the reader's minimum and maximum data length to 17 and 20, so anything shorter or longer is never reported. Add a match string on a fixed prefix if your part numbers share one, and restrict the symbology list to Code 128 so a stray QR or Code 39 is ignored. Cropping the search region around the code's expected position cuts decode time; the ROI guide for inline code reading quantifies the gain.

Which reader for which station

  • Close, static presentation at 60-120 mm: a compact reader sized for that band.
  • Mid-range line at 200–500 mm: a 1.3 MP compact on a 12 mm lens — the worked example's 163 mm field at the 3-pixel target.
  • Wide scene, tilted labels or several codes in frame: a 5 MP reader, per the 2560-pixel math above.
  • Decode plus on-device inspection: smart cameras run both in one housing.
  • Operator-presented parts: handheld code readers handle this module size easily at handheld ranges.

A pair of compact models covers the close and mid-range stations.

Fixed code readersHikrobot MV-ID3013PM-12M-WBN 12mm focal length 1.3 MP Compact Industrial Code ReaderMV-ID3013PM-12M-WBN
Interface
Fast Ethernet
Resolution
Up to 3 MP
$1,979.00View part
Fixed code readersCompact fixed industrial barcode reader, 1.2 MP, USB 2.0, 60-120 mm reading distance (LS-CRD-0047)LS-CRD-0047
Resolution
Up to 3 MP
Shutter
Global
$559.00View part

The MV-ID3013PM-12M-WBN is a 1.3 MP compact code reader with a 12 mm focal length. The LS-CRD-0047 is a 1.2 MP compact reader with a 60-120 mm reading distance over USB. Triggering decides the rest: free-run for static parts, sensor or serial trigger for moving ones — fixed barcode reader trigger modes lays out the trade-offs.

Checks before you mount it

  • Measure the printed module on a finished label with a loupe or scope; the drawing says 0.381 mm, a worn printhead may not deliver it.
  • Recompute pixels per module at the worst placement edge, not the centre of the field.
  • Keep both quiet zones fully in frame at that worst placement.
  • Cover the tilt depth — 71 mm at 45° for this symbol — within the lens's depth of field.
  • Cap motion blur at a quarter module: 0.095 mm on target, which allows 95 µs of exposure at 1 m/s. That means a strobed light, not continuous.
  • Set the length filter to 17–20 and the symbology filter to Code 128.
  • If the reader has a laser aperture, follow its laser class label: Class 1 asks nothing extra, Class 2 means never stare into the beam.

After mounting, run the link and readback steps in fixed code reader setup over USB before you call the station done.

When the usual answer is wrong

  • Tilt beyond about 60°: the module foreshortens to 7.5 mil or less, and no tuning recovers pixels you never collected. Move the reader, or add a second one at the mirrored angle.
  • The real module is smaller than the drawing calls for: shrink sleeves and packaging radius act like tilt. Re-budget pixels per module against the smallest true module on the curve.
  • A moving line: blur eats the budget no matter what the static resolution says. At 1 m/s the 95 µs rule applies; high-speed conveyor barcode reading sizes the full set-up, and sizing the strobe pulse sets the light timing.
  • Damaged or low-contrast prints: resolution cannot rebuild missing bars. Start from improving the decode rate on damaged, low-contrast codes.

Decision by station: flat part inside a 250 mm field — a 1.3 MP compact at 3 pixels per module. Flat part, 250–480 mm field or tilt to 45° — a 5 MP reader. Tilt past 60°, curved or mirrored surfaces — reposition, polarize, or add a second reader. Operator scanning — a handheld. Browse fixed code readers or the camera and reader finder, and take your field of view and distance into the system configurator. More set-ups are collected under the code reading topic.

Questions

How wide is a 20-character Code 128 if the data is all digits?

Switching to code set C pairs two digits into one 11-module character: (20 ÷ 2) × 11 + 25 = 135 modules, so 135 × 0.381 mm = 51 mm (2.0 in), or 59 mm with quiet zones — roughly half the set B width. Use set C whenever the payload is purely numeric and label width is tight.

How many pixels per module does verification grading need?

Decoding needs 2 pixels per module and a design should target 3. Print-quality grading to ISO/IEC 15416 practice is stricter: about 5 pixels per module, plus a measurement aperture matched to the module size and calibrated illumination. A verification station therefore needs a tighter field of view or more pixels than a decode-only station on the same label.

Does the 17 to 20 character filter count the start and stop patterns?

No. The length filter counts data characters only; start, check and stop characters are overhead the reader never reports. A 20-character payload reads back as exactly 20 characters. Set the acceptance window to 17–20 and add a prefix match when several Code 128 labels share one station.

Why does a code read dead-flat but fail at 40° of tilt?

Foreshortening. The apparent module becomes 15 × cos 40° = 11.5 mil, so a station tuned for exactly 2 pixels at the nominal module drops to about 1.5 pixels, and the tilted surface adds glare. Budget pixels per module divided by the cosine of your worst tilt — here ×1.3 — and keep the illuminator off the specular path.

Is a handheld reader good enough for this module size?

Yes. This module sits well inside the working range of any industrial handheld, and 2D-imager handhelds aim omnidirectionally, so presentation angle is not a limit. Choose a fixed reader when the station needs hands-free triggering, a PLC handshake or unattended reads; choose a wireless handheld for yard and warehouse roaming.