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

The Hidden Eye: How Barcode Recognition Circuits Work (P15)

The Edge Counter - Counting Transitions: How the Decoder Measures the Space Between Edges

Subtitle: A Deep Dive into Timer Capture, Edge Detection, and the Art of Measuring Pulse Widths - with Real-World Designs from Symbol, Zebra, Honeywell, Datalogic, Microchip, and NXP

Opening Summary

The digitised waveform from the comparator is a sequence of high and low pulses. The decoder's first task is to measure the duration of each of these pulses. This is the job of the edge counter - a hardware timer or a software routine that counts the time between successive edges of the waveform. The edge counter is the decoder's measuring tool. It converts the waveform's transitions into a series of numbers - the pulse widths - that can be processed further.

This article is dedicated to the edge counter - the mechanism that captures the edge timings. We will explore the different ways to implement an edge counter, from a simple polling loop to a sophisticated timer/capture module with direct memory access. We will examine the key parameters: the timer resolution, the counter size, and the interrupt latency. We will look at how major companies have implemented edge counting in their products. We will see how Symbol (now Zebra) used a timer/capture module in the LS2208, and how they optimized the interrupt service routine for speed. We will explore Honeywell's use of a DMA engine to offload the edge counting from the CPU. We will examine Datalogic's use of a high-speed counter for precision. We will also look at Microchip's and NXP's reference designs, which include detailed examples of edge counting.

By the end of this journey, you will understand that the edge counter is not just a simple timer but a carefully engineered component that must balance speed, accuracy, and efficiency. You will see how the choice of the timer, the handling of interrupts, and the management of the data buffer all contribute to the scanner's ability to capture the barcode's timing accurately.

Full Article

Section 1: The Edge Counter's Mission - To Measure Time

The edge counter is a hardware or software mechanism that measures the time between successive edges of the digitised waveform. The edges are the transitions from low to high (rising edge) and from high to low (falling edge). The time between a rising edge and the next falling edge is the duration of a high pulse (a white space). The time between a falling edge and the next rising edge is the duration of a low pulse (a black bar).

The edge counter's output is a sequence of numbers - the pulse widths. These pulse widths are the raw data that the decoder will process. The edge counter must measure the pulse widths accurately and efficiently.

Section 2: The Timer/Capture Module - The Standard Solution

The standard solution for edge counting is a timer/capture module. This is a hardware block that is integrated into most microcontrollers. The timer is a free-running counter that increments at a fixed frequency. The capture module records the timer's value when an edge occurs on a dedicated input pin.

The timer/capture module operates autonomously. The CPU is not involved in the edge capture. The CPU only reads the captured values from the module's registers. This makes the timer/capture module very efficient.

The timer/capture module is the standard solution for edge counting in barcode scanners. It is used in Symbol's LS2208, Honeywell's imagers, and Datalogic's industrial scanners.

Section 3: The Timer Frequency - Setting the Resolution

The timer frequency determines the resolution of the edge counter. A higher timer frequency gives a higher resolution. A 1-MHz timer gives a resolution of 1 microsecond. A 10-MHz timer gives a resolution of 0.1 microsecond.

The timer frequency must be high enough to resolve the narrowest pulses. For a hand-scanning application, a 1-MHz timer is usually sufficient. For a high-speed conveyor-belt application, a 10-MHz timer or higher may be needed.

The timer frequency is a trade-off. A higher frequency gives better resolution but consumes more power. The timer frequency is chosen to balance the resolution and the power consumption.

Section 4: The Timer Size - Avoiding Overflow

The timer is a counter with a finite number of bits. A 16-bit timer can count from 0 to 65535. A 32-bit timer can count from 0 to 4,294,967,295. The timer will overflow (roll over to zero) when it reaches its maximum value.

The timer must be large enough to count the longest pulse width. For a hand-scanning application, a 16-bit timer is usually sufficient. The longest pulse width is typically less than 10 milliseconds. A 16-bit timer with a 1-MHz clock has a period of 65.5 milliseconds, which is long enough.

