修改回路阻抗的测量时刻
This commit is contained in:
parent
16e9dbf3a0
commit
480aed0364
|
@ -13,6 +13,7 @@
|
|||
#include "uart_dev.h"
|
||||
#include "math.h"
|
||||
|
||||
//extern uint8_t g_interruptNum;
|
||||
void stop_mpptWork(void);
|
||||
void start_mpptWork(void);
|
||||
|
||||
|
@ -57,10 +58,10 @@ extern uint8_t g_recvBroadcastRegisterNumber; /*
|
|||
extern STR_TimeSliceOffset m_recvbroadcast;
|
||||
extern void Task_recvbroadcast(void);
|
||||
|
||||
#define impedanceCalculation_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define impedanceCalculation_reloadVal 200 /* 任务执行间隔 */
|
||||
#define impedanceCalculation_offset 0 /* 任务执行偏移量 */
|
||||
extern float_t g_impedance;
|
||||
extern float_t voltOut;
|
||||
extern uint8_t g_batteryState;
|
||||
extern STR_TimeSliceOffset m_impedanceCalculation;
|
||||
extern void Task_impedanceCalculation(void);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
config_info g_slConfigInfo = {
|
||||
.constantCurrentV = 1000,
|
||||
.constantVoltageV = 1420,
|
||||
.constantVoltageV = 1400,
|
||||
.floatI = 20,
|
||||
.startSolarOpenCircuitV = 1700,
|
||||
.stopSolarOpenCircuitV = 1500,
|
||||
|
@ -70,8 +70,6 @@ uint8_t read_config_info(void)
|
|||
g_slConfigInfo.end_Flag = defaultValue.end_Flag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -530,13 +530,13 @@ void FloatingCharge(void)
|
|||
// printf("float\n");
|
||||
// }
|
||||
|
||||
static float_t ConstantVoltageChargeV;
|
||||
static float_t FloatChargeV;
|
||||
static uint8_t onlyOnce = 1;
|
||||
if (onlyOnce) {
|
||||
ConstantVoltageChargeV = (float_t)g_slConfigInfo.FloatV / 100;
|
||||
FloatChargeV = (float_t)g_slConfigInfo.FloatV / 100;
|
||||
onlyOnce = 0;
|
||||
}
|
||||
mppt_constantVoltageO(ConstantVoltageChargeV);
|
||||
mppt_constantVoltageO(FloatChargeV);
|
||||
|
||||
}
|
||||
|
||||
|
@ -705,10 +705,11 @@ void MpptMode(void)
|
|||
|
||||
|
||||
|
||||
if (g_Mppt_Para.Solar_Open_Circuit_Voltage < StopSolarOpenCircuitV
|
||||
if (g_Mppt_Para.Input_Voltage < StopSolarOpenCircuitV
|
||||
&& (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;
|
||||
printf("nowork \n");
|
||||
stop_mpptWork();
|
||||
TimeSliceOffset_Register(&m_startMpptControl, Task_startMpptControl
|
||||
, startMpptControl_reloadVal, startMpptControl_offset);
|
||||
|
@ -737,6 +738,13 @@ void MpptMode(void)
|
|||
// g_Mppt_Para.MPPT_Mode = NoBattery;
|
||||
// g_Mppt_Para.MPPT_Mode = CONSTANTVOLTAGE;
|
||||
g_Mppt_Para.MPPT_Mode = FLOAT;
|
||||
|
||||
// printf("Charg_Current : %d/100 \n", (int)(g_Mppt_Para.Charg_Current * 100));
|
||||
// printf("Discharg_Current : %d/100 \n", (int)(g_Mppt_Para.Discharg_Current * 100));
|
||||
// printf("Battery_Voltage : %d/100 \n", (int)(g_Mppt_Para.Battery_Voltage * 100));
|
||||
|
||||
g_batteryState = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -817,6 +825,11 @@ void test(void)
|
|||
|
||||
// mppt_constantCurrentO(1);
|
||||
|
||||
|
||||
// if (g_interruptNum < 5) {
|
||||
// g_interruptNum++;
|
||||
// return;
|
||||
// }
|
||||
// g_Mppt_Para.Charg_Current = get_capturedata(get_CHG_CURR);
|
||||
// g_Mppt_Para.Discharg_Current = get_capturedata(get_DSG_CURR);
|
||||
// g_Mppt_Para.Output_Voltage = get_capturedata(get_PV_VOLT_OUT);
|
||||
|
@ -825,25 +838,37 @@ void test(void)
|
|||
g_Mppt_Para.Discharg_Current = get_DSG_CURR();
|
||||
g_Mppt_Para.Output_Voltage = get_PV_VOLT_OUT();
|
||||
g_Mppt_Para.Input_Voltage = get_PV1_VOLT_IN();
|
||||
|
||||
if (g_Mppt_Para.Discharg_Current == 0 && g_Mppt_Para.Charg_Current == 0) {
|
||||
return;
|
||||
}
|
||||
// g_Mppt_Para.Battery_Voltage = g_Mppt_Para.Output_Voltage;
|
||||
|
||||
// static float_t Volt = 0.7;
|
||||
// static float_t Curr = 5.5;
|
||||
static float_t loopImpedance;
|
||||
static uint8_t onlyone = 1;
|
||||
if (onlyone) {
|
||||
loopImpedance = (float_t)g_slConfigInfo.loopImpedance / 100;
|
||||
}
|
||||
// static float_t loopImpedance;
|
||||
// static uint8_t onlyone = 1;
|
||||
// if (onlyone) {
|
||||
// loopImpedance = (float_t)g_slConfigInfo.loopImpedance / 100;
|
||||
// }
|
||||
|
||||
|
||||
static float_t inBatteryCurr;
|
||||
inBatteryCurr = g_Mppt_Para.Charg_Current - g_Mppt_Para.Discharg_Current;
|
||||
if (inBatteryCurr > 0.1) {
|
||||
g_Mppt_Para.Battery_Voltage = g_Mppt_Para.Output_Voltage - inBatteryCurr * loopImpedance;
|
||||
g_Mppt_Para.Battery_Voltage = g_Mppt_Para.Output_Voltage - inBatteryCurr * g_impedance;
|
||||
} else {
|
||||
g_Mppt_Para.Battery_Voltage = g_Mppt_Para.Output_Voltage;
|
||||
}
|
||||
|
||||
|
||||
if (g_batteryState == 0 && inBatteryCurr > 0.1 && g_Mppt_Para.Output_Voltage < 14.2) {
|
||||
printf("int g_batteryState : %d\n", g_batteryState);
|
||||
g_batteryState = 1;
|
||||
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
|
||||
, impedanceCalculation_reloadVal, impedanceCalculation_reloadVal);
|
||||
}
|
||||
|
||||
// mppt_constantVoltage(18);
|
||||
|
||||
// if (g_Mppt_Para.MPPT_Mode == CONSTANTCURRENT
|
||||
|
|
|
@ -336,6 +336,7 @@ void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg, uint3
|
|||
recvbroadcast_flag = 1;
|
||||
RegistrationRequestFlag = 0;
|
||||
TimeSliceOffset_Unregister(&m_recvbroadcast);
|
||||
m_recvbroadcast.runFlag = 0;
|
||||
SL_Mppt_RegistrationReply_pack *rpack = (SL_Mppt_RegistrationReply_pack *)pMsg;
|
||||
g_Mppt_Para.Registration_Status = chang_8_to_16(rpack->registration_Status_L, rpack->registration_Status_H);
|
||||
|
||||
|
|
140
App/src/task.c
140
App/src/task.c
|
@ -24,11 +24,13 @@
|
|||
#include "collect_Conversion.h"
|
||||
|
||||
|
||||
//uint8_t g_interruptNum = 0; /* 每次关闭或重新开启定时器3时,先清零该引脚 */
|
||||
void stop_mpptWork(void)
|
||||
{
|
||||
// GPIO_WriteBit(EnPowerSupply_GPIO, EnPowerSupply_PIN, SET);
|
||||
g_duty_ratio = 0.7;
|
||||
TIM_Cmd(TIM3, DISABLE);
|
||||
// g_interruptNum = 0;
|
||||
TIM_SetCompare4(TIM4, 0);
|
||||
// TimeSliceOffset_Register(&m_startMpptControl, Task_startMpptControl
|
||||
// , startMpptControl_reloadVal, startMpptControl_offset);
|
||||
|
@ -39,7 +41,9 @@ void stop_mpptWork(void)
|
|||
void start_mpptWork(void)
|
||||
{
|
||||
// GPIO_WriteBit(EnPowerSupply_GPIO, EnPowerSupply_PIN, RESET);
|
||||
// g_interruptNum = 0;
|
||||
TIM_Cmd(TIM3, ENABLE);
|
||||
// TIM3->CNT = 0;
|
||||
g_Mppt_Para.MPPT_Mode = CONSTANTCURRENT;
|
||||
// TimeSliceOffset_Unregister(&m_startMpptControl);
|
||||
// Delay_Ms(500);
|
||||
|
@ -105,10 +109,18 @@ void Task_RunLED(void)
|
|||
sprintf(buffer, " mosT : %d/10 \n", (int)(g_Mppt_Para.HighSideMos_Temperature * 10));
|
||||
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
sprintf(buffer, " impedance : %d/1000 \n", (int)(g_impedance * 1000));
|
||||
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
sprintf(buffer, " mosState : %d \n", (int)(g_Mppt_Para.DischargMos_State));
|
||||
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
sprintf(buffer, " batteryState : %d \n", g_batteryState);
|
||||
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
sprintf(buffer, " 0.没有工作; 1.涓流模式; 2.恒流模式; 3.恒压模式; 4.浮充模式; 5.没有电池 : %d \n", g_Mppt_Para.MPPT_Mode);
|
||||
uart_dev_write(g_bat485_uart3_handle, buffer, sizeof(buffer));
|
||||
|
@ -116,6 +128,7 @@ void Task_RunLED(void)
|
|||
uart_dev_write(g_bat485_uart3_handle, " \n", sizeof(" \n"));
|
||||
|
||||
|
||||
|
||||
// printf("vout : %d/100 \n", (int)(get_capturedata(get_PV_VOLT_OUT) * 100));
|
||||
|
||||
// get_CHG_CURR();
|
||||
|
@ -159,9 +172,16 @@ void Task_startMpptControl(void)
|
|||
|
||||
if (g_Mppt_Para.Solar_Open_Circuit_Voltage
|
||||
> ((float_t)g_slConfigInfo.startSolarOpenCircuitV / 100)) {
|
||||
// start_mpptWork();
|
||||
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
|
||||
TimeSliceOffset_Unregister(&m_startMpptControl);
|
||||
m_startMpptControl.runFlag = 0;
|
||||
// printf("1\n");
|
||||
// start_mpptWork();
|
||||
if (g_Mppt_Para.Battery_Voltage > 10) {
|
||||
g_batteryState = 1;
|
||||
} else {
|
||||
g_batteryState = 0;
|
||||
}
|
||||
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -189,12 +209,39 @@ void Task_softStart(void)
|
|||
}
|
||||
|
||||
else if (num > 70 || dutyRatio > g_duty_ratio) {
|
||||
TimeSliceOffset_Unregister(&m_softStart);
|
||||
m_softStart.runFlag = 0;
|
||||
|
||||
dutyRatio = 0;
|
||||
num = 0;
|
||||
Set_duty_ratio(&g_duty_ratio);
|
||||
TimeSliceOffset_Unregister(&m_softStart);
|
||||
start_mpptWork();
|
||||
|
||||
if (g_batteryState == 1) {
|
||||
// start_mpptWork();
|
||||
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
|
||||
, impedanceCalculation_reloadVal, impedanceCalculation_reloadVal);
|
||||
return;
|
||||
} else {
|
||||
dutyRatio = 0;
|
||||
num = 0;
|
||||
Set_duty_ratio(&g_duty_ratio);
|
||||
// TimeSliceOffset_Unregister(&m_softStart);
|
||||
// m_softStart.runFlag = 0;
|
||||
|
||||
//软起动后bms保护板开启电池充电
|
||||
if (get_CHG_CURR() - get_DSG_CURR() > 0.2) {
|
||||
// printf("111\n");
|
||||
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
|
||||
, impedanceCalculation_reloadVal, impedanceCalculation_reloadVal);
|
||||
return;
|
||||
}
|
||||
|
||||
TIM_Cmd(TIM3, ENABLE);
|
||||
g_Mppt_Para.MPPT_Mode = NoWork;
|
||||
GPIO_WriteBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN, SET);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
|
@ -268,7 +315,7 @@ void Task_refreshRegister(void)
|
|||
}
|
||||
// g_Mppt_Para.DischargMos_State = GPIO_ReadOutputDataBit(POW_OUT_CON_GPIO, POW_OUT_CON_PIN);
|
||||
// g_Mppt_Para.Solar_Open_Circuit_Voltage = get_capturedata(get_PV1_VOLT_IN);
|
||||
g_Mppt_Para.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
|
||||
g_Mppt_Para.Input_Voltage = get_PV1_VOLT_IN();
|
||||
|
||||
if (g_Mppt_Para.HighSideMos_Temperature < g_slConfigInfo.HighSideMosTemperature_start) {
|
||||
if (overTemperature == 2) {
|
||||
|
@ -290,7 +337,6 @@ void Task_refreshRegister(void)
|
|||
overTemperature = 2;
|
||||
stop_mpptWork();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,6 +357,7 @@ void Task_recvbroadcast(void)
|
|||
RegistrationRequestFlag = 0;
|
||||
run_number = 0;
|
||||
TimeSliceOffset_Unregister(&m_recvbroadcast);
|
||||
m_recvbroadcast.runFlag = 0;
|
||||
return;
|
||||
}
|
||||
// if (g_Mppt_Para.Registration_Status == REGISTER_SUCCESS) {
|
||||
|
@ -393,7 +440,7 @@ void Task_recvbroadcast(void)
|
|||
*/
|
||||
STR_TimeSliceOffset m_impedanceCalculation;
|
||||
float_t g_impedance = 0; /* 回路阻抗的值 */
|
||||
float_t voltOut = 0; /* Êä³öµçѹµÄÖµ */
|
||||
uint8_t g_batteryState = 0; /* 有无电池 */
|
||||
void Task_impedanceCalculation(void)
|
||||
{
|
||||
static uint8_t num = 0;
|
||||
|
@ -402,39 +449,77 @@ void Task_impedanceCalculation(void)
|
|||
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 (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, 300);
|
||||
// Delay_Ms(500);
|
||||
//
|
||||
// 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);
|
||||
// currOne = get_CHG_CURR() - get_DSG_CURR();
|
||||
// voltOne = get_PV_VOLT_OUT();
|
||||
//
|
||||
//// currTwo = get_capturedata(get_CHG_CURR) - get_capturedata(get_DSG_CURR);
|
||||
//// voltTwo = get_capturedata(get_PV_VOLT_OUT);
|
||||
// currTwo = get_CHG_CURR() - get_DSG_CURR();
|
||||
// voltTwo = 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);
|
||||
// }
|
||||
|
||||
num++;
|
||||
|
||||
// printf("g_batteryState : %d\n", g_batteryState);
|
||||
|
||||
if (num == 1) {
|
||||
TIM_Cmd(TIM3, DISABLE);
|
||||
// g_interruptNum = 0;
|
||||
TIM_SetCompare4(TIM4, 300);
|
||||
return;
|
||||
}
|
||||
|
||||
if (num == 10) {
|
||||
num = 0;
|
||||
TIM_Cmd(TIM3, DISABLE);
|
||||
|
||||
TIM_SetCompare4(TIM4, 300);
|
||||
Delay_Ms(500);
|
||||
|
||||
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);
|
||||
if (num == 11) {
|
||||
currOne = get_CHG_CURR() - get_DSG_CURR();
|
||||
voltOne = get_PV_VOLT_OUT();
|
||||
TIM_SetCompare4(TIM4, 420);
|
||||
return;
|
||||
}
|
||||
|
||||
if (num == 21) {
|
||||
TimeSliceOffset_Unregister(&m_impedanceCalculation);
|
||||
m_impedanceCalculation.runFlag = 0;
|
||||
|
||||
// currTwo = get_capturedata(get_CHG_CURR) - get_capturedata(get_DSG_CURR);
|
||||
// voltTwo = get_capturedata(get_PV_VOLT_OUT);
|
||||
currTwo = get_CHG_CURR() - get_DSG_CURR();
|
||||
voltTwo = get_PV_VOLT_OUT();
|
||||
|
||||
g_impedance = (voltOne - voltTwo) / (currOne - currTwo);
|
||||
|
||||
// printf("g_batteryState : %d\n", g_batteryState);
|
||||
|
||||
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));
|
||||
|
||||
num = 0;
|
||||
start_mpptWork();
|
||||
// TIM_Cmd(TIM3, ENABLE);
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -453,10 +538,12 @@ void Task_outputAgain(void)
|
|||
if (outputAgainFlag == 1) {
|
||||
outputAgainFlag = 0;
|
||||
TimeSliceOffset_Unregister(&m_outputAgain);
|
||||
m_outputAgain.runFlag = 0;
|
||||
}
|
||||
|
||||
if (outputAgainFlag == 2) {
|
||||
TimeSliceOffset_Unregister(&m_outputAgain);
|
||||
m_outputAgain.runFlag = 0;
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -480,6 +567,7 @@ void Task_sensorEnableBroadcast(void)
|
|||
enabBroadcastTimeFlag = 0;
|
||||
run_Broadcast = 1;
|
||||
TimeSliceOffset_Unregister(&m_sensorEnableBroadcast);
|
||||
m_sensorEnableBroadcast.runFlag = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ void WORK_VOLT_INT_Init(void)
|
|||
void EXTI1_IRQHandler(void)
|
||||
{
|
||||
if(EXTI_GetITStatus(EXTI_Line1)==SET) { //EXTI_GetITStatus用来获取中断标志位状态,如果EXTI线产生中断则返回SET,否则返回RESET
|
||||
|
||||
printf(" vout low 11V \n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
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.
File diff suppressed because it is too large
Load Diff
19044
obj/mppt_Nos_V0.4.lst
19044
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