Code readingGuide

Bottle label barcode verification: fixed reader and PLC serial link

Bottle label barcode verification: reader mounting geometry, RS-232 ASCII framing, and the PLC string compare that accepts or rejects each bottle.

LumaSpec Vision12 min read Share on LinkedIn

On this page 12 sections
  1. 01The decision up front
  2. 02Checking the label is not grading the code
  3. 03Pick the interface before the focal length
  4. 04Worked geometry: distance, field of view and pixels per module
  5. 05Trigger and exposure on a moving bottle
  6. 06Gloss, curvature and frost
  7. 07Frame the string the PLC will see
  8. 08Set up the PLC port and reserve its buffer
  9. 09Compare, decide, and separate the failures
  10. 10When serial is the wrong answer
  11. 11Checklist before you order
  12. 12Questions

You are labeling bottles, and the line has to prove each one wears the right label before it packs. The dependable fix is a fixed-mount code reader over the conveyor that decodes the label's barcode and hands the ID to the PLC, which compares it with the recipe and accepts or rejects the bottle. This guide commits to one architecture - a fixed reader with a serial ASCII output wired into a spare PLC comm port - and works both sides of it: the reading distance, field of view and exposure that make the decode hold, and the baud rate, message framing and buffer sizes that make the link clean. You finish with a worked geometry, an exact serial frame, the compare logic, and a checklist you can order from.

The decision up front

Buy one fixed-mount code reader from the serial side of the catalog, aim it at the label, and let the PLC make the call. The reader outputs plain ASCII with the framing stripped to the minimum: preamble off, symbology ID off, a fixed-length label ID, a CR/LF postamble, 9600 baud, 8 data bits, no parity, 1 stop bit. Wire it TX to RX, RX to TX, signal ground to signal ground, into the PLC's second comm port, switched from its sequenced protocol to non-sequenced ASCII. The PLC accepts a bottle only when the received string equals the recipe string exactly, retries once on a no-read, and rejects anything else.

The wire is never the bottleneck. Ten characters at 8N1 is 100 bits, 10.4 ms at 9600 baud, and a 30-bottle-per-minute line gives each bottle 2 s. Serial is the wrong tool only when you run a second reader, the HMI already owns the spare port, or images must be archived; those cases close the article.

Checking the label is not grading the code

Two jobs hide inside the word verification, and they buy different hardware. Proving the right label is a string compare: decode the barcode, compare with the recipe, accept or reject the bottle. Grading print quality measures the symbol itself - contrast, defects, growth - against ISO/IEC 15416 for linear codes and ISO/IEC 15415 for 2D symbols, with a calibrated verifier; barcode reader verification for label inspection covers that discipline. A right-label station needs dependable decodes and an exact compare, not a grade. The neighboring task on bottle lines - proving the label sits straight before a servo correction - is its own subject: bottle label orientation vision for servo alignment.

Pick the interface before the focal length

Filter fixed code readers by interface first, because the interface shrinks the pool before the optics do. The Interface: Serial filter on the fixed code reader finder lists 28 models; Fast Ethernet alone lists 365. For a brick PLC whose only free input is a serial ASCII port, serial wins: one cable, one frame format, and you can watch the traffic with a terminal. The MV-ID6200PM-00C-NNG sits at the wide end of the serial pool, a 20 MP logistics code reader with a Serial interface and a C-mount lens.

Keep the RS-232 run under about 15 m at 9600 baud; past that distance, or through a noisy panel, use Ethernet and convert at the rack - a serial to Ethernet converter feeding plant data tags keeps the PLC-side ASCII intact. If your PLC has a spare Ethernet port, skip RS-232 entirely and start from planning a reliable barcode reader to PLC link.

Worked geometry: distance, field of view and pixels per module

Set the optics with one chain of arithmetic. Take a 90 mm wide label carrying an 8-character Code 128 ID, modules (the narrowest bars) of 0.25 mm, bar height 8 mm; a reader 300 mm from the bottle face; and a 1/3-inch sensor 4.8 mm wide with 1280 pixels across. These are example inputs - swap in your own label and standoff and the formulas hold.

m = sensor width / field of view f = WD × m / (1 + m) pixels per module = (sensor pixels / field of view) × module width

Magnification m is sensor width over field of view, and WD is the lens-to-label working distance.

