Operational benefits

Author : Mary Tamar Tan, Microchip Technology

05 January 2017

Mary Tamar Tan from Microchip Technology explains how using op amp modules with other peripherals in 8-bit microcontrollers can reduce production costs and produce more efficient circuits.

(Click here to view article in digital edition)

One of the fundamental building blocks of analogue circuits, the operational amplifier, or op amp, performs two basic functions – mathematical operations and amplification of differential input signals. This versatile and widely used analogue circuit can be found in a vast collection of analogue and digital applications for signal conditioning and signal processing.

Some microcontrollers, such as Microchip’s 8-bit PIC microcontroller devices, have an op amp module that provides the basic op amp functionalities. When integrated with other on-chip intelligent analogue peripherals such as the ADC, comparator, DAC, fixed voltage reference, zero cross detect, slope compensator and programmable ramp generator, many analogue applications are made possible. Furthermore, such microcontrollers provide the ease of integrating analogue and digital peripherals for lots of more complex applications.

Op amp module

The op amp module can be implemented in single supply op amp circuits with increased flexibility and reliability. Features in 8-bit PIC modules include external connections to IO ports, low-leakage inputs, rail-to-rail IO, factory calibrated input offset voltage, 3MHz gain bandwidth product, unity gain control, programmable positive and negative source selections and override controls for forced tri-state output and forced unity gain. Figure 1 shows the op amp module block diagram, which is divided into five sections. Not all sections and features are supported by all microcontrollers.

An op amp is a very high-gain electronic amplifier with a differential input and a single-ended output. It has two inputs, namely the non-inverting (positive) and inverting (negative) inputs. Sources for both the positive and negative inputs may vary per device; they may be taken from external sources through the device pins or from internal analogue sources such as other peripherals on the microcontroller.

Since the op amp is designed to operate with feedback, external feedback components must be connected to the module pins depending on the application. These external components predominantly dictate the behaviour of the module output. The output can be taken from the device pins and can be fed directly to other on-chip analogue peripherals. The module can also be operated in unity gain mode by setting the relevant bit of the register. This allows the inverting input to be internally connected to the output, which also releases a pin for general-purpose input and output.

Several microcontrollers have an output override in which the op amp output is forced to tri-state or to behave in unity gain mode. These modes can be selected through bits on the register. The module has rail-to-rail operation to increase the dynamic range of the op amp. The linear region is between VSS and VDD. Because PIC microcontrollers are designed for single supply operation, VSS is usually tied to ground allowing a maximum voltage swing of approximately between 0 and VDD.

The module exhibits linear behaviour between VDD and 0. The designer must ensure that the input signal does not go above VDD or below VSS, otherwise the microcontroller might display unexpected behaviour. Just like a typical op amp, the module can be configured for a wide variety of applications by manipulating the connections of the external control elements such as resistors, capacitors and diodes. Since the module is designed for linear operations, the user must always note the electrical specifications and limitations to optimise performance.

Unity gain mode

Some applications only require isolation between subsequent circuit stages due to load impedance variations. This can be achieved by implementing an isolation circuit that does not draw any current from the first circuit but delivers the desired current to the next circuit. This isolation circuit can also be used for power amplification. The same voltage is driven from a lower impedance source but a higher power output can be achieved in the output. An op amp exhibits a very high input impedance and a very low output impedance, which makes it practical for such applications.

The op amp can also be configured so it does not amplify or attenuate the input signal. This type of op amp circuit is known as the unity gain buffer or voltage follower. The unity gain buffer is simply a non-inverting amplifier with the output directly connected to the inverting input.

In PIC microcontrollers, the module can be configured in unity gain mode without additional external components by setting the correct bit in the register. When unity gain is selected, the output is tied internally to the inverting input, which also releases the inverting input pin as a general purpose IO pin.  

Output override mode

Several microcontrollers have an output override mode in which the output pulses from other modules can provide switching control over the op amp output. There are two mode selections for the output override – forced tri-state and forced unity gain. Figure 2 shows sample output waveforms for the two modes using PWM as the override source. A sample implementation of output override is shown in Figure 5.

Internally cascaded modules

Microcontrollers such as the Microchip PIC16F1769 allow programmable connection of the output of one op amp to the input of another op amp. These internally cascaded modules are useful if there is a need to isolate the op amp output from the load. The output of the cascaded op amp depends mainly on the gain of the individual stages. Figure 3 shows two sample circuit configurations implementing internally cascaded op amp modules.

Part A of Figure 3 is made up of two non-inverting amplifier stages to produce a very high-gain output. This configuration is useful for high-frequency circuits due to the inverse relationship between the amplifier gain and frequency below the -3dB point. Moreover, higher resistance values also result in higher thermal noise generated by the resistors. To eliminate thermal noise while achieving the desired gain, cascading amplifiers would be the best option.

On the other hand, part B of Figure 3 is composed of an inverting amplifier with a non-inverting positive reference, which basically produces an amplified difference signal between the inverting input and the reference voltage, and a unity gain amplifier that provides isolation between the preceding stage’s output and the load to eliminate any loading effects. Cascading modules can be done through firmware by simply setting the output of one module as the negative or positive input of another module.

Basic signal conditioning

One of the most common applications for an op amp is basic signal conditioning in which there is a need to manipulate input signals to meet the requirements of the succeeding stages. Figure 4 shows a basic signal conditioning circuit requiring a signal with an input of 0.6 to 1V to be translated to a 0 to 5V range for an optimised resolution before feeding the analogue-to-digital converter (ADC) module. This circuit performs two functions – scaling and level shifting.

The op amp module is in an inverting configuration, which means it will output an inverted and amplified replica of the differential input signal. The range of the output signal depends on the inverting amplifier’s gain. The product of the input signal and the gain determines the scale of the output stage.

However, the 5V scaled result does not fall exactly in the 0 to 5V range so the output voltage needs to be shifted to the desired output level by adding a positive reference voltage on the non-inverting input of the op amp.

For a more precise output, this reference voltage needs to be varied. To eliminate the use of external voltage sources, the internal fixed voltage reference (FVR) and digital-to-analogue converter (DAC) modules can be used. The FVR is configured to provide a stable voltage reference to the DAC, which then divides this fixed voltage into 512 software configurable output levels that serve as the reference to the non-inverting input of the op amp module.

Once the signal has been scaled and level shifted to the desired output, it is fed to the ADC module for digital processing. The optimised signal from the op amp module results in a significant decrease on the ADC step size, yielding a much higher effective resolution compared with the unconditioned signal. The op amp output can be fed to other analogue peripherals for further analogue processing.

PWM LED dimmer feedback circuit

Figure 5 shows a current-mode boost controller for constant-current PWM LED dimming. In this circuit, a boost converter supplies constant current to the series-connected LEDs. Maintaining the current constant from the variation of the input voltage and the LEDs’ total resistance is significant to maintain the true colour of the LEDs. The current is primarily a function of the complementary output generator (COG) output duty cycle.

The COG output is fed to the data signal modulator and used to switch power MOSFET Q1 between on and off. Its switching period is determined by the Compare/Capture/PWM (CCP) module, which serves the COG as the rising event source and the comparator module as the falling event source. The CCP is configured in PWM mode to provide a fixed frequency pulse train the value of which typically ranges from 100 to 500kHz.

On the other hand, the comparator produces an output pulse whenever the voltage across RSENSE1 exceeds the output of the PRG module. The input to the PRG module is derived from the output of the op amp module in the feedback circuit. The PRG is configured as a slope compensator to counteract inherent sub-harmonic oscillations when the duty cycle is greater than 50%.

PWM3 controls the dimming to provide the effective average current to control LED brightness without affecting colour. It provides a 200Hz PWM output for COG output modulation, load switching and op amp output override. The PWM3 duty cycle dictates the LED dimming ratio, which in turn determines the light intensity of the LEDs. A higher duty cycle ratio means a longer MOSFET Q2 on time and hence a brighter LED.

When the PWM3 output goes low, the COG output is disabled through the DSM, Q2 switches off and the op amp output is forced to tri-state. The DSM uses PWM3 as the modulation source to provide synchronised switching with Q2 and the op amp output. It also ensures that the full pulse out of the COG is completed before the output switches to fixed low. Disabling the COG prevents the occurrence of output over-voltage condition while forcing the op amp to tri-state maintains the steady state LED current.

When Q2 turns off, the feedback becomes zero and the op amp module increases its output to the maximum, overcharging the compensation network. When PWM3 turns on again, it takes the compensator several switching cycles to recover when a large current peak is driven through the LEDs. This often causes the LED current to overshoot, contributing to a shorter LED lifetime. In this application, the op amp module is configured with the PWM3 as the override source and the output is tri-stated when the PWM output is low to alleviate LED current overshoot and prevent colour shifting. 


The op amp module in 8-bit PIC microcontrollers provides not only the basic functionalities of single supply op amps but also exhibits more enhanced features to increase flexibility in op amp circuit designs. 

As portable equipment becomes more popular, single supply op amp circuits are becoming more in demand. Integrating the op amp module with other on-chip analogue peripherals reduces production costs and board space and provides more efficient circuit performance in many applications.

Contact Details and Archive...

Print this page | E-mail this page