完善控制和保护

This commit is contained in:
起床就犯困 2024-12-24 14:43:20 +08:00
parent eca3fd058a
commit 0fcdfa75d3
26 changed files with 470 additions and 142 deletions

View File

@ -31,6 +31,7 @@
"chargcontrolenum.h": "c", "chargcontrolenum.h": "c",
"chargcontroltypes.h": "c", "chargcontroltypes.h": "c",
"fm_rtc.h": "c", "fm_rtc.h": "c",
"interruptsend.h": "c" "interruptsend.h": "c",
"rtc.h": "c"
} }
} }

View File

@ -59,6 +59,8 @@ void start(void)
startInfo(); startInfo();
HAL_Delay(5000);
TimeSliceOffset_Start(); TimeSliceOffset_Start();
} }

View File

@ -9,7 +9,6 @@
#define buffLen 100 #define buffLen 100
extern uint8_t rs485_buff[buffLen]; extern uint8_t rs485_buff[buffLen];
void gw485_RxIt(void); void gw485_RxIt(void);
void bat485_RxIt(void); void bat485_RxIt(void);

View File

@ -4,6 +4,7 @@
#include "flash.h" #include "flash.h"
#include "stm32g431xx.h" #include "stm32g431xx.h"
#include "chargControlTypes.h"
#pragma pack(push, 1) #pragma pack(push, 1)
@ -94,6 +95,7 @@ typedef struct _config_info{
#define LoopImpedance_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 10) #define LoopImpedance_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 10)
#define totalElectricityConsumption_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 20) #define totalElectricityConsumption_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 20)
#define totalChargCapacity_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 30) #define totalChargCapacity_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 30)
#define time_SAVE_addr (CONFIG_INFO_SIZE + CONFIG_INFO_SIZE + 40)
// void save_config_info(config_info *save_config_info); // void save_config_info(config_info *save_config_info);
void read_config_info(config_info *output_config_info); void read_config_info(config_info *output_config_info);
@ -106,5 +108,7 @@ void savetotalElectricityConsumption(float *totalElectricityConsumption);
void readtotalElectricityConsumption(float *totalElectricityConsumption); void readtotalElectricityConsumption(float *totalElectricityConsumption);
void savetotalChargCapacity(float *totalChargCapacity); void savetotalChargCapacity(float *totalChargCapacity);
void readtotalChargCapacity(float *totalChargCapacity); void readtotalChargCapacity(float *totalChargCapacity);
void saveTime(timeInfo *time);
void readTime(timeInfo *time);
#endif #endif

View File

@ -3,6 +3,7 @@
#include "main.h" #include "main.h"
#include "comm_types.h" #include "comm_types.h"
#include "chargControlTypes.h"
#define softVer "SV01_24101501" #define softVer "SV01_24101501"
@ -22,12 +23,15 @@ typedef struct _config_parameter{
float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 (°C) */ float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */ float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
// uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */ // uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */
// uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */ // uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */ uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
uint16_t excessiveLoadFlagTime; /* 出现过载后在该间隔时间中多次2次出现过载则关闭输出 (S) */ uint16_t excessiveLoadFlagTime; /* 出现过载后在该间隔时间中多次2次出现过载则关闭输出 (S) */
uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */ uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
// uint16_t softShortTime; /* 软件短路保护延时 时间(100uS) */
uint32_t collectOpenCircuitVoltageTime; /* 充电时开路电压采集时间间隔 */ uint32_t collectOpenCircuitVoltageTime; /* 充电时开路电压采集时间间隔 */
/* SL */ /* SL */
uint16_t Access_Node_Type; /* 接入节点类型 */ uint16_t Access_Node_Type; /* 接入节点类型 */
@ -83,6 +87,8 @@ uint8_t getMosTemperState(void);
void setMosTemperState(uint8_t state); void setMosTemperState(uint8_t state);
BOOL getCheckImpedanceState(void); BOOL getCheckImpedanceState(void);
void setCheckImpedanceState(void); void setCheckImpedanceState(void);
void setLastTime(timeInfo time);
timeInfo getLastTime(void);
float getBatteryVoltage(void); float getBatteryVoltage(void);
void setBatteryVoltage(void); void setBatteryVoltage(void);

View File

@ -16,8 +16,9 @@ void uartTaskInit(void);
void startShortCircuitProtection(void); void startShortCircuitProtection(void);
void stopShortCircuitProtection(void); void stopShortCircuitProtection(void);
void startExcessiveLoadProtection(void); void startExcessiveLoadProtection(void);
void startSoftShortCircuitProtection(void);
void chargRunLed(uint8_t mode);
#endif #endif

View File

@ -9,6 +9,7 @@
#include "abnormalManage.h" #include "abnormalManage.h"
#include "pDebug.h" #include "pDebug.h"
#include "interruptSend.h" #include "interruptSend.h"
#include "FM_RTC.h"
/** /**
* @brief * @brief
@ -18,7 +19,7 @@
*/ */
void Init(void) void Init(void)
{ {
HAL_Delay(10000); // HAL_Delay(10000);
config_info_start(); config_info_start();
ADC_Capture_Init(); ADC_Capture_Init();
@ -27,6 +28,8 @@ void Init(void)
FM_GPIO_Init(); FM_GPIO_Init();
tim_Init(); tim_Init();
FM_RTC_Init();
Init_debug_uart(); Init_debug_uart();
Init_BAT485_uart(g_cfgParameter.bat485_Baud); Init_BAT485_uart(g_cfgParameter.bat485_Baud);
Init_GW485_uart(g_cfgParameter.gw485_Baud); Init_GW485_uart(g_cfgParameter.gw485_Baud);

View File

@ -22,17 +22,65 @@ static BOOL excessiveLoadFlag = FALSE;
/** /**
* @brief * @brief
* @param state TRUE * @param
* FALSE
* @retval * @retval
* *
*/ */
void setDisChargOverLoad(void) void setDisChargOverLoad(void)
{ {
/* 三段式保护中的两段 */
static int num1 = 0;
if (getDischargCurrent() > 30.0f) { if (getDischargCurrent() > 30.0f) {
disChargOverLoad = TRUE; // disChargOverLoad = TRUE;
num1++;
} else { } else {
disChargOverLoad = FALSE; // disChargOverLoad = FALSE;
num1 = 0;
}
/* 过载时间过长关闭输出(120S) */
if (num1 >= 1200000) {
num1 = 0;
disChargOverLoad = TRUE;
setPowerOutput(FALSE);
}
static int num2 = 0;
if (getDischargCurrent() > 35.0f) {
num2++;
} else {
num2 = 0;
}
/* 过载时间过长关闭输出(5S) */
if (num1 >= 50000) {
num1 = 0;
disChargOverLoad = TRUE;
setPowerOutput(FALSE);
}
}
/**
* @brief
* @param
* @retval
*
*/
void setSoftShortCircuit(void)
{
static int num = 0;
if (getDischargCurrent() > 50.0f) {
num++;
} else {
num = 0;
}
/* 200uS内都短路则关闭输出 */
if (num >= 2) {
shortCircuitFlag = TRUE;
shortCircuit++;
setPowerOutput(FALSE);
startSoftShortCircuitProtection();
} }
} }
@ -91,8 +139,7 @@ void setShortCircuitFlag(BOOL state)
{ {
if (state == TRUE || state == FALSE) { if (state == TRUE || state == FALSE) {
shortCircuitFlag = state; shortCircuitFlag = state;
} }
} }
/** /**
@ -150,8 +197,7 @@ void setExcessiveLoadFlag(BOOL state)
{ {
if (state == TRUE || state == FALSE) { if (state == TRUE || state == FALSE) {
excessiveLoadFlag = state; excessiveLoadFlag = state;
} }
} }
/** /**
@ -201,7 +247,27 @@ void checkFFMOS_CON(void)
} }
} }
// /**
// * @brief 判断是否短路
// * @param
// * @retval
// *
// */
// void checkShortCircuit(void)
// {
// static num = 0;
// if (getChargCurrent() > 50.0f) {
// num++;
// } else {
// num = 0;
// }
// if (num == g_cfgParameter.softShortTime) {
// setPowerOutput(FALSE);
// }
// }
void checkAbnormal(void) void checkAbnormal(void)
@ -218,10 +284,13 @@ void checkAbnormal(void)
/* 判断 */ /* 判断 */
checkFFMOS_CON(); checkFFMOS_CON();
setDisChargOverLoad(); setDisChargOverLoad();
setSoftShortCircuit();
// checkAbnormalTime = getCheckTime(); // checkAbnormalTime = getCheckTime();
} }
@ -233,6 +302,7 @@ void checkAbnormal(void)
*/ */
void WORK_VOLT_Interrupt(void) void WORK_VOLT_Interrupt(void)
{ {
setPowerOutput(FALSE);
setExcessiveLoad(); setExcessiveLoad();
/* 第一次进入输出过载,启动过载保护任务 */ /* 第一次进入输出过载,启动过载保护任务 */
if (getExcessiveLoad() == 1) { if (getExcessiveLoad() == 1) {
@ -243,7 +313,6 @@ void WORK_VOLT_Interrupt(void)
/* 多次进入输出过载,关闭输出 */ /* 多次进入输出过载,关闭输出 */
if (getExcessiveLoad() > 2) { if (getExcessiveLoad() > 2) {
zeroExcessiveLoad(); zeroExcessiveLoad();
setPowerOutput(FALSE);
} }
} }
@ -260,7 +329,7 @@ void DSG_PROT_Interrupt(void)
if (getShortCircuit() == 1) { if (getShortCircuit() == 1) {
setShortCircuitFlag(TRUE); setShortCircuitFlag(TRUE);
startShortCircuitProtection(); startShortCircuitProtection();
} }
/* 一定时间内第二次进入输出短路保护,关闭输出 */ /* 一定时间内第二次进入输出短路保护,关闭输出 */
else if (getShortCircuit() >= 2) { else if (getShortCircuit() >= 2) {

View File

@ -38,15 +38,20 @@ void mppt_constantVoltage(float InVoltage)
static float ki = 0.00001; static float ki = 0.00001;
// static float solarInCircuitVoltage; // static float solarInCircuitVoltage;
static float error; static float error;
static float stepPwm; static float stepPwm;
// solarInCircuitVoltage = getSolarInCircuitVoltage(); // solarInCircuitVoltage = getSolarInCircuitVoltage();
// error = InVoltage - getSolarInCircuitVoltage(); // error = InVoltage - getSolarInCircuitVoltage();
error = getSolarInCircuitVoltage() - InVoltage; error = getSolarInCircuitVoltage() - InVoltage;
stepPwm = kp * error + ki * getSolarInCircuitVoltage(); stepPwm = kp * error + ki * getSolarInCircuitVoltage();
setDutyRatio((getDutyRatio() + stepPwm)); setDutyRatio((getDutyRatio() + stepPwm));
// if (getMosTemperState() == mosTemperEnd) {
// setDutyRatio((getDutyRatio() + stepPwm - 0.1));
// } else {
// setDutyRatio((getDutyRatio() + stepPwm));
// }
} }
/** /**
@ -95,6 +100,11 @@ void mppt_constantVoltageO(float OutVoltage)
if (lastDutyRatio >= getDutyRatio()) { if (lastDutyRatio >= getDutyRatio()) {
// if (lastVolt >= outVolt) { // if (lastVolt >= outVolt) {
setDutyRatio((getDutyRatio() + StepPwm)); setDutyRatio((getDutyRatio() + StepPwm));
// if (getMosTemperState() == mosTemperEnd) {
// setDutyRatio((getDutyRatio() + StepPwm - 0.1));
// } else {
// setDutyRatio((getDutyRatio() + StepPwm));
// }
// } else { // } else {
// g_controlParameter.dutyRatio -= StepPwm; // g_controlParameter.dutyRatio -= StepPwm;
// } // }
@ -104,7 +114,12 @@ void mppt_constantVoltageO(float OutVoltage)
// } else { // } else {
// g_controlParameter.dutyRatio += StepPwm; // g_controlParameter.dutyRatio += StepPwm;
// } // }
setDutyRatio((getDutyRatio() - StepPwm)); setDutyRatio((getDutyRatio() - StepPwm));
// if (getMosTemperState() == mosTemperEnd) {
// setDutyRatio((getDutyRatio() + StepPwm - 0.1));
// } else {
// setDutyRatio((getDutyRatio() + StepPwm));
// }
} }
// lastVolt = outVolt; // lastVolt = outVolt;
@ -315,7 +330,7 @@ void mppt_readJust(void)
if (powerIndex >= 50) { if (powerIndex >= 50) {
powerIndex = 0; powerIndex = 0;
} }
static float lPower = 0; static float lPower = 0;
static float lLPower = 0; static float lLPower = 0;
// static float lLLPower = 0; // static float lLLPower = 0;
@ -344,6 +359,12 @@ void mppt_readJust(void)
return; return;
} }
if (getMosTemperState() == mosTemperEnd) {
SolarInCircuitV = 16;
}
flag = 0; flag = 0;
Power = totalPower / 50.0f; Power = totalPower / 50.0f;
@ -457,7 +478,6 @@ void startChargWork(void)
} }
/** /**
* @brief * @brief
* @param * @param
@ -465,12 +485,12 @@ void startChargWork(void)
* FALSE * FALSE
* *
*/ */
BOOL stopChargConditions(void) BOOL stopChargConditions(void)
{ {
if (getSolarInCircuitVoltage() < g_cfgParameter.stopSolarOpenCircuitV if (getSolarInCircuitVoltage() < g_cfgParameter.stopSolarOpenCircuitV
&& getChargCurrent() < 0.1f) { && getChargCurrent() < 1) {
return TRUE; return TRUE;
} }
return FALSE; return FALSE;
} }
@ -517,8 +537,8 @@ BOOL mpptChargConditions(void)
*/ */
BOOL constantVChargConditions(void) BOOL constantVChargConditions(void)
{ {
if ((g_cfgParameter.constantVoltageChargeV < getBatteryVoltage()) if ((g_cfgParameter.constantVoltageV < getBatteryVoltage())
&& ((g_cfgParameter.floatI + 0.1f) <= getChargBatteryCurrent())) { && ((g_cfgParameter.floatI + 0.1f) <= getChargBatteryCurrent())) {
return TRUE; return TRUE;
} }
@ -553,7 +573,7 @@ void chargControlMode(void)
/** /**
* @brief * @brief
* @param * @param
* @retval * @retval
* *
*/ */
void judgeYNBattery(void) void judgeYNBattery(void)
@ -658,7 +678,14 @@ void setChargControlFlag(BOOL state)
{ {
if (state == TRUE || state == FALSE) { if (state == TRUE || state == FALSE) {
chargControlFlag = state; chargControlFlag = state;
} }
if (state == TRUE) {
chargRunLed(runLedChargMode);
} else if (state == FALSE) {
chargRunLed(runLedOtherMode);
}
} }
/** /**

View File

@ -6,8 +6,6 @@
uint8_t rs485_buff[buffLen]={0x00}; uint8_t rs485_buff[buffLen]={0x00};
/** /**
* @brief gw485串口接收中断回调函数 * @brief gw485串口接收中断回调函数
* @param * @param

View File

@ -408,6 +408,8 @@ void read_and_process_config_data(void)
// } // }
uart_dev_write(g_gw485_uart2_handle, "hello world\n", sizeof("hello world\n")); uart_dev_write(g_gw485_uart2_handle, "hello world\n", sizeof("hello world\n"));
HAL_Delay(1000);
/* 复位 */ /* 复位 */
NVIC_SystemReset(); NVIC_SystemReset();

View File

@ -11,6 +11,7 @@
#include "bl_comm.h" #include "bl_comm.h"
#include "chargControlTypes.h" #include "chargControlTypes.h"
#include "FM_RTC.h" #include "FM_RTC.h"
#include "interruptSend.h"
// #include "RingQueue.h" // #include "RingQueue.h"
@ -160,7 +161,7 @@ typedef struct _HY_electricityStatisticsResponse{
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */ uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */ uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
float_t statisticalDuration; /* 统计时长 */ uint32_t statisticalDuration; /* 统计时长 */
float_t totalElectricityConsumption; /* 总电量消耗 */ float_t totalElectricityConsumption; /* 总电量消耗 */
float_t totalChargCapacity; /* 总充电电量 */ float_t totalChargCapacity; /* 总充电电量 */
uint32_t frameNumber; /* 帧序号 */ uint32_t frameNumber; /* 帧序号 */
@ -613,8 +614,8 @@ typedef struct _HY_configTime {
uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */ uint8_t communicationID[4]; /* 通信ID高字节在前低字节在后 */
uint8_t controlWord; /* 控制字 */ uint8_t controlWord; /* 控制字 */
uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */ uint8_t dataLen[2]; /* 数据长度;高字节在前,低字节在后 */
uint32_t frameNumber; /* 帧序号 */
timeInfo time; /* 年月日时分秒 */ timeInfo time; /* 年月日时分秒 */
uint32_t frameNumber; /* 帧序号 */
uint8_t check_Bit; /* 校验码 */ uint8_t check_Bit; /* 校验码 */
uint8_t end_Flag; /* 结束标志 */ uint8_t end_Flag; /* 结束标志 */
}HY_configTime; }HY_configTime;
@ -1048,7 +1049,7 @@ static int HY_uart_read_climate_pack(device_handle uart_handle,uint8_t *buff, ui
if (offset == len) { if (offset == len) {
if (buff[len - 2] != HY_CheckFunc(buff, len - 2) if (buff[len - 2] != HY_CheckFunc(buff, len - 2)
&& buff[len - 1] != g_cfgParameter.endFlagHY) { || buff[len - 1] != g_cfgParameter.endFlagHY) {
if (flag_run < 5) { if (flag_run < 5) {
flag_run = 5; flag_run = 5;
} }
@ -1153,8 +1154,8 @@ void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t Msg
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
// uart_interruptSend(device, (uint8_t *)&pack, HY_batteryStatusResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_batteryStatusResponse_PACK_SIZE);
uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE); // uart_dev_write(device, &pack, HY_batteryStatusResponse_PACK_SIZE);
} }
/* 电量统计数据报 */ /* 电量统计数据报 */
@ -1180,7 +1181,13 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint
pack.dataLen[0] = HY_electricityStatisticsResponse_dataLen >> 8; pack.dataLen[0] = HY_electricityStatisticsResponse_dataLen >> 8;
pack.dataLen[1] = HY_electricityStatisticsResponse_dataLen; pack.dataLen[1] = HY_electricityStatisticsResponse_dataLen;
pack.statisticalDuration = 0; timeInfo time1, time2 = {0};
getRTC_Time(&time1);
time2 = getLastTime();
pack.statisticalDuration = differTime(&time1, &time2);
setLastTime(time1);
// pack.statisticalDuration = 0;
pack.totalChargCapacity = getTotalChargCapacity(); pack.totalChargCapacity = getTotalChargCapacity();
pack.totalElectricityConsumption = getTotalElectricityConsumption(); pack.totalElectricityConsumption = getTotalElectricityConsumption();
@ -1194,6 +1201,7 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint
// // temp = getTotalElectricityConsumption(); // // temp = getTotalElectricityConsumption();
// savetotalElectricityConsumption(&temp); // savetotalElectricityConsumption(&temp);
HY_electricityStatisticsQuery *Tpack = (HY_electricityStatisticsQuery *)pMsg; HY_electricityStatisticsQuery *Tpack = (HY_electricityStatisticsQuery *)pMsg;
pack.frameNumber = Tpack->frameNumber; pack.frameNumber = Tpack->frameNumber;
@ -1201,8 +1209,8 @@ void HY_MsgProcFunc_electricityStatistics(device_handle device, void *pMsg, uint
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
// uart_interruptSend(device, (uint8_t *)&pack, HY_electricityStatisticsResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_electricityStatisticsResponse_PACK_SIZE);
uart_dev_write(device, &pack, HY_electricityStatisticsResponse_PACK_SIZE); // uart_dev_write(device, &pack, HY_electricityStatisticsResponse_PACK_SIZE);
} }
@ -1258,7 +1266,8 @@ void HY_MsgProcFunc_sensorNumberConfiguration(device_handle device, void *pMsg,
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberConfigurationResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberConfigurationResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_sensorNumberConfigurationResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_sensorNumberConfigurationResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_sensorNumberConfigurationResponse_PACK_SIZE);
} }
/* 传感器号码查询 */ /* 传感器号码查询 */
@ -1304,7 +1313,8 @@ void HY_MsgProcFunc_sensorNumberInquiry(device_handle device, void *pMsg, uint32
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberInquiryResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_sensorNumberInquiryResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_sensorNumberInquiryResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_sensorNumberInquiryResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_sensorNumberInquiryResponse_PACK_SIZE);
} }
/* 充电阈值电压配置 */ /* 充电阈值电压配置 */
@ -1352,7 +1362,8 @@ void HY_MsgProcFunc_resetInstruction(device_handle device, void *pMsg, uint32_t
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_resetInstructionResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_resetInstructionResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_resetInstructionResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_resetInstructionResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_resetInstructionResponse_PACK_SIZE);
/* 复位 */ /* 复位 */
NVIC_SystemReset(); NVIC_SystemReset();
@ -1404,7 +1415,8 @@ void HY_MsgProcFunc_chargingControlConfiguration(device_handle device, void *pMs
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_chargingControlConfigResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_chargingControlConfigResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_chargingControlConfigResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_chargingControlConfigResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_chargingControlConfigResponse_PACK_SIZE);
} }
/* 充电控制查询 */ /* 充电控制查询 */
@ -1447,7 +1459,8 @@ static void HY_MsgProcFunc_chargingControlQuery(device_handle device, void *pMsg
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_QueryChargingControlResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_QueryChargingControlResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_QueryChargingControlResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_QueryChargingControlResponse_PACK_SIZE);
uart_dev_write(device, (uint8_t *)&pack, HY_QueryChargingControlResponse_PACK_SIZE);
} }
@ -1499,7 +1512,9 @@ void HY_MsgProcFunc_configureProtocolType(device_handle device, void *pMsg, uint
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configProtocolTypeResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configProtocolTypeResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_configProtocolTypeResponse_PACK_SIZE);
uart_interruptSend(device, (uint8_t *)&pack, HY_configProtocolTypeResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_configProtocolTypeResponse_PACK_SIZE);
Init_GW485_uart(g_cfgParameter.gw485_Baud); Init_GW485_uart(g_cfgParameter.gw485_Baud);
} }
@ -1542,7 +1557,8 @@ void HY_MsgProcFunc_queryControlBoxConfiguration(device_handle device, void *pMs
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_queryControlBoxConfigurationResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_queryControlBoxConfigurationResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_queryControlBoxConfigurationResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_queryControlBoxConfigurationResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_queryControlBoxConfigurationResponse_PACK_SIZE);
} }
/* 查询电池控制盒软件版本 */ /* 查询电池控制盒软件版本 */
@ -1579,7 +1595,8 @@ void HY_MsgProcFunc_querySoftwareVersion(device_handle device, void *pMsg, uint3
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_SoftwareVersionQueryResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_SoftwareVersionQueryResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_SoftwareVersionQueryResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_SoftwareVersionQueryResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_SoftwareVersionQueryResponse_PACK_SIZE);
} }
/* 进入配置模式 */ /* 进入配置模式 */
@ -1615,7 +1632,8 @@ void HY_MsgProcFunc_enterConfigurationMode(device_handle device, void *pMsg, uin
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_enterConfigModeResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_enterConfigModeResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_enterConfigModeResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_enterConfigModeResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_enterConfigModeResponse_PACK_SIZE);
beginHYconfigMode(); beginHYconfigMode();
} }
@ -1677,7 +1695,8 @@ void HY_MsgProcFunc_configureHardwareID(device_handle device, void *pMsg, uint32
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configHardwareIDResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configHardwareIDResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_configHardwareIDResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_configHardwareIDResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_configHardwareIDResponse_PACK_SIZE);
} }
/* 控制盒硬件ID号及通信ID号原传感器号查询 */ /* 控制盒硬件ID号及通信ID号原传感器号查询 */
@ -1723,7 +1742,8 @@ void HY_MsgProcFunc_hardwareID_communicationIDQuery(device_handle device, void *
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_QueryhardwareID_communicationIDResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_QueryhardwareID_communicationIDResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_QueryhardwareID_communicationIDResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_QueryhardwareID_communicationIDResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_QueryhardwareID_communicationIDResponse_PACK_SIZE);
} }
/* 修改通信ID号原传感器号 */ /* 修改通信ID号原传感器号 */
@ -1778,7 +1798,8 @@ void HY_MsgProcFunc_modifyCommunicationID(device_handle device, void *pMsg, uint
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_modifyCommunicationIDChangeResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_modifyCommunicationIDChangeResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_modifyCommunicationIDChangeResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_modifyCommunicationIDChangeResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_modifyCommunicationIDChangeResponse_PACK_SIZE);
} }
/* 查询主板温度值 */ /* 查询主板温度值 */
@ -1814,7 +1835,8 @@ void HY_MsgProcFunc_checkMotherboardTemperature(device_handle device, void *pMsg
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_checkMotherboardTemperatureResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_checkMotherboardTemperatureResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_checkMotherboardTemperatureResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_checkMotherboardTemperatureResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_checkMotherboardTemperatureResponse_PACK_SIZE);
} }
/* 配置时间 */ /* 配置时间 */
@ -1822,7 +1844,10 @@ void HY_MsgProcFunc_configTime(device_handle device, void *pMsg, uint32_t MsgLen
{ {
HY_configTime *Tpack = (HY_configTime *)pMsg; HY_configTime *Tpack = (HY_configTime *)pMsg;
setRTC_Time(&Tpack->time); // static timeInfo time;
// time = Tpack->time;
// setRTC_Time(&time);
setRTC_Time((timeInfo *)&Tpack->time);
HY_configTimeResponse pack; HY_configTimeResponse pack;
@ -1851,8 +1876,9 @@ void HY_MsgProcFunc_configTime(device_handle device, void *pMsg, uint32_t MsgLen
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configTimeResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_configTimeResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_configTimeResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_configTimeResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_configTimeResponse_PACK_SIZE);
} }
@ -1884,7 +1910,7 @@ static void HY_MsgProcFunc_queryTime(device_handle device, void *pMsg, uint32_t
pack.dataLen[0] = HY_queryTimeResponse_dataLen >> 8; pack.dataLen[0] = HY_queryTimeResponse_dataLen >> 8;
pack.dataLen[1] = HY_queryTimeResponse_dataLen; pack.dataLen[1] = HY_queryTimeResponse_dataLen;
timeInfo time; static timeInfo time;
getRTC_Time(&time); getRTC_Time(&time);
pack.time = time; pack.time = time;
@ -1894,5 +1920,6 @@ static void HY_MsgProcFunc_queryTime(device_handle device, void *pMsg, uint32_t
pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_queryTimeResponse_PACK_SIZE - 2); pack.check_Bit = HY_CheckFunc((uint8_t *)(&pack), HY_queryTimeResponse_PACK_SIZE - 2);
pack.end_Flag = g_cfgParameter.endFlagHY; pack.end_Flag = g_cfgParameter.endFlagHY;
uart_dev_write(device, &pack, HY_queryTimeResponse_PACK_SIZE); uart_interruptSend(device, (uint8_t *)&pack, HY_queryTimeResponse_PACK_SIZE);
// uart_dev_write(device, (uint8_t *)&pack, HY_queryTimeResponse_PACK_SIZE);
} }

View File

@ -212,6 +212,10 @@ void config_info_start(void)
readtotalChargCapacity(&fTemp); readtotalChargCapacity(&fTemp);
totalChargCapacityInt(fTemp); totalChargCapacityInt(fTemp);
timeInfo time;
readTime(&time);
setLastTime(time);
} }
@ -269,3 +273,20 @@ void readtotalChargCapacity(float *totalChargCapacity)
read_Flash((uint8_t *)totalChargCapacity, totalChargCapacity_SAVE_addr, sizeof(float)); read_Flash((uint8_t *)totalChargCapacity, totalChargCapacity_SAVE_addr, sizeof(float));
} }
/**
* @brief flash中的时间
* @param
*/
void saveTime(timeInfo *time)
{
write_Flash((uint8_t *)time, time_SAVE_addr, sizeof(timeInfo));
}
/**
* @brief flash中的时间
* @param
*/
void readTime(timeInfo *time)
{
read_Flash((uint8_t *)time, time_SAVE_addr, sizeof(timeInfo));
}

View File

@ -291,12 +291,13 @@ void uart_interruptSend(device_handle device, uint8_t buff[], uint8_t len)
uart_send.insertData->device = device; uart_send.insertData->device = device;
// uart_send.insertData->dataState = 1; // uart_send.insertData->dataState = 1;
// uart_send.insertState--; // uart_send.insertState--;
uart_send.insertData->dataState = TRUE;
uart_send.insertState--;
break; break;
} }
} while (1); /* 0执行一次 1一直循环直到能插入 */
} while (0);
uart_send.insertData->dataState = TRUE;
uart_send.insertState--;
/* 可插入数据大于0时将插入指针指向空的储存位置,否则指向NULL */ /* 可插入数据大于0时将插入指针指向空的储存位置,否则指向NULL */
if (uart_send.insertState > 0) { if (uart_send.insertState > 0) {

View File

@ -3,15 +3,15 @@
#include "FM_TIM.h" #include "FM_TIM.h"
#include "FM_GPIO.h" #include "FM_GPIO.h"
#include "capture.h" #include "capture.h"
#include "chargControlTypes.h"
config_parameter g_cfgParameter = {0}; config_parameter g_cfgParameter = {0};
static otherParameter g_otherParameter = {0}; static otherParameter g_otherParameter = {0};
static BOOL batteryState = FALSE; /* 有无电池(估计) */ static BOOL batteryState = FALSE; /* 有无电池(估计) */
static float dutyRatio; /* 占空比 */ static float dutyRatio; /* 占空比 */
static uint8_t mosTemperState = mosTemperStop; /* mos管温度状态 */ static uint8_t mosTemperState = mosTemperStart; /* mos管温度状态 */
static BOOL checkImpedanceState = FALSE; /* 启动后是否进行了回路阻抗检测 */ static BOOL checkImpedanceState = FALSE; /* 启动后是否进行了回路阻抗检测 */
static timeInfo lastTime = {0}; /* 上次读取充放电量参数的时间 */
/** /**
* @brief * @brief
@ -55,15 +55,16 @@ float getDutyRatio(void)
*/ */
void setDutyRatio(float DutyRatio) void setDutyRatio(float DutyRatio)
{ {
if (DutyRatio > 0.9f) { if (DutyRatio > 0.95f) {
dutyRatio = 0.9f; dutyRatio = 0.95f;
} }
else if (DutyRatio < 0.05f) { else if (DutyRatio < 0.05f) {
dutyRatio = 0.05f; dutyRatio = 0.05f;
} }
else { else {
dutyRatio = DutyRatio; dutyRatio = DutyRatio;
} }
set_pwmDutyRatio(dutyRatio); set_pwmDutyRatio(dutyRatio);
} }
@ -123,6 +124,29 @@ void setCheckImpedanceState(void)
checkImpedanceState = TRUE; checkImpedanceState = TRUE;
} }
/**
* @brief
* @param
* @retval
*
*/
void setLastTime(timeInfo time)
{
lastTime = time;
}
/**
* @brief
* @param
* @retval
*
*/
timeInfo getLastTime(void)
{
return lastTime;
}
/** /**
* @brief * @brief
* @param * @param
@ -417,10 +441,10 @@ void setChargMosState(BOOL state)
{ {
if (state == FALSE) { if (state == FALSE) {
/* 关闭充电 */ /* 关闭充电 */
stopChargWork();
} else if (state == TRUE) { } else if (state == TRUE) {
/* 打开充电 */ /* 打开充电 */
beginChargWork();
} }
} }

