STM32 MPPT Controller: Reverse Polarity Protection & Voltage Measurements

1. System Overview

The controller architecture is centered around the STM32F103C8 microcontroller executing the LibreSolar MPPT charge controller firmware. The core power conversion mechanism utilizes a synchronous buck DC-to-DC converter stage, engineered to optimize solar energy extraction and precisely regulate battery charging profiles. For foundational details on the power stage and current monitoring covered previously, refer to the STM32 MPPT Solar Controller Design: Power Supply & DC/DC Converter and STM32 MPPT Solar Controller Design: Current Sense Amplifier (INA186) articles on ee-diary.net.


Reverse Polarity Protection & Voltage Measurements

STM32 MPPT Circuit Schematic 

MPPT Charge Controller Circuit Created by ee-diary STM32F103C8 ST ee-diary.net VSS VDD BOOT0 NRST PA0-WKUP OSCIN_PD0 OSCOUT_PD1 PB8 PA2 PA1 PA3 PA4 PB9 PA5 PA6 PA7 PA8 PA9 PB10 PA10 PB0 PB1 PB2 PB3 PB11 PB4 PB5 PB6 PB7 PB12 PB13 PB14 PB15 PA11 PA12 PA13 PA14 PA15 PC13_RTC PC14-OSC32_IN PC15-OSC32_OUT VDDA VBAT VSSA VSS_2 VDD_2 VSS_3 VDD_3 U1 STM32F103C8 R1 10k C1 100nF C2 100nF C3 100nF C4 100nF R2 10k C5 100nF C6 1uF R3 330 D1 LED-RED 1 2 J1 CONN-H2 D2 SS14 VR1 VARISTOR C7 10nF C8 560uF C9 560uF C10 1uF C11 100nF Q1 IPA045N10N3G Q2 IPA045N10N3G Q3 IPA045N10N3G R4 3.3 R5 3.3 D3 SS14 D4 SS14 HI 5 LI 6 VSS 7 VDD 1 HB 2 HO 3 HS 4 LO 8 U2 LM5101 D5 1N4148 R6 3.3 +12V C12 2.2uF R7 3.3 C13 100nF L1 53uH C14 2.2nF R8 4.7 R9 4.7 C15 0.22uF C16 0.22uF C17 680uF R10 2m C18 680uF 1 2 J2 CONN-H2 INA186 2 4 5 6 1 3 U3 INA186A1 R11 10 C19 1nF R12 10 R13 1k C20 1nF R14 100k R15 2.2k C21 10nF R16 100k R17 5.6k C22 10nF

2. DC-to-DC Converter & Current Sense Amplifier

  • Power Stage: Comprises high-efficiency N-channel MOSFETs (IPD040N10N3G, designated Q2 and Q3) working alongside inductor L1 in a synchronous buck topology.

  • Current Monitoring: Integrated current sensing is achieved via an INA186A1 current sense amplifier (U6) paired with a 2-milliohm current sense resistor, delivering accurate real-time telemetry of inductor and load currents to the microcontroller.

3. Reverse Polarity Protection & Gate Driver Circuitry

Input Reverse Polarity Protection

Positioned between the solar panel input and the PV input connector (J4), the input stage incorporates comprehensive hardware protection:


  • P-Channel MOSFET (Q1): An IPP80P03P4L P-channel MOSFET provides low-loss reverse polarity protection, minimizing conduction losses during normal operation while blocking reverse current flow.

  • Transient Voltage Suppression: A varistor (VR1, VDRS14T140) clamps high-voltage transients and surges originating from the solar array.

  • Input Filtering: Bulk decoupling and filtering capacitors (C7–C11) smooth incoming voltage fluctuations and attenuate high-frequency ripple.

Gate Driver & Low-Side Output (LO) Protection

