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

From Photons to Bits: The Circuit Principles and Design Reality of Barcode Scanners (P42)

Recommended: Free barcode software - Bulk barcode generator and label printing, Free for life. Download

Article 42: The Adaptive Threshold and the AGC Loop: Making Sense of a Signal That Will Not Sit Still

Summary

This article explains why the comparator that digitizes the filter output in a laser barcode scanner cannot use a fixed threshold, and how an automatic gain control loop solves the problem by sensing signal amplitude and adjusting gain. It then surveys how this principle appears in real deployments across retail, logistics, manufacturing, healthcare, banking, and other industries.

1. Introduction: The Problem of a Moving Target

The signal at the filter output is never the same twice. In a laser barcode scanner, the photodiode receives a burst of reflected light whose strength depends on the distance to the label, the angle of the label, the darkness of the ink, the glossiness of the packaging, and even the cleanliness of the scanner window. The filter cleans up the noise, but what comes out of it is still an analog waveform whose amplitude may be large when the label is close and white, and tiny when the label is far away and printed on a dark background.

The comparator must turn this analog waveform into clean digital transitions. A comparator does this by comparing the input to a threshold. If the input is above the threshold, the output is high. If the input is below the threshold, the output is low. This sounds simple, but it hides a difficult question: what should the threshold be

2. Why a Fixed Threshold Fails

A fixed threshold works only when the signal amplitude is predictable. In a laser scanner, it is not. Consider a scanner at a retail checkout counter. The cashier passes a cereal box across the window. The label is a few centimeters away, brightly lit, and printed in high-contrast black on white. The filter output might swing a full volt peak to peak. A fixed threshold set at the midpoint works perfectly.

Now consider the same scanner reading a label on a dark plastic bag of coffee beans. The label is matte black with a gold logo. The reflected light is weak. The filter output might swing only twenty millivolts. A threshold set at half a volt will never be crossed. The comparator output stays flat, and the scanner never sees a barcode.

The reverse case is just as bad. A glossy label on a shrink-wrapped package can reflect a specular highlight straight back into the detector. The signal can saturate the amplifier, clip, and produce false transitions. A fixed threshold in the middle of a clipped waveform produces a burst of spurious edges that the decoder cannot interpret.

3. The Comparator and Its Threshold

The comparator is a one-bit analog-to-digital converter. It answers a single question at every instant: is the input above or below the thresholdIn a laser scanner, the answer becomes the digital edge stream that the decoder uses to measure bar and space widths.

Because the answer is binary, the threshold decision is critical. If the threshold is too high, narrow bars in a weak signal disappear. If the threshold is too low, noise triggers false edges in the quiet spaces between bars. If the threshold is not centered on the waveform, the duty cycle of the digitized signal is distorted, and the decoder misreads the widths.

The threshold must therefore track the signal. It must sit near the middle of the waveform's swing, whatever that swing happens to be at that moment. And because the swing changes from label to label and even within a single scan line, the threshold must adapt continuously.

4. The AGC Loop: Sensing Amplitude

The automatic gain control loop solves the amplitude problem. It senses the peak-to-peak amplitude of the signal and adjusts the gain of the variable gain amplifier so that the comparator input stays within a usable range.

The loop works like a slow feedback system. A peak detector, or an envelope detector, watches the signal after the filter. It captures the maximum and minimum excursions over a short window. The difference between them is the peak-to-peak amplitude. A control circuit compares this amplitude to a target and adjusts the VGA gain up or down.

If the label is far away and the signal is weak, the loop increases the gain. The weak waveform is amplified until it fills the comparator's usable input range. If the label is close and the signal is strong, the loop decreases the gain. The strong waveform is attenuated so that it does not clip.

The result is a signal at the comparator input that has a roughly constant amplitude, regardless of how much light actually reached the detector. The comparator threshold can then be set to a stable, predictable value, because the amplitude it sees is no longer a moving target.

5. Why the Loop Must Be Slow

The AGC loop must react quickly enough to handle changes between labels, but slowly enough not to distort the barcode itself. A barcode is a sequence of bars and spaces of varying widths. If the gain changed rapidly within a single scan line, the amplitude of the signal would vary from bar to bar, and the comparator would produce distorted widths.

