Files
grabowski e7a23a3c7e Add LVSolarBuck64 firmware and debug console with uv support
STM32G474RB firmware for solar buck converter with MPPT, CC control,
Vfly compensation, and adaptive deadtime. Includes Textual TUI debug
console for real-time telemetry, parameter tuning, and SQLite logging.

Added pyproject.toml for uv: `cd code64 && uv run debug-console`

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 16:38:23 +07:00

50 lines
1.3 KiB
C

/*
* mppt.h
*
* Created on: Jun 11, 2025
* Author: janik
*/
#ifndef INC_MPPT_H_
#define INC_MPPT_H_
#include <stdint.h>
typedef struct {
float last_vin;
float last_iin;
float iref; // Output current limit setpoint (mA)
float step; // Adjustment step size (mA)
float iref_min; // Minimum allowed current (mA)
float iref_max; // Maximum allowed current (mA)
float dv_min; // Minimum dV threshold (mV)
float deadband; // Relative dP deadband (e.g. 0.005 = 0.5%)
} MPPTController;
/**
* @brief Initialize MPPT state
* @param mppt Pointer to MPPT state structure
* @param initial_iref Initial current reference
* @param step Step size for Iref adjustments
* @param iref_min Minimum allowed current
* @param iref_max Maximum allowed current
* @param dv_min Minimum dv threshold
*/
void MPPT_IncCond_Init(MPPTController *mppt,
float initial_iref,
float step,
float iref_min,
float iref_max,
float dv_min);
/**
* @brief Update MPPT controller and return new current target
* @param vin Input voltage (filtered)
* @param iin Input current (filtered)
* @return New current reference (in float, amps)
*/
float MPPT_IncCond_Update(MPPTController *mppt, float vin, float iin);
#endif /* INC_MPPT_H_ */