AN5306 · Application noteOperational Amplifier (OPAMP) usage in STM32G4 Series
Download .pdfOpen in the full document

Timing parameters of OPAMP

Timing parameters of OPAMP

The OPAMP has 2 speed settings to select from:

  • Normal mode, which offers a typical slew rate of 6.5 V/µs
  • High speed mode, which offers a typical slew rate of 45 V/µs.

The high speed mode is suitable for applications which process high frequency analog signals with large amplitudes on the OPAMP output. Both modes have different power consumptions; high speed mode power consumption is higher than consumption in the normal mode.

The high speed mode is typically used in redirecting the internal DAC output to a pin through the OPAMP; see DAC output to OPAMP input – internal DAC output redirection to external pin. Here, the fast slew rate performance is important because the OPAMP is able to follow large voltage changes from the DAC output. See Figure 17 Internal DAC redirected through OPAMP to output pin – OPAMP slew rate.

The gain bandwidth (GBW) is defined as the frequency when the OPAMP gain decreases to 1. This is almost the same for both normal and high speed modes. The GBW of the OPAMP is 13 MHz allowing high frequency signal processing. If the OPAMP is configured as PGA with an internal or external gain greater than 1 then the bandwidth lowers proportionally to the gain.

The OPAMP in STM32G4 Series is stable with unity gain but very fast. This allows it to be used in many applications without final amplifier design stability problems (because very fast operational amplifiers are usually unstable with gain = 1 and may produce an oscillating output).

Introduction

The OPAMP embedded in theSTM32G4 Series microcontroller is a general purpose analog operational amplifier designed reduce the need for external stand-alone operational amplifier circuit. The STM32G4 Series OPAMP peripheral is configured using the internal switching circuitry setup. Both non-inverting and inverting OPAMP inputs are each connected to a 4-to-1 mux (refer to the reference manual for a full description). The OPAMP output is connected to a 1-to-2 mux to route the OPAMP output signal either externally or internally.

  • OPAMP non-inverting input(+): 4 external signals are available: VINP0,VINP1,VINP2 and VINP3.
  • OPAMP inverting input(-): 2 external signals are available VINM0 and VINM1; 2 internal signal opamp_output and resistor_array_feedback.
  • OPAMP output (opamp_out): 2 path are available, an internal path to ADC peripheral or an external to VOUT pin.
Note:

When opamp_out is redirected internally to an ADC channel, the I/O on which is mapped VOUT is available to be used for any purpose.

Figure 18. OPAMP peripheral overview (principle)

OPAMP in stand-alone mode

The OPAMP stand-alone mode is the default OPAMP configuration. Both non-inverting and inverting inputs are available externally. A basic application would consist in comparing VINP and VINN level and get the comparison result with the level of OPAMP output VDDA when VINP>VINN or VSSA when VINP<VINN. Another interesting application using this mode is the current to voltage converter described in the following chapter.

Stand-alone Photodiode amplifier application

Brightness sensors are often required in consumer applications. The STM32G4 Series OPAMP peripheral in stand-alone mode matches the circuitry design needed. The following figure shows the principle of a photodiode sensor or transimpedance amplifier: the photodiode generates a reversed current depending of the amount of light received. The feedback resistor (R) should be selected to set the photodiode sensitivity and OPAMP supply range.The current generated from the photodiode is converted into an output voltage inline with the following equation : VOUT = Ip x R.

Figure 19. Transimpedance amplifier circuitry and Vout plot vs light level


Figure 20 STM32G4 Series OPAMP transimpedance configuration illustrates the STM32G4S Series OPAMP connected to the external photodiode and the associated resistor R. The resistor value should be chosen inline with the maximum photocurrent of the photodiode. If VDDA=3.3V and maximum photocurrent is 10µA then maximum value for R should be lower than VDDA/ip_max=3.3/10e-6=330kOHms to not saturate the OPAMP.

Figure 20. STM32G4 Series OPAMP transimpedance configuration

OPAMP in Follower mode

This is a simple operational amplifier mode used for buffering the voltage between 2 devices. The purpose is to prevent an excessive voltage drop from the first device with a high impedance output which is connected to the second device with a low input impedance. The OPAMP configured in this mode is associated to other STM32G4 Series peripheral such as the ADC or the DAC to answer application impedance issues such as when very high output impedance component connected to the ADC input or a very low input component is connected to DAC output.

Very high impedance sensor acquisition with STM32G4 Series ADC

Figure 21. OPAMP follower mode to ADC example
One typical application where the OPAMP is used in follower mode is the current sensing using an Hall effect. The Hall effect sensor with the following parameters is selected:
  • Sensitivity equal to 15 mV/A
  • A nominal RMS current of 100 A
  • A reference output voltage equal to 1.65 V
The sensor is directly connected to OPAMP input as shown in Figure 22 Current sensing using Hall effect sensor.
Figure 22. Current sensing using Hall effect sensor

OPAMP Programmable Gain Amplifier (PGA) mode

The PGA mode is a dedicated OPAMP peripheral circuit configuration. It amplifies the input signal with a programmable gain depending on the ratio of R1 and R2 (see Figure 23 Simplified circuitry example of a non-inverted PGA without input biasing and Figure 24 Simplified circuitry example of inverted PGA ). There are two possible PGA circuit layouts: non-inverted where the input signal is connected to the OPAMP non-inverting input VINP and inverted where the input signal is connected to inverting input VINN (VINP input should be externally connected to ground in this case). The OPAMP peripheral contains integrated switches to allow the software to change the value R1, the feedback resistor.

Figure 23. Simplified circuitry example of a non-inverted PGA without input biasing
Figure 24. Simplified circuitry example of inverted PGA

Amplification of small positive signals

The available OPAMP peripheral gains are 2,4,8,16,32 and 64 when it is used in non-inverter mode and -1,-3,-7,-15,-31 and -63 in the inverting mode. Figure 25 STM32G4 Series OPAMP internal circuitry in PGA mode configuration non-inverter shows the OPAMP PGA configuration with the gain selection defined by the PGA_GAIN[4:0] register.

Figure 25. STM32G4 Series OPAMP internal circuitry in PGA mode configuration non-inverter

A simple application based on the OPAMP non-inverting configuration is DC current sensing where a 3 phase motor control application requires the real time current monitor on each motor branch in order to adjust the motor control with the proportional, integral and differential (PID) loop controller. The STM32G4 Series OPAMP peripheral is easily connected to an external circuit which is either a simple ground shunt resistor or a hall sensor. These applications are presented in Figure 26 Current sensing using grounded shunt resistor.

Figure 26. Current sensing using grounded shunt resistor

Filtering capacitor option

The drawback of the previous example (analog to digital conversion using ADC) is the absence of an anti-alias filter (AAF) which should be implemented before sampling a signal in order to limit the required conversion bandwidth and to follow the Nyquist-Shannon sampling theorem. Figure 27 ADC conversion comparison when using an AAF shows the usage of an AAF with converting analog signals.

Figure 27. ADC conversion comparison when using an AAF

Adding an external capacitor between OPAMP VOUT and OPAMP VINN creates a low-pass filter circuit when it is used as an AAF. The cut-off frequency of the filter is given by:

  • Fc= 1/(2.π.R1.Cext)

Figure 28 Active low-pass filter using STM32G4 Series OPAMP and an external capacitor shows a simplified low-pass filter implemented with an operational amplifier.

Figure 28. Active low-pass filter using STM32G4 Series OPAMP and an external capacitor

Here is an application example where :

  • The sampling rate of the ADC is 100 kHz
  • The sampling bandwidth is 10kHz (+/-0.1 dB accuracy).
  • OPAMP in PGA mode with x2 gain (PGA_GAIN[4:0]=0x00)

In the specified bandwidth, the gain should be flat (+/- 0.1 dB), the filter frequency response should calculated and the correct nominal value for the external capacitor (Cext) chosen. The STM32G4 Series OPAMP internal feedback resistor value is 10 kΩ when PGA_GAIN[4:0]=0x00. Anantenuation value of 0.1 dB is achieved with the following parameter

  • Cext = 220 pF (nominal value E12)
  • OPAMP feedback Resistor =10 kΩ (PGA_GAIN[4:0]=0x00)
  • -3 dB Cut-off frequency =72.3 kHz
  • Bandwidth attenuation: -0.1 dB @ 10 kHz

The AAF cut-off frequency is changed depending on the OPAMP gain (feedback resistor selected with PGA_GAIN[4:0] value). When the OPAMP PGA mode is set to x4 gain, the feedback resistor is switched to 30 kΩ and the low pass filter cut-off frequency is changed.

  • Cext = 220 pF
  • OPAMP feedback Resistor =30 kΩ (PGA_GAIN[4:0]=0x01)
  • -3 dB cut-off frequency = 24.1 kHz
  • Bandwidth attenuation: -0.7 dB which is out of application requirements

Figure 29 1 st order low-pass filter frequency response with OPAMP gain x2 and x4 shows the 1st order low-pass filter frequency response with OPAMP gain x2 and x4.

Figure 29. 1st order low-pass filter frequency response with OPAMP gain x2 and x4

Figure 30 OPAMP using PGA configuration with external capacitor option shows the complete OPAMP configuration with the associated external capacitor.

Figure 30. OPAMP using PGA configuration with external capacitor option

Amplification of high impedance small signals on some DC offset

The previous OPAMP PGA mode circuit allows an easy amplification of an analog signal and to filter it as needed. The limitation of this application schematic : both DC and AC components are amplified. This is a constraint only when the sensor AC signal needs to be amplified. The alternative is the following OPAMP schematic proposal.

Example: AC signal modulated on DC offset (sensor)

The following circuitry is useful for only amplifying the AC signal and to change the DC polarization with the DC blocker (C1 capacitor). A new DC polarization (VDDA/2 for example) is done through the voltage bridge divider (R1, R2) and the OPAMP centers the VOUT signal around VDDA/2.

Figure 31. DC blocker / AC PGA circuitry with STM32G4 Serie OPAMP

This circuitry was simulated, the results with Vsensor are DC=2.5 V + AC=20 mV (peak - peak) and VDDA=3.3 V are illustrated in Figure 32 AC gain simulation result (timing).

Figure 32. AC gain simulation result (timing)

The AC signal is correctly amplified and the DC signal is also correct, however as several capacitors are used and it is recommended to validate the circuit’s transfer function .

The complete circuit response frequency is computed using the following equation.













Finally, the simulation and mathematical model had been be plotted out and the response frequencies compared. The mathematical model doesn’t take into account the frequency response of the OPAMP (blue plot) as it is considered as an ideal amplifier. The analysis of the three curves in low frequency range correlate. See Figure 33 Frequency response comparison mathematic/measurement/design simulator:

  • Mathematicallycalculated response (blue plot)
  • Measured responset (green plot)
  • Circuit simulation using LTspice for example (red plot)
Figure 33. Frequency response comparison mathematic/measurement/design simulator

This proposed circuit layout is particularly appropriate when the application requires AC signal amplification only and a new DC value to match the supply range of the MCU. Another interesting feature, where several external circuit signals are connected to seperate OPAMP non-inverting inputs.