View File

@ -11,10 +11,11 @@
#include "abnormalManage.h" #include "abnormalManage.h"
#include "interruptSend.h" #include "interruptSend.h"
#include <stdio.h>
/* 控制运行指示灯和喂狗 */ /* 控制运行指示灯和喂狗 */
// #define runled_reloadVal 1000 /* 任务执行间隔 */ #define runled_reloadVal 2000 /* 任务执行间隔 */
static uint16_t runled_reloadVal = 1000; /* 任务执行间隔 */ // static uint16_t runled_reloadVal = 1000; /* 任务执行间隔 */
#define runled_offset 0 /* 任务执行偏移量 */ #define runled_offset 0 /* 任务执行偏移量 */
static STR_TimeSliceOffset m_runled; static STR_TimeSliceOffset m_runled;
static void Task_Runled(void); static void Task_Runled(void);
@ -105,6 +106,18 @@ void Task_busFree(void);
// STR_TimeSliceOffset m_interruptSend; // STR_TimeSliceOffset m_interruptSend;
// void Task_interruptSend(void); // void Task_interruptSend(void);
// /* 软件过载保护 */
// #define softExcessiveLoad_reloadVal 1000 /* 任务执行间隔 */
// #define softExcessiveLoad_offset 0 /* 任务执行偏移量 */
// STR_TimeSliceOffset m_softExcessiveLoad;
// void Task_softExcessiveLoad(void);
/* 软件短路保护 */
#define softShortCircuit_reloadVal 1000 /* 任务执行间隔 */
#define softShortCircuit_offset 0 /* 任务执行偏移量 */
STR_TimeSliceOffset m_softShortCircuit;
void Task_softShortCircuit(void);
/** /**
* @brief * @brief
* @param None * @param None
@ -138,6 +151,23 @@ void Task_Runled(void)
RUN_LED(); RUN_LED();
} }
/**
* @brief
* @param mode 1Hz的频率闪烁
* 2Hz的频率闪烁
* @retval None
*
*/
void chargRunLed(uint8_t mode)
{
if (mode == runLedChargMode) {
m_runled.reloadVal = 500;
}
else if (mode == runLedOtherMode) {
m_runled.reloadVal = 2000;
}
}
/** /**
* @brief * @brief
* @param None * @param None
@ -159,7 +189,52 @@ void Task_wdi(void)
debug_printf("loopImpedance:%f \n", g_cfgParameter.loopImpedance); debug_printf("loopImpedance:%f \n", g_cfgParameter.loopImpedance);
debug_printf("DutyRatio:%f \n", getDutyRatio()); debug_printf("DutyRatio:%f \n", getDutyRatio());
uart_interruptSend(g_gw485_uart2_handle, "hello world\n", sizeof("hello world\n")); // char buf[100];
// sprintf(buf, "chargCurrent:%f \n", getChargCurrent());
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// memset(buf, 0, sizeof(buf));
// sprintf(buf, "outputVoltage:%f \n", getOutputVoltage());
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// memset(buf, 0, sizeof(buf));
// sprintf(buf, "BatteryVoltage:%f \n", getBatteryVoltage());
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// memset(buf, 0, sizeof(buf));
// sprintf(buf, "dischargCurrent:%f \n", getDischargCurrent());
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// memset(buf, 0, sizeof(buf));
// sprintf(buf, "solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage());
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// memset(buf, 0, sizeof(buf));
// sprintf(buf, "HighSideMosTemperature:%f \n", getHighSideMosTemperature());
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// memset(buf, 0, sizeof(buf));
// sprintf(buf, "InputVoltage:%f \n", getInputVoltage());
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// memset(buf, 0, sizeof(buf));
// sprintf(buf, "DischargMosState:%d \n", getDischargMosState());
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// memset(buf, 0, sizeof(buf));
// sprintf(buf, "MPPT_Mode:%d \n", getMPPT_Mode());
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// memset(buf, 0, sizeof(buf));
// sprintf(buf, "loopImpedance:%f \n", g_cfgParameter.loopImpedance);
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// memset(buf, 0, sizeof(buf));
// sprintf(buf, "DutyRatio:%f \n", getDutyRatio());
// uart_dev_write(g_gw485_uart2_handle, buf, strlen(buf));
// uart_interruptSend(g_gw485_uart2_handle, "hello world\n", sizeof("hello world\n"));
/* 每天复位一次复位前将电量信息写入flash中 */ /* 每天复位一次复位前将电量信息写入flash中 */
static uint32_t temp = 60 * 60 * 24; static uint32_t temp = 60 * 60 * 24;
@ -170,6 +245,9 @@ void Task_wdi(void)
savetotalElectricityConsumption(&tempF); savetotalElectricityConsumption(&tempF);
tempF = getTotalChargCapacity(); tempF = getTotalChargCapacity();
savetotalChargCapacity(&tempF); savetotalChargCapacity(&tempF);
timeInfo time;
time = getLastTime();
saveTime(&time);
NVIC_SystemReset(); NVIC_SystemReset();
} }
@ -193,10 +271,11 @@ void Task_refreshJudgeData(void)
setBatteryState(TRUE); setBatteryState(TRUE);
} }
/* 有电池,太阳能输出功率大,同时回路阻抗未测试或需要重新测试 */ /* 有电池,太阳能输出功率大,电池电压低于14V同时回路阻抗未测试或需要重新测试 */
if ((getCheckImpedanceState() == FALSE || g_cfgParameter.loopImpedance == 0.0f) if ((getCheckImpedanceState() == FALSE || g_cfgParameter.loopImpedance == 0.0f)
&& (getBatteryState() == TRUE) && (getChargCurrent() > 3.0f) && (getBatteryState() == TRUE) && (getChargCurrent() > 3.0f)
&& (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)) { && (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)
&& (getBatteryVoltage() < 14)) {
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
, impedanceCalculation_reloadVal, impedanceCalculation_reloadVal); , impedanceCalculation_reloadVal, impedanceCalculation_reloadVal);
} }
@ -212,7 +291,7 @@ void Task_refreshJudgeData(void)
} }
else if ((getMosTemperState() == mosTemperStart) else if ((getMosTemperState() == mosTemperStart)
&& getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_end) { && getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_end) {
setMosTemperState(mosTemperEnd); setMosTemperState(mosTemperEnd);
} }
else if ((getMosTemperState() == mosTemperEnd) else if ((getMosTemperState() == mosTemperEnd)
&& getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_stop) { && getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_stop) {
@ -513,7 +592,7 @@ void Task_shortCircuitProtection(void)
/* 仍然过流,彻底关闭输出 */ /* 仍然过流,彻底关闭输出 */
if (readOverCurrState() == FALSE) { if (readOverCurrState() == FALSE) {
setPowerOutput(FALSE); setPowerOutput(FALSE);
} }
/* 不过流,则状态位复位 */ /* 不过流,则状态位复位 */
else { else {
setShortCircuitFlag(FALSE); setShortCircuitFlag(FALSE);
@ -648,4 +727,40 @@ void Task_busFree(void)
// { // {
// TimeSliceOffset_Register(&m_interruptSend, Task_interruptSend // TimeSliceOffset_Register(&m_interruptSend, Task_interruptSend
// , interruptSend_reloadVal, interruptSend_offset); // , interruptSend_reloadVal, interruptSend_offset);
// } // }
/**
* @brief
* @param
* @retval
*/
void Task_softShortCircuit(void)
{
static uint8_t num = 0;
if (2 == num++) {
setPowerOutput(TRUE);
}
if (num >= g_cfgParameter.outputAgainFlagTime) {
num = 0;
if (getShortCircuit() == 1) {
setShortCircuitFlag(FALSE);
}
zeroShortCircuit();
TimeSliceOffset_Unregister(&m_softShortCircuit);
m_softShortCircuit.runFlag = 0;
}
}
/**
* @brief
* @param
* @retval
*/
void startSoftShortCircuitProtection(void)
{
TimeSliceOffset_Register(&m_softShortCircuit, Task_softShortCircuit
, softShortCircuit_reloadVal, softShortCircuit_offset);
}

View File

@ -165,11 +165,23 @@ BOOL readOverCurrState(void)
*/ */
BOOL readOnlyPowerOutputState(void) BOOL readOnlyPowerOutputState(void)
{ {
if (HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin) static volatile GPIO_PinState gpioTemp1, gpioTemp2, gpioTemp3;
&& HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin)
&& HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin)) { gpioTemp1 = HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin);
return TRUE; gpioTemp2 = HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin);
} gpioTemp3 = HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin);
if (gpioTemp1 == GPIO_PIN_SET
&& gpioTemp2 == GPIO_PIN_SET
&& gpioTemp3 == GPIO_PIN_SET) {
return TRUE;
}
// if (HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin)
// && HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin)
// && HAL_GPIO_ReadPin(DSG_PROT_GPIO_Port, DSG_PROT_Pin)) {
// return TRUE;
// }
return FALSE; return FALSE;
} }
@ -200,9 +212,9 @@ void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
WORK_VOLT_Interrupt(); WORK_VOLT_Interrupt();
} }
else if (GPIO_Pin == DSG_PROT_Pin) { // else if (GPIO_Pin == DSG_PROT_Pin) {
DSG_PROT_Interrupt(); // DSG_PROT_Interrupt();
} // }
} }