For a very slow scan, a 32-bit timer may be needed. The timer size is chosen to avoid overflow.

Section 5: The Capture Register - Storing the Timer Value

The capture register is a register that stores the timer's value when an edge occurs. The capture register is updated automatically by the hardware. The CPU reads the capture register to get the edge time.

The capture register is a 16-bit or 32-bit register, matching the timer size. The capture register is read by the CPU in the interrupt service routine.

Section 6: The Input Pin - Connecting the Comparator

The comparator's output is connected to a dedicated input pin of the microcontroller. The input pin is configured as a capture input. The pin's input voltage must match the comparator's output voltage.

The input pin typically has a Schmitt trigger input. The Schmitt trigger provides hysteresis, which helps to clean up the comparator's output.

Section 7: The Interrupt - Triggering the Capture

The capture module can generate an interrupt when an edge occurs. The interrupt is triggered on the rising edge, the falling edge, or both edges. The interrupt is used to wake the CPU and read the capture value.

The interrupt is the standard method for handling edge captures. The interrupt service routine (ISR) reads the capture value and stores it in a buffer.

Section 8: The Interrupt Service Routine - The Edge Handler

The interrupt service routine (ISR) is the firmware that handles the edge interrupts. The ISR reads the capture value, calculates the pulse width (by subtracting the previous capture value), and stores the pulse width in a buffer.

The ISR must be fast. It must execute quickly to avoid missing the next edge. The ISR is typically written in assembly language or in a highly optimized high-level language.

The ISR is the heart of the edge counter. It is the code that actually measures the pulse widths.

Section 9: The Buffer - Storing the Pulse Widths

The pulse widths are stored in a buffer. The buffer is a fixed-size array in memory. The ISR writes the pulse widths to the buffer. The decoder reads the pulse widths from the buffer.

The buffer is typically a circular buffer. The ISR writes to the buffer, and the decoder reads from the buffer. The circular buffer decouples the ISR from the decoder.

The buffer's size must be large enough to hold a complete barcode. A typical barcode has 30-50 elements. The buffer is sized to hold 100-200 pulse widths.

Section 10: Symbol's LS2208 - The Classic Edge Counter

Symbol's LS2208 uses a timer/capture module for edge counting. The timer is a 16-bit timer with a 1-MHz clock. The comparator's output is connected to a capture input pin. The capture module is configured to capture on both edges.

The ISR is triggered on every edge. The ISR reads the capture value, calculates the pulse width, and stores the pulse width in a circular buffer. The ISR is written in assembly language for speed.

The LS2208's edge counter is a classic, proven design. It is simple, robust, and efficient.

Section 11: The Edge Counter and the CPU Load

The edge counter can consume a significant amount of CPU time. The ISR is triggered on every edge. For a typical barcode, there are 50-100 edges. Each ISR takes a few microseconds to execute. The total CPU load is a few percent.

The CPU load is usually not a problem for a hand-held scanner. The CPU has plenty of spare time to perform other tasks, such as decoding and communication.

For a high-speed scanner, the CPU load can be higher. A DMA engine can be used to offload the edge counting from the CPU.

Section 12: Honeywell's DMA - Offloading the Edge Counter

Honeywell's imagers use a DMA (Direct Memory Access) engine to offload the edge counting from the CPU. The DMA engine is a hardware block that can transfer data from a peripheral (the capture module) to memory without CPU intervention.

The DMA engine is configured to read the capture values and write them to a buffer. The CPU is not involved in the edge capture. The CPU only reads the buffer when the entire barcode has been captured.

The DMA engine reduces the CPU load. The CPU is free to perform other tasks, such as decoding and communication.

Section 13: The DMA Controller - A Hardware Accelerator

The DMA controller is a hardware block that manages the data transfers. The DMA controller has a set of registers that configure the transfer. The configuration includes the source address (the capture register), the destination address (the buffer), and the number of transfers.

The DMA controller is programmed by the CPU. Once the DMA is configured, it operates autonomously. The DMA controller transfers the data without CPU intervention.

Section 14: The DMA Buffer - A Data Store

