board
Solar MPPT Power System
Public Unreviewedby TylerK
A 30 W solar battery charger with regulated 5 V and 3.3 V rails: an STM32G031 running perturb & observe MPPT and a CC/CV charge state machine, steering a TI LM5175 4-switch buck-boost through a single analog control input. Four-layer KiCad board, schematic and PCB generated from Python, with an electrothermal simulation run against the published board file.
main
TylerK
Replace discrete-analog board with MCU/IC redesign: STM32G031 P&O MPPT + CC/CV firmware, LM5175 buck-boost, INA180 curr…
e48ba30
1mo ago
#include "pwm_ref.h"
#include "board_config.h"
#include "main.h" /* CubeMX-generated: htim14 handle */
void pwm_ref_init(void) {
HAL_TIM_PWM_Start(&htim14, TIM_CHANNEL_1);
__HAL_TIM_SET_COMPARE(&htim14, TIM_CHANNEL_1, 0);
}
void pwm_ref_set_vbatt_setpoint(float vbatt_setpoint) {
float mcu_ref_v = vbatt_setpoint_to_mcu_ref(vbatt_setpoint);
float duty = mcu_ref_to_pwm_duty(mcu_ref_v);
uint32_t arr = __HAL_TIM_GET_AUTORELOAD(&htim14);
uint32_t compare = (uint32_t)(duty * (float)(arr + 1));
if (compare > arr) compare = arr;
__HAL_TIM_SET_COMPARE(&htim14, TIM_CHANNEL_1, compare);
}