The field of view must clear the label plus placement wander, so target 100 mm. Then m = 4.8 / 100 = 0.048 and f = 300 × 0.048 / 1.048 = 13.7 mm, which rounds to the nearest stock focal length of 12 mm. At 300 mm that 12 mm lens gives m = 12 / (300 - 12) = 0.042 and a field of view of 4.8 / 0.042 = 115 mm. Resolution follows: 1280 / 115 = 11.1 px/mm, so a 0.25 mm module spans 2.8 px - above the 2 px decode floor, just under the 3 px that buys margin on marginal prints.

The code fits the label with room to skew: an 8-character Code 128 runs (11 × 9 + 13) modules × 0.25 mm = 28 mm of bars plus 5 mm of quiet zone, 33 mm inside 90 mm.

If your modules are 0.20 mm, 2.2 px reads clean labels and drops marginal ones. Halve the standoff instead: at 200 mm the same 12 mm lens covers 4.8 / (12 / 188) = 75 mm, and 1280 / 75 = 17 px/mm puts 3.4 px on a 0.20 mm module. Closer standoff buys resolution and costs mounting room and depth of field - bottle diameter spread starts to matter below about 150 mm.

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.

Run your own label size and standoff through the same arithmetic:

Lens focal length, field of view and working distance
Units
Solve for
Focal length
– mm
Field of view
– mm
Working distance
– mm
Magnification
– x
Angle of view
– °
Pixel on the part
– mm

Thin-lens model: m = sensor width / field of view, f = WD × m / (1 + m). Accurate to a few percent above about 150 mm; check the lens's minimum object distance.

Find lenses with this focal length Open the full calculator

The compact catalog match for this geometry:

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
Shutter
Global
Lens mount
M12
$1,979.00View part

The MV-ID3013PM-12M-WBN is a compact industrial code reader with a 12 mm focal length, 1.3 MP resolution, a global shutter and a Fast Ethernet interface - the optics of the worked example, with the interface your architecture chooses. On a slow bench line where a PC or HMI runs the compare instead of the PLC, USB saves the serial wiring:

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
Interface
USB
$559.00View part

The LS-CRD-0047 is a compact fixed industrial barcode reader with 1.2 MP, a USB 2.0 interface and a 60-120 mm reading distance - the standoff class for a reader mounted on the labeling fixture itself. Three working-distance classes from the catalog, side by side:

Specification LS-CRD-0047 MV-IDB005EXI-05NRP MV-ID3013PM-12M-WBN LS-CRD-0028
Resolution 1280 x 960 1024 × 1280 1280 × 1024 2560× 2048 px
Shutter Global – – Global shutter
Symbologies – 1D codes: Code 39, Code 93, Code 128, EAN8, EAN13, ITF 14, ITF 25, CodaBar, UPCA, UPCE; 2D codes: QR Code, Data Matrix, MicroQR, AZTEC, HanXin; Stacked codes: PDF417 1D codes: Code 39, Code 93, Code 128, CodaBar, EAN 8, EAN 13, UPCA, UPCE, ITF 14, ITF 25, Matrix 25, MSI, China Post, Code 11, and Industrial 25; 2D matrix codes: QR Code (GS1-QR included), Data Matrix (GS1-DM included), MicroQR, AZTEC, HanXin, Maxi code; Stacked codes: PDF417, MicroPDF417 1D: Code 39, Code 93, Code 128, CodaBar, EAN8, EAN13, UPCA, UPCE, ITF14, Matrix 2 of 5, Matrix 25, MSI, China Post, Code 11, Industrial 25; 2D: QR Code, Data Matrix; Stack codes: PDF417
Max. frame rate – 50 fps 60 fps 30 fps
Max. reading speed – 30 codes/sec 84 codes/sec –
Sensor type – CMOS, global shutter, mono, 1/4", 2.7 μm × 2.7 μm Global shutter, mono, 1/2.7", 4 μm × 4 μm CMOS
Exposure time – 60 μs ~ 6000 μs 35 μs to 1 sec 35 μs ~ 1 s
Gain – 1 ~ 28 dB 0 dB to 28 dB –
Data interface – Fast Ethernet (100 Mbit/s), RS-232, DC terminal Fast Ethernet (100 Mbit/s) Fast Ethernet (100 Mbit/s)
Communication protocol – SmartSDK, TCP Client, Serial, FTP, TCP Server, UDP, Profinet, Ethernet/IP SmartSDK, TCP Client, TCP Server, Serial, FTP, Profinet, Ethernet/IP, MELSEC/SLMP, ModBus, UDP, Fins, Modbus RTU –
Digital I/O – DB15 connector for power and I/O, Incl. 2 opto-isolated inputs (pin 0/1 input), 2 opto-isolated outputs (pin 3/4 output), 1× RS-232, Trigger via side button supported, Device reboot 17-pin M12 connector provides power and I/O, including non-isolated input (LineIn 0/1/2) × 3, non-isolated output (LineOut 3/4/5) × 3, RS-232 × 1. Supports device triggering via pressing button on top.;17-pin M12 connector provides power and I/O, including isolated input (LineIn 0/1/2) × 3, isolated output (LineOut 3/4/5) × 3, RS-232 × 1. Supports device triggering via pressing button on top. 3 non-isolated inputs, 3 non-isolated outputs, 1 RS-232
Power supply – 12 ~ 24 VDC 24 VDC 24 V
Price $559.00 $719.00 · quoted $1,979.00 $920.00

Values as printed in each product's data sheet; open a part for its drawing and full specifications.

Match the class to where your bracket can live; everything downstream - framing, buffer, compare - is the same logic on every row.

Trigger and exposure on a moving bottle

Motion caps the exposure, not the decoder. With 115 mm on 1280 pixels, one pixel is 115 / 1280 = 0.09 mm on the bottle. Keep blur under one pixel and the exposure ceiling is 0.09 / 200 = 450 µs at 200 mm/s of belt. Set 250 µs: blur is 200 × 0.00025 = 0.05 mm, or 0.56 px. Trigger from a photoelectric sensor upstream of the reader rather than free-running, so each frame owns one bottle and the PLC can key its verdict to the trigger bit.

Decode rate is nowhere near a limit at bottle-line speeds: 30 bottles a minute is half a read per second, and the LS-CRD-0028 is a 2560 x 2048 fixed code reader rated 60 codes/s at 30 fps with an 8 mm lens.

Gloss, curvature and frost

A glossy film label on a curved bottle is a moving mirror: the specular stripe slides across the code as the bottle turns. Use two fixes together - tilt the reader 10-15° off the label normal so the reflection leaves the lens, and buy a polarized reader. The polarized pick:

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 is a polarized 1.3 MP industrial code reader with a 4.63 mm focal length and a 70 mm focus distance, built for exactly this short-standoff glare problem. During teach-in, keep faces out of the illuminator beam at close range; the light is aimed at the label and that is where it stays.

Frost is not a lighting problem. Condensation on a cold-filled bottle scatters the code, and no polarizer reads through it: wipe with an air knife upstream or read after the warm section. Frosty label scanning on a fast line works this same failure at 80 units per second.

Frame the string the PLC will see

A reader's serial message is assembled from four parts, in order: an optional preamble, an optional symbology ID, the data (with an optional delay between characters), and an optional postamble. Commit to the leanest frame: preamble off, symbology ID off, your fixed 8-character ID, then CR + LF. The terminator carries the message - the PLC's ASCII receive instruction ends on it instead of counting characters into silence.

At 9600 baud with 8N1, every character is 10 bits, so 8 characters plus CR and LF is 100 bits and 10.4 ms end to end. Leave the inter-character delay at zero; if the PLC port drops characters, 1 ms per character still lands the whole frame in about 20 ms.

Turn the symbology ID back on only when two code types share the station and the logic must tell them apart - then strip those bytes in ladder before the compare. Prefix and suffix framing for barcode scanner input and barcode scanner capture without a prefix take the trimming further.

Set up the PLC port and reserve its buffer

Brick PLCs expose a spare serial port as an ASCII receiver: an AIN (ASCII In) instruction on port 2, or a Receive-style instruction on the CPU module's second port. Reading a barcode scanner into a PLC CPU module over serial covers that wiring. In the port setup - the screen is usually called Setup Secondary Comm Ports - switch the port from its sequenced protocol to Non-sequence I/O, point the Memory address at a block of 9 words the port owns, and set 9600 baud, 8 data bits, no parity, 1 stop to match the reader exactly. The port packs two ASCII characters per 16-bit word, so the 10-character frame occupies 5 words of that block.

