The Brain Arrives: How the Microcontroller Takes Command of the Barcode Scanner |
Subtitle: A Deep Dive into the Embedded Processor, Its Peripherals, and Its Role in Orchestrating the Decoding Process - with Real-World Designs from Symbol, Zebra, Honeywell, Datalogic, Microchip, NXP, and STMicroelectronics |

|
Opening Summary |
Up to this point, we have followed the barcode signal through a chain of analogue and digital circuits: the photodetector, the transimpedance amplifier, the AC coupling, the gain stage, the comparator, and the edge counter. These circuits have done their work, converting a faint reflection of light into a clean sequence of pulse widths. But this sequence is still just raw data - a list of numbers. The next stage is where the real intelligence comes in: the microcontroller. |
The microcontroller is the brain of the barcode scanner. It orchestrates the entire decoding process. It controls the illumination, the timing, the edge capture, and the communication with the host. It runs the decoder algorithm, which interprets the pulse widths and turns them into meaningful data. The microcontroller is the heart of the scanner's firmware, and its choice defines the scanner's capabilities, its power consumption, and its cost. |
This article is dedicated to the microcontroller - the brain that arrives to make sense of the analogue world. We will explore the different types of microcontrollers used in barcode scanners, from the humble 8-bit devices in low-cost scanners to the powerful 32-bit ARM processors in high-end industrial readers. We will examine the key peripherals: the timer/capture modules, the analog-to-digital converters, the communication interfaces, and the direct memory access (DMA) engines. We will look at how major companies have chosen and implemented microcontrollers in their products. We will see how Symbol (now Zebra) used a Motorola HC08 in the classic LS2208. We will explore Honeywell's use of an ARM Cortex-M4 in their high-performance imagers. We will examine Datalogic's use of a custom ASIC with an embedded processor core. We will also look at reference designs from Microchip, NXP, and STMicroelectronics, which showcase the latest microcontroller technologies. |
By the end of this journey, you will understand that the microcontroller is not just a processor but a system-on-a-chip that integrates all the necessary peripherals for barcode decoding. You will see how the choice of the microcontroller affects the scanner's performance, its power consumption, and its cost. |

|
Full Article |
Section 1: The Microcontroller - The System-On-a-Chip |
The microcontroller (MCU) is a complete computer system on a single chip. It contains a processor core, memory (both program memory and data memory), and a variety of peripherals. The peripherals include timers, capture modules, analog-to-digital converters (ADCs), communication interfaces (UART, SPI, I2C, USB), and general-purpose input/output (GPIO) pins. |
The MCU is the brain of the barcode scanner. It executes the firmware that controls the scanner's operation. The firmware includes the decoder algorithm, the communication protocol, the user interface, and the power management. |
Section 2: The Processor Core - The Engine |
The processor core is the engine of the MCU. It fetches instructions from the program memory, decodes them, and executes them. The processor core's architecture determines the MCU's performance, its power consumption, and its cost. |
There are several types of processor cores used in barcode scanners. The most common are: |
8-bit cores: These are the simplest and cheapest cores. They are used in low-cost scanners. Examples include the Microchip PIC16, the Atmel AVR, and the Motorola HC08. |
16-bit cores: These are more powerful than 8-bit cores. They are used in some mid-range scanners. An example is the Microchip PIC24. |
32-bit cores: These are the most powerful cores. They are used in high-performance scanners. The most common 32-bit core is the ARM Cortex-M series. Examples include the Cortex-M0, Cortex-M3, Cortex-M4, and Cortex-M7. |

|
Section 3: Symbol's LS2208 - The Motorola HC08 |
Symbol's LS2208 uses a Motorola HC08 microcontroller. The HC08 is an 8-bit core with a maximum clock speed of 8 MHz. It has 32 kilobytes of program memory and 512 bytes of data memory. The HC08 is a simple, low-cost microcontroller that is adequate for the LS2208's requirements. |
The HC08's peripherals include a timer/capture module, a UART, and GPIO pins. The timer/capture module is used to capture the edge timings. The UART is used to communicate with the host. The GPIO pins are used to control the laser, the motor, and the beeper. |
The LS2208's firmware is written in C and assembly language. The firmware is optimized for the HC08's limited resources. |
Section 4: Honeywell's 1900 Imager - The ARM Cortex-M4 |
Honeywell's 1900 imager uses an ARM Cortex-M4 microcontroller. The Cortex-M4 is a 32-bit core with a maximum clock speed of up to 200 MHz. It has a floating-point unit (FPU) for fast mathematical calculations. The Cortex-M4 is a high-performance microcontroller that is ideal for the 1900's demanding image processing requirements. |
The Cortex-M4's peripherals include a DMA engine, multiple timer/capture modules, an ADC, and a USB interface. The DMA engine is used to offload the edge capture from the CPU. The ADC is used to digitize the image from the CMOS sensor. The USB interface is used to communicate with the host. |
The 1900's firmware is written in C and is optimized for the Cortex-M4's performance. The firmware includes a sophisticated image processing algorithm. |

|
Section 5: Datalogic's PowerScan - The Custom ASIC |
Datalogic's PowerScan series uses a custom application-specific integrated circuit (ASIC). The ASIC integrates the analogue front-end, the digital signal processing, and a processor core on a single chip. The processor core is typically an ARM Cortex-M3 or a custom RISC core. |
The custom ASIC provides the highest level of integration and performance. It also provides the lowest power consumption. The ASIC is designed specifically for barcode scanning, so it includes all the necessary peripherals. |
The custom ASIC is more expensive to develop than a standard MCU, but it provides a competitive advantage in terms of performance and power consumption. |
Section 6: The Timer/Capture Module - The Edge Counter |
The timer/capture module is the most important peripheral for barcode decoding. It is used to capture the edge timings of the digitised waveform. The timer/capture module is typically a 16-bit or 32-bit timer with a capture register. |
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. |

|
Section 7: The DMA Engine - The Data Mover |
The DMA engine is a peripheral that can transfer data between memory and peripherals without CPU intervention. The DMA engine is used to offload the data transfer from the CPU. The DMA engine can transfer the captured values from the timer/capture module to a buffer in memory. |
The DMA engine reduces the CPU load. The CPU is free to perform other tasks, such as decoding and communication. |
Section 8: The Analog-to-Digital Converter (ADC) - The Digitizer |
The ADC is a peripheral that converts an analog voltage to a digital value. The ADC is used in imaging scanners to digitize the image from the CMOS sensor. The ADC is also used in some laser scanners to measure the signal amplitude. |
The ADC has a resolution of 10-12 bits. The resolution determines the ADC's accuracy. |

|
Section 9: The Communication Interfaces - The Data Link |
The communication interfaces are used to connect the scanner to the host system. The most common interfaces are: |
UART (Universal Asynchronous Receiver/Transmitter): This is a simple serial interface. It is used in older scanners. |
USB (Universal Serial Bus): This is the most common interface for modern scanners. It provides high-speed data transfer and power. |
Bluetooth: This is a wireless interface. It is used in cordless scanners. |
Wi-Fi: This is a wireless networking interface. It is used in scanners that connect to a network. |
Section 10: The General-Purpose Input/Output (GPIO) Pins - The Control Lines |
The GPIO pins are used to control the scanner's hardware. The GPIO pins control the illumination (LED or laser), the motor, the beeper, and the trigger. The GPIO pins also read the state of the trigger and other sensors. |
The GPIO pins are configured as inputs or outputs by the firmware. |

|
Section 11: The Program Memory - The Firmware Storage |
The program memory is the non-volatile memory that stores the firmware. The program memory is typically flash memory. The firmware is stored in the flash memory and is executed by the processor core. |
The program memory's size is typically 32-256 kilobytes. The size depends on the complexity of the firmware. |
Section 12: The Data Memory - The Working Storage |
The data memory is the volatile memory that stores the working data. The data memory is typically static RAM (SRAM). The data memory is used to store the pulse width buffer, the decoded data, and the variables. |
The data memory's size is typically 4-64 kilobytes. The size depends on the complexity of the firmware. |