The LM5101 gate driver bridges the gap between the low-power PWM outputs of the STM32F103C8 and the high-capacitance gates of the power switches:


  • Signal Amplification: Translates low-current logic PWM inputs into high-peak current outputs to rapidly charge and discharge MOSFET gate capacitances, minimizing switching losses.

  • High-Side Output (HO) Network: Utilizes gate resistor R4 (3.3 Ω) to control turn-on/turn-off speed, dampening parasitic ringing and voltage overshoot.

  • Low-Side Output (LO) Network: Features gate resistor R5 (5.1 Ω) in parallel with a reverse-biased SS14FL Schottky diode (D1). The diode provides a low-impedance discharge path that prevents unintentional shoot-through and safeguards the switching transistors.

4. Voltage Measurement Networks

PV Voltage Measurement (Pin PA0 / ADC1)

  • Components: Top resistor R14 (100 kΩ), bottom resistor R15 (2.2 kΩ), and filter capacitor C21 (10 nF) located at the PV input connector (J4).

  • Function: R14 and R15 establish a voltage divider scaling down high photovoltaic array voltages to safe levels for the STM32 ADC. C21 acts as a low-pass filter (cutoff frequency ~7.4 kHz), attenuating high-frequency switching noise from the buck converter to guarantee stable readings for the MPPT algorithm.

  • Scaling Formula:
    $$\text{ADC Voltage} = \text{PV Voltage} \times \left(\frac{\text{R15}}{\text{R14} + \text{R15}}\right) = \text{PV Voltage} \times \left(\frac{2.2\text{ k}\Omega}{102.2\text{ k}\Omega}\right) \approx \text{PV Voltage} \times 0.02153$$

  • Calculation & Scale Example (18 V Nominal Input):
    $$\text{ADC Voltage} = 18\text{ V} \times \left(\frac{2.2\text{ k}\Omega}{102.2\text{ k}\Omega}\right) \approx 0.387\text{ V}$$

  • Headroom: A 0.387 V signal at 18 V nominal leaves substantial dynamic range, permitting maximum system sensing up to approximately 153.2 V prior to reaching ADC reference saturation (3.3 V).

Battery Voltage Measurement (Pin PA1 / ADC1)

  • Components: Top resistor R16 (100 kΩ), bottom resistor R17 (5.6 kΩ), and filter capacitor C22 (10 nF) located at the battery output connector (J5).

  • Function: R16 and R17 scale the battery terminal voltage down to safe operational levels for pin PA1. C22 operates as a low-pass filter across R17 to eliminate ripple and ensure accurate closed-loop charge voltage control.

  • Scaling Formula:
    $$\text{ADC Voltage} = \text{Battery Voltage} \times \left(\frac{\text{R17}}{\text{R16} + \text{R17}}\right) = \text{Battery Voltage} \times \left(\frac{5.6\text{ k}\Omega}{105.6\text{ k}\Omega}\right) \approx \text{Battery Voltage} \times 0.05303$$

  • Calculation & Scale Example (12 V Nominal Battery):
    $$\text{ADC Voltage} = 12\text{ V} \times \left(\frac{5.6\text{ k}\Omega}{105.6\text{ k}\Omega}\right) \approx 0.636\text{ V}$$

  • Headroom: A 0.636 V signal at 12 V nominal tracks system voltages accurately up to 62.2 V prior to reaching ADC reference saturation (3.3 V).

5. Summary Comparison Table of Voltage Sensing Networks

Parameter

PV Voltage Sensing

Battery Voltage Sensing

Target Node

PV Input Connector (J4)

Battery Output Connector (J5)

STM32 Pin / ADC

PA0 (ADC1)

PA1 (ADC1)

Top Resistor (SM_Rout)

R14 (100 kΩ)

R16 (100 kΩ)

Bottom Resistor (SM_Rin)

R15 (2.2 kΩ)

R17 (5.6 kΩ)

Filter Capacitor

C21 (10 nF)

C22 (10 nF)

Divider Ratio

0.02153 (1 : 46.45)

0.05303 (1 : 18.86)

Sample Output Voltage

~0.387 V (at 18V PV input)

~0.636 V (at 12V battery input)

Max Voltage (at 3.3V ADC)

~153.2 V

~62.2 V


See also:

Post a Comment

Previous Post Next Post