3阶滤波器的效果不好
This commit is contained in:
parent
ddde350bd9
commit
87cfe14c8c
|
@ -5,7 +5,7 @@
|
|||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="742743566734499151" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1096045762461598881" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "debug.h"
|
||||
#include "adc.h"
|
||||
#include "ring_queue2.h"
|
||||
#include "math.h"
|
||||
|
||||
#define adcBuffSize 100
|
||||
typedef struct _ADC_DATA{
|
||||
|
@ -21,6 +22,16 @@ typedef struct _ADC_DATA{
|
|||
}ADC_DATA;
|
||||
extern ADC_DATA g_adcData;
|
||||
|
||||
typedef struct _ADC_DATA1{
|
||||
float_t x1;
|
||||
float_t x2;
|
||||
float_t x3;
|
||||
float_t x4;
|
||||
}ADC_DATA1;
|
||||
extern ADC_DATA1 g_chargCData;
|
||||
extern ADC_DATA1 g_disChargCData;
|
||||
float_t filter3(ADC_DATA1 *ADC_DATA, uint8_t ADC_Channel);
|
||||
|
||||
void currBuffInit(void);
|
||||
void adcChangeProportionalInit(void);
|
||||
|
||||
|
|
|
@ -33,6 +33,8 @@ typedef struct _Mppt_controlparameter{
|
|||
uint16_t excessiveLoadFlagTime; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */
|
||||
uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
|
||||
uint32_t collectOpenCircuitVoltageTime; /* 开路电压采集时间间隔 */
|
||||
|
||||
float_t constantSolarInCircuitV; /* 恒定前端的电压 */
|
||||
} Mppt_controlparameter;
|
||||
extern Mppt_controlparameter g_controlParameter;
|
||||
|
||||
|
@ -93,7 +95,7 @@ typedef struct _Mppt_otherParameter{
|
|||
uint8_t HYconfigModeState; /* HY通信协议是否进入了配置模式,0x00未进入,0xFF进入 */
|
||||
uint8_t HYconfigModeT; /* HY通信协议进入配置模式后的延时时间 */
|
||||
|
||||
uint8_t randomNumber; /* 随机数 */
|
||||
// uint8_t randomNumber; /* 随机数 */
|
||||
}Mppt_otherParameter;
|
||||
extern Mppt_otherParameter g_otherParameter;
|
||||
|
||||
|
|
|
@ -102,6 +102,37 @@ ADC_DATA g_adcData;
|
|||
static uint16_t CHG_buff[adcBuffSize];
|
||||
static uint16_t DSG_buff[adcBuffSize];
|
||||
|
||||
ADC_DATA1 g_chargCData = {0};
|
||||
ADC_DATA1 g_disChargCData = {0};
|
||||
const float_t B[4] = {
|
||||
-0.119456321, 0.5984146595, 0.5984146595, -0.119456321
|
||||
};
|
||||
/**
|
||||
* @brief 3½×Â˲¨Æ÷
|
||||
* @param
|
||||
* @retval None
|
||||
*/
|
||||
float_t filter3(ADC_DATA1 *ADC_DATA, uint8_t ADC_Channel)
|
||||
{
|
||||
float_t out;
|
||||
ADC_DATA->x1 = middleAverageFilter(ADC_Channel);
|
||||
// ADC_DATA->x1 = get_adc(ADC_Channel);
|
||||
|
||||
uint16_t I_ADC;
|
||||
|
||||
I_ADC = B[0] * ADC_DATA->x1
|
||||
+ B[1] * ADC_DATA->x2
|
||||
+ B[2] * ADC_DATA->x3
|
||||
+ B[3] * ADC_DATA->x4;
|
||||
|
||||
ADC_DATA->x2 = ADC_DATA->x1;
|
||||
ADC_DATA->x3 = ADC_DATA->x2;
|
||||
ADC_DATA->x4 = ADC_DATA->x3;
|
||||
|
||||
out = (float)(I_ADC) / 4095 * 2.5 * P_CHG_CURR;
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 初始化电流采集的环形buff
|
||||
* @param
|
||||
|
|
|
@ -302,6 +302,8 @@ void config_info_start(void)
|
|||
readtotalElectricityConsumption(&g_otherParameter.totalElectricityConsumption);
|
||||
readtotalChargCapacity(&g_otherParameter.totalChargCapacity);
|
||||
|
||||
g_controlParameter.constantSolarInCircuitV = 18;
|
||||
|
||||
// printf("");
|
||||
|
||||
printf("%s\n", g_otherParameter.versionInformation);
|
||||
|
|
|
@ -32,9 +32,11 @@ void mppt_constantVoltage(float InVoltage)
|
|||
static float_t kp = 0.005;
|
||||
static float_t ki = 0.00001;
|
||||
|
||||
float_t pv1Volt = g_otherParameter.Solar_In_Circuit_Voltage;
|
||||
float_t error = pv1Volt - InVoltage;
|
||||
float_t stepPwm = kp * error + ki * pv1Volt;
|
||||
// float_t pv1Volt = g_otherParameter.Solar_In_Circuit_Voltage;
|
||||
g_otherParameter.Solar_In_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||
float_t error = g_otherParameter.Solar_In_Circuit_Voltage - InVoltage;
|
||||
// float_t error = InVoltage - g_otherParameter.Solar_In_Circuit_Voltage;
|
||||
float_t stepPwm = kp * error + ki * g_otherParameter.Solar_In_Circuit_Voltage;
|
||||
|
||||
g_controlParameter.dutyRatio += stepPwm;
|
||||
|
||||
|
@ -104,7 +106,7 @@ void mppt_constantVoltageO(float OutVoltage)
|
|||
/* 当有电池时,输出电压的曲线是先上升后下降 */
|
||||
if (lastDutyRatio >= g_controlParameter.dutyRatio) {
|
||||
// if (lastVolt >= outVolt) {
|
||||
g_controlParameter.dutyRatio += StepPwm;
|
||||
g_controlParameter.dutyRatio -= StepPwm;
|
||||
// } else {
|
||||
// g_controlParameter.dutyRatio -= StepPwm;
|
||||
// }
|
||||
|
@ -114,7 +116,7 @@ void mppt_constantVoltageO(float OutVoltage)
|
|||
// } else {
|
||||
// g_controlParameter.dutyRatio += StepPwm;
|
||||
// }
|
||||
g_controlParameter.dutyRatio -= StepPwm;
|
||||
g_controlParameter.dutyRatio += StepPwm;
|
||||
}
|
||||
|
||||
/* 过温保护 */
|
||||
|
@ -141,72 +143,297 @@ void mppt_constantVoltageO(float OutVoltage)
|
|||
* @retval
|
||||
*
|
||||
*/
|
||||
float_t lastPower = 0;
|
||||
float_t lastSolarInCircuitVoltage = 0;
|
||||
void mppt_readJust(void)
|
||||
{
|
||||
static float_t step1 = 0.005;
|
||||
static float_t step2 = 0.001;
|
||||
static float_t tempV = 0.2;
|
||||
/* 调节占空比 */
|
||||
// static float_t step1 = 0.01;
|
||||
// static float_t step2 = 0.003;
|
||||
// static float_t tempV = 0.2;
|
||||
// static float_t i = 0.005;
|
||||
// static uint16_t flag = 0;
|
||||
// static float_t lastSolarInCircuitVoltage = 0;
|
||||
// static float_t lastPower = 0;
|
||||
// flag++;
|
||||
// if (flag < 500) {
|
||||
// return;
|
||||
// }
|
||||
// flag = 0;
|
||||
//
|
||||
// float_t SolarInCircuitVoltage = get_PV1_VOLT_IN();
|
||||
// float_t power = g_otherParameter.Output_Voltage * g_otherParameter.Charg_Current;
|
||||
//
|
||||
// float_t voltageDifference = SolarInCircuitVoltage - lastSolarInCircuitVoltage;
|
||||
//
|
||||
// /* 输出电压随占空比增加电压减小 */
|
||||
// if (power <= lastPower) {
|
||||
// if (lastSolarInCircuitVoltage <= SolarInCircuitVoltage) {
|
||||
// if (voltageDifference > tempV) {
|
||||
// g_controlParameter.dutyRatio += step2 + voltageDifference / i;
|
||||
// } else {
|
||||
// g_controlParameter.dutyRatio += step1 + voltageDifference / i;
|
||||
// }
|
||||
// } else {
|
||||
// if (voltageDifference < -tempV) {
|
||||
// g_controlParameter.dutyRatio -= step2 + voltageDifference / i;
|
||||
// } else {
|
||||
// g_controlParameter.dutyRatio -= step1 + voltageDifference / i;
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// if (lastSolarInCircuitVoltage <= SolarInCircuitVoltage) {
|
||||
// if (voltageDifference > tempV) {
|
||||
// g_controlParameter.dutyRatio -= step2 - voltageDifference / i;
|
||||
// } else {
|
||||
// g_controlParameter.dutyRatio -= step1 - voltageDifference / i;
|
||||
// }
|
||||
// } else {
|
||||
// if (voltageDifference < -tempV) {
|
||||
// g_controlParameter.dutyRatio += step2 - voltageDifference / i;
|
||||
// } else {
|
||||
// g_controlParameter.dutyRatio += step1 - voltageDifference / i;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// lastPower = power;
|
||||
// lastSolarInCircuitVoltage = SolarInCircuitVoltage;
|
||||
//
|
||||
// Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
|
||||
|
||||
/* 调节电压,变步长调节 */
|
||||
// static float_t Power3 = 0; //上上次功率
|
||||
// static float_t Power2 = 0; //上次功率
|
||||
// static float_t Power1 = 0; //当前功率
|
||||
// static float_t power23 = 0; //上次和上上次功率的绝对值
|
||||
// static float_t power12 = 0; //当前功率和上次功率的绝对值
|
||||
//// static float_t SolarInCircuitVoltage3 = 0; //上上次太阳能板电压
|
||||
// static float_t SolarInCircuitVoltage2 = 0; //上次太阳能板电压
|
||||
// static float_t SolarInCircuitVoltage1 = 0; //当前太阳能板电压
|
||||
// static float_t SolarInCircuitVoltage12 = 0; //当前太阳能板电压和上次太阳能板电压的绝对值
|
||||
// SolarInCircuitVoltage1 = get_PV1_VOLT_IN();
|
||||
// Power1 = g_otherParameter.Output_Voltage * g_otherParameter.Charg_Current;
|
||||
// static float_t power12Abs = 0;
|
||||
// static float_t power23Abs = 0;
|
||||
// static float_t SolarInCircuitVoltage12Abs = 0;
|
||||
// static float_t dk = 0; //变步长因子
|
||||
// static float_t stepV = 0;
|
||||
// static float_t SolarInCircuitV = 18; //控制太阳能板的输出电压稳定在该值
|
||||
//
|
||||
// static float_t kp = 0.005;
|
||||
// static float_t ki = 0.00001;
|
||||
//
|
||||
// /* 延时一段时间才判断 */
|
||||
// static uint16_t flag = 0;
|
||||
// flag++;
|
||||
// if (flag < 1000) {
|
||||
//// float_t pv1Volt = g_otherParameter.Solar_In_Circuit_Voltage;
|
||||
// float_t pv1Volt = SolarInCircuitVoltage1;
|
||||
// float_t error = pv1Volt - SolarInCircuitV;
|
||||
// float_t stepPwm = kp * error + ki * pv1Volt;
|
||||
//
|
||||
// g_controlParameter.dutyRatio += stepPwm;
|
||||
//
|
||||
// /* 过温保护 */
|
||||
// if (g_otherParameter.overTemperature == 0) {
|
||||
//
|
||||
// } else if (g_otherParameter.overTemperature == 1) {
|
||||
// g_controlParameter.dutyRatio -= 0.1;
|
||||
// } else if (g_otherParameter.overTemperature == 2) {
|
||||
// g_controlParameter.dutyRatio -= 0.2;
|
||||
// } else if (g_otherParameter.overTemperature == 3) {
|
||||
// g_controlParameter.dutyRatio -= 0.3;
|
||||
// }
|
||||
//
|
||||
// Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
//
|
||||
// return;
|
||||
// }
|
||||
// flag = 0;
|
||||
//
|
||||
// power23 = Power2 - Power3;
|
||||
// if (power23 < 0) {
|
||||
// power23Abs = -power23;
|
||||
// } else {
|
||||
// power23Abs = power23;
|
||||
// }
|
||||
//
|
||||
// power12 = Power1 - Power2;
|
||||
// if (power12 < 0) {
|
||||
// power12Abs = -power12;
|
||||
// } else {
|
||||
// power12Abs = power12;
|
||||
// }
|
||||
//
|
||||
//// SolarInCircuitVoltage23 = SolarInCircuitVoltage2 - SolarInCircuitVoltage3;
|
||||
//
|
||||
// SolarInCircuitVoltage12 = SolarInCircuitVoltage1 - SolarInCircuitVoltage2;
|
||||
//
|
||||
// dk = power12Abs / power23Abs;
|
||||
// stepV = dk * SolarInCircuitVoltage12Abs;
|
||||
//
|
||||
//// printf(" dk : %d/10000 \n", (int)(dk * 10000));
|
||||
//
|
||||
// if (power12 > 0) {
|
||||
// if (SolarInCircuitVoltage12 > 0) {
|
||||
// SolarInCircuitV = SolarInCircuitVoltage1 + stepV;
|
||||
// } else {
|
||||
// SolarInCircuitV = SolarInCircuitVoltage1 - stepV;
|
||||
// }
|
||||
// } else {
|
||||
// if (SolarInCircuitVoltage12 > 0) {
|
||||
// SolarInCircuitV = SolarInCircuitVoltage1 - stepV;
|
||||
// } else {
|
||||
// SolarInCircuitV = SolarInCircuitVoltage1 + stepV;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// printf(" SolarInCircuitV : %d/100 \n", (int)(SolarInCircuitV * 100));
|
||||
//
|
||||
// if (SolarInCircuitV > 21) {
|
||||
// SolarInCircuitV = 21;
|
||||
// }
|
||||
// else if (SolarInCircuitV < 15) {
|
||||
// SolarInCircuitV = 15;
|
||||
// }
|
||||
//
|
||||
// printf(" SolarInCircuitV : %d/100 \n", (int)(SolarInCircuitV * 100));
|
||||
//
|
||||
// Power3 = Power2;
|
||||
// Power2 = Power1;
|
||||
//// SolarInCircuitVoltage3 = SolarInCircuitVoltage2;
|
||||
// SolarInCircuitVoltage2 = SolarInCircuitVoltage1;
|
||||
//
|
||||
//// float_t pv1Volt = g_otherParameter.Solar_In_Circuit_Voltage;
|
||||
// float_t pv1Volt = SolarInCircuitVoltage1;
|
||||
// float_t error = pv1Volt - SolarInCircuitV;
|
||||
// float_t stepPwm = kp * error + ki * pv1Volt;
|
||||
//
|
||||
// g_controlParameter.dutyRatio += stepPwm;
|
||||
//
|
||||
// /* 过温保护 */
|
||||
// if (g_otherParameter.overTemperature == 0) {
|
||||
//
|
||||
// } else if (g_otherParameter.overTemperature == 1) {
|
||||
// g_controlParameter.dutyRatio -= 0.1;
|
||||
// } else if (g_otherParameter.overTemperature == 2) {
|
||||
// g_controlParameter.dutyRatio -= 0.2;
|
||||
// } else if (g_otherParameter.overTemperature == 3) {
|
||||
// g_controlParameter.dutyRatio -= 0.3;
|
||||
// }
|
||||
//
|
||||
// Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
//
|
||||
// return;
|
||||
|
||||
/* 调节电压,两个电压步调节 */
|
||||
g_otherParameter.Solar_In_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||
static float_t Power = 0;
|
||||
Power = g_otherParameter.Output_Voltage * g_otherParameter.Charg_Current;
|
||||
static float_t lPower = 0;
|
||||
// static float_t lLPower = 0;
|
||||
// static float_t lLLPower = 0;
|
||||
|
||||
static float_t SolarInCircuitV = 17; //控制太阳能板的输出电压稳定在该值
|
||||
static float_t kp = 0.005;
|
||||
static float_t ki = 0.00001;
|
||||
|
||||
static float_t stepV1 = 0.5;
|
||||
static float_t stepV2 = 0.2;
|
||||
|
||||
static uint8_t flag1 = 0; //表明上次运算是加还是减
|
||||
|
||||
/* 延时一段时间才判断 */
|
||||
static uint16_t flag = 0;
|
||||
flag++;
|
||||
if (flag < 1000) {
|
||||
if (flag < 150) {
|
||||
float_t pv1Volt = g_otherParameter.Solar_In_Circuit_Voltage;
|
||||
float_t error = pv1Volt - SolarInCircuitV;
|
||||
float_t stepPwm = kp * error + ki * pv1Volt;
|
||||
|
||||
g_controlParameter.dutyRatio += stepPwm;
|
||||
|
||||
/* 过温保护 */
|
||||
if (g_otherParameter.overTemperature == 0) {
|
||||
|
||||
} else if (g_otherParameter.overTemperature == 1) {
|
||||
g_controlParameter.dutyRatio -= 0.1;
|
||||
} else if (g_otherParameter.overTemperature == 2) {
|
||||
g_controlParameter.dutyRatio -= 0.2;
|
||||
} else if (g_otherParameter.overTemperature == 3) {
|
||||
g_controlParameter.dutyRatio -= 0.3;
|
||||
}
|
||||
|
||||
Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
|
||||
return;
|
||||
}
|
||||
flag = 0;
|
||||
|
||||
float_t SolarInCircuitVoltage = get_PV1_VOLT_IN();
|
||||
float_t power = g_otherParameter.Output_Voltage * g_otherParameter.Charg_Current;
|
||||
static float_t powerT = 0;
|
||||
powerT = Power - lPower;
|
||||
if (powerT < 0) {
|
||||
powerT = -powerT;
|
||||
}
|
||||
|
||||
float_t voltageDifference = SolarInCircuitVoltage - lastSolarInCircuitVoltage;
|
||||
|
||||
/* 输出电压随占空比增加电压减小 */
|
||||
if (power <= lastPower) {
|
||||
if (lastSolarInCircuitVoltage <= SolarInCircuitVoltage) {
|
||||
if (voltageDifference > tempV) {
|
||||
g_controlParameter.dutyRatio += step2;
|
||||
// if ((lPower + 0.7 < Power) && (lLPower + 0.7 < Power) && (lLLPower + 0.7 < Power)) {
|
||||
// if ((lPower + 0.7 < Power) && (lLPower + 0.7 < Power)) {
|
||||
if ((lPower + 0.3 < Power)) {
|
||||
if (powerT > 5) {
|
||||
if (flag1) {
|
||||
SolarInCircuitV += stepV1;
|
||||
flag1 = 1;
|
||||
} else {
|
||||
g_controlParameter.dutyRatio += step1;
|
||||
SolarInCircuitV -= stepV1;
|
||||
flag1 = 0;
|
||||
}
|
||||
} else {
|
||||
if (voltageDifference > tempV) {
|
||||
g_controlParameter.dutyRatio -= step2;
|
||||
if (flag1) {
|
||||
SolarInCircuitV += stepV2;
|
||||
flag1 = 1;
|
||||
} else {
|
||||
g_controlParameter.dutyRatio -= step1;
|
||||
SolarInCircuitV -= stepV2;
|
||||
flag1 = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (lastSolarInCircuitVoltage <= SolarInCircuitVoltage) {
|
||||
if (voltageDifference > tempV) {
|
||||
g_controlParameter.dutyRatio -= step2;
|
||||
// } else if ((lPower - 0.7 > Power) && (lLPower - 0.7 > Power) && (lLLPower - 0.7 > Power)) {
|
||||
// } else if ((lPower - 0.7 > Power) && (lLPower - 0.7 > Power)) {
|
||||
} else if ((lPower - 0.3 > Power)) {
|
||||
if (powerT > 5) {
|
||||
if (flag1) {
|
||||
SolarInCircuitV -= stepV1;
|
||||
flag1 = 0;
|
||||
} else {
|
||||
g_controlParameter.dutyRatio -= step1;
|
||||
SolarInCircuitV += stepV1;
|
||||
flag1 = 1;
|
||||
}
|
||||
} else {
|
||||
if (voltageDifference > tempV) {
|
||||
g_controlParameter.dutyRatio += step2;
|
||||
if (flag1) {
|
||||
SolarInCircuitV -= stepV2;
|
||||
flag1 = 0;
|
||||
} else {
|
||||
g_controlParameter.dutyRatio += step1;
|
||||
SolarInCircuitV += stepV2;
|
||||
flag1 = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lastPower = power;
|
||||
lastSolarInCircuitVoltage = SolarInCircuitVoltage;
|
||||
|
||||
/* 过温保护 */
|
||||
if (g_otherParameter.overTemperature == 0) {
|
||||
|
||||
} else if (g_otherParameter.overTemperature == 1) {
|
||||
g_controlParameter.dutyRatio -= 0.1;
|
||||
} else if (g_otherParameter.overTemperature == 2) {
|
||||
g_controlParameter.dutyRatio -= 0.2;
|
||||
} else if (g_otherParameter.overTemperature == 3) {
|
||||
g_controlParameter.dutyRatio -= 0.3;
|
||||
if (SolarInCircuitV > 18.5) {
|
||||
SolarInCircuitV = 18.5;
|
||||
}
|
||||
else if (SolarInCircuitV < 16) {
|
||||
SolarInCircuitV = 16;
|
||||
}
|
||||
|
||||
Set_duty_ratio(&g_controlParameter.dutyRatio);
|
||||
// lLLPower = lLPower;
|
||||
// lLPower = lPower;
|
||||
lPower = Power;
|
||||
|
||||
// printf(" SolarInCircuitV : %d/100 \n", (int)(SolarInCircuitV * 100));
|
||||
// printf(" lPower : %d/1000 \n", (int)(lPower * 1000));
|
||||
// printf(" lLPower : %d/1000 \n", (int)(lLPower * 1000));
|
||||
// printf(" lLLPower : %d/1000 \n", (int)(lLLPower * 1000));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -218,7 +445,7 @@ void mppt_readJust(void)
|
|||
*/
|
||||
void ConstantCurrentCharge(void)
|
||||
{
|
||||
// mppt_constantVoltage(18);
|
||||
// mppt_constantVoltage(g_controlParameter.constantSolarInCircuitV);
|
||||
mppt_readJust();
|
||||
}
|
||||
|
||||
|
@ -302,7 +529,7 @@ void MpptModeChoice(void)
|
|||
// g_otherParameter.batteryState = 0;
|
||||
// return;
|
||||
// }
|
||||
if (g_otherParameter.Battery_Voltage > 16 || g_otherParameter.Battery_Voltage < 8) {
|
||||
if (g_otherParameter.Battery_Voltage > 16 || g_otherParameter.Battery_Voltage < 10) {
|
||||
g_otherParameter.MPPT_Mode = FLOAT;
|
||||
g_otherParameter.batteryState = 0;
|
||||
return;
|
||||
|
@ -358,7 +585,7 @@ void MpptContorl(void)
|
|||
if (!g_otherParameter.overTemperature) {
|
||||
// mppt_constantVoltageNoBatteryO(g_controlParameter.FloatV);
|
||||
|
||||
mppt_constantVoltageO(g_controlParameter.FloatV);
|
||||
mppt_constantVoltageNoBatteryO(g_controlParameter.FloatV);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ void Init()
|
|||
POW_FF_CON_Init();
|
||||
DSG_PROT_Init();
|
||||
|
||||
// while(1);
|
||||
|
||||
// for (int var = 0; var < 50; ++var) {
|
||||
// USART_Tbuffer[var] = var;
|
||||
// }
|
||||
|
@ -68,6 +70,21 @@ void Init()
|
|||
// };
|
||||
// send_init();
|
||||
|
||||
// RCC_PB2PeriphClockCmd(RCC_PB2Periph_GPIOB, ENABLE);
|
||||
// GPIO_InitTypeDef GPIO_InitStructure;
|
||||
// GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
|
||||
// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //推挽输出
|
||||
// GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
|
||||
// GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
// GPIO_WriteBit(GPIOB, GPIO_Pin_3, SET);
|
||||
//
|
||||
// Delay_Ms(1000);
|
||||
// TIM_SetCompare4(TIM4, 400);
|
||||
// GPIO_WriteBit(GPIOB, GPIO_Pin_3, RESET);
|
||||
// while (1) {
|
||||
//
|
||||
// }
|
||||
|
||||
/* 1ms */
|
||||
TIM3_Init(10);
|
||||
|
||||
|
@ -134,10 +151,11 @@ void Task_WdiRunled(void)
|
|||
|
||||
/* ι¹· */
|
||||
GPIO_WriteBit(WDI_INPUT_GPIO, WDI_INPUT_PIN, SET);
|
||||
// Delay_Us(100);
|
||||
GPIO_WriteBit(WDI_INPUT_GPIO, WDI_INPUT_PIN, RESET);
|
||||
|
||||
srand(TIM_GetCounter(TIM4));
|
||||
g_otherParameter.randomNumber = 1 + rand() % 10;
|
||||
// srand(TIM_GetCounter(TIM4));
|
||||
// g_otherParameter.randomNumber = 1 + rand() % 10;
|
||||
|
||||
// if (USART_RbufferLen != 0) {
|
||||
// printf("%s\n", USART_Rbuffer);
|
||||
|
@ -146,6 +164,12 @@ void Task_WdiRunled(void)
|
|||
//
|
||||
// }
|
||||
|
||||
// printf(" 0.没有工作; 1.恒流模式; 2.恒压模式; 3.浮充模式 : %d \n", g_otherParameter.MPPT_Mode);
|
||||
// printf(" duty_ratio : %d/1000 \n", (int)(g_controlParameter.dutyRatio * 1000));
|
||||
// printf(" vout : %d/100 \n", (int)(g_otherParameter.Output_Voltage * 100));
|
||||
// printf(" mosState : %d \n", (int)(g_otherParameter.DischargMos_State));
|
||||
// printf(" Iout : %d/100 \n", (int)(g_otherParameter.Charg_Current * 100));
|
||||
|
||||
// printf(" vBattery : %d/100 \n", (int)(g_otherParameter.Battery_Voltage * 100));
|
||||
|
||||
uart_dev_write(g_bat485_uart3_handle, " \n", sizeof(" \n"));
|
||||
|
@ -216,7 +240,6 @@ void Task_WdiRunled(void)
|
|||
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||
|
||||
uart_dev_write(g_bat485_uart3_handle, " \n", sizeof(" \n"));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -752,6 +775,10 @@ void Task_collectOpenCircuitVoltage(void)
|
|||
if (g_collectOpenCircuitVoltageFlag) {
|
||||
g_collectOpenCircuitVoltageFlag = 0;
|
||||
g_otherParameter.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||
g_controlParameter.constantSolarInCircuitV = 0.78 * g_otherParameter.Solar_Open_Circuit_Voltage;
|
||||
if (g_controlParameter.constantSolarInCircuitV > 20 || g_controlParameter.constantSolarInCircuitV < 16) {
|
||||
g_controlParameter.constantSolarInCircuitV = 18;
|
||||
}
|
||||
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,31 +59,31 @@ void send_init(void)
|
|||
*/
|
||||
void check_sendState(void)
|
||||
{
|
||||
static uint8_t tempGwT = 0;
|
||||
static uint8_t tempBatT = 0;
|
||||
/* 进入空闲中断一段时间后,仍然没有数据到来判断485总线空闲 */
|
||||
if (!uart_send.GwState) {
|
||||
if (uart_send.idleStateGw) {
|
||||
tempGwT++;
|
||||
if (tempGwT >= g_otherParameter.randomNumber) {
|
||||
uart_send.GwState = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tempGwT = 0;
|
||||
}
|
||||
|
||||
/* 进入空闲中断一段时间后,仍然没有数据到来判断485总线空闲 */
|
||||
if (!uart_send.BatState) {
|
||||
if (uart_send.idleStateBat) {
|
||||
tempBatT++;
|
||||
if (tempBatT >= g_otherParameter.randomNumber) {
|
||||
uart_send.BatState = 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
tempBatT = 0;
|
||||
}
|
||||
// static uint8_t tempGwT = 0;
|
||||
// static uint8_t tempBatT = 0;
|
||||
// /* 进入空闲中断一段时间后,仍然没有数据到来判断485总线空闲 */
|
||||
// if (!uart_send.GwState) {
|
||||
// if (uart_send.idleStateGw) {
|
||||
// tempGwT++;
|
||||
// if (tempGwT >= g_otherParameter.randomNumber) {
|
||||
// uart_send.GwState = 1;
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// tempGwT = 0;
|
||||
// }
|
||||
//
|
||||
// /* 进入空闲中断一段时间后,仍然没有数据到来判断485总线空闲 */
|
||||
// if (!uart_send.BatState) {
|
||||
// if (uart_send.idleStateBat) {
|
||||
// tempBatT++;
|
||||
// if (tempBatT >= g_otherParameter.randomNumber) {
|
||||
// uart_send.BatState = 1;
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// tempBatT = 0;
|
||||
// }
|
||||
|
||||
/* 向上通信总线空闲时,检测到有数据需要发送,同时上一次数据发送完成 */
|
||||
// if (uart_send.GwState && uart_send.sendStateGw && uart_send.sendOverStateGw) {
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define HARDWARE_SPI_FLASH_H_
|
||||
|
||||
#include "ch32l103.h"
|
||||
|
||||
|
||||
|
||||
/*****************************************
|
||||
*@Note
|
||||
|
|
|
@ -112,6 +112,8 @@ void TIM2_IRQHandler(void)
|
|||
|
||||
g_otherParameter.Charg_Current = get_CHG_CURR();
|
||||
g_otherParameter.Discharg_Current = get_DSG_CURR();
|
||||
// g_otherParameter.Charg_Current = filter3(&g_chargCData, ADC_Channel_1);
|
||||
// g_otherParameter.Discharg_Current = filter3(&g_disChargCData, ADC_Channel_3);
|
||||
|
||||
// totalChargCapacity += g_otherParameter.Charg_Current * g_otherParameter.Output_Voltage;
|
||||
// totalElectricityConsumption += g_otherParameter.Discharg_Current * g_otherParameter.Output_Voltage;
|
||||
|
@ -184,7 +186,7 @@ void TIM1_UP_IRQHandler(void)
|
|||
{
|
||||
if (TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET) { //检查TIM1中断是否发生。
|
||||
TIM_ClearITPendingBit(TIM1, TIM_IT_Update); //清除TIM1的中断挂起位。
|
||||
printf("in tim1 irq \n");
|
||||
// printf("in tim1 irq \n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ int main(void)
|
|||
// printf("SystemClk:%d\r\n", SystemCoreClock);
|
||||
// printf("ChipID:%08x\r\n", DBGMCU_GetCHIPID());
|
||||
|
||||
// Delay_Ms(10000);
|
||||
Delay_Ms(10000);
|
||||
|
||||
Init();
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
obj/User/main.o
BIN
obj/User/main.o
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
30125
obj/mppt_Nos_V0.4.lst
30125
obj/mppt_Nos_V0.4.lst
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue