The Gain Stage: How Programmable Gain Amplifiers Give Barcode Readers Adaptable Vision |
Executive Summary |
This article provides a comprehensive, accessible exploration of the gain stage in barcode reader signal chains, focusing on programmable gain amplifiers (PGAs). We examine how these versatile circuits allow a single reader to adapt to wildly different signal strengths, from a barcode pressed against the window to one held at arm's length in dim lighting. Rather than focusing on abstract theory, we ground every concept in concrete design examples and real products from industry leaders including Texas Instruments, Microchip Technology, and Analog Devices. We explore the fundamental need for adjustable gain, the different architectural approaches to programmability, the integration of PGAs with transimpedance amplifiers, and the practical implementation of automatic gain control. The article covers both discrete PGA solutions and highly integrated devices like the Texas Instruments OPA3S2859. The closing summary synthesizes the key lessons and offers practical guidance for anyone designing gain stages for barcode readers. |

|
Chapter 1: The Problem of the Moving Target |
Imagine trying to take a photograph of a moving object in the dark, while the object might suddenly move into bright sunlight. That is the challenge a barcode reader faces with every scan. The distance to the barcode changes as the user waves the reader. The angle changes. The ambient lighting changes. The quality of the barcode printing changes. And the reader must decode the barcode correctly every time. |
The photodetector at the heart of the reader produces a tiny current proportional to the amount of reflected light it receives. This current might be just a few nanoamps from a distant, low-contrast barcode, or it might be hundreds of microamps from a barcode pressed against the reader's window. That is a dynamic range of more than 100,000 to one. No single amplifier with a fixed gain can handle this range without saturating on strong signals or burying weak signals in noise. |
This is where the programmable gain amplifier (PGA) comes in. A PGA is an amplifier whose gain can be adjusted under the control of the microcontroller. By changing the gain, the reader can adapt to the specific conditions of each scan, ensuring that the signal is always at the optimal level for digitization and decoding. |
Chapter 2: The Concept of Programmable Gain |
A programmable gain amplifier is essentially an operational amplifier with a set of selectable feedback networks. The gain of an op-amp is determined by the ratio of feedback resistance to input resistance. By switching different resistors into the feedback path, the gain can be changed. |
The programmability can be achieved in several ways. Some PGAs use analog switches to select from a range of fixed resistors. Others use digital potentiometers. Still others use a multiplexer to route the signal through different amplifier stages. The choice of architecture affects the speed, accuracy, and cost of the PGA. |
The key benefit of programmability is adaptability. The microcontroller can measure the signal amplitude during a calibration phase and set the gain to maximize the dynamic range. This is the essence of automatic gain control (AGC), which is used in many barcode readers. |
Microchip Technology's Application Note AN865 describes how a PGA can be used with a photodiode: 'The voltage generated by the photo sensor is gained by the PGA. Consequently, in this configuration, the PGA would be programmed to higher gains and the value of the resistor R1 should be selected as low as possible' . |

