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.
STM32 MPPT Circuit Schematic
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).
