diff --git a/APP/businessLogic/Inc/bl_usart.h b/APP/businessLogic/Inc/bl_usart.h index 54b9780..bca9d1e 100644 --- a/APP/businessLogic/Inc/bl_usart.h +++ b/APP/businessLogic/Inc/bl_usart.h @@ -46,7 +46,6 @@ #endif - void uartCommonInit(void); uint16_t checkModebusCrc(uint8_t *arr_buff, uint8_t len); @@ -54,5 +53,4 @@ uint16_t checkModebusCrc(uint8_t *arr_buff, uint8_t len); void gw485DataAnalysis(device_handle device); - #endif diff --git a/APP/businessLogic/Inc/parameter.h b/APP/businessLogic/Inc/parameter.h index 9d40aa1..3331e6a 100644 --- a/APP/businessLogic/Inc/parameter.h +++ b/APP/businessLogic/Inc/parameter.h @@ -14,6 +14,8 @@ typedef struct _config_parameter{ uint32_t gw485_Baud; /* 串口波特率 */ uint32_t bat485_Baud; /* 串口波特率,为0代表bms不支持通信 */ + uint32_t supportProtocolTypes; /* 支持协议类型 */ + uint8_t powerBoxType; /* 是否只充当电源板:0x00:不是;0xFF:是*/ float constantVoltageV; /* 恒压充电阈值电压(V) */ float floatI; /* 浮充充电阈值电流(A) */ @@ -42,6 +44,9 @@ typedef struct _config_parameter{ float FloatChargeV; /* 浮充充电时的输出电压(V) */ uint16_t collectOpenCircuitVoltageTime; /* 充电时采集开路电压的间隔时间 */ float reverseChargProtectionCurr; /* 反向充电保护电流 */ + float softStartVolt; /* 软启动阈值电压 */ + float MPPTConstantVoltage; /* MPPT恒定输出电压 */ + float MPPTReduceConstantVoltage; /* MPPT降功率运行时控制输入电压稳定值 */ /* SL */ uint16_t Access_Node_Type; /* 接入节点类型 */ diff --git a/APP/businessLogic/Src/abnormalManage.c b/APP/businessLogic/Src/abnormalManage.c index 637d621..917cb76 100644 --- a/APP/businessLogic/Src/abnormalManage.c +++ b/APP/businessLogic/Src/abnormalManage.c @@ -490,7 +490,6 @@ void DSG_PROT_Interrupt(void) * @retval * */ - void EXCHG_PROT_Interrupt(void) { setShortCircuit(); @@ -503,6 +502,7 @@ void EXCHG_PROT_Interrupt(void) /* 一定时间内第二次进入输出短路保护,关闭输出 */ else if (getShortCircuit() >= 2) { stopShortCircuitProtection(); + zeroShortCircuit(); insertEventsOrderRecord(hardwareInputProtection); } } diff --git a/APP/businessLogic/Src/bl_chargControl.c b/APP/businessLogic/Src/bl_chargControl.c index c9a4729..e84cce6 100644 --- a/APP/businessLogic/Src/bl_chargControl.c +++ b/APP/businessLogic/Src/bl_chargControl.c @@ -390,9 +390,10 @@ void mppt_readJust(void) } if (getMosTemperState() == mosTemperReduce) { - SolarInCircuitV = 20; + SolarInCircuitV = g_cfgParameter.MPPTReduceConstantVoltage; + mppt_constantVoltage(SolarInCircuitV); + return; } - flag = 0; // Power = totalPower / 30.0f; @@ -417,9 +418,9 @@ void mppt_readJust(void) // hysteresisValue1 = getChargCurrent() * 1.7f; // hysteresisValue2 = getChargCurrent() * 12; currMinFlag++; - if (currMinFlag == 8) { + if (currMinFlag == 5) { currMinFlag = 0; - SolarInCircuitV = 18.0f; + SolarInCircuitV = g_cfgParameter.MPPTConstantVoltage; currMinFlag1 = 1; } @@ -428,7 +429,7 @@ void mppt_readJust(void) // else if (getChargCurrent() < 3 && currMinFlag1) { else if (totalChargeCurr < 150 && currMinFlag1) { - currMinFlag1 = 0; + // currMinFlag1 = 0; currMinFlag = 0; return; } @@ -533,7 +534,7 @@ void mppt_readJust(void) /* 一段时间内都未调节 */ if (numFlag == 10) { if (Power < 300) { - SolarInCircuitV = 17.0f; + SolarInCircuitV = g_cfgParameter.MPPTConstantVoltage; } else if (flag1) { SolarInCircuitV -= stepV2; @@ -557,6 +558,8 @@ void mppt_readJust(void) // lLLPower = lLPower; lLPower = lPower; lPower = Power; + + mppt_constantVoltage(SolarInCircuitV); } /** @@ -631,13 +634,13 @@ BOOL stopChargConditions(void) /* 异常情况关闭充电 */ static uint16_t flag = 0; if ((getSolarInCircuitVoltage() < (g_cfgParameter.stopSolarOutputCircuitV + 1) + // || getSolarInCircuitVoltage() > (g_cfgParameter.startSolarOpenCircuitV)) || getSolarInCircuitVoltage() > 18.5f) && getChargCurrent() < 0.1f && getMPPT_Mode() == MPPT) { // return TRUE; flag++; } - // if ((getSolarInCircuitVoltage() < 17.8f // || getSolarInCircuitVoltage() > 20) // && getChargCurrent() < 0.1f @@ -645,11 +648,11 @@ BOOL stopChargConditions(void) // // return TRUE; // flag++; // } - // else { - // flag = 0; - // } + else { + flag = 0; + } - if (flag > 20000) { + if (flag > 10000) { flag = 0; insertEventsOrderRecord(abnormalControl); return TRUE; diff --git a/APP/businessLogic/Src/bl_usart.c b/APP/businessLogic/Src/bl_usart.c index fe8351c..5d9d94c 100644 --- a/APP/businessLogic/Src/bl_usart.c +++ b/APP/businessLogic/Src/bl_usart.c @@ -21,7 +21,7 @@ #define HY_communicationIDStartAddr (HY_hardWordIDStartAddr + HY_hardWordIDSize) #define HY_communicationIDSize 4 static uint8_t HY_hardWordID[HY_hardWordIDSize] = {0x48, 0x59, 0x30, 0x30, 0x30, 0x31}; -static uint8_t HY_communicationID[HY_communicationIDSize] = {0x00, 0x00, 0x00, 0x01}; +static uint8_t HY_communicationID[HY_communicationIDSize] = {0x00, 0x00, 0x00, 0x02}; static uint8_t HY_startFlag = 0x68; static uint8_t HY_endFlag = 0x16; @@ -479,8 +479,9 @@ uint8_t HY_CheckFunc(uint8_t *arr_buff, uint8_t len) { uint8_t temp = 0x00; uint32_t sum = 0x00; + arr_buff++; - for(uint8_t i = 0; i < len; i++) { + for(uint8_t i = 1; i < len; i++) { sum += *arr_buff++; } @@ -568,92 +569,95 @@ void stateMachine(device_handle device) } #ifdef HY_ChargeControlBox_PROTOCOL_ENABLE - else if (state == startFlagHY) { - analysisStartFlagHY(); - } - - else if (state == hardWordIDHY) { - analysisHardWordIDHY(); - } - - else if (state == communicationIDHY) { - analysisCommunicationIDHY(); - } - - else if (state == controlWordHY) { - analysisControlWordHY(); - } - - else if (state == dataLengthHY) { - analysisDataLengthHY(); - } - - else if (state == batteryStatusHY) { - analysisBatteryStatusHY(); - } - - else if (state == electricityStatisticsHY) { - analysisElectricityStatisticsHY(); - } - - else if (state == sensorNumberConfigurationHY) { - analysisSensorNumberConfigurationHY(); - } - - else if (state == sensorNumberInquiryHY) { - analysisSensorNumberInquiryHY(); - } - - else if (state == resetInstructionHY) { - analysisResetInstructionHY(); - } + else if (g_cfgParameter.supportProtocolTypes & 0x01) + { + if (state == startFlagHY) { + analysisStartFlagHY(); + } + + else if (state == hardWordIDHY) { + analysisHardWordIDHY(); + } + + else if (state == communicationIDHY) { + analysisCommunicationIDHY(); + } + + else if (state == controlWordHY) { + analysisControlWordHY(); + } + + else if (state == dataLengthHY) { + analysisDataLengthHY(); + } + + else if (state == batteryStatusHY) { + analysisBatteryStatusHY(); + } + + else if (state == electricityStatisticsHY) { + analysisElectricityStatisticsHY(); + } + + else if (state == sensorNumberConfigurationHY) { + analysisSensorNumberConfigurationHY(); + } + + else if (state == sensorNumberInquiryHY) { + analysisSensorNumberInquiryHY(); + } + + else if (state == resetInstructionHY) { + analysisResetInstructionHY(); + } - else if (state == chargeControlConfigurationHY) { - analysisChargeControlConfigurationHY(); - } - - else if (state == chargeControlQueryHY) { - analysisChargeControlQueryHY(); - } - - else if (state == configureTimeHY) { - analysisConfigureTimeHY(); - } - - else if (state == queryTimeHY) { - analysisQueryTimeHY(); - } - - else if (state == configureProtocolTypeHY) { - analysisConfigureProtocolTypeHY(); - } - - else if (state == queryControlBoxConfigurationHY) { - analysisQueryControlBoxConfigurationHY(); - } + else if (state == chargeControlConfigurationHY) { + analysisChargeControlConfigurationHY(); + } + + else if (state == chargeControlQueryHY) { + analysisChargeControlQueryHY(); + } + + else if (state == configureTimeHY) { + analysisConfigureTimeHY(); + } + + else if (state == queryTimeHY) { + analysisQueryTimeHY(); + } + + else if (state == configureProtocolTypeHY) { + analysisConfigureProtocolTypeHY(); + } + + else if (state == queryControlBoxConfigurationHY) { + analysisQueryControlBoxConfigurationHY(); + } - else if (state == querySoftwareVersionHY) { - analysisQuerySoftwareVersionHY(); - } - - else if (state == enterConfigurationModeHY) { - analysisEnterConfigurationModeHY(); - } - - else if (state == configureHardwareIDHY) { - analysisConfigureHardwareIDHY(); - } - - else if (state == hardwareID_communicationIDQueryHY) { - analysisHardwareID_communicationIDQueryHY(); - } - - else if (state == modifyCommunicationIDHY) { - analysisModifyCommunicationIDHY(); - } - - else if (state == checkMotherboardTemperatureHY) { - analysisCheckMotherboardTemperatureHY(); + else if (state == querySoftwareVersionHY) { + analysisQuerySoftwareVersionHY(); + } + + else if (state == enterConfigurationModeHY) { + analysisEnterConfigurationModeHY(); + } + + else if (state == configureHardwareIDHY) { + analysisConfigureHardwareIDHY(); + } + + else if (state == hardwareID_communicationIDQueryHY) { + analysisHardwareID_communicationIDQueryHY(); + } + + else if (state == modifyCommunicationIDHY) { + analysisModifyCommunicationIDHY(); + } + + else if (state == checkMotherboardTemperatureHY) { + analysisCheckMotherboardTemperatureHY(); + } } #endif } @@ -4672,7 +4676,7 @@ BOOL analysisModifyCommunicationIDHY(void) { /* 解析帧 */ if (gw485RxBufferIndex >= frameLength) { - log_info("analysisSensorNumberConfigurationHY \n"); + // log_info("analysisSensorNumberConfigurationHY \n"); /* 比较校验位和结束标志 */ if (gw485RxBuffer[frameLength - 2] != HY_CheckFunc(gw485RxBuffer, frameLength - 2) @@ -4787,7 +4791,7 @@ BOOL analysisCheckMotherboardTemperatureHY(void) { /* 解析帧 */ if (gw485RxBufferIndex >= frameLength) { - log_info("analysisCheckMotherboardTemperatureHY \n"); + // log_info("analysisCheckMotherboardTemperatureHY \n"); /* 比较校验位和结束标志 */ if (gw485RxBuffer[frameLength - 2] != HY_CheckFunc(gw485RxBuffer, frameLength - 2) @@ -4925,13 +4929,20 @@ void HY_readHardWordID_Flash(void) HY_hardWordID[i] = temp[i]; } } + + // HY_hardWordID[0] = g_cfgParameter.uniqueDeviceID[0]; + // HY_hardWordID[1] = g_cfgParameter.uniqueDeviceID[1]; + // HY_hardWordID[2] = g_cfgParameter.uniqueDeviceID[2]; + // HY_hardWordID[3] = g_cfgParameter.uniqueDeviceID[3]; + // HY_hardWordID[4] = g_cfgParameter.uniqueDeviceID[4]; + // HY_hardWordID[5] = g_cfgParameter.uniqueDeviceID[5]; - log_info("HY_hardWordID[0]:%x\n", HY_hardWordID[0]); - log_info("HY_hardWordID[1]:%x\n", HY_hardWordID[1]); - log_info("HY_hardWordID[2]:%x\n", HY_hardWordID[2]); - log_info("HY_hardWordID[3]:%x\n", HY_hardWordID[3]); - log_info("HY_hardWordID[4]:%x\n", HY_hardWordID[4]); - log_info("HY_hardWordID[5]:%x\n", HY_hardWordID[5]); + // log_info("HY_hardWordID[0]:%x\n", HY_hardWordID[0]); + // log_info("HY_hardWordID[1]:%x\n", HY_hardWordID[1]); + // log_info("HY_hardWordID[2]:%x\n", HY_hardWordID[2]); + // log_info("HY_hardWordID[3]:%x\n", HY_hardWordID[3]); + // log_info("HY_hardWordID[4]:%x\n", HY_hardWordID[4]); + // log_info("HY_hardWordID[5]:%x\n", HY_hardWordID[5]); } /** @@ -4957,7 +4968,7 @@ void HY_readCommunicationID_Flash(void) for (; i < HY_communicationIDSize; i++) { if (temp[0] != 0xFF) { break; - } + } } if (i != HY_communicationIDSize) { @@ -4967,10 +4978,10 @@ void HY_readCommunicationID_Flash(void) } } - log_info("HY_communicationID[0]:%x\n", HY_communicationID[0]); - log_info("HY_communicationID[1]:%x\n", HY_communicationID[1]); - log_info("HY_communicationID[2]:%x\n", HY_communicationID[2]); - log_info("HY_communicationID[3]:%x\n", HY_communicationID[3]); + // log_info("HY_communicationID[0]:%x\n", HY_communicationID[0]); + // log_info("HY_communicationID[1]:%x\n", HY_communicationID[1]); + // log_info("HY_communicationID[2]:%x\n", HY_communicationID[2]); + // log_info("HY_communicationID[3]:%x\n", HY_communicationID[3]); } #endif \ No newline at end of file diff --git a/APP/businessLogic/Src/inFlash.c b/APP/businessLogic/Src/inFlash.c index cddc356..6ba79fe 100644 --- a/APP/businessLogic/Src/inFlash.c +++ b/APP/businessLogic/Src/inFlash.c @@ -228,7 +228,9 @@ void config_info_start(void) g_cfgParameter.Communication_Methods = RS485; g_cfgParameter.gw485_Baud = temp_configInfo.gw485_Baud; + // g_cfgParameter.gw485_Baud = 9600; g_cfgParameter.bat485_Baud = temp_configInfo.bat485_Baud; + g_cfgParameter.supportProtocolTypes = 0x01; // g_cfgParameter.bat485_Baud = 115200; // static volatile uint32_t tempBatBaud; // tempBatBaud = temp_configInfo.bat485_Baud; @@ -276,6 +278,10 @@ void config_info_start(void) g_cfgParameter.collectOpenCircuitVoltageTime= temp_configInfo.collectOpenCircuitVoltageTime; g_cfgParameter.reverseChargProtectionCurr = temp_configInfo.reverseChargProtectionCurr; + g_cfgParameter.softStartVolt = 18.5f; + g_cfgParameter.MPPTConstantVoltage = 17.0f; + g_cfgParameter.MPPTReduceConstantVoltage = 20.0f; + /* 读取的回路阻抗无效则回路阻抗设置为0 */ float fTemp; // fTemp = 0.01f; diff --git a/APP/businessLogic/Src/task.c b/APP/businessLogic/Src/task.c index f626c0a..55d7ad9 100644 --- a/APP/businessLogic/Src/task.c +++ b/APP/businessLogic/Src/task.c @@ -304,8 +304,9 @@ void Task_refreshJudgeData(void) // debug_printf("get_OUT_VOLT_IN:%f \n", tempOutV); /* 判断有无电池 */ - if (getBatteryState() == FALSE && (getChargBatteryCurrent() > 1 || getChargBatteryCurrent() < -1) - && getOutputVoltage() < 14.2f) { + if (getBatteryState() == FALSE && (getChargBatteryCurrent() > 0.5f || getChargBatteryCurrent() < -0.5f) + && getBatteryVoltage() < 14.2f) { + // && getOutputVoltage() < 14.2f) { setBatteryState(TRUE); } @@ -476,7 +477,7 @@ void Task_softStart(void) // debug_printf("getSolarInCircuitVoltage : %f", getSolarInCircuitVoltage()); //电压过低时不启动 - if (getSolarInCircuitVoltage() < 18.5f) { + if (getSolarInCircuitVoltage() < g_cfgParameter.softStartVolt) { TimeSliceOffset_Register(&m_startControl, Task_startControl, startControl_reloadVal, startControl_offset); setDutyRatioToZero(); return;