The loop is therefore designed with a time constant that is long compared to the duration of a single scan line but short compared to the time between labels. In a typical handheld scanner, a scan line crosses the label in a few milliseconds, while the operator takes hundreds of milliseconds to move from one item to the next. The loop settles during the gap between items and holds steady during the scan.

This is a classic tradeoff in control loop design. Too fast, and the loop chases the signal and distorts it. Too slow, and the loop cannot recover from a sudden change in brightness, such as moving from a white label to a black one.

6. The Interaction Between AGC and Threshold

The AGC loop and the comparator threshold are partners. The AGC loop normalizes the amplitude. The threshold decision then becomes reliable because the signal swing is known.

In many designs, the threshold is derived from the signal itself. A common approach is to use a peak-and-valley detector to estimate the midpoint of the waveform and set the threshold there. Another approach is to use a fixed threshold after the AGC has normalized the amplitude. Both approaches rely on the AGC loop to keep the signal in range.

The two loops must be designed together. If the AGC loop is too aggressive, it can interact with the threshold tracking and produce oscillation. If the threshold tracking is too aggressive, it can fight the AGC loop and produce hunting. Careful design keeps the loops stable and complementary.

7. Real-World Example: Retail Checkout

In a supermarket checkout, the scanner must read labels on products of every color and finish. A white paper label on a cereal box is easy. A black label on a dark bottle is hard. A shiny label on a shrink-wrapped package is hardest of all, because the specular reflection can saturate the detector.

The AGC loop handles this diversity. When the cashier scans a dark bottle, the loop increases gain to pull the weak signal up. When the cashier scans a glossy package, the loop decreases gain to prevent clipping. The comparator threshold stays centered, and the decoder sees clean edges.

The practical benefit is speed. A cashier can scan item after item without adjusting anything. The scanner adapts to each label automatically. This is why modern checkout scanners can read dozens of items per minute with high first-pass read rates.

8. Real-World Example: Warehouse and Logistics

In a distribution center, workers scan labels on cardboard boxes at a distance. The label may be a meter away, and the lighting may be dim. The reflected signal is weak, and the label may be wrinkled or partially obscured.

The AGC loop is essential here. It amplifies the weak signal so that the comparator can digitize it. Without AGC, the scanner would have a short working range and would fail on distant labels. With AGC, the scanner can read labels across a wide range of distances and lighting conditions.

Logistics also demands ruggedness. Labels may be dirty, smudged, or printed on low-contrast thermal paper. The AGC loop keeps the signal in range, and the threshold tracking keeps the edges clean, so the decoder can still recover the data even when the print quality is poor.

9. Real-World Example: Manufacturing and Production Lines

On a production line, scanners read labels on parts moving at high speed. The label may be small, and the scanner may be mounted at a fixed distance. The lighting may be controlled, but the parts themselves may vary in color and finish.

The AGC loop handles the variation. When a dark part passes, the loop increases gain. When a shiny part passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Manufacturing also demands repeatability. The AGC loop must settle quickly and predictably so that every part is read the same way. This requires careful design of the loop time constant and the peak detector.

10. Real-World Example: Healthcare and Pharmaceuticals

In a hospital or pharmacy, scanners read labels on medication vials, test tubes, and patient wristbands. These labels are often small and printed in low contrast. The scanner may be a handheld unit used at close range.

The AGC loop helps here because the signal is often weak. A small label on a curved vial reflects little light back to the detector. The loop amplifies the weak signal so that the comparator can digitize it. The threshold tracking keeps the edges clean, so the decoder can read the small symbols.

Healthcare also demands accuracy. A misread label can have serious consequences. The AGC loop and threshold tracking must be reliable, and the scanner must be designed to reject false reads. This requires careful attention to noise and signal integrity.

11. Real-World Example: Banking and Document Processing

In banking, scanners read barcodes on checks, forms, and documents. These labels are often printed on paper with varying reflectance. The scanner may be part of a high-speed document sorter.

