电流大时回路阻抗问题较大

This commit is contained in:
起床就犯困 2024-08-29 17:24:57 +08:00
parent e12fc66caa
commit 228f632d95
17 changed files with 11116 additions and 11044 deletions

View File

@ -11,7 +11,7 @@
#include "timeSliceOffset.h"
#include "uart_dev.h"
#include "math.h"
void stop_mpptWork(void);
void start_mpptWork(void);
@ -19,12 +19,12 @@ void start_mpptWork(void);
#define runled_reloadVal 1000 /* 任务执行间隔 */
#define runled_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_runled;
void Task_RunLED(void);
extern void Task_RunLED(void);
#define startMpptControl_reloadVal 1000 /* 任务执行间隔 */
#define startMpptControl_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_startMpptControl;;
void Task_startMpptControl(void);
extern void Task_startMpptControl(void);
#define softStart_reloadVal 30 /* 任务执行间隔 */
#define softStart_offset 0 /* 任务执行偏移量 */
@ -41,13 +41,13 @@ void Task_usart(void);
#define wdi_offset 30 /* 任务执行偏移量 */
#define wdi_RESET (60 * 60 * 24) /* 一天复位一次 */
extern STR_TimeSliceOffset m_wdi;
void Task_wdi(void);
extern void Task_wdi(void);
#define refreshRegister_reloadVal 1000 /* 任务执行间隔 */
#define refreshRegister_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_refreshRegister;
extern uint8_t overTemperature;
void Task_refreshRegister(void);
extern void Task_refreshRegister(void);
#define recvbroadcast_reloadVal 3000 /* 任务执行间隔 */
#define recvbroadcast_offset 0 /* 任务执行偏移量 */
@ -55,20 +55,27 @@ extern uint8_t recvbroadcast_flag; /*
extern device_handle g_recvBroadcastDevice; /* 串口句柄 */
extern uint8_t g_recvBroadcastRegisterNumber; /* 寄存器长度 */
extern STR_TimeSliceOffset m_recvbroadcast;
void Task_recvbroadcast(void);
extern void Task_recvbroadcast(void);
#define outputAgain_reloadVal 1000 /* 任务执行间隔 */
#define outputAgain_offset 30 /* 任务执行偏移量 */
#define impedanceCalculation_reloadVal 1000 /* 任务执行间隔 */
#define impedanceCalculation_offset 0 /* 任务执行偏移量 */
extern float_t g_impedance;
extern float_t voltOut;
extern STR_TimeSliceOffset m_impedanceCalculation;
extern void Task_impedanceCalculation(void);
#define outputAgain_reloadVal 2 /* 任务执行间隔 */
#define outputAgain_offset 0 /* 任务执行偏移量 */
extern uint8_t outputAgainFlag;
extern STR_TimeSliceOffset m_outputAgain;
void Task_outputAgain(void);
extern void Task_outputAgain(void);
#define sensorEnableBroadcast_reloadVal 1000 /* 任务执行间隔 */
#define sensorEnableBroadcast_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset m_sensorEnableBroadcast;
/* 是否接收广播帧标志位 */
extern uint8_t run_Broadcast;
void Task_sensorEnableBroadcast(void);
extern void Task_sensorEnableBroadcast(void);
void task_Init(void);
void hardware_Init(void);

View File

@ -21,9 +21,9 @@ config_info g_slConfigInfo = {
.registerRefreshTime = 1,
.resRefreshTime = 1,
.sensorEnableBroadcastTime = 20,
.HighSideMosTemperature_stop = 90,
.HighSideMosTemperature_end = 70,
.HighSideMosTemperature_start = 50,
.HighSideMosTemperature_stop = 70,
.HighSideMosTemperature_end = 50,
.HighSideMosTemperature_start = 40,
};

View File