The DMA buffer is a memory area where the DMA controller writes the data. The buffer is typically a circular buffer. The DMA controller writes the data to the buffer, and the CPU reads the data from the buffer.

The DMA buffer's size must be large enough to hold a complete barcode. The buffer's size is typically the same as the circular buffer used in the ISR-based approach.

Section 15: The DMA Transfer Complete Interrupt

The DMA controller can generate an interrupt when the transfer is complete. The interrupt signals the CPU that the buffer is full and ready for processing.

The DMA transfer complete interrupt is used to trigger the decoder. The decoder reads the buffer and processes the pulse widths.

Section 16: Datalogic's High-Speed Counter

Datalogic's industrial scanners use a high-speed counter for edge counting. The high-speed counter is a dedicated hardware block that can count pulses at very high frequencies (e.g., up to 100 MHz). The counter provides a very high resolution for the pulse width measurement.

The high-speed counter is used in Datalogic's PowerScan series, which is designed for high-speed conveyor-belt applications. The counter's high resolution allows the scanner to accurately measure the very narrow bars of a fast-moving barcode.

Section 17: The High-Speed Counter - A Dedicated Hardware Block

The high-speed counter is a dedicated hardware block that is separate from the main CPU. The counter is driven by a high-frequency clock (e.g., 100 MHz). The counter's value is read by the CPU through a register.

The high-speed counter is simpler than a timer/capture module. It does not capture the timer value on an edge. It just counts the edges. The CPU must read the counter value at regular intervals to measure the pulse widths. This is a less efficient method, but it can be faster for very high-speed scanning.

Section 18: The Edge Counter and the Jitter

The edge counter is affected by jitter. Jitter is the uncertainty in the edge timing. The jitter is caused by noise on the comparator's input and by the timer's quantization. The jitter causes errors in the pulse width measurements.

The jitter can be reduced by using a high-frequency timer and by using hysteresis in the comparator.

Section 19: The Edge Counter and the Noise

The edge counter is affected by noise. Noise can cause false edges. A false edge is an edge that is not caused by a genuine barcode transition. The false edges cause errors in the pulse width measurements.

The noise can be reduced by using a comparator with hysteresis and by using an adaptive threshold.

Section 20: The Edge Counter and the Missed Edges

The edge counter can miss edges. An edge can be missed if the ISR is not fast enough to handle the interrupt. A missed edge causes a large error in the pulse width measurement.

To avoid missed edges, the ISR must be fast and the interrupt priority must be high. The ISR is typically given the highest interrupt priority.

Section 21: The Edge Counter and the Timer Overflow

The timer can overflow. The timer overflow occurs when the timer reaches its maximum value and rolls over to zero. The timer overflow causes an error in the pulse width measurement.

To avoid timer overflow, the timer's period must be longer than the longest pulse width. A 16-bit timer with a 1-MHz clock has a period of 65.5 milliseconds, which is usually sufficient.

Section 22: The Edge Counter and the Capture Overflow

The capture register can overflow. The capture overflow occurs when the capture register is overwritten before it is read. The capture overflow causes a loss of data.

To avoid capture overflow, the ISR must read the capture register before the next edge occurs. The ISR must be fast enough to read the capture register on every edge.

Section 23: The Edge Counter and the Buffer Overflow

The buffer can overflow. The buffer overflow occurs when the buffer is full and a new pulse width is written. The buffer overflow causes a loss of data.

To avoid buffer overflow, the buffer must be large enough to hold a complete barcode. The buffer is typically sized to hold 100-200 pulse widths.

Section 24: The Edge Counter and the Symbology

The edge counter is independent of the symbology. The edge counter measures the pulse widths, regardless of the symbology. The symbology determines how the pulse widths are interpreted.

Section 25: The Edge Counter and the Scanning Speed

The edge counter is affected by the scanning speed. A faster scanning speed produces narrower pulses. A slower scanning speed produces wider pulses. The edge counter must be able to measure both narrow and wide pulses.

The timer frequency and the timer size must be chosen to handle the expected range of scanning speeds.

Section 26: The Edge Counter and the Quiet Zone

