修改pi范围,解决第一段保护soe问题,修改配置文件问题
This commit is contained in:
parent
ade6e13f20
commit
931a71a25c
|
@ -5,8 +5,8 @@
|
|||
#include "FM_TIM.h"
|
||||
#include "comm_types.h"
|
||||
|
||||
#define PI_CONTROL_MAX 0.1f
|
||||
#define PI_CONTROL_MIN -0.1f
|
||||
#define PI_CONTROL_MAX 0.03f
|
||||
#define PI_CONTROL_MIN -0.03f
|
||||
|
||||
BOOL getChargControlFlag(void);
|
||||
void setChargControlFlag(BOOL state);
|
||||
|
|
|
@ -23,6 +23,9 @@ void Init(void)
|
|||
// HAL_Delay(10000);
|
||||
|
||||
config_info_start();
|
||||
|
||||
Init_debug_uart();
|
||||
|
||||
ADC_Capture_Init();
|
||||
proportionalInt(g_cfgParameter.powerBoxType);
|
||||
|
||||
|
@ -32,7 +35,6 @@ void Init(void)
|
|||
tim_Init();
|
||||
FM_RTC_Init();
|
||||
|
||||
Init_debug_uart();
|
||||
Init_BAT485_uart(g_cfgParameter.bat485_Baud);
|
||||
Init_GW485_uart(g_cfgParameter.gw485_Baud);
|
||||
// Init_BAT485_uart(115200);
|
||||
|
|
|
@ -137,7 +137,7 @@ void insertEventsOrderRecord(eventsOrderRecordMode mode)
|
|||
soeInfo.insertData->temp = get_EXCHG_CURR();
|
||||
}
|
||||
|
||||
else if (mode == hardwareShortCircuitProtection) {
|
||||
else if (mode == InputProtection) {
|
||||
soeInfo.insertData->temp = get_EXCHG_CURR();
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ void setDisChargOverLoad(void)
|
|||
/* 过载时间过长关闭输出 */
|
||||
if (num2 >= g_cfgParameter.secondStageProtectionDelay) {
|
||||
num2 = 0;
|
||||
// debug_printf("in secondStageProtection \n");
|
||||
setPowerOutput(FALSE);
|
||||
disChargOverLoad = TRUE;
|
||||
insertEventsOrderRecord(secondStageProtection);
|
||||
|
@ -94,11 +95,14 @@ void setSoftShortCircuit(uint16_t disChargCurrAdcNum)
|
|||
|
||||
/* 20uS内都短路则关闭输出 */
|
||||
if (num >= g_cfgParameter.firstStageProtectionDelay) {
|
||||
num = 0;
|
||||
setPowerOutput(FALSE);
|
||||
shortCircuitFlag = TRUE;
|
||||
shortCircuit++;
|
||||
// shortCircuitFlag = TRUE;
|
||||
// shortCircuit++;
|
||||
// debug_printf("in firstStageProtection %d \n", g_cfgParameter.firstStageProtectionValue);
|
||||
// debug_printf("in firstStageProtection %d \n", disChargCurrAdcNum);
|
||||
insertEventsOrderRecord(firstStageProtection);
|
||||
startSoftShortCircuitProtection();
|
||||
// startSoftShortCircuitProtection();
|
||||
}
|
||||
}
|
||||
void setSoftShortCircuit1(void)
|
||||
|
@ -379,7 +383,15 @@ void lowInputLoadDetection(void)
|
|||
*/
|
||||
void judgeChargCurr(void)
|
||||
{
|
||||
static uint16_t num = 0;
|
||||
if (getChargCurrent() > g_cfgParameter.maxChargCurr) {
|
||||
num++;
|
||||
} else {
|
||||
num = 0;
|
||||
}
|
||||
|
||||
if (num > 500) {
|
||||
num = 0;
|
||||
stopChargWork();
|
||||
insertEventsOrderRecord(overchargCurr);
|
||||
}
|
||||
|
|
|
@ -506,6 +506,7 @@ BOOL stopChargConditions(void)
|
|||
{
|
||||
if (getSolarInCircuitVoltage() < g_cfgParameter.stopSolarOutputCircuitV
|
||||
&& getChargCurrent() < 1) {
|
||||
// log_info("in stopChargConditions stopChargWork");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -678,7 +679,8 @@ void BatteryChargControl(void)
|
|||
|
||||
default:
|
||||
setMPPT_Mode(noWork);
|
||||
stopChargWork();
|
||||
// stopChargWork();
|
||||
endChargWork();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -699,12 +701,15 @@ void setChargControlFlag(BOOL state)
|
|||
{
|
||||
if (state == TRUE || state == FALSE) {
|
||||
chargControlFlag = state;
|
||||
// debug_printf("chargControlFlag : %d", state);
|
||||
}
|
||||
|
||||
if (state == TRUE) {
|
||||
chargRunLed(runLedChargMode);
|
||||
// debug_printf("setChargControlFlag is true");
|
||||
} else if (state == FALSE) {
|
||||
chargRunLed(runLedOtherMode);
|
||||
// debug_printf("setChargControlFlag is false");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "SOE.h"
|
||||
#include "FM_RTC.h"
|
||||
#include "SOE.h"
|
||||
#include "abnormalManage.h"
|
||||
|
||||
/* 状态机 */
|
||||
typedef enum {
|
||||
|
@ -65,9 +66,12 @@ typedef enum
|
|||
SL_Register_totalChargCapacity = 0x0109, /* 总充电量 */
|
||||
SL_Register_totalElectricityConsumption = 0x010A, /* 总放电量 */
|
||||
SL_Register_MPPT_Mode = 0x010B, /* 工作模式 */
|
||||
|
||||
SL_Register_eliminateStatistical = 0x0120, /* 消除统计 */
|
||||
SL_Register_Charg_Control = 0x0121, /* 充电控制 */
|
||||
SL_Register_Clean_SOE = 0x0122, /* 清除SOE */
|
||||
SL_Register_DisCharg_Control = 0x0122, /* 放电控制 */
|
||||
SL_Register_Clean_SOE = 0x0123, /* 清除SOE */
|
||||
|
||||
SL_Register_YearMonth = 0x0130, /* rtc时钟校准-年月 */
|
||||
SL_Register_DayHour = 0x0131, /* rtc时钟校准-日时 */
|
||||
SL_Register_MinuteSecond = 0x0132, /* rtc时钟校准-分秒 */
|
||||
|
@ -167,7 +171,9 @@ static uint16_t SL_ReadRegisterMinuteSecond(void *pMsg);
|
|||
|
||||
static uint16_t SL_WriteRegisterEliminateStatistical(void *pMsg);
|
||||
static uint16_t SL_WriteRegisterChargControl(void *pMsg);
|
||||
static uint16_t SL_WriteRegisterDisChargControl(void *pMsg);
|
||||
static uint16_t SL_WriteRegisterCleanSOE(void *pMsg);
|
||||
|
||||
static uint16_t SL_WriteRegisterYearMonth(void *pMsg);
|
||||
static uint16_t SL_WriteRegisterDayHour(void *pMsg);
|
||||
static uint16_t SL_WriteRegisterMinuteSecond(void *pMsg);
|
||||
|
@ -212,6 +218,7 @@ SL_RegProcTable g_RegTblW[] =
|
|||
// {SL_Register_Communication_Methods, SL_WriteRegisterCommunicationMethods},
|
||||
{SL_Register_eliminateStatistical, SL_WriteRegisterEliminateStatistical},
|
||||
{SL_Register_Charg_Control, SL_WriteRegisterChargControl},
|
||||
{SL_Register_DisCharg_Control, SL_WriteRegisterDisChargControl},
|
||||
{SL_Register_Clean_SOE, SL_WriteRegisterCleanSOE},
|
||||
{SL_Register_YearMonth, SL_WriteRegisterYearMonth},
|
||||
{SL_Register_DayHour, SL_WriteRegisterDayHour},
|
||||
|
@ -1110,7 +1117,7 @@ uint16_t SL_ReadRegisterChargState(void *pMsg)
|
|||
uint16_t SL_ReadRegisterTotalChargCapacity(void *pMsg)
|
||||
{
|
||||
volatile uint16_t temp = 0;
|
||||
temp = (uint16_t)(getTotalChargCapacity() * floatMagnification);
|
||||
temp = (uint16_t)(getTotalChargCapacity() * floatMagnification * 1000);
|
||||
totalChargCapacityInt(0);
|
||||
return temp;
|
||||
}
|
||||
|
@ -1123,7 +1130,7 @@ uint16_t SL_ReadRegisterTotalChargCapacity(void *pMsg)
|
|||
uint16_t SL_ReadRegisterTotalElectricityConsumption(void *pMsg)
|
||||
{
|
||||
volatile uint16_t temp = 0;
|
||||
temp = (uint16_t)(getTotalElectricityConsumption() * floatMagnification);
|
||||
temp = (uint16_t)(getTotalElectricityConsumption() * floatMagnification * 1000);
|
||||
totalElectricityConsumptionInt(0);
|
||||
return temp;
|
||||
}
|
||||
|
@ -1182,7 +1189,7 @@ uint16_t SL_ReadRegisterMinuteSecond(void *pMsg)
|
|||
*/
|
||||
uint16_t SL_WriteRegisterEliminateStatistical(void *pMsg)
|
||||
{
|
||||
debug_printf("SL_WriteRegisterEliminateStatistical\n");
|
||||
// debug_printf("SL_WriteRegisterEliminateStatistical\n");
|
||||
totalChargCapacityInt(0);
|
||||
totalElectricityConsumptionInt(0);
|
||||
return 0;
|
||||
|
@ -1195,13 +1202,33 @@ uint16_t SL_WriteRegisterEliminateStatistical(void *pMsg)
|
|||
*/
|
||||
uint16_t SL_WriteRegisterChargControl(void *pMsg)
|
||||
{
|
||||
debug_printf("SL_WriteRegisterChargControl\n");
|
||||
if ((*(uint16_t*)pMsg) == 0xFFFF) {
|
||||
// debug_printf("SL_WriteRegisterChargControl\n");
|
||||
if ((*(uint16_t*)pMsg) == 0x0000) {
|
||||
stopChargWork();
|
||||
}
|
||||
|
||||
else if ((*(uint16_t*)pMsg) == 0x0000) {
|
||||
else if ((*(uint16_t*)pMsg) == 0xFFFF) {
|
||||
beginChargWork();
|
||||
// setPowerOutput(TRUE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 控制放电开关状态
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
uint16_t SL_WriteRegisterDisChargControl(void *pMsg)
|
||||
{
|
||||
// debug_printf("SL_WriteRegisterDisChargControl\n");
|
||||
if ((*(uint16_t*)pMsg) == 0x0000) {
|
||||
setPowerOutput(FALSE);
|
||||
}
|
||||
|
||||
else if ((*(uint16_t*)pMsg) == 0xFFFF) {
|
||||
setPowerOutput(TRUE);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -1214,7 +1241,7 @@ uint16_t SL_WriteRegisterChargControl(void *pMsg)
|
|||
*/
|
||||
uint16_t SL_WriteRegisterCleanSOE(void *pMsg)
|
||||
{
|
||||
debug_printf("SL_WriteRegisterCleanSOE\n");
|
||||
// debug_printf("SL_WriteRegisterCleanSOE\n");
|
||||
cleanEventsOrderRecord();
|
||||
|
||||
return 0;
|
||||
|
@ -1586,10 +1613,11 @@ uint8_t *analysisDistributionProfile(uint8_t *pMsg, config_info *temp)
|
|||
/* 配置 最大充电电流 */
|
||||
else if (dataType == max_Charg_Curr) {
|
||||
float tempFloat = ((*(pMsg + 2) << 8) | *(pMsg + 3)) / floatMagnification;
|
||||
if (tempFloat > 40 || tempFloat < 30) {
|
||||
if (tempFloat > 40 || tempFloat < 20) {
|
||||
// debug_printf("max_Charg_Curr\n");
|
||||
return NULL;
|
||||
}
|
||||
// debug_printf("max_Charg_Curr : %f\n", tempFloat);
|
||||
|
||||
temp->maxChargCurr = tempFloat;
|
||||
return (pMsg + 4);
|
||||
|
@ -1603,7 +1631,7 @@ uint8_t *analysisDistributionProfile(uint8_t *pMsg, config_info *temp)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
temp->maxChargCurr = tempFloat;
|
||||
temp->minCheckLoopImpedanceChargCurr = tempFloat;
|
||||
return (pMsg + 4);
|
||||
}
|
||||
|
||||
|
@ -1669,7 +1697,7 @@ uint8_t *analysisDistributionProfile(uint8_t *pMsg, config_info *temp)
|
|||
/* 配置 充电时采集开路电压的间隔时间 */
|
||||
else if (dataType == collect_OpenCircuit_Voltage_Time) {
|
||||
uint16_t tempU16 = (*(pMsg + 2) << 8) | *(pMsg + 3);
|
||||
if (tempU16 > 10000 || tempU16 < 1000) {
|
||||
if (tempU16 > 10000 || tempU16 < 100) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -1680,7 +1708,7 @@ uint8_t *analysisDistributionProfile(uint8_t *pMsg, config_info *temp)
|
|||
/* 配置 反向充电保护电流 */
|
||||
else if (dataType == reverse_Charge_Protection_Curr) {
|
||||
float tempFloat = ((*(pMsg + 2) << 8) | *(pMsg + 3)) / floatMagnification;
|
||||
if (tempFloat > 10.0f || tempFloat < 0.1f) {
|
||||
if (tempFloat > 12.0f || tempFloat < 0.1f) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2071,7 +2099,7 @@ uint8_t *analysisReadProfile(uint8_t *pMsg, uint8_t **outData, uint16_t *dataLen
|
|||
return (pMsg + 2);
|
||||
}
|
||||
|
||||
debug_printf("dataType error : %d\n", dataType);
|
||||
// debug_printf("dataType error : %d\n", dataType);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -2216,7 +2244,7 @@ void SL_MsgProcFunc_Registration_request(device_handle device, void *pMsg, uint3
|
|||
*/
|
||||
void SL_MsgProcFunc_Distribution_Profile(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
debug_printf("SL_MsgProcFunc_Distribution_Profile\n");
|
||||
// debug_printf("SL_MsgProcFunc_Distribution_Profile\n");
|
||||
/* 确保帧不乱序,依次发完 */
|
||||
static uint8_t flag = 0;
|
||||
static config_info cfgInfo = {0};
|
||||
|
@ -2407,7 +2435,7 @@ singlePackageError:
|
|||
*/
|
||||
void SL_MsgProcFunc_Read_Profile(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
debug_printf("SL_MsgProcFunc_Read_Profile\n");
|
||||
// debug_printf("SL_MsgProcFunc_Read_Profile\n");
|
||||
uint8_t *replay_pack = getInsertData();
|
||||
if (replay_pack == NULL) {
|
||||
return;
|
||||
|
@ -2483,7 +2511,7 @@ void SL_MsgProcFunc_Read_Profile(device_handle device, void *pMsg, uint32_t MsgL
|
|||
uart_insertDataSend(device, 15 + replayPackDatalen);
|
||||
|
||||
|
||||
debug_printf("SL_MsgProcFunc_Read_Profile end\n");
|
||||
// debug_printf("SL_MsgProcFunc_Read_Profile end\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2495,7 +2523,7 @@ void SL_MsgProcFunc_Read_Profile(device_handle device, void *pMsg, uint32_t MsgL
|
|||
*/
|
||||
void SL_MsgProcFunc_Read_SOE(device_handle device, void *pMsg, uint32_t MsgLen)
|
||||
{
|
||||
debug_printf("SL_MsgProcFunc_Read_SOE\n");
|
||||
// debug_printf("SL_MsgProcFunc_Read_SOE\n");
|
||||
uint8_t *replay_pack = getInsertData();
|
||||
if (replay_pack == NULL) {
|
||||
return;
|
||||
|
|
|
@ -134,7 +134,7 @@ STR_TimeSliceOffset m_uart;
|
|||
void Task_uart(void);
|
||||
|
||||
/* 将记录下来的时间存入flash中 */
|
||||
#define SOE_reloadVal 3000 /* 任务执行间隔 */
|
||||
#define SOE_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define SOE_offset 100 /* 任务执行偏移量 */
|
||||
STR_TimeSliceOffset m_SOE;
|
||||
void Task_SOE(void);
|
||||
|
@ -338,6 +338,14 @@ void Task_refreshJudgeData(void)
|
|||
setPowerOutput(FALSE);
|
||||
insertEventsOrderRecord(InputProtection);
|
||||
}
|
||||
|
||||
/* 充电输入电压过高 */
|
||||
if (getSolarInCircuitVoltage() >= g_cfgParameter.maxOpenSolarOutputCircuitV) {
|
||||
// log_info("getSolarInCircuitVoltage : %f", getSolarInCircuitVoltage());
|
||||
// log_info("g_cfgParameter.maxOpenSolarOutputCircuitV : %f", g_cfgParameter.maxOpenSolarOutputCircuitV);
|
||||
stopChargWork();
|
||||
insertEventsOrderRecord(overInputVolt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -368,11 +376,6 @@ void Task_startControl(void)
|
|||
/* 启动软起动任务 */
|
||||
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
|
||||
}
|
||||
|
||||
if (getSolarInCircuitVoltage() >= g_cfgParameter.maxOpenSolarOutputCircuitV) {
|
||||
insertEventsOrderRecord(overInputVolt);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief 打开启动任务
|
||||
|
|
|
@ -54,7 +54,6 @@ typedef enum {
|
|||
runLedOtherMode = 2, //其他模式
|
||||
}runLedMode;
|
||||
|
||||
|
||||
/* 顺序事件记录 */
|
||||
typedef enum {
|
||||
firstStageProtection = 1, //第一段保护,短路保护
|
||||
|
|
Loading…
Reference in New Issue