@ -281,13 +281,14 @@ void mppt_constantVoltageO(float OutVoltage)
// }
// }
static float_t kp = 0.02;
static float_t ki = 0.00001;
static float_t kp = 0.0005;
static float_t ki = 0.000001;
// static float_t kp = 0.1;
// static float_t ki = 0.001;
// float_t outVolt = get_PV_VOLT_OUT();
float_t outVolt = g_Mppt_Para.Battery_Voltage;
// float_t outVolt = voltOut;
// float_t error = outVolt - OutVoltage;
float_t error = OutVoltage - outVolt;
float_t stepPwm = kp * error + ki * outVolt;
@ -445,6 +446,7 @@ void FloatingCharge(void)
num = 0;
ConstantVoltageCharge();
g_Mppt_Para.MPPT_Mode = CONSTANTVOLTAGE;
// printf("float charge \n");
}
}
@ -466,11 +468,20 @@ void NoBatteryCharge(void)
mppt_constantVoltageO(NoBatteryChargeV);
if ((g_Mppt_Para.Battery_Voltage - NoBatteryChargeV > 0.1 && g_Mppt_Para.Charg_Current < 0.1)
|| (NoBatteryChargeV - g_Mppt_Para.Battery_Voltage > 0.1 && g_Mppt_Para.Charg_Current > 0.5)) {
// if ((g_Mppt_Para.Battery_Voltage - NoBatteryChargeV > 0.2 && g_Mppt_Para.Charg_Current < 0.1)
// || (NoBatteryChargeV - g_Mppt_Para.Battery_Voltage > 0.1 && g_Mppt_Para.Charg_Current > 0.5)) {
// ConstantCurrentCharge();
// g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
// }
if (!overTemperature) {
if (!(g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current < 0.3
&& g_Mppt_Para.Discharg_Current - g_Mppt_Para.Charg_Current < 0.3)) {
ConstantCurrentCharge();
g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
}
}
}
void MpptContorl(void)
@ -607,13 +618,21 @@ void MpptMode(void)
&& (g_Mppt_Para.Discharg_Current >= g_Mppt_Para.Charg_Current
|| g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current < 0.05)) {
g_Mppt_Para.MPPT_Mode = NoWork;
stop_mpptWork();
TimeSliceOffset_Register(&m_startMpptControl, Task_startMpptControl
, startMpptControl_reloadVal, startMpptControl_offset);
return;
}
if ((g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current < 0.03
&& g_Mppt_Para.Discharg_Current - g_Mppt_Para.Charg_Current < 0.03)
|| g_Mppt_Para.Battery_Voltage < 6
|| g_Mppt_Para.Battery_Voltage > 16
|| g_Mppt_Para.MPPT_Mode == NoBattery) {
g_Mppt_Para.MPPT_Mode = NoBattery;
return;
}
if (((ConstantVoltageV < g_Mppt_Para.Battery_Voltage) &&
(FloatI > g_Mppt_Para.Charg_Current)) || g_Mppt_Para.MPPT_Mode == FLOAT) {
g_Mppt_Para.MPPT_Mode = FLOAT;
@ -628,6 +647,9 @@ void MpptMode(void)
if ((ConstantVoltageV < g_Mppt_Para.Battery_Voltage) &&
(FloatI + 0.1 <= g_Mppt_Para.Charg_Current)) {
// printf("mppt mode \n");
// printf(" vout : %d/100 \n", (int)(g_Mppt_Para.Battery_Voltage * 100));
g_Mppt_Para.MPPT_Mode = CONSTANTVOLTAGE;
return;
}
@ -637,11 +659,7 @@ void MpptMode(void)
return;
}
if (g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current < 0.03
&& g_Mppt_Para.Discharg_Current - g_Mppt_Para.Charg_Current < 0.03) {
g_Mppt_Para.MPPT_Mode = NoBattery;
return;
}
}
void findMiNDutyRatio(void)
@ -677,11 +695,22 @@ void test(void)
// mppt_constantCurrentO(1);
g_Mppt_Para.Battery_Voltage = get_capturedata(get_PV_VOLT_OUT);
g_Mppt_Para.Charg_Current = get_capturedata(get_CHG_CURR);
g_Mppt_Para.Discharg_Current = get_capturedata(get_DSG_CURR);
// if (g_Mppt_Para.MPPT_Mode == CONSTANTCURRENT
// || g_Mppt_Para.MPPT_Mode == CONSTANTVOLTAGE) {
//
// g_Mppt_Para.Battery_Voltage = get_capturedata(get_PV_VOLT_OUT)
// - g_impedance * (g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current);
// } else {
g_Mppt_Para.Battery_Voltage = get_capturedata(get_PV_VOLT_OUT);
// }
// voltOut = get_capturedata(get_PV_VOLT_OUT);
// g_Mppt_Para.Battery_Voltage = voltOut - g_impedance * (g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current);
if (!overTemperature) {
MpptMode();
}

View File