The quiet zone is a white margin before and after the barcode. The quiet zone is not decoded. The edge counter may measure the quiet zone, but the decoder ignores it.

Section 27: The Edge Counter and the Start/Stop Characters

The start and stop characters are special patterns that mark the beginning and end of the barcode. The edge counter measures the pulse widths of the start and stop characters. The decoder uses the start and stop characters to identify the symbology.

Section 28: The Edge Counter and the Checksum

The checksum is not directly related to the edge counter. The edge counter measures the pulse widths. The checksum is calculated from the decoded data.

Section 29: The Edge Counter and the Decode Security

The 'Decode Security' setting in Honeywell's scanners is related to the decoder's tolerance for variations in the pulse widths. The edge counter is not affected by the Decode Security setting. The edge counter measures the pulse widths, regardless of the setting.

Section 30: The Edge Counter and the Minimum Contrast

The 'Minimum Contrast' setting in Datalogic's scanners is not related to the edge counter. The Minimum Contrast setting is related to the signal amplitude. The edge counter measures the pulse timing.

Section 31: The Edge Counter and the ROI Threshold

The 'ROI Threshold' in Datalogic's scanners is not related to the edge counter. The ROI Threshold is related to the image contrast. The edge counter measures the pulse timing.

Section 32: The Edge Counter and the Object Sense Mode

The 'Object Sense' mode in Datalogic's scanners is not related to the edge counter. The Object Sense mode is used to detect the presence of an object. The edge counter is used to decode the barcode.

Section 33: The Edge Counter in Texas Instruments' TIDA-00857

Texas Instruments' TIDA-00857 reference design uses a timer/capture module for edge counting. The design includes a code example that demonstrates the edge counting with an interrupt service routine.

The TIDA-00857's edge counter is a classic, proven design.

Section 34: The Edge Counter in Analog Devices' Reference Design

Analog Devices' reference design uses a timer/capture module with a DMA engine. The DMA engine offloads the edge counting from the CPU.

The DMA-based edge counter is more efficient than the interrupt-based approach.

Section 35: The Edge Counter in Microchip's Reference Design

Microchip's reference design uses a timer/capture module for edge counting. The design includes a complete code example for Code 39, UPC, and Code 128.

Section 36: The Edge Counter - A Summary of Best Practices

Based on our exploration, let us summarize the best practices for implementing the edge counter in a barcode scanner:

1. Use a Timer/Capture Module: The timer/capture module is the standard solution for edge counting. It is efficient and accurate.

2. Choose the Timer Frequency: The timer frequency must be high enough to resolve the narrowest pulses. A 1-MHz timer is sufficient for hand-scanning. A higher frequency may be needed for high-speed applications.

3. Choose the Timer Size: The timer must be large enough to avoid overflow. A 16-bit timer is usually sufficient. A 32-bit timer may be needed for very slow scans.

4. Use an Interrupt Service Routine: The ISR handles the edge interrupts. The ISR must be fast and efficient.

5. Use a Circular Buffer: The circular buffer decouples the ISR from the decoder. The buffer stores the pulse widths.

6. Consider a DMA Engine: For high-performance applications, use a DMA engine to offload the edge counting from the CPU.

7. Test the Edge Counter: The edge counter must be tested with a variety of barcodes, under a variety of conditions, to ensure it is working correctly.

Final Summary

The edge counter is the decoder's measuring tool. It captures the timing of the digitised waveform's edges and converts them into a sequence of pulse widths. The edge counter is implemented with a timer/capture module, an interrupt service routine, and a circular buffer.

We have seen how major companies have implemented the edge counter in their products. Symbol's LS2208 uses a timer/capture module with an ISR. Honeywell uses a DMA engine to offload the edge counting from the CPU. Datalogic uses a high-speed counter for precision. Microchip and NXP provide reference designs with detailed edge counting examples.

The edge counter is a critical component of the barcode scanner. Its accuracy and efficiency directly affect the decoder's performance. The edge counter must be carefully designed to handle the varying pulse widths and the high edge rates.

 

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:

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

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

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