|
Chapter 3: The Role of the PGA in the Signal Chain |
The PGA typically sits after the transimpedance amplifier (TIA) in the barcode reader signal chain. The TIA converts the photodiode current to a voltage, and then the PGA amplifies that voltage to a level suitable for digitization. |
Texas Instruments describes a common architecture: 'One method to implement a programmable gain TIA is to use a TIA stage cascaded by a second Programmable Gain Amplifier (PGA) stage... The TIA gain is set according to the maximum current range from the photodiode. Then, the user adjusts the PGA according to the photodiode current conditions' . |
This cascaded approach has a significant advantage: it separates the current-to-voltage conversion from the voltage amplification. The TIA can be optimized for low noise and high bandwidth, while the PGA can be optimized for flexibility and wide gain range. The two stages can be independently controlled, allowing fine-tuning of the overall signal chain. |
Microchip's MCP6SX2 PGA Photodiode PICtail Demo Board illustrates this architecture. The board features a PNZ334 photodiode, an MCP6001U op-amp that acts as a TIA, and then an MCP6S22 or MCP6S92 PGA. The PGA buffers the TIA output and provides multiple selectable gains . |
Chapter 4: Automatic Gain Control |
Automatic gain control, or AGC, is the process of automatically adjusting the gain to keep the signal within the optimal range. In a barcode reader, the microcontroller typically performs AGC during a short calibration phase at the beginning of each scan. |
The concept is simple but powerful. The reader samples the signal amplitude, compares it to a target level, and adjusts the gain accordingly. If the signal is too small, the gain is increased. If the signal is too large, the gain is decreased. The goal is to maintain a consistent signal amplitude at the ADC or digitizer input. |
An EE Times article on magnetic card readers explains the importance of AGC: 'The amplitude of the waveform is highly dependent on the card swipe speed. Faster swipe speeds produce waveforms with peaks of greater amplitude, and slower swipe speeds produce waveforms with peaks of smaller amplitude... During a given swipe, a user will inadvertently change swipe speed several times. As such, the gain of the circuit should be adjusted throughout the swipe to be sure any changes in signal amplitude are accounted for' . |
In barcode readers, a similar principle applies. The reflected light intensity varies with distance, surface reflectivity, and ambient light. AGC ensures that the signal is always within the dynamic range of the digitizer. |

|
Chapter 5: Microchip's MCP6S22 and MCP6S92 PGAs |
Microchip Technology offers a family of programmable gain amplifiers that are well-suited for barcode reader applications. The MCP6S22 and MCP6S92 are single and dual-channel PGAs with a range of selectable gains. |
The MCP6S22 and MCP6S92 feature gains of 1, 2, 4, 5, 8, 10, 16, and 32. The gain is selected via a serial peripheral interface (SPI), allowing the microcontroller to change the gain on the fly. The devices have a rail-to-rail output and operate from a single 2.5V to 5.5V supply, making them suitable for battery-powered handheld readers. |
Microchip's Application Note AN865 describes how these PGAs can be used with photodiodes in both photoconductive and photovoltaic modes . The photoconductive mode, with reverse bias on the photodiode, is optimized for fast response to light sources, making it ideal for digital communications and barcode reading. |
The MCP6SX2 PGA Photodiode PICtail Demo Board is a practical example of this application. The board includes an on-board photodiode, a transimpedance amplifier, and an MCP6S22 PGA. The PGA buffers the TIA output and provides multiple gains, allowing the user to experiment with different signal conditioning strategies . |
Chapter 6: Analog Devices' AD526 - A Precision SPGA |
Analog Devices' AD526 is a classic example of a high-precision software programmable gain amplifier (SPGA). The AD526 provides gains of 1, 2, 4, 8, and 16, selected via TTL-compatible inputs. It is complete, including amplifier, resistor network, and latched inputs, and requires no external components . |
The AD526's key feature is its precision. It offers low gain error (as low as 0.01% for the C grade), low nonlinearity, and excellent DC accuracy. The input offset voltage is guaranteed to be less than 0.5 mV for the C grade, and the offset drift is just 3 uV per degree Celsius . |
These characteristics make the AD526 ideal for precision instrumentation applications where accuracy is paramount. While its bandwidth of 350 kHz at a gain of 16 is modest by today's standards, it is sufficient for many barcode reading applications. |
The AD526 also offers flexibility with force/sense outputs, preserving accuracy when connected to remote or low-impedance loads. This is useful in barcode readers where the PGA output may drive a cable or a downstream ADC . |

|
Chapter 7: Texas Instruments' OPA3S2859 - A Modern Programmable TIA |
Texas Instruments' OPA3S2859 represents a more modern approach: a programmable gain transimpedance amplifier that integrates the gain switching directly into the TIA stage. The device features three internal switched feedback paths plus an optional parallel non-switched feedback path, allowing up to four selectable gain configurations . |
The OPA3S2859 is a wideband, low-noise amplifier with a gain-bandwidth product of 900 MHz. The internal switches minimize parasitic contributions compared to systems that use discrete external switches. Each switch is optimized for feedback resistor values ranging from under 1 kilohm to over 100 kilohms, providing a wide dynamic range . |
This integration of the PGA function directly into the TIA is a significant advantage. It eliminates the need for a separate PGA stage, reducing component count and board space. It also reduces parasitic capacitance and inductance, improving high-frequency performance. |
The OPA3S2859 is controlled via a two-wire parallel interface, and the gain path can be latched to prevent unintended gain changes. The device is available in an enhanced product version for defense, aerospace, and medical applications, with a temperature range of -55 to 105 degrees Celsius . |
Chapter 8: The Programmable Gain Transimpedance Amplifier Architecture |
Texas Instruments has published application notes describing the architecture of a programmable gain TIA. The architecture typically consists of a transimpedance stage followed by a programmable gain stage . |
In this architecture, the TIA stage converts the photodiode current to a voltage. The gain of the TIA is set to accommodate the maximum expected photodiode current. The PGA stage then provides additional amplification, with the gain adjusted based on the actual signal conditions. |
The advantage of this architecture is that the TIA gain can be set high enough to achieve low noise performance for weak signals, while the PGA gain can be reduced to prevent saturation for strong signals. The TIA's output noise is multiplied by the PGA gain, plus the noise contribution of the PGA itself, so careful design is required to maintain a good signal-to-noise ratio . |
The Texas Instruments application note also discusses methods for biasing the photodiode in a unipolar supply system. One method is to bias the op-amp non-inverting input with a positive DC voltage, which reverse biases the photodiode while allowing the amplifier output to reach true zero when the photodiode is unexposed to light. For larger reverse bias voltages, a bipolar supply configuration may be used . |

|
Chapter 9: The XRD98L63 - An Integrated Image Digitizer |
MaxLinear's XRD98L63 is an integrated image digitizer that includes a programmable gain amplifier along with a correlated double sampler (CDS) and a 12-bit analog-to-digital converter. The device is designed for CCD video, digital, and PC cameras, and is also suitable for barcode scanners . |
The XRD98L63 is a complete analog front end for imaging applications. The CDS reduces reset noise and fixed-pattern noise from CCD sensors. The PGA provides adjustable gain to handle varying signal levels. The 12-bit ADC digitizes the signal for further processing. |
This level of integration is common in modern barcode readers. By combining the PGA, the ADC, and other signal processing functions on a single chip, the reader can be made smaller, cheaper, and more reliable. The XRD98L63 is a good example of how functionality that was once implemented with discrete components is now integrated into a single device. |
Chapter 10: AGC Implementation with ADC and PGA |
The implementation of automatic gain control typically requires an analog-to-digital converter (ADC) and a PGA, working together under the control of a microcontroller. The ADC samples the input signal, and the microcontroller uses those samples to determine the appropriate gain setting for the PGA. |
The EE Times article on magnetic card readers describes this process: 'In order to know what gain should be applied to the PGA at any given time, we must know the current amplitude of our input waveform. The ADC can be used to monitor the input signal level and adjust the PGA when needed. If the input signal passes below a set minimum threshold, the gain is increased. If the input signal passes above a set maximum threshold and approaches saturation, the gain is decreased' . |
This approach can be implemented in several ways. The ADC can sample the signal continuously, and the microcontroller can adjust the gain on the fly. Alternatively, the gain can be set once at the beginning of the scan, based on a brief calibration measurement. |
The EE Times article also notes that 'since the peaks of a magnetic card signal are very pronounced, it can be difficult for an ADC to sample the input signal at a high enough rate to ensure the amplitude of the peaks in the waveform are accurately measured.' A peak-and-hold circuit can be used to hold the amplitude of each peak, simplifying the ADC's task . |

|
Chapter 11: The PGA in UHF RFID Readers |
Programmable gain amplifiers are also used in UHF RFID readers, which have similar signal conditioning requirements to barcode readers. A 2014 paper describes a high-precision PGA designed in 0.18-micron CMOS technology for UHF RFID readers . |
The PGA uses a closed-loop resistive-feedback technique for fine gain control and improved linearity, and an open-loop source negative-feedback technique for coarse gain control and power reduction. The gain can be tuned from 0 dB to 48 dB in 1 dB steps, with a gain error of less than 0.016 dB. The PGA consumes 4.65 mW from a single 1.8 V supply . |
This PGA is a good example of the high-performance analog circuits that can be integrated into modern reader ICs. The combination of fine and coarse gain control provides a wide dynamic range with high precision. The low power consumption is essential for battery-powered handheld readers. |
Chapter 12: The Force/Sense Output Configuration |
The Analog Devices AD526 includes a force/sense output configuration that preserves accuracy when the output is connected to remote or low-impedance loads. This is a useful feature in barcode readers where the PGA output may be connected to a cable or an external processing module . |
The force/sense configuration uses separate force and sense pins. The force pin drives the output voltage, while the sense pin monitors the voltage at the load. This compensates for the voltage drop in the output connections, ensuring that the load receives the correct voltage. |
This is particularly important when the PGA is driving a long cable or a low-impedance load. Without force/sense, the voltage drop in the cable can cause errors. With force/sense, the amplifier compensates for the drop, preserving accuracy. |

|
Chapter 13: The PGA and Peak Detection |
In some barcode readers, the PGA is used in conjunction with a peak detection circuit. The peak detection circuit captures the maximum and minimum values of the signal, and the PGA's gain is adjusted based on these values. |
The EE Times article describes how the ADC can be used for peak detection: 'Since a magnetic card reader system will likely already have an ADC available, the ADC can also be leveraged to perform peak detection. The peaks in the magnetic card waveform can be narrow during a fast swipe, which means the ADC needs to be high speed in order to accurately resolve the peaks of the waveform' . |
Once the ADC has sampled the data, a firmware algorithm can determine where the peaks occurred. This method is extremely flexible, since the algorithm can be adjusted to fit the needs of the system. Unwanted noise can be ignored, and the AGC can be directly controlled from the data that has been collected . |
Chapter 14: Gain Error and Nonlinearity |
The gain error and nonlinearity of the PGA are important parameters for barcode reader design. Gain error is the deviation of the actual gain from the nominal gain. Nonlinearity is the deviation of the output from a straight line. |
The Analog Devices AD526 is an example of a precision PGA with very low gain error and nonlinearity. The C grade device has a maximum gain error of 0.01% for gains of 1, 2, and 4, and 0.02% for gains of 8 and 16. The nonlinearity is less than 0.005% of full-scale range for the J grade . |
Low gain error and nonlinearity are important for maintaining the integrity of the barcode signal. If the PGA introduces distortion, the edges of the barcode pulses may be blurred, making it difficult for the decoder to measure the bar and space widths accurately. |

|
Chapter 15: The PGA and Power Consumption |
Power consumption is a critical consideration for handheld barcode readers. The PGA must provide the required performance while consuming as little power as possible. |
The UHF RFID PGA described in the 2014 paper consumes only 4.65 mW from a single 1.8 V supply . This is a good example of the low power consumption that can be achieved in modern CMOS designs. |
The Texas Instruments OPA3S2859 has a quiescent current of 22 mA per channel, but includes a power-down mode with a current of just 75 microamps . This allows the reader to power down the PGA when it is not in use, conserving battery life. |
Chapter 16: The PGA and System Integration |
The trend in barcode reader design is toward greater system integration. The PGA is increasingly being integrated with the TIA, the ADC, and other signal processing functions on a single chip. |
The XRD98L63 image digitizer is an example of this trend. The device integrates a correlated double sampler, a programmable gain amplifier, and a 12-bit ADC on a single chip . This reduces component count, board space, and cost. |
The Texas Instruments OPA3S2859 integrates the gain switching directly into the TIA, eliminating the need for a separate PGA stage . This integration also improves performance by reducing parasitic capacitance and inductance. |