The AGC loop handles the variation in paper reflectance. When a dark form passes, the loop increases gain. When a light form passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the barcode reliably.

Banking also demands speed. A document sorter may process hundreds of documents per minute. The AGC loop must settle quickly so that each document is read correctly. This requires a fast peak detector and a well-designed control loop.

12. Real-World Example: Access Control and Ticketing

In access control, scanners read badges and tickets. These labels may be printed on plastic cards, paper tickets, or mobile phone screens. The scanner may be mounted at a fixed distance, and the lighting may vary.

The AGC loop handles the variation in label type and lighting. When a dark badge passes, the loop increases gain. When a bright phone screen passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the barcode reliably.

Access control also demands convenience. The user expects the scanner to work the first time, every time. The AGC loop and threshold tracking must be robust enough to handle real-world conditions, including dirty lenses and varying ambient light.

13. Real-World Example: Automotive and Parts Tracking

In automotive manufacturing, scanners read labels on parts and assemblies. These labels may be printed on metal, plastic, or painted surfaces. The scanner may be mounted on a robot arm or a fixed station.

The AGC loop handles the variation in surface reflectance. When a dark painted part passes, the loop increases gain. When a shiny metal part passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Automotive also demands durability. The scanner must work in a factory environment with dust, vibration, and temperature variation. The AGC loop and threshold tracking must be designed to withstand these conditions.

14. Real-World Example: Agriculture and Food Processing

In agriculture and food processing, scanners read labels on produce, packaging, and shipping containers. These labels may be printed on cardboard, plastic, or paper. The scanner may be exposed to moisture, dust, and varying temperatures.

The AGC loop handles the variation in label type and environment. When a wet label passes, the loop adjusts gain to compensate for the change in reflectance. When a dry label passes, the loop adjusts again. The comparator threshold stays stable, and the decoder reads the label reliably.

Agriculture also demands robustness. The scanner must work in harsh conditions, including rain, dust, and extreme temperatures. The AGC loop and threshold tracking must be designed to withstand these conditions.

15. Real-World Example: Postal and Parcel Sorting

In postal and parcel sorting, scanners read labels on envelopes and packages moving at high speed. These labels may be printed on paper, plastic, or cardboard. The scanner may be mounted above a conveyor belt.

The AGC loop handles the variation in label type and distance. When a small envelope passes, the loop increases gain. When a large package passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Postal sorting also demands speed. A sorting machine may process thousands of items per hour. The AGC loop must settle quickly so that each item is read correctly. This requires a fast peak detector and a well-designed control loop.

16. Real-World Example: Library and Archival Systems

In libraries and archives, scanners read barcodes on books and documents. These labels may be printed on paper, plastic, or cloth. The scanner may be a handheld unit used at close range.

The AGC loop handles the variation in label type and condition. When a worn label passes, the loop increases gain to compensate for the reduced contrast. When a new label passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Library systems also demand accuracy. A misread label can cause a book to be misfiled. The AGC loop and threshold tracking must be reliable, and the scanner must be designed to reject false reads.

17. Real-World Example: Event Ticketing and Venue Access

In event ticketing, scanners read barcodes on tickets and wristbands. These labels may be printed on paper, plastic, or fabric. The scanner may be a handheld unit used at a gate.

The AGC loop handles the variation in label type and lighting. When a dark ticket passes, the loop increases gain. When a bright ticket passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Event ticketing also demands speed. A venue may need to process thousands of attendees in a short time. The AGC loop must settle quickly so that each ticket is read correctly. This requires a fast peak detector and a well-designed control loop.

18. Real-World Example: Mobile Scanning and Consumer Apps

In mobile scanning, the scanner is a smartphone camera, and the barcode is read from a screen or a printed label. The lighting may vary widely, and the label may be at an angle.

The AGC loop in the camera's image sensor pipeline handles the variation in brightness. When the scene is dark, the loop increases gain. When the scene is bright, the loop decreases gain. The comparator threshold, implemented in software, stays stable, and the decoder reads the barcode reliably.

Mobile scanning also demands convenience. The user expects the app to work the first time, every time. The AGC loop and threshold tracking must be robust enough to handle real-world conditions, including shaky hands and poor lighting.

19. Real-World Example: Industrial Automation and Robotics

In industrial automation, scanners are mounted on robots and conveyor belts. The scanner may read labels on parts moving at high speed, or it may read labels on stationary parts from a distance.

The AGC loop handles the variation in distance and reflectance. When a distant part is scanned, the loop increases gain. When a close part is scanned, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Industrial automation also demands reliability. A misread label can cause a production line to stop. The AGC loop and threshold tracking must be designed to withstand harsh conditions, including dust, vibration, and temperature variation.

20. Real-World Example: Cold Chain and Refrigerated Storage

In cold chain logistics, scanners read labels on products stored in refrigerators and freezers. These labels may be printed on paper or plastic, and they may be covered in frost or condensation.

The AGC loop handles the variation in label condition. When a frosted label passes, the loop increases gain to compensate for the reduced contrast. When a clear label passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Cold chain also demands robustness. The scanner must work in low temperatures and high humidity. The AGC loop and threshold tracking must be designed to withstand these conditions.

21. Real-World Example: Outdoor and Field Service

In outdoor and field service, scanners read labels on equipment, vehicles, and infrastructure. These labels may be exposed to sunlight, rain, and dirt.

The AGC loop handles the variation in lighting and label condition. When a label is in bright sunlight, the loop decreases gain to prevent saturation. When a label is in shadow, the loop increases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Outdoor scanning also demands durability. The scanner must work in harsh conditions, including extreme temperatures and weather. The AGC loop and threshold tracking must be designed to withstand these conditions.

22. Real-World Example: Entertainment and Media

In entertainment and media, scanners read barcodes on tickets, merchandise, and promotional materials. These labels may be printed on paper, plastic, or fabric. The scanner may be a handheld unit used at a venue.

The AGC loop handles the variation in label type and lighting. When a dark ticket passes, the loop increases gain. When a bright ticket passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Entertainment also demands speed. A venue may need to process thousands of attendees in a short time. The AGC loop must settle quickly so that each ticket is read correctly. This requires a fast peak detector and a well-designed control loop.

23. Real-World Example: Government and Identification

In government and identification, scanners read barcodes on ID cards, passports, and licenses. These labels may be printed on plastic or paper, and they may be covered in protective coatings.

The AGC loop handles the variation in label type and condition. When a worn ID passes, the loop increases gain to compensate for the reduced contrast. When a new ID passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Government ID also demands security. A misread ID can have serious consequences. The AGC loop and threshold tracking must be reliable, and the scanner must be designed to reject false reads.

24. Real-World Example: Hospitality and Tourism

In hospitality and tourism, scanners read barcodes on room keys, event tickets, and boarding passes. These labels may be printed on plastic or paper, and they may be used in a variety of lighting conditions.

The AGC loop handles the variation in label type and lighting. When a dark key card passes, the loop increases gain. When a bright boarding pass passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Hospitality also demands convenience. The guest expects the scanner to work the first time, every time. The AGC loop and threshold tracking must be robust enough to handle real-world conditions, including dirty scanners and varying ambient light.

25. Real-World Example: Transportation and Tolling

In transportation and tolling, scanners read barcodes on vehicles and toll tags. These labels may be printed on stickers or mounted on windshields, and they may be read at highway speeds.

The AGC loop handles the variation in distance and reflectance. When a distant vehicle approaches, the loop increases gain. When a close vehicle passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Tolling also demands speed and reliability. A misread tag can cause a billing error or a traffic delay. The AGC loop and threshold tracking must be designed to withstand harsh conditions, including weather and vibration.

26. Real-World Example: Sports and Fitness

In sports and fitness, scanners read barcodes on race bibs, gym equipment, and membership cards. These labels may be printed on paper, plastic, or fabric, and they may be used in a variety of lighting conditions.

The AGC loop handles the variation in label type and lighting. When a dark bib passes, the loop increases gain. When a bright card passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Sports also demands speed. A race may need to process thousands of participants in a short time. The AGC loop must settle quickly so that each bib is read correctly. This requires a fast peak detector and a well-designed control loop.

