修改数据解析方式,添加配置文件读取和下发
This commit is contained in:
parent
688f925657
commit
bccfc0c450
|
@ -7,49 +7,51 @@
|
|||
#include "parameter.h"
|
||||
#include "FM_TIM.h"
|
||||
|
||||
|
||||
void startInfo(void)
|
||||
{
|
||||
log_info("uniqueDeviceID : 0x%x%x%x%x%x%x%x \n", g_cfgParameter.uniqueDeviceID[0]
|
||||
, g_cfgParameter.uniqueDeviceID[1]
|
||||
, g_cfgParameter.uniqueDeviceID[2]
|
||||
, g_cfgParameter.uniqueDeviceID[3]
|
||||
, g_cfgParameter.uniqueDeviceID[4]
|
||||
, g_cfgParameter.uniqueDeviceID[5]
|
||||
, g_cfgParameter.uniqueDeviceID[6]);
|
||||
log_info("gw485_Baud : %d \n", g_cfgParameter.gw485_Baud);
|
||||
log_info("bat485_Baud : %d \n", g_cfgParameter.bat485_Baud);
|
||||
log_info("powerBoxType : 0x%x \n", g_cfgParameter.powerBoxType);
|
||||
log_info("constantVoltageV : %f \n", g_cfgParameter.constantVoltageV);
|
||||
log_info("floatI : %f \n", g_cfgParameter.floatI);
|
||||
log_info("startSolarOpenCircuitV : %f \n", g_cfgParameter.startSolarOpenCircuitV);
|
||||
log_info("stopSolarOpenCircuitV : %f \n", g_cfgParameter.stopSolarOpenCircuitV);
|
||||
log_info("stopSolarOutputCircuitV : %f \n", g_cfgParameter.stopSolarOutputCircuitV);
|
||||
log_info("checkCanStartTime : %d \n", g_cfgParameter.checkCanStartTime);
|
||||
log_info("shortCircuitJudgmentDelay : %d \n", g_cfgParameter.shortCircuitJudgmentDelay);
|
||||
log_info("inputPowerLowJudgmentDelay : %d \n", g_cfgParameter.inputPowerLowJudgmentDelay);
|
||||
log_info("inputPowerLowAgainOutputDelay : %d \n", g_cfgParameter.inputPowerLowAgainOutputDelay);
|
||||
log_info("firstStageProtectionDelay : %d \n", g_cfgParameter.firstStageProtectionDelay);
|
||||
log_info("firstStageProtectionValue : %d \n", g_cfgParameter.firstStageProtectionValue);
|
||||
log_info("firstStageProtectionCurr : %f \n", g_cfgParameter.firstStageProtectionCurr);
|
||||
log_info("secondStageProtectionDelay : %d \n", g_cfgParameter.secondStageProtectionDelay);
|
||||
log_info("secondStageProtectionCurr : %f \n", g_cfgParameter.secondStageProtectionCurr);
|
||||
log_info("thirdStageProtectionDelay : %d \n", g_cfgParameter.thirdStageProtectionDelay);
|
||||
log_info("thirdStageProtectionCurr : %f \n", g_cfgParameter.thirdStageProtectionCurr);
|
||||
log_info("inputPowerLowDetectionDelay : %d \n", g_cfgParameter.inputPowerLowDetectionDelay);
|
||||
log_info("inputPowerLowDetectionVolt : %f \n", g_cfgParameter.inputPowerLowDetectionVolt);
|
||||
log_info("maxOpenSolarOutputCircuitV : %f \n", g_cfgParameter.maxOpenSolarOutputCircuitV);
|
||||
log_info("maxChargCurr : %f \n", g_cfgParameter.maxChargCurr);
|
||||
log_info("minCheckLoopImpedanceChargCurr : %f \n", g_cfgParameter.minCheckLoopImpedanceChargCurr);
|
||||
log_info("fullPowerOutputTemperature : %f \n", g_cfgParameter.fullPowerOutputTemperature);
|
||||
log_info("reducePowerOutputTemperature : %f \n", g_cfgParameter.reducePowerOutputTemperature);
|
||||
log_info("stopPowerOutputTemperature : %f \n", g_cfgParameter.stopPowerOutputTemperature);
|
||||
log_info("constantVoltageChargeV : %f \n", g_cfgParameter.constantVoltageChargeV);
|
||||
log_info("FloatV : %f \n", g_cfgParameter.FloatV);
|
||||
log_info("loopImpedance : %f \n", g_cfgParameter.loopImpedance);
|
||||
log_info("HighSideMosTemperature_stop : %f \n", g_cfgParameter.HighSideMosTemperature_stop);
|
||||
log_info("HighSideMosTemperature_end : %f \n", g_cfgParameter.HighSideMosTemperature_end);
|
||||
log_info("HighSideMosTemperature_start : %f \n", g_cfgParameter.HighSideMosTemperature_start);
|
||||
log_info("outputAgainFlagTime : %d \n", g_cfgParameter.outputAgainFlagTime);
|
||||
log_info("excessiveLoadFlagTime : %d \n", g_cfgParameter.excessiveLoadFlagTime);
|
||||
log_info("FloatChargeV : %f \n", g_cfgParameter.FloatChargeV);
|
||||
log_info("collectOpenCircuitVoltageTime : %d \n", g_cfgParameter.collectOpenCircuitVoltageTime);
|
||||
log_info("Access_Node_Type : %d \n", g_cfgParameter.Access_Node_Type);
|
||||
log_info("Communication_Methods : %d \n", g_cfgParameter.Communication_Methods);
|
||||
log_info("Registration_Status : %d \n", g_cfgParameter.Registration_Status);
|
||||
log_info("address : 0x%x%x%x%x%x%x%x \n", g_cfgParameter.address[0]
|
||||
, g_cfgParameter.address[1]
|
||||
, g_cfgParameter.address[2]
|
||||
, g_cfgParameter.address[3]
|
||||
, g_cfgParameter.address[4]
|
||||
, g_cfgParameter.address[5]
|
||||
, g_cfgParameter.address[6]);
|
||||
log_info("Access_Node_Type : %x \n", g_cfgParameter.Access_Node_Type);
|
||||
log_info("Communication_Methods : %x \n", g_cfgParameter.Communication_Methods);
|
||||
log_info("startFlagSL : 0x%x%x \n", g_cfgParameter.startFlagSL[0], g_cfgParameter.startFlagSL[1]);
|
||||
log_info("endFlagSL : 0x%x \n", g_cfgParameter.endFlagSL);
|
||||
log_info("hardwareID : 0x%x%x%x%x%x%x \n", g_cfgParameter.hardwareID[0]
|
||||
, g_cfgParameter.hardwareID[1]
|
||||
, g_cfgParameter.hardwareID[2]
|
||||
, g_cfgParameter.hardwareID[3]
|
||||
, g_cfgParameter.hardwareID[4]
|
||||
, g_cfgParameter.hardwareID[5]);
|
||||
log_info("communicationID : 0x%x%x%x%x \n", g_cfgParameter.communicationID[0]
|
||||
, g_cfgParameter.communicationID[1]
|
||||
, g_cfgParameter.communicationID[2]
|
||||
, g_cfgParameter.communicationID[3]);
|
||||
log_info("protocolType : 0x%x \n", g_cfgParameter.protocolType);
|
||||
log_info("startFlagHY : 0x%x \n", g_cfgParameter.startFlagHY);
|
||||
log_info("endFlagHY : 0x%x \n", g_cfgParameter.endFlagHY);
|
||||
log_info("onlyPower : 0x%x \n", g_cfgParameter.onlyPower);
|
||||
log_info("gw485_Baud : %d \n", g_cfgParameter.gw485_Baud);
|
||||
log_info("gw485_Baud : %d \n", g_cfgParameter.gw485_Baud);
|
||||
|
||||
log_info("loopImpedance : %f \n", getLoopImpedance());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -24,15 +24,16 @@
|
|||
/* SL协议写入寄存器最大长度 */
|
||||
#define maxWriteRegAddrNumMacro 10
|
||||
|
||||
|
||||
/* SL协议寄存器长度 */
|
||||
#define RegAddrNumMacro 32
|
||||
|
||||
/* SL协议下发配置文件内容最长长度 */
|
||||
#define maxDistributionCfgLen 230
|
||||
/* SL协议读取配置文件内容最长长度 */
|
||||
#define maxReadCfgLen 32
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define floatMagnification 10.0f
|
||||
|
||||
|
||||
uint16_t checkModebusCrc(uint8_t *arr_buff, uint8_t len);
|
||||
|
|
|
@ -9,82 +9,112 @@
|
|||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
/* 高字节在前,低字节在后 */
|
||||
typedef struct _recv_config_info{
|
||||
uint8_t start_Flag[2]; /* 开始标志 */
|
||||
/* SL */
|
||||
uint8_t address[7]; /* 地址 */
|
||||
// uint8_t Access_Node_Type[2]; /* 接入节点类型 */
|
||||
// uint8_t Communication_Methods[2]; /* 通信方式 */
|
||||
uint8_t gw485_Baud[4]; /* 串口波特率 */
|
||||
uint8_t bat485_Baud[4]; /* 串口波特率,为0代表bms不支持通信 */
|
||||
// /* 高字节在前,低字节在后 */
|
||||
// typedef struct _recv_config_info{
|
||||
// uint8_t start_Flag[2]; /* 开始标志 */
|
||||
// /* SL */
|
||||
// uint8_t address[7]; /* 地址 */
|
||||
// // uint8_t Access_Node_Type[2]; /* 接入节点类型 */
|
||||
// // uint8_t Communication_Methods[2]; /* 通信方式 */
|
||||
// uint8_t gw485_Baud[4]; /* 串口波特率 */
|
||||
// uint8_t bat485_Baud[4]; /* 串口波特率,为0代表bms不支持通信 */
|
||||
|
||||
/* HY */
|
||||
uint8_t hardwareID[6]; /* 硬件ID */
|
||||
uint8_t communicationID[4]; /* 通信ID */
|
||||
uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/
|
||||
// /* HY */
|
||||
// uint8_t hardwareID[6]; /* 硬件ID */
|
||||
// uint8_t communicationID[4]; /* 通信ID */
|
||||
// uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/
|
||||
|
||||
|
||||
uint8_t CommunicationProtocolType; /* 0x00:SL
|
||||
0x01:HY*/
|
||||
uint8_t onlyPower; /* 是否只充当电源板:0x00:不是
|
||||
0x01:是*/
|
||||
// uint8_t CommunicationProtocolType; /* 0x00:SL
|
||||
// 0x01:HY*/
|
||||
// uint8_t onlyPower; /* 是否只充当电源板:0x00:不是
|
||||
// 0x01:是*/
|
||||
|
||||
uint8_t ConstantVoltageV[2]; /* 高于该(电压 / 100)且电流大于FloatI * 100进行恒压充电 */
|
||||
uint8_t FloatI[2]; /* 高于该(电压 / 100)且电流低于FloatI * 100进行浮充充电 */
|
||||
uint8_t startSolarOpenCircuitV[2]; /* 高于该(电压 / 100)开始充电 */
|
||||
uint8_t stopSolarOpenCircuitV[2]; /* 太阳能板开路电压高于该电压停止充电 (V) */
|
||||
uint8_t constantVoltageChargeV[2]; /* 恒压充电时的输出电压 (V) */
|
||||
uint8_t FloatChargeV[2]; /* 浮充充电时的输出电压 (V) */
|
||||
uint8_t HighSideMosTemperature_stop[2]; /* 当上桥温度达到该值时,停止输出 (°C) */
|
||||
uint8_t HighSideMosTemperature_end[2]; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
|
||||
uint8_t HighSideMosTemperature_start[2];/* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
|
||||
// uint8_t ConstantVoltageV[2]; /* 高于该(电压 / 100)且电流大于FloatI * 100进行恒压充电 */
|
||||
// uint8_t FloatI[2]; /* 高于该(电压 / 100)且电流低于FloatI * 100进行浮充充电 */
|
||||
// uint8_t startSolarOpenCircuitV[2]; /* 高于该(电压 / 100)开始充电 */
|
||||
// uint8_t stopSolarOpenCircuitV[2]; /* 太阳能板开路电压高于该电压停止充电 (V) */
|
||||
// uint8_t constantVoltageChargeV[2]; /* 恒压充电时的输出电压 (V) */
|
||||
// uint8_t FloatChargeV[2]; /* 浮充充电时的输出电压 (V) */
|
||||
// uint8_t HighSideMosTemperature_stop[2]; /* 当上桥温度达到该值时,停止输出 (°C) */
|
||||
// uint8_t HighSideMosTemperature_end[2]; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
|
||||
// uint8_t HighSideMosTemperature_start[2];/* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
|
||||
|
||||
// uint8_t checkSolarOpenCircuitVTime[2]; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
|
||||
// uint8_t sensorEnableBroadcastTime[2]; /* 传感器运行再次注册的间隔 (S) */
|
||||
uint8_t outputAgainFlagTime[2]; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
|
||||
uint8_t excessiveLoadFlagTime[2]; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */
|
||||
uint8_t eLAgainTime[2]; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
|
||||
uint8_t crc[2]; /* 校验 */
|
||||
uint8_t end_Flag; /* 结束标志 */
|
||||
}recv_config_info;
|
||||
#define RECV_CONFIG_INFO sizeof(recv_config_info)
|
||||
// // uint8_t checkSolarOpenCircuitVTime[2]; /* 启动任务中太阳能板开路电压检测间隔时间 (S) */
|
||||
// // uint8_t sensorEnableBroadcastTime[2]; /* 传感器运行再次注册的间隔 (S) */
|
||||
// uint8_t outputAgainFlagTime[2]; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 (S) */
|
||||
// uint8_t excessiveLoadFlagTime[2]; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */
|
||||
// uint8_t eLAgainTime[2]; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
|
||||
// uint8_t crc[2]; /* 校验 */
|
||||
// uint8_t end_Flag; /* 结束标志 */
|
||||
// }recv_config_info;
|
||||
// #define RECV_CONFIG_INFO sizeof(recv_config_info)
|
||||
|
||||
typedef struct _config_info{
|
||||
/* SL */
|
||||
uint8_t address[7]; /* 地址 */
|
||||
// uint16_t Access_Node_Type; /* 接入节点类型 */
|
||||
// uint16_t Communication_Methods; /* 通信方式 */
|
||||
uint32_t gw485_Baud; /* 串口波特率,为0代表bms不支持通信 */
|
||||
uint32_t bat485_Baud; /* 串口波特率 */
|
||||
// /* SL */
|
||||
// uint8_t address[7]; /* 地址 */
|
||||
// // uint16_t Access_Node_Type; /* 接入节点类型 */
|
||||
// // uint16_t Communication_Methods; /* 通信方式 */
|
||||
// uint32_t gw485_Baud; /* 串口波特率,为0代表bms不支持通信 */
|
||||
// uint32_t bat485_Baud; /* 串口波特率 */
|
||||
|
||||
/* HY */
|
||||
uint8_t hardwareID[6]; /* 硬件ID */
|
||||
uint8_t communicationID[4]; /* 通信ID */
|
||||
uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/
|
||||
// /* HY */
|
||||
// uint8_t hardwareID[6]; /* 硬件ID */
|
||||
// uint8_t communicationID[4]; /* 通信ID */
|
||||
// uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/
|
||||
|
||||
uint8_t CommunicationProtocolType; /* 0x00:SL
|
||||
0x01:HY*/
|
||||
uint8_t onlyPower; /* 是否只充当电源板:0x00:不是
|
||||
0x01:是*/
|
||||
// uint8_t CommunicationProtocolType; /* 0x00:SL
|
||||
// 0x01:HY*/
|
||||
// uint8_t onlyPower; /* 是否只充当电源板:0x00:不是
|
||||
// 0x01:是*/
|
||||
|
||||
float constantVoltageV; /* 电压高于ConstantVoltageV且电流大于FloatI + 0.1)进行恒压充电 */
|
||||
float floatI; /* 电压高于ConstantVoltageV且电流低于FloatI进行浮充充电 */
|
||||
float startSolarOpenCircuitV; /* 太阳能板开路电压高于该电压开始充电 */
|
||||
float stopSolarOpenCircuitV; /* 太阳能板开路电压高于该电压 停止充电 */
|
||||
float constantVoltageChargeV; /* 恒压充电时的输出电压 */
|
||||
float FloatChargeV; /* 浮充电压 */
|
||||
float HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 */
|
||||
float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 */
|
||||
float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 */
|
||||
// float constantVoltageV; /* 电压高于ConstantVoltageV且电流大于FloatI + 0.1)进行恒压充电 */
|
||||
// float floatI; /* 电压高于ConstantVoltageV且电流低于FloatI进行浮充充电 */
|
||||
// float startSolarOpenCircuitV; /* 太阳能板开路电压高于该电压开始充电 */
|
||||
// float stopSolarOpenCircuitV; /* 太阳能板开路电压高于该电压 停止充电 */
|
||||
// float constantVoltageChargeV; /* 恒压充电时的输出电压 */
|
||||
// float FloatChargeV; /* 浮充电压 */
|
||||
// float HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 */
|
||||
// float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 */
|
||||
// float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 */
|
||||
|
||||
// uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */
|
||||
// uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */
|
||||
uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 */
|
||||
uint16_t excessiveLoadFlagTime; /* 出现过载后,在该段时间中再次出现过载,则关闭输出 */
|
||||
uint16_t eLAgainTime; /* 出现过载过载保护后,该段时间后,再次尝试输出 */
|
||||
// // uint16_t checkSolarOpenCircuitVTime; /* 启动任务中太阳能板开路电压检测时间 */
|
||||
// // uint16_t sensorEnableBroadcastTime; /* 传感器运行再次注册的间隔 */
|
||||
// uint16_t outputAgainFlagTime; /* 出现短路保护后延长该段时间再次检测是否短路,仍然短路则关闭输出 */
|
||||
// uint16_t excessiveLoadFlagTime; /* 出现过载后,在该段时间中再次出现过载,则关闭输出 */
|
||||
// uint16_t eLAgainTime; /* 出现过载过载保护后,该段时间后,再次尝试输出 */
|
||||
|
||||
uint16_t crc; /* 校验 */
|
||||
uint8_t uniqueDeviceID[7]; /* 设备唯一ID */
|
||||
uint32_t gw485_Baud; /* 串口波特率 */
|
||||
uint32_t bat485_Baud; /* 串口波特率,为0代表bms不支持通信 */
|
||||
uint8_t powerBoxType; /* 是否只充当电源板:0x00:不是;0x01:是*/
|
||||
float constantVoltageV; /* 恒压充电阈值电压(V) */
|
||||
float floatI; /* 浮充充电阈值电流(A) */
|
||||
float startSolarOpenCircuitV; /* 启动充电太阳能板开路电压(V) */
|
||||
float stopSolarOutputCircuitV; /* 停止充电太阳能板输出电压(V) */
|
||||
uint16_t checkCanStartTime; /* 检测能否启动间隔时间(S) */
|
||||
uint16_t shortCircuitJudgmentDelay; /* 短路判断延时(S) */
|
||||
uint16_t inputPowerLowJudgmentDelay; /* 前端输入功率不足判断延时(S) */
|
||||
uint16_t inputPowerLowAgainOutputDelay; /* 前端输入功率不足再次输出延时(S) */
|
||||
uint16_t firstStageProtectionDelay; /* 第一段保护延时(10uS) */
|
||||
float firstStageProtectionCurr; /* 第一段保护电流(A) */
|
||||
uint16_t secondStageProtectionDelay; /* 第二段保护延时(100uS) */
|
||||
float secondStageProtectionCurr; /* 第二段保护电流(A) */
|
||||
uint32_t thirdStageProtectionDelay; /* 第三段保护延时(100uS) */
|
||||
float thirdStageProtectionCurr; /* 第三段保护电流(A) */
|
||||
uint16_t inputPowerLowDetectionDelay; /* 前端输入功率不足检测延时(100uS) */
|
||||
float inputPowerLowDetectionVolt; /* 前端输入功率不足检测电压(V) */
|
||||
float maxOpenSolarOutputCircuitV; /* 最大太阳能板输出电压(V) */
|
||||
float maxChargCurr; /* 最大充电电流(A) */
|
||||
float minCheckLoopImpedanceChargCurr; /* 检测回路阻抗时的最小充电电流(A) */
|
||||
float fullPowerOutputTemperature; /* 满功率输出温度(℃) */
|
||||
float reducePowerOutputTemperature; /* 降功率输出温度(℃) */
|
||||
float stopPowerOutputTemperature; /* 停止输出温度(℃) */
|
||||
float constantVoltageChargeV; /* 恒压充电时的输出电压(V) */
|
||||
float FloatChargeV; /* 浮充充电时的输出电压(V) */
|
||||
uint16_t collectOpenCircuitVoltageTime; /* 充电时采集开路电压的间隔时间 */
|
||||
|
||||
uint16_t crc; /* 校验 */
|
||||
}config_info;
|
||||
|
||||
#define CONFIG_INFO_SIZE (sizeof(config_info))
|
||||
|
@ -102,9 +132,10 @@ typedef struct _config_info{
|
|||
void read_config_info(config_info *output_config_info);
|
||||
void saveConfigInfo(config_info *config_info);
|
||||
void config_info_start(void);
|
||||
void readFlashContent(config_info *configInfo);
|
||||
|
||||
void saveLoopImpedance(float *loopImpedance);
|
||||
void readLoopImpedance(float *loopImpedance);
|
||||
void saveLoopImpedance();
|
||||
BOOL readLoopImpedance();
|
||||
void savetotalElectricityConsumption(float *totalElectricityConsumption);
|
||||
void readtotalElectricityConsumption(float *totalElectricityConsumption);
|
||||
void savetotalChargCapacity(float *totalChargCapacity);
|
||||
|
|
|
@ -19,4 +19,7 @@ void send_init(void);
|
|||
void check_sendState(void);
|
||||
void uart_interruptSend(device_handle device, uint8_t buff[], uint8_t len);
|
||||
|
||||
uint8_t *getInsertData(void);
|
||||
void uart_insertDataSend(device_handle device, uint8_t len);
|
||||
|
||||
#endif
|
|
@ -10,62 +10,44 @@
|
|||
|
||||
/* 主要有配置文件读取出来的数据 */
|
||||
typedef struct _config_parameter{
|
||||
float constantVoltageV; /* 电压高于ConstantVoltageV且电流大于(FloatI + 0.1)进行恒压充电
|
||||
电压低于该(ConstantVoltageV - 0.2) 进行恒流充电 (V) */
|
||||
float floatI; /* 电压高于该ConstantVoltageV且电流低于FloatI进行浮充充电 (A) */
|
||||
float startSolarOpenCircuitV; /* 太阳能板开路电压高于该电压开始充电 (V) */
|
||||
float stopSolarOpenCircuitV; /* 太阳能板开路电压高于该电压停止充电 (V) */
|
||||
float constantVoltageChargeV; /* 恒压充电时的输出电压 (V) */
|
||||
float FloatV; /* 浮充充电时的输出电压 (V) */
|
||||
float loopImpedance; /* 回路阻抗大小 (mΩ) */
|
||||
float HighSideMosTemperature_stop; /* 当上桥温度达到该值时,停止输出 (°C) */
|
||||
float HighSideMosTemperature_end; /* 当上桥温度上升到该值时,降低功率运行 (°C) */
|
||||
float HighSideMosTemperature_start; /* 当上桥温度降低到该值时,按照正常情况输出 (°C) */
|
||||
uint8_t uniqueDeviceID[7]; /* 设备唯一ID */
|
||||
|
||||
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) */
|
||||
uint16_t excessiveLoadFlagTime; /* 出现过载后,在该间隔时间中多次(2次)出现过载,则关闭输出 (S) */
|
||||
uint16_t eLAgainTime; /* 出现过载过载保护后,在该间隔段时间后,再次尝试输出 (S) */
|
||||
// uint16_t softShortTime; /* 软件短路保护延时 时间(100uS) */
|
||||
|
||||
uint32_t collectOpenCircuitVoltageTime; /* 充电时开路电压采集时间间隔(S) */
|
||||
|
||||
uint32_t gw485_Baud; /* 串口波特率 */
|
||||
uint32_t bat485_Baud; /* 串口波特率,为0代表bms不支持通信 */
|
||||
uint8_t powerBoxType; /* 是否只充当电源板:0x00:不是;0x01:是*/
|
||||
float constantVoltageV; /* 恒压充电阈值电压(V) */
|
||||
float floatI; /* 浮充充电阈值电流(A) */
|
||||
float startSolarOpenCircuitV; /* 启动充电太阳能板开路电压(V) */
|
||||
float stopSolarOutputCircuitV; /* 停止充电太阳能板输出电压(V) */
|
||||
uint16_t checkCanStartTime; /* 检测能否启动间隔时间(S) */
|
||||
uint16_t shortCircuitJudgmentDelay; /* 短路判断延时(S) */
|
||||
uint16_t inputPowerLowJudgmentDelay; /* 前端输入功率不足判断延时(S) */
|
||||
uint16_t inputPowerLowAgainOutputDelay; /* 前端输入功率不足再次输出延时(S) */
|
||||
uint16_t firstStageProtectionDelay; /* 第一段保护延时(10uS) */
|
||||
float firstStageProtectionCurr; /* 第一段保护电流(A) */
|
||||
uint16_t firstStageProtectionValue; /* 第一段保护ADC值 */
|
||||
uint16_t secondStageProtectionDelay; /* 第二段保护延时(100uS) */
|
||||
float secondStageProtectionCurr; /* 第二段保护电流(A) */
|
||||
uint16_t thirdStageProtectionDelay; /* 第三段保护延时(100uS) */
|
||||
float thirdStageProtectionCurr; /* 第三段保护电流(A) */
|
||||
uint16_t inputPowerLowDetectionDelay; /* 前端输入功率不足检测延时(100uS) */
|
||||
float inputPowerLowDetectionVolt; /* 前端输入功率不足检测电压(V) */
|
||||
float maxOpenSolarOutputCircuitV; /* 最大太阳能板输出电压(V) */
|
||||
float maxChargCurr; /* 最大充电电流(A) */
|
||||
float minCheckLoopImpedanceChargCurr; /* 检测回路阻抗时的最小充电电流(A) */
|
||||
float fullPowerOutputTemperature; /* 满功率输出温度(℃) */
|
||||
float reducePowerOutputTemperature; /* 降功率输出温度(℃) */
|
||||
float stopPowerOutputTemperature; /* 停止输出温度(℃) */
|
||||
float constantVoltageChargeV; /* 恒压充电时的输出电压(V) */
|
||||
float FloatChargeV; /* 浮充充电时的输出电压(V) */
|
||||
uint16_t collectOpenCircuitVoltageTime; /* 充电时采集开路电压的间隔时间 */
|
||||
|
||||
/* SL */
|
||||
uint16_t Access_Node_Type; /* 接入节点类型 */
|
||||
uint16_t Communication_Methods; /* 通信方式 */
|
||||
uint16_t Registration_Status; /* 注册状态 */
|
||||
uint8_t address[7]; /* 地址 */
|
||||
uint8_t startFlagSL[2]; /* 起始标志 */
|
||||
uint8_t endFlagSL; /* 结束标志 */
|
||||
|
||||
/* HY */
|
||||
uint8_t hardwareID[6]; /* 硬件ID */
|
||||
uint8_t communicationID[4]; /* 通信ID */
|
||||
uint8_t protocolType; /* 协议类型; 0x01表示:汇源协议(波特率9600) 0x02表示:南瑞协议(波特率115200)*/
|
||||
uint8_t startFlagHY; /* 起始码 */
|
||||
uint8_t endFlagHY; /* 结束码 */
|
||||
|
||||
uint8_t onlyPower; /* 是否只充当电源板:0x00:不是
|
||||
0x01:是*/
|
||||
|
||||
uint32_t gw485_Baud; /* 串口波特率 */
|
||||
uint32_t bat485_Baud; /* 串口波特率,为0代表bms不支持通信 */
|
||||
} config_parameter;
|
||||
extern config_parameter g_cfgParameter;
|
||||
typedef struct _otherParameter{
|
||||
|
@ -84,8 +66,11 @@ typedef struct _otherParameter{
|
|||
|
||||
int MPPT_Mode; /* 工作模式 */
|
||||
|
||||
uint8_t versionInformation[13]; /* 软件版本信息 */
|
||||
uint8_t versionInformation[13]; /* 软件版本信息 */
|
||||
|
||||
float loopImpedance; /* 回路阻抗大小 (Ω) */
|
||||
|
||||
uint16_t Registration_Status; /* 注册状态 */
|
||||
}otherParameter;
|
||||
|
||||
// #pragma pack(pop)
|
||||
|
@ -133,8 +118,11 @@ float getChargBatteryCurrent(void);
|
|||
BOOL getChargMosState(void);
|
||||
void setChargMosState(BOOL state);
|
||||
BOOL getDischargMosState(void);
|
||||
uint8_t *getVersionInformation(void);
|
||||
|
||||
uint8_t *getVersionnInformation(void);
|
||||
float getLoopImpedance(void);
|
||||
BOOL setLoopImpedance(float loopImpedance);
|
||||
uint16_t getRegistrationStatus(void);
|
||||
void setRegistrationStatus(uint16_t status);
|
||||
|
||||
|
||||
#endif
|
|
@ -23,7 +23,9 @@ void Init(void)
|
|||
|
||||
config_info_start();
|
||||
ADC_Capture_Init();
|
||||
proportionalInt(g_cfgParameter.onlyPower);
|
||||
proportionalInt(g_cfgParameter.powerBoxType);
|
||||
|
||||
g_cfgParameter.firstStageProtectionValue = setfirstStageProtectionValue(g_cfgParameter.firstStageProtectionCurr);
|
||||
|
||||
FM_GPIO_Init();
|
||||
tim_Init();
|
||||
|
@ -41,7 +43,6 @@ void Init(void)
|
|||
send_init();
|
||||
// POW_FF_PCON_Open();
|
||||
// POW_OUT_PCON_Open();
|
||||
|
||||
HAL_Delay(100);
|
||||
setPowerOutput(TRUE);
|
||||
|
||||
|
|
|
@ -259,8 +259,13 @@ BOOL getExcessiveLoadFlag(void)
|
|||
*/
|
||||
void setPowerOutput(BOOL state)
|
||||
{
|
||||
// static volatile float temp_OUT_VOLT_IN;
|
||||
// static volatile float temp_PV_VOLT_OUT;
|
||||
// temp_PV_VOLT_OUT = get_PV_VOLT_OUT();
|
||||
// temp_OUT_VOLT_IN = get_OUT_VOLT_IN();
|
||||
if (state == TRUE) {
|
||||
if (get_OUT_VOLT_IN() < (get_PV_VOLT_OUT() - 0.1f)) {
|
||||
if (get_OUT_VOLT_IN() < (get_PV_VOLT_OUT() - 0.1f)) {
|
||||
// if (temp_OUT_VOLT_IN < (temp_PV_VOLT_OUT - 0.5f)) {
|
||||
POW_FF_PCON_Open();
|
||||
POW_OUT_PCON_Open();
|
||||
}
|
||||
|
@ -348,14 +353,14 @@ void lowInputLoadDetection(void)
|
|||
{
|
||||
static int num = 0;
|
||||
|
||||
if (excessiveLoadInterruptFlag == TRUE && getOutputVoltage() < g_cfgParameter.lowInputLoadDetectionVolt) {
|
||||
if (excessiveLoadInterruptFlag == TRUE && getOutputVoltage() < g_cfgParameter.inputPowerLowDetectionVolt) {
|
||||
num++;
|
||||
} else {
|
||||
num = 0;
|
||||
excessiveLoadInterruptFlag = FALSE;
|
||||
}
|
||||
|
||||
if (excessiveLoadInterruptFlag == TRUE && num == g_cfgParameter.lowInputLoadDetectionDelay) {
|
||||
if (excessiveLoadInterruptFlag == TRUE && num == g_cfgParameter.inputPowerLowDetectionDelay) {
|
||||
setOverLoad();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,7 +360,7 @@ void mppt_readJust(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if (getMosTemperState() == mosTemperEnd) {
|
||||
if (getMosTemperState() == mosTemperReduce) {
|
||||
SolarInCircuitV = 16;
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ void startChargWork(void)
|
|||
*/
|
||||
BOOL stopChargConditions(void)
|
||||
{
|
||||
if (getSolarInCircuitVoltage() < g_cfgParameter.stopSolarOpenCircuitV
|
||||
if (getSolarInCircuitVoltage() < g_cfgParameter.stopSolarOutputCircuitV
|
||||
&& getChargCurrent() < 1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -600,7 +600,7 @@ void judgeYNBattery(void)
|
|||
*/
|
||||
void noBatteryChargControl(void)
|
||||
{
|
||||
mppt_constantVoltageNoBatteryO(g_cfgParameter.FloatV);
|
||||
mppt_constantVoltageNoBatteryO(g_cfgParameter.FloatChargeV);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -633,7 +633,7 @@ void constantVoltageCharge(void)
|
|||
*/
|
||||
void floatCharge(void)
|
||||
{
|
||||
mppt_constantVoltageO(g_cfgParameter.FloatV);
|
||||
mppt_constantVoltageO(g_cfgParameter.FloatChargeV);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -59,22 +59,21 @@ void saveConfigInfo(config_info *configInfo)
|
|||
* @retval None
|
||||
*
|
||||
*/
|
||||
static void readFlashContent(config_info *configInfo)
|
||||
void readFlashContent(config_info *configInfo)
|
||||
{
|
||||
read_config_info(configInfo);
|
||||
/* 配置文件正确就返回 */
|
||||
// static volatile uint16_t tempCrc1, tempCrc2;
|
||||
// static volatile config_info *tempConfigInfo1;
|
||||
// tempConfigInfo1 = configInfo;
|
||||
// tempCrc1 = configInfo->crc;
|
||||
// tempCrc2 = checkModebusCrc((uint8_t *)configInfo, CONFIG_INFO_SIZE - 2);
|
||||
// if (tempCrc1 == tempCrc2) {
|
||||
// return;
|
||||
// }
|
||||
// static volatile uint16_t tempCrc1, tempCrc2;
|
||||
// tempCrc1 = configInfo->crc;
|
||||
// tempCrc2 = checkModebusCrc((uint8_t *)configInfo, CONFIG_INFO_SIZE - 2);
|
||||
// if (tempCrc1 == tempCrc2) {
|
||||
// return;
|
||||
// }
|
||||
if (configInfo->crc == checkModebusCrc((uint8_t *)configInfo, CONFIG_INFO_SIZE - 2)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// /* 更深处的配置文件正确就返回 */
|
||||
// read_backups_config_info(config_info);
|
||||
// if (config_info->crc == configCheckFunc((uint8_t *)config_info, CONFIG_INFO_SIZE - 2)) {
|
||||
|
@ -83,48 +82,65 @@ static void readFlashContent(config_info *configInfo)
|
|||
// }
|
||||
|
||||
/* 配置文件错误使用默认配置 */
|
||||
configInfo->address[0] = 0x11;
|
||||
configInfo->address[1] = 0x11;
|
||||
configInfo->address[2] = 0x11;
|
||||
configInfo->address[3] = 0x11;
|
||||
configInfo->address[4] = 0x11;
|
||||
configInfo->address[5] = 0x11;
|
||||
configInfo->address[6] = 0x11;
|
||||
// config_info->Access_Node_Type = 0x01;
|
||||
// config_info->Communication_Methods = 0x02;
|
||||
configInfo->uniqueDeviceID[0] = 0x11;
|
||||
configInfo->uniqueDeviceID[1] = 0x11;
|
||||
configInfo->uniqueDeviceID[2] = 0x11;
|
||||
configInfo->uniqueDeviceID[3] = 0x11;
|
||||
configInfo->uniqueDeviceID[4] = 0x11;
|
||||
configInfo->uniqueDeviceID[5] = 0x11;
|
||||
configInfo->uniqueDeviceID[6] = 0x11;
|
||||
|
||||
configInfo->gw485_Baud = 115200;
|
||||
configInfo->bat485_Baud = 115200;
|
||||
|
||||
configInfo->hardwareID[0] = 0x48;
|
||||
configInfo->hardwareID[1] = 0x59;
|
||||
configInfo->hardwareID[2] = 0x30;
|
||||
configInfo->hardwareID[3] = 0x30;
|
||||
configInfo->hardwareID[4] = 0x30;
|
||||
configInfo->hardwareID[5] = 0x31;
|
||||
configInfo->communicationID[0] = 0x00;
|
||||
configInfo->communicationID[1] = 0x00;
|
||||
configInfo->communicationID[2] = 0x00;
|
||||
configInfo->communicationID[3] = 0x01;
|
||||
configInfo->protocolType = 0x01;
|
||||
|
||||
configInfo->CommunicationProtocolType = 0x01;
|
||||
configInfo->onlyPower = 0x01;
|
||||
configInfo->powerBoxType = 0x01;
|
||||
|
||||
configInfo->constantVoltageV = 14;
|
||||
configInfo->floatI = 0.1f;
|
||||
configInfo->startSolarOpenCircuitV = 17;
|
||||
configInfo->stopSolarOpenCircuitV = 15;
|
||||
configInfo->stopSolarOutputCircuitV = 15;
|
||||
|
||||
configInfo->checkCanStartTime = 5;
|
||||
configInfo->shortCircuitJudgmentDelay = 10;
|
||||
configInfo->inputPowerLowJudgmentDelay = 30;
|
||||
configInfo->inputPowerLowAgainOutputDelay = 1800;
|
||||
|
||||
configInfo->firstStageProtectionDelay = 2;
|
||||
configInfo->firstStageProtectionCurr = 50;
|
||||
configInfo->secondStageProtectionDelay = 50000;
|
||||
configInfo->secondStageProtectionCurr = 35;
|
||||
configInfo->thirdStageProtectionDelay = 600000;
|
||||
configInfo->thirdStageProtectionCurr = 30;
|
||||
|
||||
configInfo->inputPowerLowDetectionDelay = 10;
|
||||
configInfo->inputPowerLowDetectionVolt = 10.0f;
|
||||
|
||||
configInfo->maxOpenSolarOutputCircuitV = 25;
|
||||
configInfo->maxChargCurr = 35;
|
||||
|
||||
configInfo->minCheckLoopImpedanceChargCurr = 5;
|
||||
|
||||
configInfo->stopPowerOutputTemperature = 100;
|
||||
configInfo->reducePowerOutputTemperature = 90;
|
||||
configInfo->fullPowerOutputTemperature = 50;
|
||||
|
||||
configInfo->constantVoltageChargeV = 14.4f;
|
||||
configInfo->FloatChargeV = 14.2f;
|
||||
configInfo->HighSideMosTemperature_stop = 100;
|
||||
configInfo->HighSideMosTemperature_end = 90;
|
||||
configInfo->HighSideMosTemperature_start = 50;
|
||||
configInfo->collectOpenCircuitVoltageTime = 1800;
|
||||
|
||||
// configInfo->firstStageProtectionCurr = firstStageProtectionCurrMacro;
|
||||
// configInfo->firstStageProtectionDelay = firstStageProtectionDelayMacro;
|
||||
// configInfo->firstStageProtectionValue = firstStageProtectionValueMacro;
|
||||
// configInfo->secondStageProtectionCurr = secondStageProtectionCurrMacro;
|
||||
// configInfo->secondStageProtectionDelay = secondStageProtectionDelayMacro;
|
||||
// configInfo->thirdStageProtectionCurr = thirdStageProtectionCurrMacro;
|
||||
// configInfo->thirdStageProtectionDelay = thirdStageProtectionDelayMacro;
|
||||
// configInfo->checkLoopImpedanceChargCurr = checkLoopImpedanceChargCurrMacro;
|
||||
// configInfo->lowInputLoadDetectionVolt = lowInputLoadDetectionVoltMacro;
|
||||
// configInfo->lowInputLoadDetectionDelay = lowInputLoadDetectionDelayMacro;
|
||||
// configInfo->maxChargCurr = maxChargCurrMacro;
|
||||
// configInfo->maxOpenSolarOpenCircuitV = maxOpenSolarOpenCircuitVMacro;
|
||||
|
||||
// configInfo->checkSolarOpenCircuitVTime = 10;
|
||||
// configInfo->sensorEnableBroadcastTime = 20;
|
||||
configInfo->outputAgainFlagTime = 10;
|
||||
configInfo->excessiveLoadFlagTime = 60;
|
||||
configInfo->eLAgainTime = 1800;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,74 +156,65 @@ void config_info_start(void)
|
|||
config_info temp_configInfo;
|
||||
readFlashContent(&temp_configInfo);
|
||||
|
||||
g_cfgParameter.constantVoltageV = temp_configInfo.constantVoltageV;
|
||||
g_cfgParameter.floatI = temp_configInfo.floatI;
|
||||
g_cfgParameter.startSolarOpenCircuitV = temp_configInfo.startSolarOpenCircuitV;
|
||||
g_cfgParameter.stopSolarOpenCircuitV = temp_configInfo.stopSolarOpenCircuitV;
|
||||
g_cfgParameter.constantVoltageChargeV = temp_configInfo.constantVoltageChargeV;
|
||||
g_cfgParameter.FloatV = temp_configInfo.FloatChargeV;
|
||||
g_cfgParameter.HighSideMosTemperature_stop = temp_configInfo.HighSideMosTemperature_stop;
|
||||
g_cfgParameter.HighSideMosTemperature_end = temp_configInfo.HighSideMosTemperature_end;
|
||||
g_cfgParameter.HighSideMosTemperature_start = temp_configInfo.HighSideMosTemperature_start;
|
||||
// g_cfgParameter.sensorEnableBroadcastTime = temp_configInfo.sensorEnableBroadcastTime;
|
||||
// g_cfgParameter.checkSolarOpenCircuitVTime = temp_configInfo.checkSolarOpenCircuitVTime;
|
||||
g_cfgParameter.outputAgainFlagTime = temp_configInfo.outputAgainFlagTime;
|
||||
g_cfgParameter.excessiveLoadFlagTime = temp_configInfo.excessiveLoadFlagTime;
|
||||
g_cfgParameter.eLAgainTime = temp_configInfo.eLAgainTime;
|
||||
g_cfgParameter.collectOpenCircuitVoltageTime= 3600;
|
||||
g_cfgParameter.address[0] = temp_configInfo.address[0];
|
||||
g_cfgParameter.address[1] = temp_configInfo.address[1];
|
||||
g_cfgParameter.address[2] = temp_configInfo.address[2];
|
||||
g_cfgParameter.address[3] = temp_configInfo.address[3];
|
||||
g_cfgParameter.address[4] = temp_configInfo.address[4];
|
||||
g_cfgParameter.address[5] = temp_configInfo.address[5];
|
||||
g_cfgParameter.address[6] = temp_configInfo.address[6];
|
||||
// g_cfgParameter.Access_Node_Type = temp_configInfo.Access_Node_Type;
|
||||
// g_cfgParameter.Communication_Methods = temp_configInfo.Communication_Methods;
|
||||
g_cfgParameter.hardwareID[0] = temp_configInfo.hardwareID[0];
|
||||
g_cfgParameter.hardwareID[1] = temp_configInfo.hardwareID[1];
|
||||
g_cfgParameter.hardwareID[2] = temp_configInfo.hardwareID[2];
|
||||
g_cfgParameter.hardwareID[3] = temp_configInfo.hardwareID[3];
|
||||
g_cfgParameter.hardwareID[4] = temp_configInfo.hardwareID[4];
|
||||
g_cfgParameter.hardwareID[5] = temp_configInfo.hardwareID[5];
|
||||
g_cfgParameter.communicationID[0] = temp_configInfo.communicationID[0];
|
||||
g_cfgParameter.communicationID[1] = temp_configInfo.communicationID[1];
|
||||
g_cfgParameter.communicationID[2] = temp_configInfo.communicationID[2];
|
||||
g_cfgParameter.communicationID[3] = temp_configInfo.communicationID[3];
|
||||
g_cfgParameter.protocolType = temp_configInfo.protocolType;
|
||||
// g_cfgParameter.CommunicationProtocolType = temp_configInfo.CommunicationProtocolType;
|
||||
g_cfgParameter.onlyPower = temp_configInfo.onlyPower;
|
||||
|
||||
g_cfgParameter.startFlagSL[0] = 'S';
|
||||
g_cfgParameter.startFlagSL[1] = 'L';
|
||||
g_cfgParameter.endFlagSL = 0x16;
|
||||
g_cfgParameter.startFlagHY = 0x68;
|
||||
g_cfgParameter.endFlagHY = 0x16;
|
||||
|
||||
// if (g_cfgParameter.CommunicationProtocolType == 0x00) {
|
||||
// g_cfgParameter.gw485_Baud = temp_configInfo.gw485_Baud;
|
||||
// g_cfgParameter.bat485_Baud = temp_configInfo.bat485_Baud;
|
||||
// } else if (g_cfgParameter.CommunicationProtocolType == 0x01) {
|
||||
// g_cfgParameter.bat485_Baud = temp_configInfo.bat485_Baud;
|
||||
// if (g_cfgParameter.protocolType == 0x01) {
|
||||
// g_cfgParameter.gw485_Baud = 9600;
|
||||
// } else if (g_cfgParameter.protocolType == 0x02) {
|
||||
// g_cfgParameter.gw485_Baud = 115200;
|
||||
// }
|
||||
// }
|
||||
g_cfgParameter.gw485_Baud = 115200;
|
||||
g_cfgParameter.bat485_Baud = 115200;
|
||||
g_cfgParameter.Access_Node_Type = POWERBOX;
|
||||
g_cfgParameter.Communication_Methods = RS485;
|
||||
|
||||
g_cfgParameter.gw485_Baud = temp_configInfo.gw485_Baud;
|
||||
g_cfgParameter.bat485_Baud = temp_configInfo.bat485_Baud;
|
||||
|
||||
g_cfgParameter.uniqueDeviceID[0] = temp_configInfo.uniqueDeviceID[0];
|
||||
g_cfgParameter.uniqueDeviceID[1] = temp_configInfo.uniqueDeviceID[1];
|
||||
g_cfgParameter.uniqueDeviceID[2] = temp_configInfo.uniqueDeviceID[2];
|
||||
g_cfgParameter.uniqueDeviceID[3] = temp_configInfo.uniqueDeviceID[3];
|
||||
g_cfgParameter.uniqueDeviceID[4] = temp_configInfo.uniqueDeviceID[4];
|
||||
g_cfgParameter.uniqueDeviceID[5] = temp_configInfo.uniqueDeviceID[5];
|
||||
g_cfgParameter.uniqueDeviceID[6] = temp_configInfo.uniqueDeviceID[6];
|
||||
|
||||
g_cfgParameter.powerBoxType = temp_configInfo.powerBoxType;
|
||||
|
||||
g_cfgParameter.constantVoltageV = temp_configInfo.constantVoltageV;
|
||||
g_cfgParameter.floatI = temp_configInfo.floatI;
|
||||
|
||||
g_cfgParameter.startSolarOpenCircuitV = temp_configInfo.startSolarOpenCircuitV;
|
||||
g_cfgParameter.stopSolarOutputCircuitV = temp_configInfo.stopSolarOutputCircuitV;
|
||||
|
||||
g_cfgParameter.checkCanStartTime = temp_configInfo.checkCanStartTime;
|
||||
g_cfgParameter.shortCircuitJudgmentDelay = temp_configInfo.shortCircuitJudgmentDelay;
|
||||
g_cfgParameter.inputPowerLowJudgmentDelay = temp_configInfo.inputPowerLowJudgmentDelay;
|
||||
g_cfgParameter.inputPowerLowAgainOutputDelay= temp_configInfo.inputPowerLowAgainOutputDelay;
|
||||
|
||||
g_cfgParameter.firstStageProtectionCurr = temp_configInfo.firstStageProtectionCurr;
|
||||
g_cfgParameter.firstStageProtectionDelay = temp_configInfo.firstStageProtectionDelay;
|
||||
g_cfgParameter.secondStageProtectionCurr = temp_configInfo.secondStageProtectionCurr;
|
||||
g_cfgParameter.secondStageProtectionDelay = temp_configInfo.secondStageProtectionDelay;
|
||||
g_cfgParameter.thirdStageProtectionCurr = temp_configInfo.thirdStageProtectionCurr;
|
||||
g_cfgParameter.thirdStageProtectionDelay = temp_configInfo.thirdStageProtectionDelay;
|
||||
|
||||
g_cfgParameter.inputPowerLowDetectionDelay = temp_configInfo.inputPowerLowDetectionDelay;
|
||||
g_cfgParameter.inputPowerLowDetectionVolt = temp_configInfo.inputPowerLowDetectionVolt;
|
||||
|
||||
g_cfgParameter.maxOpenSolarOutputCircuitV = temp_configInfo.maxOpenSolarOutputCircuitV;
|
||||
g_cfgParameter.maxChargCurr = temp_configInfo.maxChargCurr;
|
||||
g_cfgParameter.minCheckLoopImpedanceChargCurr = temp_configInfo.minCheckLoopImpedanceChargCurr;
|
||||
g_cfgParameter.stopPowerOutputTemperature = temp_configInfo.stopPowerOutputTemperature;
|
||||
g_cfgParameter.reducePowerOutputTemperature = temp_configInfo.reducePowerOutputTemperature;
|
||||
g_cfgParameter.fullPowerOutputTemperature = temp_configInfo.fullPowerOutputTemperature;
|
||||
|
||||
g_cfgParameter.constantVoltageChargeV = temp_configInfo.constantVoltageChargeV;
|
||||
g_cfgParameter.FloatChargeV = temp_configInfo.FloatChargeV;
|
||||
g_cfgParameter.collectOpenCircuitVoltageTime= temp_configInfo.collectOpenCircuitVoltageTime;
|
||||
|
||||
/* 读取的回路阻抗无效则回路阻抗设置为0 */
|
||||
if (readLoopImpedance() == FALSE) {
|
||||
setLoopImpedance(0);
|
||||
saveLoopImpedance();
|
||||
}
|
||||
|
||||
float fTemp;
|
||||
readLoopImpedance(&fTemp);
|
||||
/* 读取的回路阻抗偏差过大则不使用 */
|
||||
if (fTemp > (float)0.005 && fTemp < (float)1) {
|
||||
g_cfgParameter.loopImpedance = fTemp;
|
||||
}
|
||||
else {
|
||||
g_cfgParameter.loopImpedance = 0;
|
||||
saveLoopImpedance(&g_cfgParameter.loopImpedance);
|
||||
}
|
||||
readtotalElectricityConsumption(&fTemp);
|
||||
totalElectricityConsumptionInt(fTemp);
|
||||
readtotalChargCapacity(&fTemp);
|
||||
|
@ -216,39 +223,30 @@ void config_info_start(void)
|
|||
timeInfo time;
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief 保存回路阻抗在flash中
|
||||
* @param
|
||||
*/
|
||||
void saveLoopImpedance(float *loopImpedance)
|
||||
void saveLoopImpedance(void)
|
||||
{
|
||||
write_Flash((uint8_t *)loopImpedance, LoopImpedance_SAVE_addr, sizeof(float));
|
||||
float loopImpedance;
|
||||
loopImpedance = getLoopImpedance();
|
||||
write_Flash((uint8_t *)&loopImpedance, LoopImpedance_SAVE_addr, sizeof(float));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 读取flash中的回路阻抗
|
||||
* @param
|
||||
*/
|
||||
void readLoopImpedance(float *loopImpedance)
|
||||
BOOL readLoopImpedance(void)
|
||||
{
|
||||
read_Flash((uint8_t *)loopImpedance, LoopImpedance_SAVE_addr, sizeof(float));
|
||||
float loopImpedance;
|
||||
read_Flash((uint8_t *)&loopImpedance, LoopImpedance_SAVE_addr, sizeof(float));
|
||||
return setLoopImpedance(loopImpedance);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include "interruptSend.h"
|
||||
|
||||
|
||||
#define RS485_MAX_PACK_DATA_LEN 60
|
||||
#define RS485_MAX_PACK_DATA_LEN 256
|
||||
|
||||
static uint8_t dataLocation1[RS485_MAX_PACK_DATA_LEN];
|
||||
static uint8_t dataLocation2[RS485_MAX_PACK_DATA_LEN];
|
||||
|
@ -55,7 +55,7 @@ typedef struct _uart_send_info {
|
|||
/* 恢复默认的对齐设置 */
|
||||
#pragma pack(pop)
|
||||
|
||||
static uart_send_info uart_send = {0};
|
||||
uart_send_info uart_send = {0};
|
||||
|
||||
/**
|
||||
* @brief 串口中断发送的初始化,通过空闲中断来判断总线空闲状态
|
||||
|
@ -162,6 +162,12 @@ void setBatState(void)
|
|||
*/
|
||||
void setSendOverStateGw(void)
|
||||
{
|
||||
/* 配置文件传输完成,复位 */
|
||||
if (uart_send.sendDataGw->data[9] = 0xD0
|
||||
&& uart_send.sendDataGw->data[12] == 0xAA) {
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
uart_send.sendOverStateGw = TRUE;
|
||||
uart_send.sendStateGw = FALSE;
|
||||
uart_send.sendDataGw->dataState = FALSE;
|
||||
|
@ -192,7 +198,7 @@ void setSendOverStateBat(void)
|
|||
uart_send.sendStateBat = FALSE;
|
||||
uart_send.sendDataBat->dataState = FALSE;
|
||||
uart_send.sendDataBat = NULL;
|
||||
uart_send.insertState++;
|
||||
uart_send.insertState++;
|
||||
|
||||
/* 插入指针指向为空时 */
|
||||
if (uart_send.data1.dataState == FALSE) {
|
||||
|
@ -315,3 +321,46 @@ void uart_interruptSend(device_handle device, uint8_t buff[], uint8_t len)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 得到中断发送插入数据指针
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
uint8_t *getInsertData(void)
|
||||
{
|
||||
return uart_send.insertData->data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief 将数据发送指针的内容发送
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void uart_insertDataSend(device_handle device, uint8_t len)
|
||||
{
|
||||
uart_send.insertData->Counter = 0;
|
||||
uart_send.insertData->dataLen = len;
|
||||
uart_send.insertData->device = device;
|
||||
|
||||
uart_send.insertData->dataState = TRUE;
|
||||
uart_send.insertState--;
|
||||
|
||||
/* 可插入数据大于0时,将插入指针指向空的储存位置,否则指向NULL */
|
||||
if (uart_send.insertState > 0) {
|
||||
if (uart_send.data1.dataState == FALSE) {
|
||||
uart_send.insertData = &uart_send.data1;
|
||||
}
|
||||
else if (uart_send.data2.dataState == FALSE) {
|
||||
uart_send.insertData = &uart_send.data2;
|
||||
}
|
||||
else if (uart_send.data3.dataState == FALSE) {
|
||||
uart_send.insertData = &uart_send.data3;
|
||||
}
|
||||
} else {
|
||||
uart_send.insertData = NULL;
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ static otherParameter g_otherParameter = {0};
|
|||
|
||||
static BOOL batteryState = FALSE; /* 有无电池(估计) */
|
||||
static float dutyRatio = 0; /* 占空比 */
|
||||
static uint8_t mosTemperState = mosTemperStart; /* mos管温度状态 */
|
||||
static uint8_t mosTemperState = mosTemperFull; /* mos管温度状态 */
|
||||
static BOOL checkImpedanceState = FALSE; /* 启动后是否进行了回路阻抗检测 */
|
||||
static timeInfo lastTime = {0}; /* 上次读取充放电量参数的时间 */
|
||||
|
||||
|
@ -98,7 +98,7 @@ uint8_t getMosTemperState(void)
|
|||
*/
|
||||
void setMosTemperState(uint8_t state)
|
||||
{
|
||||
if (state == mosTemperStart || state == mosTemperEnd || state == mosTemperStop) {
|
||||
if (state == mosTemperFull || state == mosTemperReduce || state == mosTemperStop) {
|
||||
mosTemperState = state;
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ float getBatteryVoltage(void)
|
|||
void setBatteryVoltage(void)
|
||||
{
|
||||
g_otherParameter.Battery_Voltage = g_otherParameter.Output_Voltage
|
||||
- getChargBatteryCurrent() * g_cfgParameter.loopImpedance;
|
||||
- getChargBatteryCurrent() * getLoopImpedance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -456,7 +456,7 @@ void setChargMosState(BOOL state)
|
|||
*/
|
||||
BOOL getDischargMosState(void)
|
||||
{
|
||||
if (g_cfgParameter.onlyPower) {
|
||||
if (g_cfgParameter.powerBoxType) {
|
||||
return readOnlyPowerOutputState();
|
||||
} else {
|
||||
return readOutputState();
|
||||
|
@ -468,8 +468,55 @@ BOOL getDischargMosState(void)
|
|||
* @param
|
||||
* @retval softVer 软件版本号
|
||||
*/
|
||||
uint8_t *getVersionInformation(void)
|
||||
uint8_t *getVersionnInformation(void)
|
||||
{
|
||||
return softVer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 得到回路阻抗大小
|
||||
* @param
|
||||
* @retval 回路阻抗大小
|
||||
*/
|
||||
float getLoopImpedance(void)
|
||||
{
|
||||
return g_otherParameter.loopImpedance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置回路阻抗大小
|
||||
* @param loopImpedance 回路阻抗大小
|
||||
* @retval
|
||||
*/
|
||||
BOOL setLoopImpedance(float loopImpedance)
|
||||
{
|
||||
/* 读取的回路阻抗偏差过大则不使用 */
|
||||
if (loopImpedance < 0 || loopImpedance > 0.3f) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
g_otherParameter.loopImpedance = loopImpedance;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 得到注册状态
|
||||
* @param
|
||||
* @retval 注册状态
|
||||
*/
|
||||
uint16_t getRegistrationStatus(void)
|
||||
{
|
||||
return g_otherParameter.Registration_Status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置注册状态
|
||||
* @param 注册状态
|
||||
* @retval
|
||||
*/
|
||||
void setRegistrationStatus(uint16_t status)
|
||||
{
|
||||
if (status == UNREGISTER || status == REGISTER_FAIL || status == REGISTER_SUCCESS) {
|
||||
g_otherParameter.Registration_Status = status;
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ static STR_TimeSliceOffset m_runled;
|
|||
static void Task_Runled(void);
|
||||
|
||||
/* 喂狗 */
|
||||
#define wdi_reloadVal 1000 /* 任务执行间隔 */
|
||||
#define wdi_reloadVal 3000 /* 任务执行间隔 */
|
||||
#define wdi_offset 0 /* 任务执行偏移量 */
|
||||
static STR_TimeSliceOffset m_wdi;
|
||||
static void Task_wdi(void);
|
||||
|
@ -126,7 +126,7 @@ void Task_softShortCircuit(void);
|
|||
|
||||
|
||||
/* 串口任务 */
|
||||
#define uart_reloadVal 100 /* 任务执行间隔 */
|
||||
#define uart_reloadVal 10 /* 任务执行间隔 */
|
||||
#define uart_offset 0 /* 任务执行偏移量 */
|
||||
STR_TimeSliceOffset m_uart;
|
||||
void Task_uart(void);
|
||||
|
@ -188,17 +188,22 @@ void Task_wdi(void)
|
|||
{
|
||||
feedDog();
|
||||
|
||||
// debug_printf("chargCurrent:%f \n", getChargCurrent());
|
||||
// debug_printf("outputVoltage:%f \n", getOutputVoltage());
|
||||
// debug_printf("BatteryVoltage:%f \n", getBatteryVoltage());
|
||||
// debug_printf("dischargCurrent:%f \n", getDischargCurrent());
|
||||
// debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage());
|
||||
// debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature());
|
||||
// debug_printf("InputVoltage:%f \n", getInputVoltage());
|
||||
// debug_printf("DischargMosState:%d \n", getDischargMosState());
|
||||
// debug_printf("MPPT_Mode:%d \n", getMPPT_Mode());
|
||||
// debug_printf("loopImpedance:%f \n", g_cfgParameter.loopImpedance);
|
||||
// debug_printf("DutyRatio:%f \n", getDutyRatio());
|
||||
// debug_printf("chargCurrent:%f \n", getChargCurrent());
|
||||
// debug_printf("outputVoltage:%f \n", getOutputVoltage());
|
||||
// debug_printf("BatteryVoltage:%f \n", getBatteryVoltage());
|
||||
// debug_printf("dischargCurrent:%f \n", getDischargCurrent());
|
||||
// debug_printf("solarInCircuitVoltage:%f \n", getSolarInCircuitVoltage());
|
||||
// debug_printf("HighSideMosTemperature:%f \n", getHighSideMosTemperature());
|
||||
// debug_printf("InputVoltage:%f \n", getInputVoltage());
|
||||
// debug_printf("DischargMosState:%d \n", getDischargMosState());
|
||||
// debug_printf("MPPT_Mode:%d \n", getMPPT_Mode());
|
||||
// debug_printf("loopImpedance:%f \n", getLoopImpedance());
|
||||
// debug_printf("DutyRatio:%f \n", getDutyRatio());
|
||||
// debug_printf("OUT_VOLT_IN:%f \n", get_OUT_VOLT_IN());
|
||||
// debug_printf("HAL_GetTick:%d \n", HAL_GetTick());
|
||||
|
||||
|
||||
|
||||
|
||||
// char buf[100];
|
||||
// sprintf(buf, "chargCurrent:%f \n", getChargCurrent());
|
||||
|
@ -261,7 +266,6 @@ void Task_wdi(void)
|
|||
saveTime(&time);
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,8 +291,8 @@ void Task_refreshJudgeData(void)
|
|||
}
|
||||
|
||||
/* 有电池,太阳能输出功率大,电池电压低于14V,同时回路阻抗未测试或需要重新测试 */
|
||||
if ((getCheckImpedanceState() == FALSE || g_cfgParameter.loopImpedance == 0.0f)
|
||||
&& (getBatteryState() == TRUE) && (getChargCurrent() > g_cfgParameter.checkLoopImpedanceChargCurr)
|
||||
if ((getCheckImpedanceState() == FALSE || getLoopImpedance() == 0.0f)
|
||||
&& (getBatteryState() == TRUE) && (getChargCurrent() > g_cfgParameter.maxChargCurr)
|
||||
&& (getOutputVoltage() > 9) && (getSolarInCircuitVoltage() > 14)
|
||||
&& (getBatteryVoltage() < 14)) {
|
||||
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
|
||||
|
@ -296,20 +300,20 @@ void Task_refreshJudgeData(void)
|
|||
}
|
||||
|
||||
/* 温度检测 */
|
||||
if ((getMosTemperState() != mosTemperStart)
|
||||
&& (getHighSideMosTemperature() < g_cfgParameter.HighSideMosTemperature_start)) {
|
||||
if ((getMosTemperState() != mosTemperFull)
|
||||
&& (getHighSideMosTemperature() < g_cfgParameter.fullPowerOutputTemperature)) {
|
||||
/* 状态处于停止运行则打开充电开关 */
|
||||
if (getMosTemperState() == mosTemperStop) {
|
||||
beginChargWork();
|
||||
}
|
||||
setMosTemperState(mosTemperStart);
|
||||
setMosTemperState(mosTemperFull);
|
||||
}
|
||||
else if ((getMosTemperState() == mosTemperStart)
|
||||
&& getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_end) {
|
||||
setMosTemperState(mosTemperEnd);
|
||||
else if ((getMosTemperState() == mosTemperFull)
|
||||
&& getHighSideMosTemperature() > g_cfgParameter.reducePowerOutputTemperature) {
|
||||
setMosTemperState(mosTemperReduce);
|
||||
}
|
||||
else if ((getMosTemperState() == mosTemperEnd)
|
||||
&& getHighSideMosTemperature() > g_cfgParameter.HighSideMosTemperature_stop) {
|
||||
else if ((getMosTemperState() == mosTemperReduce)
|
||||
&& getHighSideMosTemperature() > g_cfgParameter.stopPowerOutputTemperature) {
|
||||
setMosTemperState(mosTemperStop);
|
||||
/* 停止充电 */
|
||||
stopChargWork();
|
||||
|
@ -329,7 +333,7 @@ void Task_startControl(void)
|
|||
{
|
||||
/* 是否达到启动条件 */
|
||||
if (getSolarInCircuitVoltage() > g_cfgParameter.startSolarOpenCircuitV
|
||||
&& getSolarInCircuitVoltage() < g_cfgParameter.maxOpenSolarOpenCircuitV) {
|
||||
&& getSolarInCircuitVoltage() < g_cfgParameter.maxOpenSolarOutputCircuitV) {
|
||||
TimeSliceOffset_Unregister(&m_startControl);
|
||||
m_startControl.runFlag = 0;
|
||||
|
||||
|
@ -444,12 +448,16 @@ void Task_impedanceCalculation(void)
|
|||
float tempLoopImpedance = 0;
|
||||
tempLoopImpedance = (voltOne - voltTwo) / (currOne - currTwo);
|
||||
|
||||
// if (tempLoopImpedance < 1.0f && tempLoopImpedance > 0.05f) {
|
||||
// g_cfgParameter.loopImpedance = tempLoopImpedance;
|
||||
// saveLoopImpedance(&g_cfgParameter.loopImpedance);
|
||||
// setCheckImpedanceState();
|
||||
// }
|
||||
/* 判断回路阻抗是否合理 */
|
||||
if (tempLoopImpedance < 1.0f && tempLoopImpedance > 0.05f) {
|
||||
g_cfgParameter.loopImpedance = tempLoopImpedance;
|
||||
saveLoopImpedance(&g_cfgParameter.loopImpedance);
|
||||
if (setLoopImpedance(tempLoopImpedance) == TRUE) {
|
||||
saveLoopImpedance();
|
||||
setCheckImpedanceState();
|
||||
}
|
||||
}
|
||||
|
||||
setMPPT_Mode(MPPT);
|
||||
setChargControlFlag(TRUE);
|
||||
|
@ -603,7 +611,7 @@ void Task_shortCircuitProtection(void)
|
|||
num++;
|
||||
|
||||
/* 设定输出短路保护时间 */
|
||||
if (num == g_cfgParameter.outputAgainFlagTime) {
|
||||
if (num == g_cfgParameter.shortCircuitJudgmentDelay) {
|
||||
num = 0;
|
||||
zeroShortCircuit();
|
||||
TimeSliceOffset_Unregister(&m_shortCircuitProtection);
|
||||
|
@ -679,7 +687,7 @@ void Task_excessiveLoad(void)
|
|||
}
|
||||
|
||||
/* 仅过载一次,达到时间后关闭该任务 */
|
||||
if (num == g_cfgParameter.excessiveLoadFlagTime) {
|
||||
if (num == g_cfgParameter.inputPowerLowJudgmentDelay) {
|
||||
num = 0;
|
||||
setExcessiveLoadFlag(FALSE);
|
||||
TimeSliceOffset_Unregister(&m_excessiveLoad);
|
||||
|
@ -693,7 +701,7 @@ void Task_excessiveLoad(void)
|
|||
}
|
||||
|
||||
/* 达到时间就重新尝试输出 */
|
||||
if (numLong == g_cfgParameter.eLAgainTime) {
|
||||
if (numLong == g_cfgParameter.inputPowerLowAgainOutputDelay) {
|
||||
numLong = 0;
|
||||
TimeSliceOffset_Unregister(&m_excessiveLoad);
|
||||
m_excessiveLoad.runFlag = 0;
|
||||
|
@ -762,7 +770,7 @@ void Task_softShortCircuit(void)
|
|||
setPowerOutput(TRUE);
|
||||
}
|
||||
|
||||
if (num >= g_cfgParameter.outputAgainFlagTime) {
|
||||
if (num >= g_cfgParameter.shortCircuitJudgmentDelay) {
|
||||
num = 0;
|
||||
if (getShortCircuit() == 1) {
|
||||
setShortCircuitFlag(FALSE);
|
||||
|
|
|
@ -23,6 +23,7 @@ typedef struct _adcCapture
|
|||
|
||||
void ADC_Capture_Init(void);
|
||||
void proportionalInt(int mode);
|
||||
uint16_t setfirstStageProtectionValue(float curr);
|
||||
|
||||
float get_CHG_CURR(void);
|
||||
float get_PV_VOLT_OUT(void);
|
||||
|
|
|
@ -178,7 +178,8 @@ BOOL readOverCurrState(void)
|
|||
*/
|
||||
BOOL readOnlyPowerOutputState(void)
|
||||
{
|
||||
static volatile GPIO_PinState gpioTemp1, gpioTemp2, gpioTemp3;
|
||||
// static volatile GPIO_PinState gpioTemp1, gpioTemp2, gpioTemp3;
|
||||
GPIO_PinState gpioTemp1, gpioTemp2, gpioTemp3;
|
||||
|
||||
gpioTemp1 = HAL_GPIO_ReadPin(POW_FF_CON_GPIO_Port, POW_FF_CON_Pin);
|
||||
gpioTemp2 = HAL_GPIO_ReadPin(POW_OUT_CON_GPIO_Port, POW_OUT_CON_Pin);
|
||||
|
|
|
@ -213,7 +213,8 @@ void proportionalInt(int mode)
|
|||
/* 输出外部电压比例 */
|
||||
P_OUT_VOLT_IN = ((47.0 + 4.7) / 4.7) * Proportion;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// /* 光伏充电输出电流比例,放大倍数*电阻 */
|
||||
// P_CHG_CURR = (1.0 / (50 * (1 / (1 / 0.01 + 1 / 0.002)))) * Proportion;
|
||||
// /* 充电控制盒输出电压比例,分压系数 */
|
||||
|
@ -226,6 +227,18 @@ void proportionalInt(int mode)
|
|||
// P_PV_VOLT_IN1 = ((47 + 4.7) / 4.7) * Proportion;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置第一段保护ADC采样的值
|
||||
* @param
|
||||
* @retval None
|
||||
*/
|
||||
uint16_t setfirstStageProtectionValue(float curr)
|
||||
{
|
||||
return (uint16_t)(curr / P_DSG_CURR);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#define N 4
|
||||
/**
|
||||
* @brief 中位值平均滤波
|
||||
|
@ -424,7 +437,8 @@ float get_OUT_VOLT_IN(void)
|
|||
{
|
||||
float V;
|
||||
uint16_t V_ADC;
|
||||
static uint16_t V_ADCTemp = (uint16_t)(0.55f / 3.0f * 4095);
|
||||
static uint16_t V_ADCTemp = (uint16_t)(0.52f / 3.0f * 4095);
|
||||
// static uint16_t V_ADCTemp = (uint16_t)(0.17f / 3.0f * 4095);
|
||||
|
||||
V_ADC = ADC2_Capture(OUT_VOLT_IN_CHANNEL);
|
||||
|
||||
|
@ -432,7 +446,10 @@ float get_OUT_VOLT_IN(void)
|
|||
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;
|
||||
if (V_ADC > V_ADCTemp) {
|
||||
V = (float)(V_ADC - V_ADCTemp) * P_OUT_VOLT_IN;
|
||||
}
|
||||
V = (float)(V_ADC) * P_OUT_VOLT_IN;
|
||||
}
|
||||
|
||||
#ifdef enable_Printf_VI
|
||||
|
|
|
@ -13,12 +13,11 @@ typedef enum _chargMode{
|
|||
}chargMode;
|
||||
|
||||
typedef enum {
|
||||
mosTemperStart = 0, /* 满功率充电mos状态 */
|
||||
mosTemperEnd = 1, /* 降功率充电mos状态 */
|
||||
mosTemperFull = 0, /* 满功率充电mos状态 */
|
||||
mosTemperReduce = 1, /* 降功率充电mos状态 */
|
||||
mosTemperStop = 2, /* 停止充电mos状态 */
|
||||
}mosTState;
|
||||
|
||||
|
||||
/* 注册状态 */
|
||||
typedef enum {
|
||||
UNREGISTER = 0, /* 未注册 */
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
// #define NDEBUG
|
||||
|
||||
#define log_info_enable 1
|
||||
#define log_warn_enable 0
|
||||
#define log_error_enable 0
|
||||
#define log_warn_enable 1
|
||||
#define log_error_enable 1
|
||||
|
||||
/* Comment out this define to include log messages */
|
||||
// #define NLOG
|
||||
|
|
Loading…
Reference in New Issue