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
/*
* adc_sense.h -- reads VBATT_SENSE/IIN_SENSE/ICHG_SENSE (PA0/PA1/PA2,
* ADC1 channels 0/1/2) and returns an engineering-unit sensor_frame_t.
* Assumes STM32CubeMX/HAL has configured ADC1 for a 3-channel scan
* sequence (rank 1=IN0, rank 2=IN1, rank 3=IN2) triggered by software or a
* timer, plus GPIO inputs for MPPT_PGOOD/BIAS_PGOOD.
*/
#ifndef ADC_SENSE_H
#define ADC_SENSE_H
#include "charge_control.h"
/* Simple exponential moving average -- enough to tame shunt/ADC noise
* without adding phase lag that would fight the (much slower) control
* loop cadence. alpha in (0,1], smaller = more filtering. */
typedef struct {
float vbatt_f, iin_f, ichg_f;
uint8_t initialized;
} adc_filter_state_t;
void adc_sense_init(adc_filter_state_t *filt);
/* Blocking read of all 3 ADC channels + the 2 PGOOD GPIOs, filtered.
* Call HAL_ADC_Start / poll-for-conversion internally. */
void adc_sense_read(adc_filter_state_t *filt, sensor_frame_t *out);
#endif /* ADC_SENSE_H */