|
Section 13: The Clock Source - The Heartbeat |
The clock source provides the timing for the microcontroller. The clock source is typically a crystal oscillator or an internal RC oscillator. The crystal oscillator provides a more accurate clock. The internal RC oscillator is cheaper and consumes less power. |
The clock frequency determines the microcontroller's speed. A higher clock frequency gives faster performance but consumes more power. |
Section 14: The Power Management - The Energy Saver |
The power management is a critical feature for battery-powered scanners. The microcontroller can enter a low-power sleep mode when it is not in use. The sleep mode reduces the power consumption to a few microamperes. |
The microcontroller wakes up from the sleep mode when an interrupt occurs (e.g., the trigger is pressed). The wake-up time is typically a few microseconds. |

|
Section 15: The Interrupt Controller - The Event Manager |
The interrupt controller is a peripheral that manages the interrupts. The interrupts are signals from the peripherals that require the CPU's attention. The interrupt controller prioritizes the interrupts and sends them to the CPU. |
The interrupt controller is essential for real-time performance. The edge capture interrupts have the highest priority. |
Section 16: The Watchdog Timer - The Safety Monitor |
The watchdog timer is a timer that resets the microcontroller if the firmware does not clear it periodically. The watchdog timer is a safety feature that prevents the firmware from getting stuck in an infinite loop. |
The watchdog timer is used in industrial scanners to ensure reliability. |

|
Section 17: The Bootloader - The Firmware Updater |
The bootloader is a small program that is stored in a protected area of the flash memory. The bootloader is used to update the firmware. The bootloader receives the new firmware through a communication interface and writes it to the flash memory. |
The bootloader allows the scanner to be updated in the field. |
Section 18: The Firmware - The Decoding Algorithm |
The firmware is the software that runs on the microcontroller. The firmware includes the decoder algorithm, the communication protocol, the user interface, and the power management. |
The decoder algorithm is the most important part of the firmware. The decoder algorithm interprets the pulse widths and turns them into meaningful data. |
Section 19: The Decoder Algorithm - The Pattern Matcher |
The decoder algorithm is a pattern matcher. It compares the measured pattern of pulse widths to the patterns in a lookup table. The lookup table is specific to the barcode symbology. |
The decoder algorithm is implemented in C or assembly language. |

|
Section 20: The Communication Protocol - The Data Transmitter |
The communication protocol is the format of the data that is sent to the host. The most common protocol is the USB HID (Human Interface Device) protocol. The USB HID protocol emulates a keyboard. The scanner sends the decoded data as keystrokes. |
The communication protocol is implemented in the firmware. |
Section 21: The User Interface - The Human Interaction |
The user interface includes the beeper, the LED indicator, and the trigger. The beeper provides audible feedback. The LED indicator provides visual feedback. The trigger starts the scan. |
The user interface is controlled by the firmware. |
Section 22: The Power Management - The Energy Efficiency |
The power management is a critical feature for battery-powered scanners. The firmware controls the power consumption by turning off the illumination and the motor when they are not in use. |
The power management is implemented in the firmware. |

|
Section 23: The Edge Capture Interrupt - The Highest Priority |
The edge capture interrupt has the highest priority in the microcontroller. The edge capture interrupt is triggered on every edge of the digitised waveform. The interrupt service routine (ISR) reads the capture value and stores it in the buffer. |
The edge capture ISR must be fast and efficient. It is typically written in assembly language. |
Section 24: The DMA Transfer - The Data Offload |
The DMA transfer is used to offload the edge capture from the CPU. The DMA controller transfers the captured values from the timer/capture module to the buffer. The CPU is not involved in the transfer. |
The DMA transfer is configured by the firmware. The DMA controller is triggered on every edge. |
Section 25: The ADC Sampling - The Image Capture |
The ADC sampling is used in imaging scanners to capture the image. The ADC converts the analog signal from the CMOS sensor to a digital value. The ADC is triggered by the firmware. |
The ADC sampling is a critical part of the image capture process. |

|
Section 26: The USB Communication - The Data Transfer |
The USB communication is used to transfer the decoded data to the host. The USB interface is a high-speed serial interface. The USB interface is controlled by the firmware. |
The USB communication is a critical part of the scanner's operation. |
Section 27: The Bluetooth Communication - The Wireless Link |
The Bluetooth communication is used in cordless scanners. The Bluetooth interface is a wireless serial interface. The Bluetooth interface is controlled by the firmware. |
The Bluetooth communication is a critical part of the cordless scanner's operation. |
Section 28: The Wi-Fi Communication - The Network Connection |
The Wi-Fi communication is used in scanners that connect to a network. The Wi-Fi interface is a wireless networking interface. The Wi-Fi interface is controlled by the firmware. |
The Wi-Fi communication is a critical part of the network scanner's operation. |

|
Section 29: The Firmware Development - The Software Engineering |
The firmware development is a software engineering process. The firmware is written in C and assembly language. The firmware is developed using an integrated development environment (IDE). The IDE includes a compiler, a debugger, and a programmer. |
The firmware development is a critical part of the scanner's design. |
Section 30: The Firmware Testing - The Quality Assurance |
The firmware testing is a quality assurance process. The firmware is tested with a variety of barcodes, under a variety of conditions. The testing includes unit testing, integration testing, and system testing. |
The firmware testing is a critical part of the scanner's development. |
Section 31: The Firmware Update - The Field Upgrade |
The firmware update is a process that allows the scanner's firmware to be updated in the field. The firmware update is done through the bootloader. The bootloader receives the new firmware through a communication interface and writes it to the flash memory. |
The firmware update is a critical feature for maintaining the scanner's performance. |

|
Section 32: Microchip's Reference Design - A PIC Example |
Microchip provides a reference design for a barcode scanner based on a PIC microcontroller. The reference design includes a complete code example for Code 39, UPC, and Code 128. The reference design is a useful starting point for engineers developing barcode scanners. |
Section 33: NXP's Reference Design - An LPC Example |
NXP provides a reference design for a barcode scanner based on an LPC microcontroller. The reference design uses a DMA engine to offload the edge capture. The reference design includes a complete code example for Code 39, UPC, and Code 128. |
Section 34: STMicroelectronics' Reference Design - An STM32 Example |
STMicroelectronics provides a reference design for a barcode scanner based on an STM32 microcontroller. The reference design uses an ARM Cortex-M4 core. The reference design includes a complete code example for Code 39, UPC, and Code 128. |

|
Section 35: The Microcontroller's Future - More Integration |
The trend in microcontrollers is towards more integration. More peripherals are being integrated into the microcontroller. The microcontroller is becoming a complete system-on-a-chip (SoC). The SoC includes the processor core, the memory, the peripherals, and the analogue front-end. |
The future of barcode scanners is a single chip solution. |
Section 36: The Microcontroller - A Summary of Best Practices |
Based on our exploration, let us summarize the best practices for choosing and using a microcontroller in a barcode scanner: |
1. Choose the Right Core: The processor core must be powerful enough for the application. For a simple scanner, an 8-bit core may be sufficient. For a complex scanner, a 32-bit core is needed. |
2. Choose the Right Peripherals: The microcontroller must have the necessary peripherals: a timer/capture module, a DMA engine (for high-performance applications), an ADC (for imaging scanners), and communication interfaces. |
3. Choose the Right Memory: The program memory must be large enough for the firmware. The data memory must be large enough for the buffers and the variables. |
4. Consider the Power Consumption: For battery-powered scanners, the microcontroller must have a low-power sleep mode. |
5. Consider the Development Tools: The microcontroller must have a good development environment with a compiler, a debugger, and a programmer. |
6. Consider the Cost: The microcontroller's cost must be within the scanner's budget. |

|
Final Summary |
The microcontroller is the brain of the barcode scanner. It orchestrates the entire decoding process. It controls the illumination, the timing, the edge capture, and the communication with the host. It runs the decoder algorithm, which interprets the pulse widths and turns them into meaningful data. |
We have seen how major companies have chosen and implemented microcontrollers in their products. Symbol's LS2208 uses a Motorola HC08 8-bit microcontroller. Honeywell's 1900 imager uses an ARM Cortex-M4 32-bit microcontroller. Datalogic's PowerScan series uses a custom ASIC with an embedded processor core. Microchip, NXP, and STMicroelectronics provide reference designs that showcase the latest microcontroller technologies. |
The microcontroller is the heart of the scanner's firmware. The choice of the microcontroller defines the scanner's capabilities, its power consumption, and its cost. The microcontroller is the brain that makes sense of the analogue world. |