View File

@ -22,9 +22,9 @@ void FM_RTC_Init(void)
void setRTC_Time(timeInfo *time) void setRTC_Time(timeInfo *time)
{ {
/* 日期结构体 */ /* 日期结构体 */
RTC_DateTypeDef setData; static RTC_DateTypeDef setData;
/* 时间结构体 */ /* 时间结构体 */
RTC_TimeTypeDef setTime; static RTC_TimeTypeDef setTime;
setData.Year = time->year; setData.Year = time->year;
setData.Month = time->month; setData.Month = time->month;
@ -46,9 +46,9 @@ void setRTC_Time(timeInfo *time)
void getRTC_Time(timeInfo *time) void getRTC_Time(timeInfo *time)
{ {
/* 日期结构体 */ /* 日期结构体 */
RTC_DateTypeDef getData; static RTC_DateTypeDef getData;
/* 时间结构体 */ /* 时间结构体 */
RTC_TimeTypeDef getTime; static RTC_TimeTypeDef getTime;
HAL_RTC_GetDate(&hrtc, &getData, RTC_FORMAT_BIN); HAL_RTC_GetDate(&hrtc, &getData, RTC_FORMAT_BIN);
HAL_RTC_GetTime(&hrtc, &getTime, RTC_FORMAT_BIN); HAL_RTC_GetTime(&hrtc, &getTime, RTC_FORMAT_BIN);

View File

@ -187,7 +187,7 @@ void proportionalInt(int mode)
/* 光伏充电输出电流比例,放大倍数*电阻 */ /* 光伏充电输出电流比例,放大倍数*电阻 */
P_CHG_CURR = (1.0 / (50 * (1 / (1 / 0.01 + 1 / 0.002)))) * Proportion; P_CHG_CURR = (1.0 / (50 * (1 / (1 / 0.01 + 1 / 0.002)))) * Proportion;
/* 充电控制盒输出电压比例,分压系数 */ /* 充电控制盒输出电压比例,分压系数 */
P_PV_VOLT_OUT = ((47.0 + 4.7) / 4.7) * Proportion; P_PV_VOLT_OUT = ((56.0 + 10.0) / 10.0) * Proportion;
/* 放电电流采集电流倍数 */ /* 放电电流采集电流倍数 */
P_DSG_CURR = (1.0 / (50 * (1 / (1 / 0.002 * 2)))) * Proportion; P_DSG_CURR = (1.0 / (50 * (1 / (1 / 0.002 * 2)))) * Proportion;
/* 光伏板输出电压比例 */ /* 光伏板输出电压比例 */
@ -203,7 +203,7 @@ void proportionalInt(int mode)
/* 光伏充电输出电流比例,放大倍数*电阻 */ /* 光伏充电输出电流比例,放大倍数*电阻 */
P_CHG_CURR = (1.0 / (50 * 0.005)) * Proportion; P_CHG_CURR = (1.0 / (50 * 0.005)) * Proportion;
/* 光伏充电输出电压比例,分压系数 */ /* 光伏充电输出电压比例,分压系数 */
P_PV_VOLT_OUT = ((47.0 + 4.7) / 4.7) * Proportion; P_PV_VOLT_OUT = ((56.0 + 10.0) / 10.0) * Proportion;
/* 放电电流采集电流倍数 */ /* 放电电流采集电流倍数 */
P_DSG_CURR = (1.0 / (50 * 0.005)) * Proportion; P_DSG_CURR = (1.0 / (50 * 0.005)) * Proportion;
/* 光伏1开路输出电压比例 */ /* 光伏1开路输出电压比例 */

View File

@ -48,8 +48,8 @@ void HD_GPIO_Init(void)
/*Configure GPIO pin : WORK_VOLT_INT_Pin */ /*Configure GPIO pin : WORK_VOLT_INT_Pin */
GPIO_InitStruct.Pin = WORK_VOLT_INT_Pin; GPIO_InitStruct.Pin = WORK_VOLT_INT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING;
GPIO_InitStruct.Pull = GPIO_PULLUP; GPIO_InitStruct.Pull = GPIO_PULLDOWN;
HAL_GPIO_Init(WORK_VOLT_INT_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(WORK_VOLT_INT_GPIO_Port, &GPIO_InitStruct);
/* EXTI interrupt init*/ /* EXTI interrupt init*/

View File

@ -1,11 +1,23 @@
#include "HD_RTC.h" #include "HD_RTC.h"
#include "stm32g431xx.h"
void HD_RTC_Init(void) void HD_RTC_Init(void)
{ {
MX_RTC_Init(); hrtc.Instance = RTC;
hrtc.Init.HourFormat = RTC_HOURFORMAT_24;
hrtc.Init.AsynchPrediv = 127;
hrtc.Init.SynchPrediv = 255;
hrtc.Init.OutPut = RTC_OUTPUT_DISABLE;
hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE;
hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH;
hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN;
hrtc.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE;
if (HAL_RTC_Init(&hrtc) != HAL_OK)
{
Error_Handler();
}
} }

View File

@ -248,7 +248,7 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
__HAL_RCC_TIM7_CLK_ENABLE(); __HAL_RCC_TIM7_CLK_ENABLE();
/* TIM7 interrupt Init */ /* TIM7 interrupt Init */
HAL_NVIC_SetPriority(TIM7_IRQn, 0, 0); HAL_NVIC_SetPriority(TIM7_IRQn, 1, 0);
HAL_NVIC_EnableIRQ(TIM7_IRQn); HAL_NVIC_EnableIRQ(TIM7_IRQn);
/* USER CODE BEGIN TIM7_MspInit 1 */ /* USER CODE BEGIN TIM7_MspInit 1 */

View File

@ -36,7 +36,7 @@
</option> </option>
<option> <option>
<name>MacFile</name> <name>MacFile</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>MemOverride</name> <name>MemOverride</name>
@ -60,7 +60,7 @@
</option> </option>
<option> <option>
<name>CExtraOptions</name> <name>CExtraOptions</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CFpuProcessor</name> <name>CFpuProcessor</name>
@ -68,7 +68,7 @@
</option> </option>
<option> <option>
<name>OCDDFArgumentProducer</name> <name>OCDDFArgumentProducer</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCDownloadSuppressDownload</name> <name>OCDownloadSuppressDownload</name>
@ -104,7 +104,7 @@
</option> </option>
<option> <option>
<name>MacFile2</name> <name>MacFile2</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CDevice</name> <name>CDevice</name>
@ -120,7 +120,7 @@
</option> </option>
<option> <option>
<name>OCImagesPath1</name> <name>OCImagesPath1</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCImagesSuppressCheck2</name> <name>OCImagesSuppressCheck2</name>
@ -128,7 +128,7 @@
</option> </option>
<option> <option>
<name>OCImagesPath2</name> <name>OCImagesPath2</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCImagesSuppressCheck3</name> <name>OCImagesSuppressCheck3</name>
@ -136,7 +136,7 @@
</option> </option>
<option> <option>
<name>OCImagesPath3</name> <name>OCImagesPath3</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OverrideDefFlashBoard</name> <name>OverrideDefFlashBoard</name>
@ -148,11 +148,11 @@
</option> </option>
<option> <option>
<name>OCImagesOffset2</name> <name>OCImagesOffset2</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCImagesOffset3</name> <name>OCImagesOffset3</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCImagesUse1</name> <name>OCImagesUse1</name>
@ -184,15 +184,15 @@
</option> </option>
<option> <option>
<name>OCMulticoreWorkspace</name> <name>OCMulticoreWorkspace</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCMulticoreSlaveProject</name> <name>OCMulticoreSlaveProject</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCMulticoreSlaveConfiguration</name> <name>OCMulticoreSlaveConfiguration</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCDownloadExtraImage</name> <name>OCDownloadExtraImage</name>
@ -216,7 +216,7 @@
</option> </option>
<option> <option>
<name>OCMulticoreSessionFile</name> <name>OCMulticoreSessionFile</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCTpiuBaseOption</name> <name>OCTpiuBaseOption</name>
@ -228,7 +228,7 @@
</option> </option>
<option> <option>
<name>OCOverrideSlavePath</name> <name>OCOverrideSlavePath</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>C_32_64Device</name> <name>C_32_64Device</name>
@ -244,11 +244,11 @@
</option> </option>
<option> <option>
<name>AuthSdmManifest</name> <name>AuthSdmManifest</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>AuthSdmExplicitLib</name> <name>AuthSdmExplicitLib</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>AuthEnforce</name> <name>AuthEnforce</name>
@ -277,7 +277,7 @@
</option> </option>
<option> <option>
<name>OCSimPspConfigFile</name> <name>OCSimPspConfigFile</name>
<state /> <state></state>
</option> </option>
</data> </data>
</settings> </settings>
@ -294,7 +294,7 @@
</option> </option>
<option> <option>
<name>Fast Model</name> <name>Fast Model</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCADILogFileCheck</name> <name>CCADILogFileCheck</name>
@ -328,7 +328,7 @@
<option> <option>
<name>CMSISDAPResetList</name> <name>CMSISDAPResetList</name>
<version>1</version> <version>1</version>
<state>10</state> <state>9</state>
</option> </option>
<option> <option>
<name>CMSISDAPHWResetDuration</name> <name>CMSISDAPHWResetDuration</name>
@ -348,7 +348,7 @@
</option> </option>
<option> <option>
<name>CMSISDAPInterfaceRadio</name> <name>CMSISDAPInterfaceRadio</name>
<state>0</state> <state>1</state>
</option> </option>
<option> <option>
<name>CMSISDAPInterfaceCmdLine</name> <name>CMSISDAPInterfaceCmdLine</name>
@ -461,7 +461,7 @@
</option> </option>
<option> <option>
<name>OCProbeConfig</name> <name>OCProbeConfig</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CMSISDAPProbeConfigRadio</name> <name>CMSISDAPProbeConfigRadio</name>
@ -469,11 +469,11 @@
</option> </option>
<option> <option>
<name>CMSISDAPSelectedCPUBehaviour</name> <name>CMSISDAPSelectedCPUBehaviour</name>
<state>0</state> <state></state>
</option> </option>
<option> <option>
<name>ICpuName</name> <name>ICpuName</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCJetEmuParams</name> <name>OCJetEmuParams</name>
@ -481,7 +481,7 @@
</option> </option>
<option> <option>
<name>CCCMSISDAPUsbSerialNo</name> <name>CCCMSISDAPUsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCCMSISDAPUsbSerialNoSelect</name> <name>CCCMSISDAPUsbSerialNoSelect</name>
@ -502,7 +502,7 @@
</option> </option>
<option> <option>
<name>CE2UsbSerialNo</name> <name>CE2UsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CE2IdCodeEditB</name> <name>CE2IdCodeEditB</name>
@ -642,7 +642,7 @@
</option> </option>
<option> <option>
<name>IjetCpuClockEdit</name> <name>IjetCpuClockEdit</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>IjetSwoPrescalerList</name> <name>IjetSwoPrescalerList</name>
@ -735,7 +735,7 @@
</option> </option>
<option> <option>
<name>OCProbeConfig</name> <name>OCProbeConfig</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>IjetProbeConfigRadio</name> <name>IjetProbeConfigRadio</name>
@ -755,7 +755,7 @@
</option> </option>
<option> <option>
<name>ICpuName</name> <name>ICpuName</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>OCJetEmuParams</name> <name>OCJetEmuParams</name>
@ -781,7 +781,7 @@
</option> </option>
<option> <option>
<name>CCIjetUsbSerialNo</name> <name>CCIjetUsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCIjetUsbSerialNoSelect</name> <name>CCIjetUsbSerialNoSelect</name>
@ -1004,7 +1004,7 @@
</option> </option>
<option> <option>
<name>CCJLinkUsbSerialNo</name> <name>CCJLinkUsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCTcpIpAlt</name> <name>CCTcpIpAlt</name>
@ -1013,11 +1013,11 @@
</option> </option>
<option> <option>
<name>CCJLinkTcpIpSerialNo</name> <name>CCJLinkTcpIpSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCCpuClockEdit</name> <name>CCCpuClockEdit</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCSwoClockAuto</name> <name>CCSwoClockAuto</name>
@ -1074,7 +1074,7 @@
</option> </option>
<option> <option>
<name>CCLmiftdiUsbSerialNo</name> <name>CCLmiftdiUsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCLmiftdiUsbSerialNoSelect</name> <name>CCLmiftdiUsbSerialNoSelect</name>
@ -1163,7 +1163,7 @@
</option> </option>
<option> <option>
<name>CCSwoClockAuto</name> <name>CCSwoClockAuto</name>
<state>0</state> <state>1</state>
</option> </option>
<option> <option>
<name>CCSwoClockEdit</name> <name>CCSwoClockEdit</name>
@ -1227,7 +1227,7 @@
</option> </option>
<option> <option>
<name>CCSTLinkUsbSerialNo</name> <name>CCSTLinkUsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCSTLinkUsbSerialNoSelect</name> <name>CCSTLinkUsbSerialNoSelect</name>
@ -1240,7 +1240,7 @@
</option> </option>
<option> <option>
<name>CCSTLinkDAPNumber</name> <name>CCSTLinkDAPNumber</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCSTLinkDebugAccessPortRadio</name> <name>CCSTLinkDebugAccessPortRadio</name>
@ -1253,7 +1253,7 @@
<option> <option>
<name>CCSTLinkProbeList</name> <name>CCSTLinkProbeList</name>
<version>2</version> <version>2</version>
<state>0</state> <state>2</state>
</option> </option>
<option> <option>
<name>CCSTLinkTargetVccEnable</name> <name>CCSTLinkTargetVccEnable</name>
@ -1378,11 +1378,11 @@
</option> </option>
<option> <option>
<name>TIPackage</name> <name>TIPackage</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>BoardFile</name> <name>BoardFile</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>DoLogfile</name> <name>DoLogfile</name>
@ -1474,7 +1474,7 @@
</option> </option>
<option> <option>
<name>CCXds100CpuClockEdit</name> <name>CCXds100CpuClockEdit</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCXds100SwoClockAuto</name> <name>CCXds100SwoClockAuto</name>
@ -1495,7 +1495,7 @@
</option> </option>
<option> <option>
<name>CCXds100UsbSerialNo</name> <name>CCXds100UsbSerialNo</name>
<state /> <state></state>
</option> </option>
<option> <option>
<name>CCXds100UsbSerialNoSelect</name> <name>CCXds100UsbSerialNoSelect</name>

View File

@ -189,7 +189,7 @@
<option> <option>
<name>TrustZoneModes</name> <name>TrustZoneModes</name>
<version>0</version> <version>0</version>
<state>1</state> <state>0</state>
</option> </option>
<option> <option>
<name>OGAarch64Abi</name> <name>OGAarch64Abi</name>
@ -694,7 +694,7 @@
<data> <data>
<extensions></extensions> <extensions></extensions>
<cmdline></cmdline> <cmdline></cmdline>
<hasPrio>0</hasPrio> <hasPrio>160</hasPrio>
<buildSequence>inputOutputBased</buildSequence> <buildSequence>inputOutputBased</buildSequence>
</data> </data>
</settings> </settings>

View File

@ -148,7 +148,7 @@ NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
NVIC.TIM1_BRK_TIM15_IRQn=true\:4\:0\:true\:false\:true\:true\:true\:true NVIC.TIM1_BRK_TIM15_IRQn=true\:4\:0\:true\:false\:true\:true\:true\:true
NVIC.TIM1_UP_TIM16_IRQn=true\:4\:0\:true\:false\:true\:false\:true\:true NVIC.TIM1_UP_TIM16_IRQn=true\:4\:0\:true\:false\:true\:false\:true\:true
NVIC.TIM7_IRQn=true\:0\:0\:true\:false\:true\:true\:true\:true NVIC.TIM7_IRQn=true\:1\:0\:true\:false\:true\:true\:true\:true
NVIC.USART2_IRQn=true\:2\:0\:true\:false\:true\:true\:true\:true NVIC.USART2_IRQn=true\:2\:0\:true\:false\:true\:true\:true\:true
NVIC.USART3_IRQn=true\:2\:0\:true\:false\:true\:true\:true\:true NVIC.USART3_IRQn=true\:2\:0\:true\:false\:true\:true\:true\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false

View File

@ -48,6 +48,10 @@ typedef struct _timeInfo {
uint8_t second; uint8_t second;
}timeInfo; }timeInfo;
/* 方式 */
typedef enum {
runLedChargMode = 1,
runLedOtherMode = 2,
}runLedMode;
#endif #endif