2024-07-11 06:58:55 +00:00
|
|
|
|
/*
|
|
|
|
|
* mppt_control.c
|
|
|
|
|
*
|
|
|
|
|
* Created on: 2024<EFBFBD><EFBFBD>6<EFBFBD><EFBFBD>29<EFBFBD><EFBFBD>
|
|
|
|
|
* Author: psx
|
|
|
|
|
*/
|
2024-08-17 03:14:19 +00:00
|
|
|
|
#include <math.h>
|
2024-07-11 06:58:55 +00:00
|
|
|
|
|
|
|
|
|
#include "mppt_control.h"
|
|
|
|
|
#include "collect_Conversion.h"
|
|
|
|
|
#include "pwm.h"
|
|
|
|
|
#include "inflash.h"
|
2024-07-22 06:20:24 +00:00
|
|
|
|
#include "gpio.h"
|
2024-07-11 06:58:55 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
#include "uart_dev.h"
|
|
|
|
|
|
2024-07-11 06:58:55 +00:00
|
|
|
|
SL_Mppt_para g_Mppt_Para = {0};
|
|
|
|
|
|
2024-07-12 09:02:26 +00:00
|
|
|
|
static void TrickleCharge(void);
|
|
|
|
|
static void ConstantCurrentCharge(void);
|
|
|
|
|
static void ConstantVoltageCharge(void);
|
|
|
|
|
static void FloatingCharge(void);
|
|
|
|
|
|
2024-08-05 02:35:10 +00:00
|
|
|
|
/* ռ<>ձ<EFBFBD> */
|
2024-08-17 03:14:19 +00:00
|
|
|
|
float g_duty_ratio = 0.7;
|
2024-08-05 02:35:10 +00:00
|
|
|
|
/* <20><><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ */
|
|
|
|
|
static uint8_t modeFlag = 0;
|
|
|
|
|
|
2024-07-11 06:58:55 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval OutputPower <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*/
|
|
|
|
|
static float Get_OutputPower(void)
|
|
|
|
|
{
|
|
|
|
|
static float OutputPower;
|
|
|
|
|
static float V_out, I_out;
|
|
|
|
|
|
|
|
|
|
V_out = get_PV_VOLT_OUT();
|
|
|
|
|
I_out = get_CHG_CURR();
|
|
|
|
|
|
|
|
|
|
OutputPower = V_out * I_out;
|
|
|
|
|
|
|
|
|
|
printf(" V = %d/100, I = %d/10000, OutputPower = %d/10000 \r\n",
|
|
|
|
|
(int)(V_out*100), (int)(I_out * 10000), (int)(OutputPower * 10000));
|
|
|
|
|
|
|
|
|
|
return OutputPower;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief ʹ<EFBFBD>õ<EFBFBD>Ϊ<EFBFBD>Ŷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ŷ<EFBFBD>,<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ,ʹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*/
|
|
|
|
|
/* pwmռ<6D>ձȵ<D5B1><C8B5>ڲ<EFBFBD><DAB2><EFBFBD> */
|
|
|
|
|
const float step1_pwm = 0.01;
|
2024-08-05 02:35:10 +00:00
|
|
|
|
const float step2_pwm = 0.005;
|
2024-07-11 06:58:55 +00:00
|
|
|
|
//#define array_num 10
|
|
|
|
|
void mppt_readJust(void)
|
|
|
|
|
{
|
2024-07-24 08:57:38 +00:00
|
|
|
|
// static float last_duty_ratio = 0.5;
|
|
|
|
|
// static float now_duty_ratio;
|
|
|
|
|
// static float last_OutputPower;
|
|
|
|
|
// static float now_OutputPower;
|
|
|
|
|
// static float step_pwm = step1_pwm;
|
|
|
|
|
//
|
|
|
|
|
// last_OutputPower = Get_OutputPower();
|
|
|
|
|
//
|
|
|
|
|
// printf(" duty_ratio = %d/1000 \r\n", (int)(last_duty_ratio * 1000));
|
|
|
|
|
//
|
|
|
|
|
// /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ鿴<DAB2><E9BFB4><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
// now_duty_ratio = last_duty_ratio + step_pwm;
|
|
|
|
|
// if (now_duty_ratio > 1) {
|
|
|
|
|
// now_duty_ratio = 1;
|
|
|
|
|
// }
|
|
|
|
|
// Set_duty_ratio(now_duty_ratio);
|
|
|
|
|
// now_OutputPower = Get_OutputPower();
|
|
|
|
|
// if (now_OutputPower > last_OutputPower) {
|
|
|
|
|
// printf(" now_OutputPower > last_OutputPower1 \r\n");
|
|
|
|
|
// last_duty_ratio = now_duty_ratio;
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ鿴<DAB2><E9BFB4><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
|
|
|
|
// now_duty_ratio = last_duty_ratio - step_pwm;
|
|
|
|
|
// if (now_duty_ratio < 0) {
|
|
|
|
|
// now_duty_ratio = 0;
|
|
|
|
|
// }
|
|
|
|
|
// Set_duty_ratio(now_duty_ratio);
|
|
|
|
|
// now_OutputPower = Get_OutputPower();
|
|
|
|
|
// if (now_OutputPower > last_OutputPower) {
|
|
|
|
|
// printf(" now_OutputPower > last_OutputPower2 \r\n");
|
|
|
|
|
// last_duty_ratio = now_duty_ratio;
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// /* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹ<EFBFBD><DAB9>ʾ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>Ϊԭ<CEAA><D4AD><EFBFBD>ĵ<EFBFBD> */
|
|
|
|
|
// Set_duty_ratio(last_duty_ratio);
|
2024-08-05 02:35:10 +00:00
|
|
|
|
// step_pwm = step2_pwm;
|
2024-07-24 08:57:38 +00:00
|
|
|
|
|
2024-07-11 06:58:55 +00:00
|
|
|
|
static float last_duty_ratio = 0.5;
|
|
|
|
|
static float last_OutputPower;
|
|
|
|
|
static float now_OutputPower;
|
|
|
|
|
static float step_pwm = step1_pwm;
|
|
|
|
|
|
|
|
|
|
last_OutputPower = Get_OutputPower();
|
|
|
|
|
|
|
|
|
|
printf(" duty_ratio = %d/1000 \r\n", (int)(last_duty_ratio * 1000));
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ鿴<DAB2><E9BFB4><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2024-08-05 02:35:10 +00:00
|
|
|
|
g_duty_ratio = last_duty_ratio + step_pwm;
|
|
|
|
|
|
|
|
|
|
Set_duty_ratio(&g_duty_ratio);
|
2024-07-11 06:58:55 +00:00
|
|
|
|
now_OutputPower = Get_OutputPower();
|
|
|
|
|
if (now_OutputPower > last_OutputPower) {
|
|
|
|
|
printf(" now_OutputPower > last_OutputPower1 \r\n");
|
2024-08-05 02:35:10 +00:00
|
|
|
|
last_duty_ratio = g_duty_ratio;
|
2024-07-11 06:58:55 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڲ鿴<DAB2><E9BFB4><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
|
2024-08-05 02:35:10 +00:00
|
|
|
|
g_duty_ratio = last_duty_ratio - step_pwm;
|
|
|
|
|
Set_duty_ratio(&g_duty_ratio);
|
2024-07-11 06:58:55 +00:00
|
|
|
|
now_OutputPower = Get_OutputPower();
|
|
|
|
|
if (now_OutputPower > last_OutputPower) {
|
|
|
|
|
printf(" now_OutputPower > last_OutputPower2 \r\n");
|
2024-08-05 02:35:10 +00:00
|
|
|
|
last_duty_ratio = g_duty_ratio;
|
2024-07-11 06:58:55 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڹ<EFBFBD><DAB9>ʾ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ù<EFBFBD><C3B9><EFBFBD>Ϊԭ<CEAA><D4AD><EFBFBD>ĵ<EFBFBD> */
|
2024-08-05 02:35:10 +00:00
|
|
|
|
g_duty_ratio = last_duty_ratio;
|
|
|
|
|
Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
step_pwm = step2_pwm;
|
2024-07-11 06:58:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void printf_data(void)
|
|
|
|
|
{
|
|
|
|
|
printf("\n");
|
|
|
|
|
get_CHG_CURR();
|
|
|
|
|
get_PV_VOLT_OUT();
|
|
|
|
|
get_DSG_CURR();
|
2024-08-17 03:14:19 +00:00
|
|
|
|
// get_PV1_VOLT_IN();
|
2024-07-11 06:58:55 +00:00
|
|
|
|
get_PV_VOLT_IN1();
|
|
|
|
|
get_MOSFET_Temper();
|
|
|
|
|
get_PV2_VOLT_IN();
|
|
|
|
|
printf("\n");
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-12 09:34:47 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>㶨<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void mppt_constantVoltage(float InVoltage)
|
2024-07-11 06:58:55 +00:00
|
|
|
|
{
|
2024-08-17 03:14:19 +00:00
|
|
|
|
// static uint8_t ConstantVoltageFlag = 1;
|
|
|
|
|
// float PV1_V = get_PV1_VOLT_IN();
|
|
|
|
|
//
|
|
|
|
|
// if (ConstantVoltageFlag) {
|
|
|
|
|
// if (PV1_V > InVoltage) {
|
|
|
|
|
// g_duty_ratio += step1_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// } else {
|
|
|
|
|
// g_duty_ratio -= step1_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (PV1_V - InVoltage < 0.1) {
|
|
|
|
|
// ConstantVoltageFlag = 0;
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// if (PV1_V > InVoltage) {
|
|
|
|
|
// g_duty_ratio += step2_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// } else {
|
|
|
|
|
// g_duty_ratio -= step2_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (PV1_V - InVoltage > 0.1) {
|
|
|
|
|
// ConstantVoltageFlag = 1;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2024-07-12 09:34:47 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
static float_t kp = 0.05;
|
|
|
|
|
static float_t ki = 0.0001;
|
|
|
|
|
// static float_t allError = 0;
|
2024-07-11 06:58:55 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
// float_t error = (get_PV1_VOLT_IN()) - InVoltage;
|
|
|
|
|
// float_t error = InVoltage - (get_PV2_VOLT_IN());
|
|
|
|
|
// allError += error;
|
2024-07-22 06:20:24 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
float_t pv1Volt = get_PV2_VOLT_IN();
|
|
|
|
|
float_t error = pv1Volt - InVoltage;
|
|
|
|
|
// float_t error = InVoltage - pv1Volt;
|
|
|
|
|
float_t stepPwm = kp * error + ki * pv1Volt;
|
|
|
|
|
g_duty_ratio += stepPwm;
|
|
|
|
|
|
|
|
|
|
// printf("setPwm : %d/10000 \n", (int)(stepPwm * 10000));
|
2024-07-22 06:20:24 +00:00
|
|
|
|
|
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
Set_duty_ratio(&g_duty_ratio);
|
2024-07-11 06:58:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 02:35:10 +00:00
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD>㶨<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѹ
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void mppt_constantVoltageO(float OutVoltage)
|
|
|
|
|
{
|
2024-08-17 03:14:19 +00:00
|
|
|
|
// static uint8_t ConstantVoltageFlag = 1;
|
|
|
|
|
// float PV1_V = get_PV_VOLT_OUT();
|
|
|
|
|
//
|
|
|
|
|
// if (ConstantVoltageFlag) {
|
|
|
|
|
// if (PV1_V > OutVoltage) {
|
|
|
|
|
// g_duty_ratio -= step1_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// } else {
|
|
|
|
|
// g_duty_ratio += step1_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (PV1_V - OutVoltage < 0.1) {
|
|
|
|
|
// ConstantVoltageFlag = 0;
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// if (PV1_V > OutVoltage) {
|
|
|
|
|
// g_duty_ratio -= step2_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// } else {
|
|
|
|
|
// g_duty_ratio += step2_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (PV1_V - OutVoltage > 0.1) {
|
|
|
|
|
// ConstantVoltageFlag = 1;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
static float_t kp = 0.02;
|
|
|
|
|
static float_t ki = 0.00001;
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
float_t outVolt = get_PV_VOLT_OUT();
|
|
|
|
|
// float_t error = outVolt - OutVoltage;
|
|
|
|
|
float_t error = OutVoltage - outVolt;
|
|
|
|
|
float_t stepPwm = kp * error + ki * outVolt;
|
|
|
|
|
g_duty_ratio += stepPwm;
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
printf("setPwm : %d/10000 \n", (int)(stepPwm * 10000));
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
Set_duty_ratio(&g_duty_ratio);
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>ǯλ<EFBFBD><EFBFBD><EFBFBD>㶨<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void mppt_constantCurrentO(float outCurrent)
|
|
|
|
|
{
|
2024-08-17 03:14:19 +00:00
|
|
|
|
// static uint8_t ConstantCurrent = 1;
|
|
|
|
|
// float out_I = get_CHG_CURR();
|
|
|
|
|
//
|
|
|
|
|
// if (ConstantCurrent) {
|
|
|
|
|
// if (out_I > outCurrent) {
|
|
|
|
|
// g_duty_ratio -= step1_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// } else {
|
|
|
|
|
// g_duty_ratio += step1_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (out_I - outCurrent < 0.1) {
|
|
|
|
|
// ConstantCurrent = 0;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// else {
|
|
|
|
|
// if (out_I > outCurrent) {
|
|
|
|
|
// g_duty_ratio -= step2_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// } else {
|
|
|
|
|
// g_duty_ratio += step2_pwm;
|
|
|
|
|
// Set_duty_ratio(&g_duty_ratio);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (out_I - outCurrent > 0.1) {
|
|
|
|
|
// ConstantCurrent = 1;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
static float_t kp = 0.01;
|
|
|
|
|
static float_t ki = 0.0001;
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
// static float_t last_CHG_CURR = 0;
|
|
|
|
|
// static float_t flag = 0;
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
float_t outCurr = get_CHG_CURR();
|
|
|
|
|
float_t error = outCurrent - outCurr;
|
|
|
|
|
// float_t error = outCurr - outCurrent;
|
|
|
|
|
float_t stepPwm = kp * error + ki * outCurr;
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
// if ((last_CHG_CURR > outCurr) && flag) {
|
|
|
|
|
// g_duty_ratio -= stepPwm;
|
|
|
|
|
// } else {
|
|
|
|
|
g_duty_ratio += stepPwm;
|
|
|
|
|
// }
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
printf("setPwm : %d/10000 \n", (int)(stepPwm * 10000));
|
|
|
|
|
|
|
|
|
|
Set_duty_ratio(&g_duty_ratio);
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
// last_CHG_CURR = outCurr;
|
|
|
|
|
// if (stepPwm > 0 && (last_CHG_CURR > outCurr)) {
|
|
|
|
|
// flag = 1;
|
|
|
|
|
// } else {
|
|
|
|
|
// flag = 0;
|
|
|
|
|
// }
|
2024-08-05 02:35:10 +00:00
|
|
|
|
}
|
2024-07-22 06:20:24 +00:00
|
|
|
|
|
2024-07-12 09:02:26 +00:00
|
|
|
|
/**
|
2024-07-12 09:34:47 +00:00
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2024-07-12 09:02:26 +00:00
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void TrickleCharge(void)
|
|
|
|
|
{
|
2024-08-05 02:35:10 +00:00
|
|
|
|
mppt_constantCurrentO(0.7);
|
2024-07-12 09:02:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2024-07-12 09:34:47 +00:00
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>磨<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>磩<EFBFBD><EFBFBD>mppt<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʳ<EFBFBD><EFBFBD><EFBFBD>
|
2024-07-12 09:02:26 +00:00
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void ConstantCurrentCharge(void)
|
|
|
|
|
{
|
2024-07-24 08:57:38 +00:00
|
|
|
|
mppt_readJust();
|
2024-07-12 09:02:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD>ѹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void ConstantVoltageCharge(void)
|
|
|
|
|
{
|
2024-07-24 08:57:38 +00:00
|
|
|
|
mppt_constantVoltage(17.5);
|
2024-07-12 09:02:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
* @param
|
|
|
|
|
* @retval
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
void FloatingCharge(void)
|
|
|
|
|
{
|
2024-08-05 02:35:10 +00:00
|
|
|
|
static uint8_t run_num;
|
|
|
|
|
|
|
|
|
|
if (get_CHG_CURR() > 0.1) {
|
|
|
|
|
mppt_constantVoltageO(12);
|
|
|
|
|
if (run_num++ > 100) {
|
|
|
|
|
if ((get_PV_VOLT_OUT()) < 14) {
|
|
|
|
|
run_num = 0;
|
|
|
|
|
modeFlag = CONSTANTVOLTAGE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
TIM_SetCompare4(TIM4, 0);
|
|
|
|
|
if (run_num++) {
|
|
|
|
|
if ((get_PV_VOLT_OUT()) < 14) {
|
|
|
|
|
run_num = 0;
|
|
|
|
|
modeFlag = CONSTANTVOLTAGE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-12 09:02:26 +00:00
|
|
|
|
|
2024-08-05 02:35:10 +00:00
|
|
|
|
if (run_num > 100) {
|
|
|
|
|
run_num = 0;
|
|
|
|
|
modeFlag = CONSTANTVOLTAGE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (run_num > 200) {
|
|
|
|
|
run_num = 100;
|
|
|
|
|
}
|
2024-07-12 09:02:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-07-12 09:02:26 +00:00
|
|
|
|
void MpptContorl(void)
|
|
|
|
|
{
|
2024-07-24 08:57:38 +00:00
|
|
|
|
switch(modeFlag) {
|
|
|
|
|
case TRICKLE:
|
2024-07-12 09:02:26 +00:00
|
|
|
|
TrickleCharge();
|
2024-07-24 08:57:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CONSTANTCURRENT:
|
2024-07-12 09:02:26 +00:00
|
|
|
|
ConstantCurrentCharge();
|
2024-07-24 08:57:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CONSTANTVOLTAGE:
|
2024-07-12 09:02:26 +00:00
|
|
|
|
ConstantVoltageCharge();
|
2024-07-24 08:57:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FLOAT:
|
2024-07-12 09:02:26 +00:00
|
|
|
|
FloatingCharge();
|
2024-07-24 08:57:38 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MpptMode(void)
|
|
|
|
|
{
|
|
|
|
|
static uint8_t temp_flag = 1;
|
|
|
|
|
static float ConstantCurrentV;
|
|
|
|
|
static float ConstantVoltageV;
|
|
|
|
|
static float FloatI;
|
2024-08-05 02:35:10 +00:00
|
|
|
|
/* <20><>ֵ<EFBFBD><D6B5>ִ<EFBFBD><D6B4>һ<EFBFBD><D2BB> */
|
2024-07-24 08:57:38 +00:00
|
|
|
|
if (temp_flag) {
|
|
|
|
|
ConstantCurrentV = (float)g_slConfigInfo.ConstantCurrentV / 100;
|
|
|
|
|
ConstantVoltageV = (float)g_slConfigInfo.ConstantVoltageV / 100;
|
|
|
|
|
FloatI = (float)g_slConfigInfo.FloatI / 100;
|
|
|
|
|
temp_flag = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((ConstantCurrentV < g_Mppt_Para.Battery_Voltage) &&
|
|
|
|
|
(ConstantVoltageV > g_Mppt_Para.Battery_Voltage)) {
|
|
|
|
|
modeFlag = CONSTANTCURRENT;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(ConstantVoltageV > g_Mppt_Para.Battery_Voltage) &&
|
|
|
|
|
(FloatI < get_CHG_CURR())) {
|
|
|
|
|
modeFlag = CONSTANTVOLTAGE;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 02:35:10 +00:00
|
|
|
|
if ((!(ConstantVoltageV > g_Mppt_Para.Battery_Voltage) &&
|
|
|
|
|
(FloatI > get_CHG_CURR())) || modeFlag == FLOAT) {
|
2024-07-24 08:57:38 +00:00
|
|
|
|
modeFlag = FLOAT;
|
|
|
|
|
return;
|
2024-07-12 09:02:26 +00:00
|
|
|
|
}
|
2024-07-24 08:57:38 +00:00
|
|
|
|
|
|
|
|
|
modeFlag = TRICKLE;
|
|
|
|
|
return;
|
2024-07-12 09:02:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-05 02:35:10 +00:00
|
|
|
|
void findMiNDutyRatio(void)
|
|
|
|
|
{
|
|
|
|
|
static uint8_t num = 100;
|
|
|
|
|
if (0.05 < get_CHG_CURR()) {
|
|
|
|
|
num -= 1;
|
|
|
|
|
TIM_SetCompare4(TIM4, num);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
printf("min duty ratio : %d/200 \n", num);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-07-11 06:58:55 +00:00
|
|
|
|
void test(void)
|
|
|
|
|
{
|
|
|
|
|
// mppt_readjust();
|
|
|
|
|
// Get_OutputPower();
|
2024-08-17 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
// mppt_constantVoltage(17);
|
|
|
|
|
|
2024-08-05 02:35:10 +00:00
|
|
|
|
// findMiNDutyRatio();
|
2024-07-24 08:57:38 +00:00
|
|
|
|
// MpptContorl();
|
2024-07-11 06:58:55 +00:00
|
|
|
|
|
2024-08-05 02:35:10 +00:00
|
|
|
|
// printf_data();
|
2024-07-22 06:20:24 +00:00
|
|
|
|
// void MpptContorl();
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
2024-08-17 03:14:19 +00:00
|
|
|
|
// mppt_constantVoltageO(13);
|
2024-08-05 02:35:10 +00:00
|
|
|
|
// FloatingCharge();
|
2024-08-17 03:14:19 +00:00
|
|
|
|
// mppt_readJust();
|
|
|
|
|
|
|
|
|
|
// mppt_constantCurrentO(1.0);
|
2024-08-05 02:35:10 +00:00
|
|
|
|
|
|
|
|
|
// static uint32_t run_num = 0;
|
|
|
|
|
// if (1000 < run_num++) {
|
|
|
|
|
// FloatingCharge();
|
|
|
|
|
// run_num = 1200;
|
|
|
|
|
// printf("in floatcharge \n");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// mppt_readJust();
|
|
|
|
|
// mppt_constantCurrentO(1.2);
|
2024-08-17 03:14:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// int16_t var = 0;
|
|
|
|
|
// char buff[4];
|
|
|
|
|
// for (var = 0; var < 100; ++var) {
|
|
|
|
|
// sprintf(buff, "%3d:", var);
|
|
|
|
|
// uart_dev_write(g_gw485_uart4_handle, buff, sizeof(buff));
|
|
|
|
|
// uart_dev_write(g_gw485_uart4_handle, "1234567890\n", sizeof("1234567890\n"));
|
|
|
|
|
// Delay_Ms(1);
|
|
|
|
|
// }
|
|
|
|
|
// uart_dev_write(g_gw485_uart4_handle, "\n\n\n\n\n\n", sizeof("\n\n\n\n\n\n"));
|
2024-07-11 06:58:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|