27. Real-World Example: Utilities and Meter Reading

In utilities and meter reading, scanners read barcodes on meters and equipment. These labels may be printed on metal or plastic, and they may be exposed to weather and dirt.

The AGC loop handles the variation in label condition. When a dirty label passes, the loop increases gain to compensate for the reduced contrast. When a clean label passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Meter reading also demands durability. The scanner must work in harsh conditions, including outdoor weather and extreme temperatures. The AGC loop and threshold tracking must be designed to withstand these conditions.

28. Real-World Example: Textiles and Apparel

In textiles and apparel, scanners read barcodes on garments and tags. These labels may be printed on fabric, paper, or plastic, and they may be used in a variety of lighting conditions.

The AGC loop handles the variation in label type and lighting. When a dark garment passes, the loop increases gain. When a light garment passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Apparel also demands speed. A retail store may need to process hundreds of items during inventory. The AGC loop must settle quickly so that each item is read correctly. This requires a fast peak detector and a well-designed control loop.

29. Real-World Example: Electronics and Component Tracking

In electronics manufacturing, scanners read barcodes on components and circuit boards. These labels may be printed on plastic, metal, or ceramic, and they may be very small.

The AGC loop handles the variation in label size and reflectance. When a small label passes, the loop increases gain. When a reflective label passes, the loop decreases gain. The comparator threshold stays stable, and the decoder reads the label reliably.

Electronics also demands precision. A misread label can cause a component to be misplaced. The AGC loop and threshold tracking must be reliable, and the scanner must be designed to reject false reads.

30. Detailed Summary

The comparator at the end of the analog chain in a laser barcode scanner cannot use a fixed threshold. The signal amplitude varies with distance, label color, surface finish, and lighting. A fixed threshold works only when the signal is predictable, which it never is in real deployments.

The AGC loop solves this problem by sensing the peak-to-peak amplitude and adjusting the VGA gain to keep the comparator input within a usable range. The loop is designed to be slow enough to avoid distorting the barcode, but fast enough to adapt between labels. The comparator threshold is then derived from the normalized signal, either by tracking the midpoint or by using a fixed threshold after AGC.

This principle appears across many industries. In retail checkout, AGC handles the diversity of product labels. In warehouse logistics, it extends the working range. In manufacturing, it handles variation in part color and finish. In healthcare, it enables reading of small, low-contrast labels. In banking, it handles variation in paper reflectance. In access control, it handles variation in badge type and lighting. In automotive, it handles variation in surface reflectance. In agriculture, it handles harsh environmental conditions. In postal sorting, it enables high-speed reading. In libraries, it handles worn labels. In event ticketing, it enables fast processing. In mobile scanning, it handles variation in lighting and angle. In industrial automation, it ensures reliable reading. In cold chain, it handles frost and condensation. In outdoor service, it handles sunlight and weather. In entertainment, it enables fast processing. In government ID, it ensures security. In hospitality, it ensures convenience. In transportation, it ensures speed and reliability. In sports, it enables fast processing. In utilities, it ensures durability. In textiles, it enables fast inventory. In electronics, it ensures precision.

The AGC loop and the comparator threshold are partners. Together, they make it possible for a laser scanner to read labels reliably across the wide range of conditions found in the real world. This is the design reality behind the flying spot: the signal will not sit still, and the scanner must adapt to it.

 

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:

Other Barcode Label Format Settings

Barcode types supported by this program

Barcode Label Font Settings

Configuring the Barcode Print Rotation

Text Alignment for Barcode Labels

Automatically Adjusting Barcode Width

Text Beneath the Barcode

Configuring Barcode Size

Auto Calculate the Barcode Size

Export Barcode images

Export Barcode Image Format

File Names for Exported Barcode

Resolution of Exported Barcode Images

Fixed Folder for Exporting Barcode

Default Barcode Image Export Format

Print bulk barcodes quickly

Print barcodes to Avery 5160 label

How to bulk Barcode Printing

Sample - Avery 5162 (2x7) Label Sheet

Example: Print barcodes to 5*3cm roll

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

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