Settings that disagree announce themselves as garbage in the buffer: fixing garbage characters from a barcode scanner on the PLC serial link points at baud, then parity, then wiring, in that order. When the same string must appear on an HMI, the byte-to-display conversion is a step of its own: barcode reader ASCII conversion and HMI display.

Compare, decide, and separate the failures

Three rungs of ladder per bottle:

  1. Arm on the trigger bit and start a 300 ms watchdog.
  2. On frame received, check length first - exactly 8 characters - then compare buffer words against the recipe register, two characters at a time.
  3. Latch the verdict before the next trigger clears the buffer.

PLC ladder logic to compare barcode strings and count three reads gives the compare-and-count pattern, and judging whether a decode is trustworthy covers flagging marginal decodes with the reader's read-quality indicator even when the string matched.

When serial is the wrong answer

Serial ASCII is the right call for one reader and one free port. Move to Ethernet when the HMI already occupies that port, when a second reader joins the station, or when images must be kept for traceability - archiving barcode inspection images to cloud storage begins at the reader's image stream, which an RS-232 link cannot carry.

Checklist before you order

  • Label ID fixed at 8 characters; X-dimension 0.25 mm or wider at a 115 mm field, 0.20 mm at 75 mm.
  • Standoff and lens from the formula: 12 mm at 300 mm covers 115 mm on a 4.8 mm sensor, 2.8 px per 0.25 mm module.
  • Exposure 450 µs or shorter at 200 mm/s; confirm blur stays under one pixel at your real belt speed.
  • Reader frame: preamble off, symbology ID off, CR/LF postamble, 9600 baud, 8 data bits, no parity.
  • PLC port in Non-sequence ASCII, 9-word block reserved, buffer read two characters per word with one guard word spare.
  • Photoelectric trigger upstream, 300 ms watchdog, one retry, diverter wired to the latched verdict.
  • Glare plan: polarized reader or a 10-15° tilt. Frost plan: air knife upstream of the reader.
  • RS-232 cable under 15 m, TX and RX crossed, shield grounded at one end only.
Code readers & vision sensorsFixed code readers

1D/2D codes on the line

658 models · from $399.00

Take the label artwork and your port map into the system configurator, or contact the team and we will size the station with you.

Questions

Do I need the preamble and symbology ID in the serial string?

No. For one reader, one symbology and one PLC port, turn both off: the message is then exactly your fixed-length label ID plus CR/LF, and the string compare needs no stripping. Keep the symbology ID only when two code types share the station and your logic must tell them apart, and move those bytes into a tag before comparing. A preamble buys nothing on a dedicated line and gives the compare logic one more way to disagree.

How fast can a 9600-baud serial link verify bottles?

Faster than your mechanics. A 10-character frame at 8N1 is 100 bits, about 10.4 ms at 9600 baud and 5.2 ms at 19,200. Even five bottles per second spends under 30 ms of each second on the wire. The real ceiling is the PLC scan and your retry window: budget the 300 ms watchdog, one re-trigger and the diverter travel, not the serial bit time.

Where should the string compare live, in the reader or the PLC?

In the PLC when the expected label changes with the recipe and the PLC already owns accept and reject - the recipe register then feeds one compare rung for every product. In the reader when its own string-match output can drive the reject directly and recipes rarely change. You still need a PLC path for the no-read case, because a reader that decodes nothing switches no output at all.

My labels are glossy and the bottles come out of the filler cold. Will the reads hold?

Gloss and frost fail differently. Gloss throws a specular stripe that slides with the bottle: a polarized reader or a 10-15 degree tilt off the label normal removes it. Frost is condensation, not contrast - no filter reads through it, so wipe the bottle with an air knife upstream or read after the warmer. Size the air knife for your bottle pitch, not the average bottle.

What differs between checking the right label and grading barcode print quality?

The right-label check asks whether this bottle decoded to the ID the recipe expects. A grade asks how well the symbol was printed: ISO/IEC 15416 governs linear codes and ISO/IEC 15415 governs 2D symbols, and only a calibrated verifier may issue one. Label verification needs dependable decodes and an exact compare; grading is only worth its cost when a customer audits print quality.

How many PLC words do I reserve for the message?

Two ASCII characters per 16-bit word is the rule on brick PLCs, so an 8-character ID with CR and LF occupies 5 words of your buffer. On top of that, the port itself wants its own block - 9 words on this class of PLC - reserved in the port setup before any instruction runs. Give the buffer one guard word past the longest frame so a double-read cannot run past the end.