@ -27,8 +27,8 @@ void stop_mpptWork(void)
{
GPIO_WriteBit(EnPowerSupply_GPIO, EnPowerSupply_PIN, SET);
g_duty_ratio = 0.7;
TIM_SetCompare4(TIM4, 0);
TIM_Cmd(TIM3, DISABLE);
TIM_SetCompare4(TIM4, 0);
// TimeSliceOffset_Register(&m_startMpptControl, Task_startMpptControl
// , startMpptControl_reloadVal, startMpptControl_offset);
// GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
@ -38,8 +38,8 @@ void stop_mpptWork(void)
void start_mpptWork(void)
{
// GPIO_WriteBit(EnPowerSupply_GPIO, EnPowerSupply_PIN, RESET);
g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
TIM_Cmd(TIM3, ENABLE);
g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
// TimeSliceOffset_Unregister(&m_startMpptControl);
// Delay_Ms(500);
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, SET);
@ -56,6 +56,8 @@ void Task_RunLED(void)
// uart_sendstr(g_gw485_uart4_handle, "\n\n\n\n\n");
// uart_sendstr(g_gw485_uart4_handle, "is gw485\n");
// uart_sendstr(g_bat485_uart3_handle, "is bat485\n");get_PV1_VOLT_IN();
printf(" \n");
printf(" duty_ratio : %d/1000 \n", (int)(g_duty_ratio * 1000));
printf(" vout : %d/100 \n", (int)(g_Mppt_Para.Battery_Voltage * 100));
@ -68,6 +70,7 @@ void Task_RunLED(void)
printf(" 0.没有工作; 1.涓流模式; 2.恒流模式; 3.恒压模式; 4.浮充模式; 5.没有电池 : %d \n", g_Mppt_Para.MPPT_Mode);
printf(" \n");
// printf("vout : %d/100 \n", (int)(get_capturedata(get_PV_VOLT_OUT) * 100));
@ -110,6 +113,7 @@ void Task_startMpptControl(void)
> ((float_t)g_slConfigInfo.startSolarOpenCircuitV / 100)) {
// start_mpptWork();
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
TimeSliceOffset_Unregister(&m_startMpptControl);
}
}
return;
@ -130,7 +134,6 @@ void Task_softStart(void)
if (num == 1) {
GPIO_WriteBit(EnPowerSupply_GPIO, EnPowerSupply_PIN, RESET);
TimeSliceOffset_Unregister(&m_startMpptControl);
}
if (num < 5) {
@ -185,10 +188,6 @@ void Task_wdi(void)
return;
}
/**
* @brief ,mos管温度
* @param
@ -232,9 +231,6 @@ void Task_refreshRegister(void)
}
}
/**
* @brief 广,3s
* @param
@ -327,6 +323,55 @@ void Task_recvbroadcast(void)
}
}
/**
* @brief
* @param
* @retval
*/
STR_TimeSliceOffset m_impedanceCalculation;
float_t g_impedance = 0; /* 回路阻抗的值 */
float_t voltOut = 0; /* 输出电压的值 */
void Task_impedanceCalculation(void)
{
static uint8_t num = 0;
static float_t currOne = 0;
static float_t voltOne = 0;
static float_t currTwo = 0;
static float_t voltTwo = 0;
if (g_Mppt_Para.MPPT_Mode == CONSTANTCURRENT
|| g_Mppt_Para.MPPT_Mode == CONSTANTVOLTAGE) {
++num;
} else {
num = 0;
}
if (num == 10) {
num = 0;
TIM_Cmd(TIM3, DISABLE);
TIM_SetCompare4(TIM4, 420);
Delay_Ms(5);
currOne = get_capturedata(get_CHG_CURR) - get_capturedata(get_DSG_CURR);
voltOne = get_capturedata(get_PV_VOLT_OUT);
TIM_SetCompare4(TIM4, 350);
Delay_Ms(5);
currTwo = get_capturedata(get_CHG_CURR) - get_capturedata(get_DSG_CURR);
voltTwo = get_capturedata(get_PV_VOLT_OUT);
g_impedance = (voltOne - voltTwo) / (currOne - currTwo);
printf("currOne = %d/1000, voltOne = %d/100 \n", (int)(currOne * 1000), (int)(voltOne * 100));
printf("currTwo = %d/1000, voltTwo = %d/100 \n", (int)(currTwo * 1000), (int)(voltTwo * 100));
printf("Res = %d/1000, E = %d/100 \n", (int)(g_impedance * 1000), (int)((voltTwo - currTwo * g_impedance) * 100));
TIM_Cmd(TIM3, ENABLE);
}
return;
}
/**
* @brief
* @param
@ -336,6 +381,7 @@ STR_TimeSliceOffset m_outputAgain;
uint8_t outputAgainFlag = 0;
void Task_outputAgain(void)
{
if (outputAgainFlag == 1) {
outputAgainFlag = 0;
TimeSliceOffset_Unregister(&m_outputAgain);
@ -423,6 +469,9 @@ void task_Init(void)
TimeSliceOffset_Register(&m_wdi, Task_wdi, wdi_reloadVal, wdi_offset);
// TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
// , impedanceCalculation_reloadVal, impedanceCalculation_reloadVal);
TimeSliceOffset_Register(&m_refreshRegister, Task_refreshRegister
, refreshRegister_reloadVal, refreshRegister_reloadVal);

View File

@ -103,12 +103,15 @@ void EXTI2_IRQHandler(void)
// printf("Run at EXTI\r\n");
GPIO_WriteBit(DSG_PROT_GPIO, DSG_PROT_PIN, RESET);
if (outputAgainFlag == 0) {
Delay_Ms(1);
GPIO_WriteBit(DSG_PROT_GPIO, DSG_PROT_PIN, SET);
// TimeSliceOffset_Register(&m_outputAgain, Task_outputAgain
// , outputAgain_reloadVal, outputAgain_offset);
outputAgainFlag = 1;
}
if (outputAgainFlag == 1) {
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
// GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, RESET);
outputAgainFlag = 2;
}

View File

@ -50,7 +50,7 @@ void TIM3_Int_Init(uint16_t arr, uint16_t psc)
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; //使能通道1中断
NVIC_Init(&NVIC_InitStructure); //初始化NVIC
// TIM_Cmd(TIM3, ENABLE); //TIM3使能
TIM_Cmd(TIM3, ENABLE); //TIM3使能
}
void TIM3_IRQHandler(void)

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.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff