FluxionX Powertech
Published © CC BY-NC-SA

VIDYUT — Compact MPPT Solar Controller for Autonomous Device

Finally, a production-qualified smart MPPT scaled down for field sensors, remote hardware, and custom battery systems. Meet VIDYUT.

BeginnerFull instructions providedOver 4 days17
VIDYUT — Compact MPPT Solar Controller for Autonomous Device

Things used in this project

Hardware components

Vishay SIR184DP-T1-RE3
×1
Texas Instruments bq24650
×1
STMicroelectronics STM32G030FCPCTR
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Custom parts and enclosures

CAD Enclosure

This is the enclosure of the PCBA

Bottom Part of the Enclosure

Schematics

PCB Image - Section Marked

PCB Images

Product Test

Battery Charge Test Image

PCBA - DSO Test Image

Schematic Of the PCB Used

The user can use the schematic to build a custom PCBA based on the user's requirements

Field Testing

Code

Test Code for STM32

C/C++
#define PV_SENSE_PIN PA0
#define BAT_SENSE_PIN PA1
#define MPPT_ENABLE_PIN PA4
#define TEMP_SENSE_PIN PA5
#define LOAD_SWITCH_PIN PA6
#define LOAD_BUTTON_PIN PB7
#define CHARGE_TERM_EN_PIN PB2
#define BQ_STATUS1_PIN PB3
#define BQ_STATUS2_PIN PA11
#define DEBUG_LED_PIN PA12
// #define USER_GPIO_PIN PB9
#define UART_TX_PIN PA2
#define UART_RX_PIN PA3

#define DEBOUNCE_TIME 50
#define REPORT_INTERVAL 1000

volatile bool buttonEvent = false;
volatile uint32_t lastInterruptTime = 0;
bool loadState = false;

unsigned long startTime = 0;
uint32_t reportTimer = 0;

void loadButtonISR()
{
  uint32_t now = millis();

  if((now - lastInterruptTime) > DEBOUNCE_TIME)
  {
    buttonEvent = true;
    lastInterruptTime = now;
  }
}

HardwareSerial DebugUART(UART_RX_PIN, UART_TX_PIN);

void setup()
{
  DebugUART.begin(115200);
  analogReadResolution(12);

  pinMode(DEBUG_LED_PIN, OUTPUT);
  pinMode(MPPT_ENABLE_PIN, OUTPUT);
  pinMode(CHARGE_TERM_EN_PIN, OUTPUT);
  pinMode(LOAD_SWITCH_PIN, OUTPUT);
  pinMode(BQ_STATUS1_PIN, INPUT);
  pinMode(BQ_STATUS2_PIN, INPUT);
  pinMode(LOAD_BUTTON_PIN, INPUT);
  // pinMode(USER_GPIO_PIN, OUTPUT);
  digitalWrite(MPPT_ENABLE_PIN, HIGH);
  digitalWrite(CHARGE_TERM_EN_PIN, LOW);

  digitalWrite(LOAD_SWITCH_PIN, LOW);
  attachInterrupt(digitalPinToInterrupt(LOAD_BUTTON_PIN), loadButtonISR, FALLING);

  DebugUART.println("<-----Solar Battery Charger Functional Testing----->");

  startTime = millis();

  while ((millis() - startTime) < 5000) 
  {
    digitalWrite(DEBUG_LED_PIN, HIGH);
    delay(500);
    digitalWrite(DEBUG_LED_PIN, LOW);
    delay(500);
    DebugUART.println("<-----Blink----->");
  }

  digitalWrite(DEBUG_LED_PIN, LOW);

  DebugUART.println("PV ADC Ready");
  DebugUART.println("BAT ADC Ready");
  DebugUART.println("Temperature ADC Ready");
  DebugUART.println("Interrupt Ready");

  digitalWrite(MPPT_ENABLE_PIN, LOW);
  DebugUART.println("<-----MPPT Enabled----->");
  delay(1000);
  digitalWrite(CHARGE_TERM_EN_PIN, HIGH);
  DebugUART.println("<-----Charge Termination Enabled----->");
  delay(1000);
}

void loop()
{
  if(buttonEvent)
  {
    buttonEvent = false;
    loadState = !loadState;

    digitalWrite(LOAD_SWITCH_PIN, loadState);
    digitalWrite(DEBUG_LED_PIN, loadState);
    DebugUART.print("Load State: ");
    DebugUART.println(loadState ? "ON" : "OFF");
  }
  
  if ((millis() - reportTimer) >= REPORT_INTERVAL)
  {
    reportTimer = millis();

    uint16_t pvADC = analogRead(PV_SENSE_PIN);
    uint16_t batADC = analogRead(BAT_SENSE_PIN);
    uint16_t tempADC = analogRead(TEMP_SENSE_PIN);

    float pvADCVoltage = (pvADC * 3.3f) / 4095.0f;
    float batADCVoltage = (batADC * 3.3f) / 4095.0f;
    float tempVoltage = (tempADC * 3.3f) / 4095.0f;

    float pvActual = pvADCVoltage * 9.91f; // Divider ratio = 499k / 56k
    float batActual = batADCVoltage * 9.91f;

    bool bqStat1 = digitalRead(BQ_STATUS1_PIN);
    bool bqStat2 = digitalRead(BQ_STATUS2_PIN);

    DebugUART.print("PV Voltage: ");
    DebugUART.print(pvActual, 2);
    DebugUART.println(" V");

    DebugUART.print("BAT Voltage: ");
    DebugUART.print(batActual, 2);
    DebugUART.println(" V");

    DebugUART.print("PV ADC TESTPOINT Voltage: ");
    DebugUART.print(pvADCVoltage, 2);
    DebugUART.println(" V");

    DebugUART.print("BATTERY ADC TESTPOINT Voltage: ");
    DebugUART.print(batADCVoltage, 2);
    DebugUART.println(" V");

    DebugUART.print("Temperature Voltage: ");
    DebugUART.print(tempVoltage, 3);
    DebugUART.println(" V");

    DebugUART.print("BQ Status 1: ");
    DebugUART.println(bqStat1 ? "ACTIVE" : "INACTIVE");

    DebugUART.print("BQ Status 2: ");
    DebugUART.println(bqStat2 ? "ACTIVE" : "INACTIVE");

    DebugUART.println("--------------------------------");
  }
}

Credits

FluxionX Powertech
1 project • 0 followers
FluxionX Powertech develops smart power, electronics, IoT, and embedded solutions for a connected, sustainable future.

Comments