From 8053971109ee5b241b7fe1a87078409502e3e7dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B7=E5=BA=8A=E5=B0=B1=E7=8A=AF=E5=9B=B0?= <11730503+psx123456@user.noreply.gitee.com> Date: Fri, 3 Jan 2025 17:25:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=AF=E4=BB=B6=E7=A1=AC=E4=BB=B6=E4=BF=9D?= =?UTF-8?q?=E6=8A=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/settings.json | 5 +- APP/businessLogic/Inc/SOE.h | 19 + APP/businessLogic/Inc/inFlash.h | 9 - APP/businessLogic/Inc/parameter.h | 16 +- APP/businessLogic/Src/Init.c | 4 + APP/businessLogic/Src/SOE.c | 161 ++ APP/businessLogic/Src/abnormalManage.c | 32 +- APP/businessLogic/Src/bl_chargControl.c | 1 - APP/businessLogic/Src/inFlash.c | 82 +- APP/businessLogic/Src/parameter.c | 10 +- APP/businessLogic/Src/task.c | 23 +- APP/functionalModule/Inc/FM_GPIO.h | 1 + APP/functionalModule/Src/FM_GPIO.c | 13 + APP/functionalModule/Src/FM_TIM.c | 2 +- APP/functionalModule/Src/capture.c | 14 +- Core/Src/main.c | 44 +- Core/Src/rtc.c | 2 +- EWARM/chargeController.ewd | 74 +- EWARM/chargeController.ewp | 2659 ++++++++++++----------- chargeController.ioc | 10 +- tools/chargControlTypes.h | 3 +- tools/configParameter.h | 30 +- 22 files changed, 1697 insertions(+), 1517 deletions(-) create mode 100644 APP/businessLogic/Inc/SOE.h create mode 100644 APP/businessLogic/Src/SOE.c diff --git a/.vscode/settings.json b/.vscode/settings.json index 4776e21..6123606 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -32,6 +32,9 @@ "chargcontroltypes.h": "c", "fm_rtc.h": "c", "interruptsend.h": "c", - "rtc.h": "c" + "rtc.h": "c", + "soe.h": "c", + "hd_rtc.h": "c", + "flash.h": "c" } } \ No newline at end of file diff --git a/APP/businessLogic/Inc/SOE.h b/APP/businessLogic/Inc/SOE.h new file mode 100644 index 0000000..b60b8e3 --- /dev/null +++ b/APP/businessLogic/Inc/SOE.h @@ -0,0 +1,19 @@ +#ifndef BL_SOE_ +#define BL_SOE_ + +#include "chargControlTypes.h" +#include "inFlash.h" +#include "comm_types.h" +#include "flash.h" + + + +void eventsOrderRecordStartInit(void); +void setEventsOrderRecord(void); +void printfEventsOrderRecord(void); +void insertEventsOrderRecord(eventsOrderRecordMode mode); + + + + +#endif diff --git a/APP/businessLogic/Inc/inFlash.h b/APP/businessLogic/Inc/inFlash.h index eef9e5f..69d62e2 100644 --- a/APP/businessLogic/Inc/inFlash.h +++ b/APP/businessLogic/Inc/inFlash.h @@ -113,13 +113,4 @@ void readTime(timeInfo *time); - -#define eventsOrderRecordStartAddr 200 -void eventsOrderRecordStartInit(void); -void setEventsOrderRecord(eventsOrderRecordMode mode); -void printfEventsOrderRecord(void); - - - - #endif diff --git a/APP/businessLogic/Inc/parameter.h b/APP/businessLogic/Inc/parameter.h index 401d247..b89530a 100644 --- a/APP/businessLogic/Inc/parameter.h +++ b/APP/businessLogic/Inc/parameter.h @@ -23,6 +23,20 @@ typedef struct _config_parameter{ float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 (°C) */ float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */ + float firstStageProtectionCurr; /* 第一段保护的电流(单位A) */ + uint16_t firstStageProtectionValue; /* 第一段保护的电流采集的ADC的值 */ + uint16_t firstStageProtectionDelay; /* 第一段保护的延时时间(单位10uS) */ + float secondStageProtectionCurr; /* 第二段保护的电流(单位A) */ + uint32_t secondStageProtectionDelay; /* 第二段保护的延时时间(单位100uS) */ + float thirdStageProtectionCurr; /* 第三段保护的电流(单位A) */ + uint32_t thirdStageProtectionDelay; /* 第三段保护的延时时间(单位100uS) */ + float checkLoopImpedanceChargCurr; /* 检测回路阻抗时的充电电流要大于该值(单位A) */ + float lowInputLoadDetectionVolt; /* 输入功率较低延时电压(单位V) */ + uint16_t lowInputLoadDetectionDelay; /* 输入功率较低延时(单位100uS) */ + float maxChargCurr; /* 最大充电电流(A) */ + float maxOpenSolarOpenCircuitV; /* 最大充电电压(V) */ + + // uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 (S) */ // uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */ uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */ @@ -30,7 +44,7 @@ typedef struct _config_parameter{ uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */ // uint16_t softShortTime; /* 软件短路保护延时 时间(100uS) */ - uint32_t collectOpenCircuitVoltageTime; /* 充电时开路电压采集时间间隔 */ + uint32_t collectOpenCircuitVoltageTime; /* 充电时开路电压采集时间间隔(S) */ /* SL */ diff --git a/APP/businessLogic/Src/Init.c b/APP/businessLogic/Src/Init.c index 406a701..e93066c 100644 --- a/APP/businessLogic/Src/Init.c +++ b/APP/businessLogic/Src/Init.c @@ -44,4 +44,8 @@ void Init(void) HAL_Delay(100); setPowerOutput(TRUE); + + // EN_PWMOUT_Eable(); + // setDutyRatio(0.5); + // while(1); } diff --git a/APP/businessLogic/Src/SOE.c b/APP/businessLogic/Src/SOE.c new file mode 100644 index 0000000..8088a79 --- /dev/null +++ b/APP/businessLogic/Src/SOE.c @@ -0,0 +1,161 @@ + +#include "SOE.h" +#include "stdio.h" +#include "parameter.h" +#include "FM_RTC.h" + + +#define eventsOrderRecordStartAddr 4096 + +typedef struct _soeDataInfo { + uint16_t mode; //故障类型 2byte + timeInfo time; //时间 6byte + float temp; //故障发生时刻的值 4byte +} soeDataInfo; +#define soeDataInfoSize sizeof(soeDataInfo) + +typedef struct _soeSaveInfo { + soeDataInfo data[5]; + + uint8_t insertPos; //记录插入数据的位置 + uint8_t outPos; //记录输出数据的位置 + uint8_t count; //记录可插入数据插入数据个数 + soeDataInfo *insertData; //指向能插入数据的位置 + soeDataInfo *outData; //指向能输出数据的位置 +} soeSaveInfo; + +typedef struct _soeStorageParameters { + uint16_t len; //soe记录次数 + uint16_t pos; //下次soe记录的位置 +} soeStorageParameters; + +static soeSaveInfo soeInfo = {0}; +static soeStorageParameters soeParameters = {0}; + + + +/** + * @brief 初始化事件顺序记录 + * @param + */ +void eventsOrderRecordStartInit(void) +{ + soeInfo.count = 5; + soeInfo.insertPos = 0; + soeInfo.outPos = 0; + soeInfo.outData = NULL; + soeInfo.insertData = &soeInfo.data[soeInfo.insertPos]; + + read_Flash((uint8_t *)(&soeParameters), sizeof(soeParameters)); +} + +/** + * @brief 插入事件顺序记录 + * @param + */ +/* +| 故障类型 | temp | +| :-------------------: | :-------: | +| firstStageProtection | 输出电流 | +| secondStageProtection | 输出电流 | +| thirdStageProtection | 输出电流 | +| lowInputLoad | 输出电压 | +| overTemperature | mos管温度 | +| stopTemperature | mos管温度 | +| overchargCurr | 充电电流 | +*/ +void insertEventsOrderRecord(eventsOrderRecordMode mode) +{ + /* 无位置插入时,退出 */ + if (soeInfo.count <= 0 || soeInfo.insertData == NULL) { + return; + } + + soeInfo.count--; + soeInfo.insertData->data.mode = mode; + getRTC_Time(&soeInfo.insertData->time); + + if (mode == firstStageProtection) { + soeInfo.insertData->data.temp = getDischargCurrent(); + } + + else if (mode == secondStageProtection) { + soeInfo.insertData->data.temp = getDischargCurrent(); + } + + else if (mode == thirdStageProtection) { + soeInfo.insertData->data.temp = getDischargCurrent(); + } + + else if (mode == lowInputLoad) { + soeInfo.insertData->data.temp = getOutputVoltage(); + } + + else if (mode == overTemperature) { + soeInfo.insertData->data.temp = getHighSideMosTemperature(); + } + + else if (mode == stopTemperature) { + soeInfo.insertData->data.temp = getHighSideMosTemperature(); + } + + else if (mode == overchargCurr) { + soeInfo.insertData->data.temp = getChargCurrent(); + } + + + soeInfo.insertPos++; + if (soeInfo.insertPos >= 5) { + soeInfo.insertPos = 0; + } + + if (count <= 0) { + soeInfo.insertData = NULL; + } else { + soeInfo.insertData = &soeInfo.data[soeInfo.insertPos]; + } + + soeInfo.outData = &soeInfo.data[soeInfo.outPos]; +} + + +/** + * @brief 将事件顺序记录在flash中 + * @param + */ +void setEventsOrderRecord(void) +{ + if (soeInfo.outData == NULL || soeInfo.count >= 5) { + return; + } + + // write_Flash((uint8_t *)(&soeInfo.outData), soeDataInfoSize); + + soeInfo.outPos++; + if (soeInfo.outPos >= 5) { + soeInfo.outPos = 0; + } + soeInfo.count++; + + if (soeInfo.count >= 5) { + soeInfo.outData = NULL; + } else { + soeInfo.outData = &soeInfo.data[soeInfo.outPos]; + } + + if (soeInfo.insertData == NULL) { + soeInfo.insertData = &soeInfo.data[soeInfo.insertPos]; + } +} + +/** + * @brief 将事件从flash中依次读取出来 + * @param + */ + +void printfEventsOrderRecord(void) +{ + +} + + diff --git a/APP/businessLogic/Src/abnormalManage.c b/APP/businessLogic/Src/abnormalManage.c index d8f2b46..8ecfbb0 100644 --- a/APP/businessLogic/Src/abnormalManage.c +++ b/APP/businessLogic/Src/abnormalManage.c @@ -7,6 +7,7 @@ #include "task.h" #include "configParameter.h" #include "capture.h" +#include "bl_chargControl.h" //static int checkMode = 0; @@ -32,7 +33,7 @@ void setDisChargOverLoad(void) { /* 三段式保护中的第三段 */ static int num1 = 0; - if (getDischargCurrent() > thirdStageProtectionCurr) { + if (getDischargCurrent() > g_cfgParameter.thirdStageProtectionCurr) { // disChargOverLoad = TRUE; num1++; } else { @@ -41,7 +42,7 @@ void setDisChargOverLoad(void) } /* 过载时间过长关闭输出 */ - if (num1 >= thirdStageProtectionDelay) { + if (num1 >= g_cfgParameter.thirdStageProtectionDelay) { num1 = 0; setPowerOutput(FALSE); disChargOverLoad = TRUE; @@ -50,15 +51,15 @@ void setDisChargOverLoad(void) /* 三段式保护中的第二段 */ static int num2 = 0; - if (getDischargCurrent() > secondStageProtectionCurr) { + if (getDischargCurrent() > g_cfgParameter.secondStageProtectionCurr) { num2++; } else { num2 = 0; } /* 过载时间过长关闭输出 */ - if (num1 >= secondStageProtectionDelay) { - num1 = 0; + if (num2 >= g_cfgParameter.secondStageProtectionDelay) { + num2 = 0; setPowerOutput(FALSE); disChargOverLoad = TRUE; } @@ -82,14 +83,14 @@ void setSoftShortCircuit(uint16_t disChargCurrAdcNum) /* 三段式保护中的第一段 */ static int num = 0; - if (disChargCurrAdcNum > firstStageProtectionValue) { + if (disChargCurrAdcNum > g_cfgParameter.firstStageProtectionValue) { num++; } else { num = 0; } /* 20uS内都短路则关闭输出 */ - if (num >= firstStageProtectionDelay) { + if (num >= g_cfgParameter.firstStageProtectionDelay) { setPowerOutput(FALSE); shortCircuitFlag = TRUE; shortCircuit++; @@ -278,10 +279,17 @@ BOOL getExcessiveLoadFlag(void) */ void checkFFMOS_CON(void) { - if (get_CHG_CURR() > 2.0f) { + // if (get_CHG_CURR() > 5.0f && FALSE == FFMOS_CON_read()) { + // FFMOS_CON_Open(); + // } + // else if (get_CHG_CURR() < 2.0f && TRUE == FFMOS_CON_read()) { + // FFMOS_CON_Close(); + // } + + if (getChargCurrent() > 5.0f && FALSE == FFMOS_CON_read()) { FFMOS_CON_Open(); } - else if (get_CHG_CURR() < 1.0f) { + else if (getChargCurrent() < 2.0f && TRUE == FFMOS_CON_read()) { FFMOS_CON_Close(); } } @@ -340,14 +348,14 @@ void lowInputLoadDetection(void) { static int num = 0; - if (excessiveLoadInterruptFlag == TRUE && getOutputVoltage() < lowInputLoadDetectionVolt) { + if (excessiveLoadInterruptFlag == TRUE && getOutputVoltage() < g_cfgParameter.lowInputLoadDetectionVolt) { num++; } else { num = 0; excessiveLoadInterruptFlag = FALSE; } - if (excessiveLoadInterruptFlag == TRUE && num == lowInputLoadDetectionDelay) { + if (excessiveLoadInterruptFlag == TRUE && num == g_cfgParameter.lowInputLoadDetectionDelay) { setOverLoad(); } } @@ -361,7 +369,7 @@ void lowInputLoadDetection(void) */ void judgeChargCurr(void) { - if (getChargCurrent() > maxChargCurr) { + if (getChargCurrent() > g_cfgParameter.maxChargCurr) { stopChargWork(); } } diff --git a/APP/businessLogic/Src/bl_chargControl.c b/APP/businessLogic/Src/bl_chargControl.c index 7ac4995..23e5710 100644 --- a/APP/businessLogic/Src/bl_chargControl.c +++ b/APP/businessLogic/Src/bl_chargControl.c @@ -689,7 +689,6 @@ void setChargControlFlag(BOOL state) } else if (state == FALSE) { chargRunLed(runLedOtherMode); } - } /** diff --git a/APP/businessLogic/Src/inFlash.c b/APP/businessLogic/Src/inFlash.c index 168dfaa..a4164aa 100644 --- a/APP/businessLogic/Src/inFlash.c +++ b/APP/businessLogic/Src/inFlash.c @@ -3,6 +3,7 @@ #include "parameter.h" #include "pDebug.h" #include "cfg_protocol.h" +#include "configParameter.h" static void save_config_info(config_info *save_config_info); @@ -91,7 +92,7 @@ static void readFlashContent(config_info *configInfo) configInfo->address[6] = 0x11; // config_info->Access_Node_Type = 0x01; // config_info->Communication_Methods = 0x02; - configInfo->gw485_Baud = 9600; + configInfo->gw485_Baud = 115200; configInfo->bat485_Baud = 115200; configInfo->hardwareID[0] = 0x48; @@ -110,11 +111,11 @@ static void readFlashContent(config_info *configInfo) configInfo->onlyPower = 0x01; configInfo->constantVoltageV = 14; - configInfo->floatI = 0.02; + configInfo->floatI = 0.1f; configInfo->startSolarOpenCircuitV = 17; configInfo->stopSolarOpenCircuitV = 15; - configInfo->constantVoltageChargeV = 14.4; - configInfo->FloatChargeV = 14; + configInfo->constantVoltageChargeV = 14.4f; + configInfo->FloatChargeV = 14.2f; configInfo->HighSideMosTemperature_stop = 100; configInfo->HighSideMosTemperature_end = 90; configInfo->HighSideMosTemperature_start = 50; @@ -216,6 +217,19 @@ void config_info_start(void) readTime(&time); setLastTime(time); + g_cfgParameter.firstStageProtectionCurr = firstStageProtectionCurrMacro; + g_cfgParameter.firstStageProtectionDelay = firstStageProtectionDelayMacro; + g_cfgParameter.firstStageProtectionValue = firstStageProtectionValueMacro; + g_cfgParameter.secondStageProtectionCurr = secondStageProtectionCurrMacro; + g_cfgParameter.secondStageProtectionDelay = secondStageProtectionDelayMacro; + g_cfgParameter.thirdStageProtectionCurr = thirdStageProtectionCurrMacro; + g_cfgParameter.thirdStageProtectionDelay = thirdStageProtectionDelayMacro; + g_cfgParameter.checkLoopImpedanceChargCurr = checkLoopImpedanceChargCurrMacro; + g_cfgParameter.lowInputLoadDetectionVolt = lowInputLoadDetectionVoltMacro; + g_cfgParameter.lowInputLoadDetectionDelay = lowInputLoadDetectionDelayMacro; + g_cfgParameter.maxChargCurr = maxChargCurrMacro; + g_cfgParameter.maxOpenSolarOpenCircuitV = maxOpenSolarOpenCircuitVMacro; + } @@ -292,64 +306,4 @@ void readTime(timeInfo *time) } -/** - * @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); - } -} - diff --git a/APP/businessLogic/Src/parameter.c b/APP/businessLogic/Src/parameter.c index 20cda5a..ecd49a8 100644 --- a/APP/businessLogic/Src/parameter.c +++ b/APP/businessLogic/Src/parameter.c @@ -8,11 +8,11 @@ config_parameter g_cfgParameter = {0}; static otherParameter g_otherParameter = {0}; -static BOOL batteryState = FALSE; /* 有无电池(估计) */ -static float dutyRatio; /* 占空比 */ -static uint8_t mosTemperState = mosTemperStart; /* mos管温度状态 */ -static BOOL checkImpedanceState = FALSE; /* 启动后是否进行了回路阻抗检测 */ -static timeInfo lastTime = {0}; /* 上次读取充放电量参数的时间 */ +static BOOL batteryState = FALSE; /* 有无电池(估计) */ +static float dutyRatio = 0; /* 占空比 */ +static uint8_t mosTemperState = mosTemperStart; /* mos管温度状态 */ +static BOOL checkImpedanceState = FALSE; /* 启动后是否进行了回路阻抗检测 */ +static timeInfo lastTime = {0}; /* 上次读取充放电量参数的时间 */ /** * @brief 获取电池状态 diff --git a/APP/businessLogic/Src/task.c b/APP/businessLogic/Src/task.c index 87fb90e..2236615 100644 --- a/APP/businessLogic/Src/task.c +++ b/APP/businessLogic/Src/task.c @@ -11,6 +11,7 @@ #include "abnormalManage.h" #include "interruptSend.h" #include "configParameter.h" +#include "capture.h" #include @@ -47,7 +48,7 @@ static void Task_softStart(void); /* 回路阻抗检测 */ #define impedanceCalculation_reloadVal 20 /* 任务执行间隔 */ -#define impedanceCalculation_offset 0 /* 任务执行偏移量 */ +#define impedanceCalculation_offset 0 /* 任务执行偏移量 */ static STR_TimeSliceOffset m_impedanceCalculation; static void Task_impedanceCalculation(void); @@ -266,6 +267,10 @@ void Task_refreshJudgeData(void) setInputVoltage(); setHighSideMosTemperature(); + // static float tempOutV; + // tempOutV = get_OUT_VOLT_IN(); + // debug_printf("get_OUT_VOLT_IN:%f \n", tempOutV); + /* 判断有无电池 */ if (getBatteryState() == FALSE && (getChargBatteryCurrent() > 1 || getChargBatteryCurrent() < -1) && getOutputVoltage() < 14.2f) { @@ -274,7 +279,7 @@ void Task_refreshJudgeData(void) /* 有电池,太阳能输出功率大,电池电压低于14V,同时回路阻抗未测试或需要重新测试 */ if ((getCheckImpedanceState() == FALSE || g_cfgParameter.loopImpedance == 0.0f) - && (getBatteryState() == TRUE) && (getChargCurrent() > checkLoopImpedanceChargCurr) + && (getBatteryState() == TRUE) && (getChargCurrent() > g_cfgParameter.checkLoopImpedanceChargCurr) && (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14) && (getBatteryVoltage() < 14)) { TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation @@ -314,7 +319,8 @@ void Task_refreshJudgeData(void) void Task_startControl(void) { /* 是否达到启动条件 */ - if (getSolarInCircuitVoltage() > g_cfgParameter.startSolarOpenCircuitV) { + if (getSolarInCircuitVoltage() > g_cfgParameter.startSolarOpenCircuitV + && getSolarInCircuitVoltage() < g_cfgParameter.maxOpenSolarOpenCircuitV) { TimeSliceOffset_Unregister(&m_startControl); m_startControl.runFlag = 0; @@ -405,8 +411,8 @@ void Task_impedanceCalculation(void) if (num == 1) { setChargControlFlag(FALSE); - setDutyRatio(0.7); - set_pwmDutyRatio(getDutyRatio()); + setDutyRatio(0.5); +// set_pwmDutyRatio(getDutyRatio()); return; } @@ -414,11 +420,13 @@ void Task_impedanceCalculation(void) currOne = getChargCurrent() - getDischargCurrent(); voltOne = getOutputVoltage(); setDutyRatio(0.85); - set_pwmDutyRatio(getDutyRatio()); +// set_pwmDutyRatio(getDutyRatio()); return; } if (num == 21) { + num = 0; + TimeSliceOffset_Unregister(&m_impedanceCalculation); m_impedanceCalculation.runFlag = 0; @@ -433,9 +441,8 @@ void Task_impedanceCalculation(void) saveLoopImpedance(&g_cfgParameter.loopImpedance); setCheckImpedanceState(); } - num = 0; - setMPPT_Mode(MPPT); + setMPPT_Mode(MPPT); setChargControlFlag(TRUE); return; } diff --git a/APP/functionalModule/Inc/FM_GPIO.h b/APP/functionalModule/Inc/FM_GPIO.h index 7774ee4..faf9af4 100644 --- a/APP/functionalModule/Inc/FM_GPIO.h +++ b/APP/functionalModule/Inc/FM_GPIO.h @@ -17,6 +17,7 @@ void RUN_LEN_Open(void); void RUN_LEN_Close(void); void RUN_LED(void); +BOOL FFMOS_CON_read(void); void FFMOS_CON_Open(void); void FFMOS_CON_Close(void); diff --git a/APP/functionalModule/Src/FM_GPIO.c b/APP/functionalModule/Src/FM_GPIO.c index b79c3f5..620b8d8 100644 --- a/APP/functionalModule/Src/FM_GPIO.c +++ b/APP/functionalModule/Src/FM_GPIO.c @@ -93,6 +93,19 @@ void RUN_LED(void) HAL_GPIO_TogglePin(RUN_LED_GPIO_Port, RUN_LED_Pin); } +/** + * @brief 打开mppt电感后的输出mos管 + * @param None + * @retval None + */ +BOOL FFMOS_CON_read(void) +{ + if (HAL_GPIO_ReadPin(FFMOS_CON_GPIO_Port, FFMOS_CON_Pin)) { + return FALSE; + } + return TRUE; +} + /** * @brief 打开mppt电感后的输出mos管 * @param None diff --git a/APP/functionalModule/Src/FM_TIM.c b/APP/functionalModule/Src/FM_TIM.c index 83a6e0e..f2e35d1 100644 --- a/APP/functionalModule/Src/FM_TIM.c +++ b/APP/functionalModule/Src/FM_TIM.c @@ -62,7 +62,7 @@ void set_pwmDutyRatio(float DutyRatio) { uint32_t Pulse = (int)(DutyRatio * PWM_RESOLUTION); - set_pwmPulse(Pulse); + set_pwmPulse(Pulse); } /** diff --git a/APP/functionalModule/Src/capture.c b/APP/functionalModule/Src/capture.c index 111126b..dda22a1 100644 --- a/APP/functionalModule/Src/capture.c +++ b/APP/functionalModule/Src/capture.c @@ -189,13 +189,13 @@ void proportionalInt(int mode) /* 充电控制盒输出电压比例,分压系数 */ 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 + 1 / 0.001)))) * Proportion; /* 光伏板输出电压比例 */ P_PV1_VOLT_IN = ((47.0 + 4.7) / 4.7) * Proportion; /* 系统电源电压比例 */ P_PV_VOLT_IN1 = ((47.0 + 4.7) / 4.7) * Proportion; /* 输出外部电压比例 */ - P_OUT_VOLT_IN = ((100 + 4.7) / 4.7) * Proportion; + P_OUT_VOLT_IN = ((47.0 + 4.7) / 4.7) * Proportion; } /* 电源盒外还有网关功能 */ @@ -211,7 +211,7 @@ void proportionalInt(int mode) /* 系统电源电压比例 */ P_PV_VOLT_IN1 = ((47 + 4.7) / 4.7) * Proportion; /* 输出外部电压比例 */ - P_OUT_VOLT_IN = ((100 + 4.7) / 4.7) * Proportion; + P_OUT_VOLT_IN = ((47.0 + 4.7) / 4.7) * Proportion; } // /* 光伏充电输出电流比例,放大倍数*电阻 */ @@ -424,10 +424,16 @@ float get_OUT_VOLT_IN(void) { float V; uint16_t V_ADC; + static uint16_t V_ADCTemp = (uint16_t)(0.55f / 3.0f * 4095); V_ADC = ADC2_Capture(OUT_VOLT_IN_CHANNEL); - V = (float)(V_ADC) * P_OUT_VOLT_IN; + + if (HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin)) { + V = (float)(V_ADC) * P_OUT_VOLT_IN; + } else { + V = (float)(V_ADC - V_ADCTemp) * P_OUT_VOLT_IN; + } #ifdef enable_Printf_VI debug("\n OUT_VOLT_IN ADC : %d \n", V_ADC); diff --git a/Core/Src/main.c b/Core/Src/main.c index 902d7b8..31087a7 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -95,20 +95,20 @@ int main(void) /* USER CODE END SysInit */ /* Initialize all configured peripherals */ -// MX_GPIO_Init(); -// MX_DMA_Init(); -// MX_ADC1_Init(); -// MX_ADC2_Init(); -// MX_SPI1_Init(); -// MX_TIM3_Init(); -// MX_TIM6_Init(); -// MX_UART4_Init(); -// MX_USART2_UART_Init(); -// MX_USART3_UART_Init(); -// MX_TIM7_Init(); -// MX_TIM16_Init(); -// MX_TIM15_Init(); -// MX_RTC_Init(); +// MX_GPIO_Init(); +// MX_DMA_Init(); +// MX_ADC1_Init(); +// MX_ADC2_Init(); +// MX_SPI1_Init(); +// MX_TIM3_Init(); +// MX_TIM6_Init(); +// MX_UART4_Init(); +// MX_USART2_UART_Init(); +// MX_USART3_UART_Init(); +// MX_TIM7_Init(); +// MX_TIM16_Init(); +// MX_TIM15_Init(); +// MX_RTC_Init(); /* USER CODE BEGIN 2 */ start(); @@ -142,21 +142,17 @@ void SystemClock_Config(void) */ HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1); - /** Configure LSE Drive Capability - */ - HAL_PWR_EnableBkUpAccess(); - __HAL_RCC_LSEDRIVE_CONFIG(RCC_LSEDRIVE_LOW); - /** Initializes the RCC Oscillators according to the specified parameters * in the RCC_OscInitTypeDef structure. */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE|RCC_OSCILLATORTYPE_LSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; -// RCC_OscInitStruct.LSEState = RCC_LSE_ON; + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_LSI; + RCC_OscInitStruct.HSIState = RCC_HSI_ON; + RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT; + RCC_OscInitStruct.LSIState = RCC_LSI_ON; RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI; RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV1; - RCC_OscInitStruct.PLL.PLLN = 18; + RCC_OscInitStruct.PLL.PLLN = 9; RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2; RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2; diff --git a/Core/Src/rtc.c b/Core/Src/rtc.c index 4f0f950..7d4de0e 100644 --- a/Core/Src/rtc.c +++ b/Core/Src/rtc.c @@ -101,7 +101,7 @@ void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle) /** Initializes the peripherals clocks */ PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC; - PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; + PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI; if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) { diff --git a/EWARM/chargeController.ewd b/EWARM/chargeController.ewd index ae5b760..2f04eb2 100644 --- a/EWARM/chargeController.ewd +++ b/EWARM/chargeController.ewd @@ -36,7 +36,7 @@ @@ -294,7 +294,7 @@