Compare commits
No commits in common. "c31fddb450cdd65602a5a82dc9a9988ecc8a305a" and "0fcdfa75d38549970666d3c8492dd936cc2abf80" have entirely different histories.
c31fddb450
...
0fcdfa75d3
|
@ -5,7 +5,6 @@
|
|||
#include "task.h"
|
||||
#include "pDebug.h"
|
||||
#include "parameter.h"
|
||||
#include "FM_TIM.h"
|
||||
|
||||
void startInfo(void)
|
||||
{
|
||||
|
@ -60,7 +59,7 @@ void start(void)
|
|||
|
||||
startInfo();
|
||||
|
||||
// HAL_Delay(5000);
|
||||
HAL_Delay(5000);
|
||||
|
||||
TimeSliceOffset_Start();
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ uint8_t getExcessiveLoad(void);
|
|||
void setExcessiveLoadFlag(BOOL state);
|
||||
BOOL getExcessiveLoadFlag(void);
|
||||
|
||||
void setSoftShortCircuit(uint16_t disChargCurrAdcNum);
|
||||
|
||||
void setPowerOutput(BOOL state);
|
||||
|
||||
void checkAbnormal(void);
|
||||
|
|
|
@ -111,15 +111,4 @@ void readtotalChargCapacity(float *totalChargCapacity);
|
|||
void saveTime(timeInfo *time);
|
||||
void readTime(timeInfo *time);
|
||||
|
||||
|
||||
|
||||
|
||||
#define eventsOrderRecordStartAddr 200
|
||||
void eventsOrderRecordStartInit(void);
|
||||
void setEventsOrderRecord(eventsOrderRecordMode mode);
|
||||
void printfEventsOrderRecord(void);
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -5,10 +5,8 @@
|
|||
#include "checkTime.h"
|
||||
#include "FM_GPIO.h"
|
||||
#include "task.h"
|
||||
#include "configParameter.h"
|
||||
#include "capture.h"
|
||||
|
||||
//static int checkMode = 0;
|
||||
|
||||
|
||||
/* 软件输出过载标志位 */
|
||||
static BOOL disChargOverLoad = FALSE;
|
||||
|
@ -20,7 +18,7 @@ static BOOL shortCircuitFlag = FALSE;
|
|||
/* 硬件过载状态位 */
|
||||
static uint8_t excessiveLoad = 0;
|
||||
static BOOL excessiveLoadFlag = FALSE;
|
||||
static BOOL excessiveLoadInterruptFlag = FALSE;
|
||||
|
||||
|
||||
/**
|
||||
* @brief 设定放电过载状态
|
||||
|
@ -30,9 +28,9 @@ static BOOL excessiveLoadInterruptFlag = FALSE;
|
|||
*/
|
||||
void setDisChargOverLoad(void)
|
||||
{
|
||||
/* 三段式保护中的第三段 */
|
||||
/* 三段式保护中的两段 */
|
||||
static int num1 = 0;
|
||||
if (getDischargCurrent() > thirdStageProtectionCurr) {
|
||||
if (getDischargCurrent() > 30.0f) {
|
||||
// disChargOverLoad = TRUE;
|
||||
num1++;
|
||||
} else {
|
||||
|
@ -40,27 +38,25 @@ void setDisChargOverLoad(void)
|
|||
num1 = 0;
|
||||
}
|
||||
|
||||
/* 过载时间过长关闭输出 */
|
||||
if (num1 >= thirdStageProtectionDelay) {
|
||||
/* 过载时间过长关闭输出(120S) */
|
||||
if (num1 >= 1200000) {
|
||||
num1 = 0;
|
||||
setPowerOutput(FALSE);
|
||||
disChargOverLoad = TRUE;
|
||||
setPowerOutput(FALSE);
|
||||
}
|
||||
|
||||
|
||||
/* 三段式保护中的第二段 */
|
||||
static int num2 = 0;
|
||||
if (getDischargCurrent() > secondStageProtectionCurr) {
|
||||
if (getDischargCurrent() > 35.0f) {
|
||||
num2++;
|
||||
} else {
|
||||
num2 = 0;
|
||||
}
|
||||
|
||||
/* 过载时间过长关闭输出 */
|
||||
if (num1 >= secondStageProtectionDelay) {
|
||||
/* 过载时间过长关闭输出(5S) */
|
||||
if (num1 >= 50000) {
|
||||
num1 = 0;
|
||||
setPowerOutput(FALSE);
|
||||
disChargOverLoad = TRUE;
|
||||
setPowerOutput(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,58 +66,23 @@ void setDisChargOverLoad(void)
|
|||
* @retval
|
||||
*
|
||||
*/
|
||||
void setSoftShortCircuit(uint16_t disChargCurrAdcNum)
|
||||
void setSoftShortCircuit(void)
|
||||
{
|
||||
// /* 三段式保护中的第一段 */
|
||||
// static int num = 0;
|
||||
// if (getDischargCurrent() > firstStageProtectionCurr) {
|
||||
// num++;
|
||||
// } else {
|
||||
// num = 0;
|
||||
// }
|
||||
|
||||
/* 三段式保护中的第一段 */
|
||||
static int num = 0;
|
||||
if (disChargCurrAdcNum > firstStageProtectionValue) {
|
||||
if (getDischargCurrent() > 50.0f) {
|
||||
num++;
|
||||
} else {
|
||||
num = 0;
|
||||
}
|
||||
|
||||
/* 20uS内都短路则关闭输出 */
|
||||
if (num >= firstStageProtectionDelay) {
|
||||
setPowerOutput(FALSE);
|
||||
/* 200uS内都短路则关闭输出 */
|
||||
if (num >= 2) {
|
||||
shortCircuitFlag = TRUE;
|
||||
shortCircuit++;
|
||||
setPowerOutput(FALSE);
|
||||
startSoftShortCircuitProtection();
|
||||
}
|
||||
}
|
||||
void setSoftShortCircuit1(void)
|
||||
{
|
||||
// /* 三段式保护中的第一段 */
|
||||
// static int num = 0;
|
||||
// if (getDischargCurrent() > firstStageProtectionCurr) {
|
||||
// num++;
|
||||
// } else {
|
||||
// num = 0;
|
||||
// }
|
||||
|
||||
// /* 三段式保护中的第一段 */
|
||||
// static int num = 0;
|
||||
// if (getDischargCurrent() > firstStageProtectionCurr) {
|
||||
// num++;
|
||||
// } else {
|
||||
// num = 0;
|
||||
// }
|
||||
|
||||
// /* 200uS内都短路则关闭输出 */
|
||||
// if (num >= firstStageProtectionDelay) {
|
||||
// setPowerOutput(FALSE);
|
||||
// shortCircuitFlag = TRUE;
|
||||
// shortCircuit++;
|
||||
// startSoftShortCircuitProtection();
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 得到放电过载状态
|
||||
|
@ -308,63 +269,6 @@ void checkFFMOS_CON(void)
|
|||
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief 输入功率过低保护
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void setOverLoad(void)
|
||||
{
|
||||
setPowerOutput(FALSE);
|
||||
setExcessiveLoad();
|
||||
/* 第一次进入输出过载,启动过载保护任务 */
|
||||
if (getExcessiveLoad() == 1) {
|
||||
setExcessiveLoadFlag(TRUE);
|
||||
startExcessiveLoadProtection();
|
||||
}
|
||||
|
||||
/* 多次进入输出过载,关闭输出 */
|
||||
if (getExcessiveLoad() > 2) {
|
||||
zeroExcessiveLoad();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 判断是否输入功率过低
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void lowInputLoadDetection(void)
|
||||
{
|
||||
static int num = 0;
|
||||
|
||||
if (excessiveLoadInterruptFlag == TRUE && getOutputVoltage() < lowInputLoadDetectionVolt) {
|
||||
num++;
|
||||
} else {
|
||||
num = 0;
|
||||
excessiveLoadInterruptFlag = FALSE;
|
||||
}
|
||||
|
||||
if (excessiveLoadInterruptFlag == TRUE && num == lowInputLoadDetectionDelay) {
|
||||
setOverLoad();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 判断充电电流是否过高,过高则关闭充电
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void judgeChargCurr(void)
|
||||
{
|
||||
if (getChargCurrent() > maxChargCurr) {
|
||||
stopChargWork();
|
||||
}
|
||||
}
|
||||
|
||||
void checkAbnormal(void)
|
||||
{
|
||||
|
@ -381,9 +285,9 @@ void checkAbnormal(void)
|
|||
/* 判断 */
|
||||
checkFFMOS_CON();
|
||||
setDisChargOverLoad();
|
||||
setSoftShortCircuit1();
|
||||
lowInputLoadDetection();
|
||||
judgeChargCurr();
|
||||
setSoftShortCircuit();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -398,19 +302,18 @@ void checkAbnormal(void)
|
|||
*/
|
||||
void WORK_VOLT_Interrupt(void)
|
||||
{
|
||||
// setPowerOutput(FALSE);
|
||||
// setExcessiveLoad();
|
||||
// /* 第一次进入输出过载,启动过载保护任务 */
|
||||
// if (getExcessiveLoad() == 1) {
|
||||
// setExcessiveLoadFlag(TRUE);
|
||||
// startExcessiveLoadProtection();
|
||||
// }
|
||||
setPowerOutput(FALSE);
|
||||
setExcessiveLoad();
|
||||
/* 第一次进入输出过载,启动过载保护任务 */
|
||||
if (getExcessiveLoad() == 1) {
|
||||
setExcessiveLoadFlag(TRUE);
|
||||
startExcessiveLoadProtection();
|
||||
}
|
||||
|
||||
// /* 多次进入输出过载,关闭输出 */
|
||||
// if (getExcessiveLoad() > 2) {
|
||||
// zeroExcessiveLoad();
|
||||
// }
|
||||
excessiveLoadInterruptFlag = TRUE;
|
||||
/* 多次进入输出过载,关闭输出 */
|
||||
if (getExcessiveLoad() > 2) {
|
||||
zeroExcessiveLoad();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -557,10 +557,6 @@ void chargControlMode(void)
|
|||
endChargWork();
|
||||
}
|
||||
|
||||
else if (getBatteryState() == FALSE) {
|
||||
setMPPT_Mode(noBattery);
|
||||
}
|
||||
|
||||
else if (floatChargConditions()) {
|
||||
setMPPT_Mode(floatCharg);
|
||||
}
|
||||
|
|
|
@ -290,66 +290,3 @@ void readTime(timeInfo *time)
|
|||
{
|
||||
read_Flash((uint8_t *)time, time_SAVE_addr, sizeof(timeInfo));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 初始化事件顺序记录
|
||||
* @param
|
||||
*/
|
||||
|
||||
void eventsOrderRecordStartInit(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 将事件顺序记录在flash中
|
||||
* @param
|
||||
*/
|
||||
void setEventsOrderRecord(eventsOrderRecordMode mode)
|
||||
{
|
||||
static uint32_t len = sizeof(int);
|
||||
float temp;
|
||||
write_Flash((uint8_t *)&mode, eventsOrderRecordStartAddr + len, sizeof(mode));
|
||||
len += sizeof(mode);
|
||||
temp = getDischargCurrent();
|
||||
write_Flash((uint8_t *)&temp, eventsOrderRecordStartAddr + len, sizeof(float));
|
||||
len += sizeof(float);
|
||||
temp = getOutputVoltage();
|
||||
write_Flash((uint8_t *)&temp, eventsOrderRecordStartAddr + len, sizeof(float));
|
||||
|
||||
int count = 0;
|
||||
read_Flash((uint8_t *)&count, eventsOrderRecordStartAddr, sizeof(count));
|
||||
count++;
|
||||
write_Flash((uint8_t *)&count, eventsOrderRecordStartAddr, sizeof(count));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 将事件从flash中依次读取出来
|
||||
* @param
|
||||
*/
|
||||
|
||||
void printfEventsOrderRecord(void)
|
||||
{
|
||||
int count = 0;
|
||||
read_Flash((uint8_t *)&count, eventsOrderRecordStartAddr, sizeof(count));
|
||||
|
||||
float temp;
|
||||
eventsOrderRecordMode mode;
|
||||
|
||||
for (int i = 0; i < count; i++) {
|
||||
read_Flash((uint8_t *)&temp, eventsOrderRecordStartAddr + sizeof(int)
|
||||
+ i * (sizeof(float) + sizeof(float)), sizeof(mode));
|
||||
log_info("eventsOrderRecordMode:%d\n", mode);
|
||||
|
||||
read_Flash((uint8_t *)&temp, eventsOrderRecordStartAddr + sizeof(int)
|
||||
+ i * (sizeof(float) + sizeof(float)) + sizeof(mode), sizeof(float));
|
||||
log_info("dischargCurrent:%f\n", temp);
|
||||
|
||||
read_Flash((uint8_t *)&temp, eventsOrderRecordStartAddr + sizeof(int)
|
||||
+ i * (sizeof(float) + sizeof(float)) + sizeof(mode) + sizeof(float), sizeof(float));
|
||||
log_info("OutputVoltage:%f\n", temp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "FM_TIM.h"
|
||||
#include "FM_GPIO.h"
|
||||
#include "capture.h"
|
||||
#include "bl_chargControl.h"
|
||||
|
||||
config_parameter g_cfgParameter = {0};
|
||||
static otherParameter g_otherParameter = {0};
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "uart_dev.h"
|
||||
#include "abnormalManage.h"
|
||||
#include "interruptSend.h"
|
||||
#include "configParameter.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -274,7 +273,7 @@ void Task_refreshJudgeData(void)
|
|||
|
||||
/* 有电池,太阳能输出功率大,电池电压低于14V,同时回路阻抗未测试或需要重新测试 */
|
||||
if ((getCheckImpedanceState() == FALSE || g_cfgParameter.loopImpedance == 0.0f)
|
||||
&& (getBatteryState() == TRUE) && (getChargCurrent() > checkLoopImpedanceChargCurr)
|
||||
&& (getBatteryState() == TRUE) && (getChargCurrent() > 3.0f)
|
||||
&& (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)
|
||||
&& (getBatteryVoltage() < 14)) {
|
||||
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
|
||||
|
@ -478,7 +477,7 @@ void Task_collectOpenCircuitVoltage(void)
|
|||
if (getBatteryState()) {
|
||||
collectOpenCircuitVoltageYesFlag = TRUE;
|
||||
stopChargWork();
|
||||
/* 设置延时为(1000-500)ms */
|
||||
/* 设置延时为1000-500ms */
|
||||
m_collectOpenCircuitVoltage.count = 500;
|
||||
}
|
||||
collectOpenCircuitVoltageYesNUM = 0;
|
||||
|
@ -486,14 +485,11 @@ void Task_collectOpenCircuitVoltage(void)
|
|||
|
||||
/* 检测开路电压 */
|
||||
if (collectOpenCircuitVoltageYesNUM == g_cfgParameter.collectOpenCircuitVoltageTime + 1) {
|
||||
/* 有电池才进行开路电压检测 */
|
||||
if (getBatteryState()) {
|
||||
setSolarOpenCircuitVoltage();
|
||||
beginChargWork();
|
||||
collectOpenCircuitVoltageYesFlag = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 开启HY配置模式后,配置完成后120S后自动退出
|
||||
|
|
|
@ -34,6 +34,4 @@ float get_OUT_VOLT_IN(void);
|
|||
|
||||
void adcCaptureFir();
|
||||
|
||||
extern void setSoftShortCircuit(uint16_t disChargCurrAdcNum);
|
||||
|
||||
#endif
|
|
@ -446,8 +446,6 @@ float get_OUT_VOLT_IN(void)
|
|||
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hdma)
|
||||
{
|
||||
if (hdma->Instance == ADC1) {
|
||||
setSoftShortCircuit(adcBuff[DSG_CURR_NUM]);
|
||||
|
||||
WORK_VOLT_capture.totalInData -= WORK_VOLT_capture.inData16[pointer];
|
||||
DSG_CURR_capture.totalInData -= DSG_CURR_capture.inData16[pointer];
|
||||
PV_VOLT_IN_capture.totalInData -= PV_VOLT_IN_capture.inData16[pointer];
|
||||
|
|
|
@ -152,7 +152,7 @@ void SystemClock_Config(void)
|
|||
*/
|
||||
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE;
|
||||
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
|
||||
// RCC_OscInitStruct.LSEState = RCC_LSE_ON;
|
||||
RCC_OscInitStruct.LSEState = RCC_LSE_ON;
|
||||
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
|
||||
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
|
||||
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1;
|
||||
|
|
|
@ -8,8 +8,7 @@ typedef enum _chargMode{
|
|||
noWork = 0, /* 未进行充电 */
|
||||
MPPT = 1, /* 最大功率充电 */
|
||||
constantVoltage = 2, /* 恒压充电 */
|
||||
floatCharg = 3, /* 浮充充电 */
|
||||
noBattery = 4, /* 无电池 */
|
||||
floatCharg = 3 /* 浮充充电 */
|
||||
}chargMode;
|
||||
|
||||
typedef enum {
|
||||
|
@ -51,22 +50,8 @@ typedef struct _timeInfo {
|
|||
|
||||
/* 方式 */
|
||||
typedef enum {
|
||||
runLedChargMode = 1, //充电模式
|
||||
runLedOtherMode = 2, //其他模式
|
||||
runLedChargMode = 1,
|
||||
runLedOtherMode = 2,
|
||||
}runLedMode;
|
||||
|
||||
|
||||
/* 顺序事件记录 */
|
||||
typedef enum {
|
||||
firstStageProtection = 1, //第一段保护,短路保护
|
||||
secondStageProtection , //第二段保护,介于过载和短路之间
|
||||
thirdStageProtection, //第三段保护,过载保护
|
||||
lowInputLoad, //输入功率不足保护
|
||||
overTemperature, //过温保护
|
||||
stopTemperature, //停止温度保护
|
||||
overchargCurr, //充电功率过大保护
|
||||
}eventsOrderRecordMode;
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
#ifndef CONFIG_PARAMETER_
|
||||
#define CONFIG_PARAMETER_
|
||||
|
||||
#include "comm_types.h"
|
||||
|
||||
|
||||
|
||||
// /* 第一段保护的延时时间(单位100uS) */
|
||||
// const uint32_t firstStageProtectionDelay = 2; // 200uS
|
||||
// /* 第一段保护的电流(单位A) */
|
||||
// const float_t firstStageProtectionCurr = 50.0f;
|
||||
|
||||
// /* 第二段保护的延时时间(单位100uS) */
|
||||
// const uint32_t secondStageProtectionDelay = 50000; // 5S
|
||||
// /* 第二段保护的电流(单位A) */
|
||||
// const float_t secondStageProtectionCurr = 30.0f;
|
||||
|
||||
// /* 第三段保护的延时时间(单位100uS) */
|
||||
// const uint32_t thirdStageProtectionDelay = 1200000; // 120S
|
||||
// /* 第三段保护的电流(单位A) */
|
||||
// const uint32_t thirdStageProtectionCurr = 35.0f;
|
||||
|
||||
// /* 检测回路阻抗时的充电电流要大于该值(单位A) */
|
||||
// const float_t checkLoopImpedanceChargCurr = 10.0f;
|
||||
|
||||
|
||||
// /* 第三段保护的延时时间(单位100uS) */
|
||||
// const uint32_t lowInputLoadDetectionDelay = 30; // 120S
|
||||
|
||||
|
||||
// /* 第一段保护的延时时间(单位100uS) */
|
||||
/* 第一段保护的延时时间(单位10uS) */
|
||||
#define firstStageProtectionDelay 2
|
||||
// /* 第一段保护的电流(单位A) */
|
||||
#define firstStageProtectionCurr 50.0f
|
||||
/* 第一段保护的电流采集的ADC的值 */
|
||||
#define firstStageProtectionValue 3412
|
||||
|
||||
/* 第二段保护的延时时间(单位100uS) */
|
||||
#define secondStageProtectionDelay 50000 // 5S
|
||||
/* 第二段保护的电流(单位A) */
|
||||
#define secondStageProtectionCurr 30.0f
|
||||
|
||||
/* 第三段保护的延时时间(单位100uS) */
|
||||
#define thirdStageProtectionDelay 1200000 // 120S
|
||||
/* 第三段保护的电流(单位A) */
|
||||
#define thirdStageProtectionCurr 35.0f
|
||||
|
||||
/* 检测回路阻抗时的充电电流要大于该值(单位A) */
|
||||
#define checkLoopImpedanceChargCurr 10.0f
|
||||
|
||||
/* 输入功率较低延时(单位100uS) */
|
||||
#define lowInputLoadDetectionDelay 30 // 120S
|
||||
/* 输入功率较低延时电流(单位A) */
|
||||
#define lowInputLoadDetectionVolt 10.0f
|
||||
|
||||
/* 最大充电电流(A) */
|
||||
#define maxChargCurr 35.0f
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue