In this example, the STM32G4 Series OPAMP PGA is used in an inverted configuration which also reduces the number of external components needed. The drawback of this circuit design is the 180° phase shift introduced between the OPAMP input and output.
Amplification of small signals on some DC offset
The DC biasing at OPAMP VOUT is given by the voltage at VINP input. If an application requires a voltage centered around VDDA/2 for the VOUT signal, VINP input voltage must be polarized at the same voltage. An external voltage divider bridge should be designed with R1=100 kΩ and R2=100 kΩ to get the correct voltage at VINP input. The circuit diagram layout is givn in Figure 34 Simplified circuitry with inverted input
Figure 34. Simplified circuitry with inverted input
External bias (offset) control by DAC/ADC
The same application is achieved with a reduced bill of material (BOM) which also frees space on PCB application board. In this case, the non-inverting input of the OPAMP is internally connected to the DAC output and the output of the OPAMP is also internally connected to the ADC input. Table 1 Application levels calculation Sensor/OPAMP/DAC/ADC presents the optimized configuration for the ADC acquisition with VREF+/VDDA=3.3V.
Sensor connected via a 10 µF capacitor to remove DC
DC level=2.5V
Maximum peak-peak amplitude from the sencor = 40 mVpp
OPAMP
OPAMP_VOUT
OPAMP_VOUT DC level = VDDA/2=VREF+/2=1.65 V
Maximum peak-peak amplitude VSSA+100 mV .. VDDA-100 mV=3.1 Vpp due to OPAMP saturation voltage
OPAMP
OPAMP_VINP
DAC is connected internally to VINP
DAC code calculation is needed to fix the OPAMP_VOUT DC biasing around voltage 1.65 V(VDDA/2=3.3V/2). The DAC output volatge is set according formula:
DACoutput = VREF × DAC_DOR/4096
For setting VDDA/2 (=VREF/2) voltage the DAC_DOR register must be set to 2048.
OPAMP
GAIN
OPAMP gain calculation: OPAMP_VOUT maximum amplitude/Sensor maximum amplitude which is equal to 3.1/0.04=77.5 nearest available lower gain = “-63”. Updated OPAMP_VOUT maximum amplitude is 0.04*63=2.52 Vpp
Signals levels in the application are updated at the ADC input: the maximum AC amplitude is reduced from 3.1 Vpp to 2.52 Vpp (81.3% of the full OPAMP_VOUT amplitude is used) and the DC range is 1.65V. Levels are correct regarding the OPAMP saturation voltage specification: Vmin_sat = 1.65 V-(2.52/2) = 390 mV and Vmax_sat = 3.3-(1.65+(2.52/2)) = 390 mV.
Figure 35. OPAMP PGA inverting connected to DAC and ADC for AC signal amplification
This application circuitry shows how to connect and configure on demand the OPAMP, DAC and ADC together to acquire an external voltage from a sensor. It also brings flexibility if an application variant is designed with a different value of VREF+ voltage (only the DAC should be updated and not an external voltage bridge divider). Finally, it is important to calculate correctly the OPAMP gain and the DC voltage of OPAMP VOUT to maximize the ADC dynamic range and optimize the post signal processing.
OPAMP Timer controlled multiplexer mode feature
The STM32G4 Series OPAMP integrates a new feature oriented to dual motor control. It is however available to be used for any other application purpose. The objective of this feature is to control the input multiplexers on the non-inverting and inverting input of the OPAMP by hardware (according the signal from timer peripheral).
Presentation
The multiplexer input selection depends on the control signal level: default input is selected when the control signal is low and secondary input is selected when the control signal is high. The default configuration is defined with OPAMPx_CSR register and the secondary configuration is defined with OPAMPx_TCM register. The OPAMP switch control signal is connected to the advanced-control timers (TIM1/TIM8/TIM20) capture/compare 6 timer signals. This is illustrated in Figure 36 OPAMP multiplexer switch per hardware feature principle
Figure 36. OPAMP multiplexer switch per hardware feature principle
Figure 37 OPAMP multiplexer switch feature signal capture is an oscilloscope capture showing the OPAMP output signal (red curve) while OPAMP output is switched from default to secondary input with the timer CC6 signal (blue curve).
Figure 37. OPAMP multiplexer switch feature signal capture
Dual motor control application
Figure 38 Dual motors control application overview using STM32G4 Series microcontroller shows a basic STM32G4 Series configuration dedicated to a time multiplexed dual motor control application. The two motors are connected to the STM32G4 Series microcontroller through two types of signal: PWM digital signals from the TIMER peripheral to independently control each motor branch high side and low side nMOS transistors. The Isense analog signals measure the motor current value in each branch of the motor (A,B,C). This application needs three OPAMPs to measure the current couples A/B, A/C and B/C for both motors. The three OPAMPs are connected to 2 ADCs which acquire (in injected mode) simultaneously the motors’ current couples. ADC conversion results are processed with the STM32G4 Sereis Motor Control software libraries. Finally both timers associated to each motors are updated to adjust the correct PWM width value for the next PWM cycle. The peripheral TIM1 is the synchronous master timer for this application; it triggers the second timer start and the OPAMPs multiplexer input selection. The second timer, TIM8 (slave to TIM1) triggers both ADCs for each motor control cycle which is illustrated in Figure 39 Dual motors control application timing using STM32G4 Series microcontroller.
Figure 38. Dual motors control application overview using STM32G4 Series microcontroller
Figure 39. Dual motors control application timing using STM32G4 Series microcontroller
Conclusion
The STM32G4 Series architecture is designed to fit dual motor control applications with time multiplexing by using the STM32G4 Series internal OPAMP and software libraries. The application’s bill of materials is minimized. Therefore external components (OPAMPs, ADCs) are removed from the design where appropriate.