|
Chapter 17: A Complete Solution with Microchip's Demo Board |
Microchip's MCP6SX2 PGA Photodiode PICtail Demo Board is a complete solution for evaluating PGA-based photodiode signal conditioning. The board includes a PNZ334 photodiode, an MCP6001U op-amp that acts as a TIA, and an MCP6S22 or MCP6S92 PGA . |
The board is designed to work with the PICkit 1 Flash Starter Kit and the Signal Analysis PICtail Daughter Board. With these tools, a complete solution can be achieved, including a PC software interface, a PICmicro microcontroller, firmware programmability, a 10-bit ADC, and firmware with relocatable assembler code . |
This demo board is a valuable resource for designers who want to understand how to use a PGA in a barcode reader. The board allows users to experiment with different gain settings and signal conditioning strategies, gaining practical experience with PGA-based photodiode amplification. |
Chapter 18: System Design - Total Noise |
When cascading a TIA and a PGA, the total noise of the system must be considered. The Texas Instruments application note notes that 'the total output noise of the cascaded TIA and PGA circuit is the TIA's output noise multiplied by the PGA gain plus the noise contribution of the PGA gain stage' . |
This means that the TIA's noise is amplified by the PGA gain, and the PGA's own noise is added. If the PGA gain is high, the TIA's noise may dominate. If the PGA gain is low, the PGA's own noise may dominate. |
Careful design is required to achieve the best signal-to-noise ratio. The gain of the TIA and PGA must be optimized for the expected signal levels. The noise performance of both stages must be considered. |

|
Chapter 19: Summary |
The programmable gain amplifier is an essential component in modern barcode readers. It allows the reader to adapt to a wide range of signal strengths, ensuring that the signal is always at the optimal level for digitization and decoding. |
We have examined how different companies and technologies have approached the challenges of PGA design and integration: |
Microchip Technology offers the MCP6S22 and MCP6S92 PGAs, which provide gains of 1 to 32 and are controlled via an SPI interface. The MCP6SX2 PGA Photodiode PICtail Demo Board provides a complete solution for evaluating PGA-based photodiode signal conditioning . |
Analog Devices offers the AD526, a precision software programmable gain amplifier with gains of 1, 2, 4, 8, and 16. The AD526 offers low gain error, low nonlinearity, and excellent DC accuracy . |
Texas Instruments offers the OPA3S2859, a programmable gain transimpedance amplifier that integrates the gain switching directly into the TIA. The device features three internal switched feedback paths and a gain-bandwidth product of 900 MHz . |
MaxLinear offers the XRD98L63, an integrated image digitizer that includes a PGA, a correlated double sampler, and a 12-bit ADC on a single chip . |
Research papers describe PGAs for UHF RFID readers that achieve gains from 0 dB to 48 dB with 1 dB steps, consuming just 4.65 mW from a 1.8 V supply . |

|
The key lessons from our exploration are: |
PGAs provide adaptability. By allowing the gain to be adjusted under microcontroller control, the reader can adapt to changing signal conditions. |
AGC improves performance. Automatic gain control ensures that the signal is always within the dynamic range of the digitizer, maximizing signal-to-noise ratio. |
Integration reduces cost. Integrating the PGA with other signal processing functions on a single chip reduces component count, board space, and cost. |
The PGA architecture affects performance. The choice of resistor network, switching architecture, and amplifier topology affects the gain error, nonlinearity, and bandwidth of the PGA. |
Power consumption is a key consideration. For handheld readers, the PGA must provide the required performance while consuming as little power as possible. |
In the end, the programmable gain amplifier is a testament to the importance of adaptability in barcode reader design. A fixed-gain amplifier is a one-size-fits-all solution that fits no one well. The PGA, by contrast, is a chameleon that changes its characteristics to meet the demands of the moment. It is the key to a reader that works reliably in any environment, on any barcode, at any distance. |