241113.16

This commit is contained in:
起床就犯困 2024-11-13 16:44:13 +08:00
parent daec605235
commit a768f1cf3f
26 changed files with 18537 additions and 18426 deletions

View File

@ -63,8 +63,12 @@ typedef enum
HY_success1 = 0x01, /* 成功 */
/* 充电开关状态 */
HY_switchON = 0x00, /* 打开 */
HY_switchOFF = 0x01, /* 关闭 */
HY_switchON = 0x01, /* 打开 */
HY_switchOFF = 0x00, /* 关闭 */
/* 控制开关状态 */
HY_cSwitchON = 0x00, /* 打开 */
HY_cSwitchOFF = 0x01, /* 关闭 */
}HY_state;

View File

@ -20,7 +20,6 @@
#define log_warn_enable 0
#define log_error_enable 0
/* Comment out this define to include log messages */
//#define NLOG

View File

@ -106,6 +106,7 @@ extern void Task_uartConfigFile(void);
#define collectOpenCircuitVoltage_reloadVal 1000 /* 任务执行间隔 */
#define collectOpenCircuitVoltage_offset 0 /* 任务执行偏移量 */
extern STR_TimeSliceOffset g_collectOpenCircuitVoltage;
extern uint8_t g_collectOpenCircuitVoltageFlag;
extern void Task_collectOpenCircuitVoltage(void);

View File

@ -129,13 +129,14 @@ void adcChangeProportionalInit(void)
if (g_otherParameter.onlyPower) {
/* 光伏充电输出电流比例,放大倍数*电阻 */
// P_CHG_CURR = (1.0 / (50 * 0.005 / 2));
P_CHG_CURR = (1.0 / (50 * (1 / (1 / 0.005 * 3))));
P_CHG_CURR = (1.0 / (50 * (1 / (1 / 0.01 + 1 / 0.002))));
/* 光伏充电输出电压比例,分压系数(放电时采集不准) */
//const float P_PV_VOLT_OUT = (47.0 + 10.0) / 10.0;
//const float P_PV_VOLT_OUT = (47.0 + 4.7) / 4.7;
P_PV_VOLT_OUT = (56.0 + 10.0) / 10.0;
/* 放电电流采集电流倍数 */
P_DSG_CURR = (1.0 / (50 * (1 / (1 / 0.005 * 5))));
// P_DSG_CURR = (1.0 / (50 * (1 / (1 / 0.005 * 5))));
P_DSG_CURR = (1.0 / (50 * (1 / (1 / 0.002 * 2))));
///* 光伏1开路输出电压比例 */
// P_PV1_VOLT_IN = (100 + 4.7) / 4.7;
P_PV1_VOLT_IN = (47.0 + 4.7) / 4.7;

View File

@ -461,15 +461,15 @@ void HY_MsgProcFunc_batteryStatus(device_handle device, void *pMsg, uint32_t Msg
pack.dataLen[0] = HY_batteryStatusResponse_dataLen >> 8;
pack.dataLen[1] = HY_batteryStatusResponse_dataLen;
// pack.batteryVoltage = g_otherParameter.Battery_Voltage;
pack.batteryVoltage = g_otherParameter.Battery_Voltage;
pack.batteryVoltage = 6.66;
// pack.batteryVoltage = 6.66;
pack.dischargCurrent = g_otherParameter.Discharg_Current;
pack.chargCurrent1 = g_otherParameter.Charg_Current;
pack.SOC = g_otherParameter.SOC;
pack.openCircuitVoltage1 = g_otherParameter.Solar_In_Circuit_Voltage;
if (g_controlParameter.dutyRatio && g_otherParameter.Charg_Current > 0.05) {
if (g_controlParameter.dutyRatio > 0 && g_otherParameter.Charg_Current > 0.05) {
pack.chargSwitchStatus1 = HY_switchON;
} else {
pack.chargSwitchStatus1 = HY_switchOFF;
@ -757,7 +757,7 @@ void HY_MsgProcFunc_chargingControlConfiguration(device_handle device, void *pMs
{
HY_chargingControlConfig *Tpack = (HY_chargingControlConfig *)pMsg;
if (Tpack->chargInterfaceControl == HY_switchON) {
if (Tpack->chargInterfaceControl == HY_cSwitchON) {
if (g_controlParameter.dutyRatio == 0) {
if (g_otherParameter.Output_Voltage > 11) {
g_otherParameter.batteryState = 1;
@ -768,7 +768,7 @@ void HY_MsgProcFunc_chargingControlConfiguration(device_handle device, void *pMs
}
}
if (Tpack->chargInterfaceControl == HY_switchOFF) {
if (Tpack->chargInterfaceControl == HY_cSwitchOFF) {
if (g_controlParameter.dutyRatio != 0) {
TIM_Cmd(TIM3, DISABLE);
TIM_SetCompare4(TIM4, 0);

View File

@ -275,7 +275,7 @@ void config_info_start(void)
g_otherParameter.gw485_Baud = temp_configInfo.gw485_Baud;
g_otherParameter.bat485_Baud = temp_configInfo.bat485_Baud;
} else if (g_otherParameter.CommunicationProtocolType == 0x01) {
g_otherParameter.bat485_Baud = temp_configInfo.bat485_Baud;
g_otherParameter.bat485_Baud = temp_configInfo.bat485_Baud;
if (g_otherParameter.protocolType == 0x01) {
g_otherParameter.gw485_Baud = 9600;
} else if (g_otherParameter.protocolType == 0x02) {
@ -283,7 +283,16 @@ void config_info_start(void)
}
}
readLoopImpedance(&g_controlParameter.loopImpedance);
// readLoopImpedance(&g_controlParameter.loopImpedance);
float_t fTemp;
readLoopImpedance(&fTemp);
if (fTemp > 0.005 && fTemp < 1) {
g_controlParameter.loopImpedance = fTemp;
}
else {
g_controlParameter.loopImpedance = 0;
saveLoopImpedance(&g_controlParameter.loopImpedance);
}
readtotalElectricityConsumption(&g_otherParameter.totalElectricityConsumption);
readtotalChargCapacity(&g_otherParameter.totalChargCapacity);
@ -344,6 +353,7 @@ void read_and_process_config_data(void)
/* 判断起始标志是否正确 */
if (pack->start_Flag[0] != g_otherParameter.startFlagSL[0]
|| pack->start_Flag[1] != g_otherParameter.startFlagSL[1]) {
// printf(" start_Flag : 0x%x, 0x%x \n", pack->start_Flag[0], pack->start_Flag[1]);
goto err;
}
// memset(buffer, 0, sizeof(buffer));
@ -728,13 +738,12 @@ void read_and_process_config_data(void)
SUpdateProfile_pack.end_Flag = g_otherParameter.endFlagSL;
while (1) {
Delay_Ms(randomDelay());
if (!Check_485_bus_busy(g_gw485_uart4_handle)) {
uart_dev_write(g_gw485_uart4_handle, (uint8_t *)&SUpdateProfile_pack, SL_MPPT_SOTHER_PACK_SIZE);
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
break;
}
Delay_Ms(randomDelay());
}
/* 复位 */

View File

@ -51,6 +51,9 @@ void Init()
/* 1ms */
TIM3_Init(10);
// uart_dev_write(g_gw485_uart4_handle, "1\n", sizeof("1\n"));
TimeSliceOffset_Register(&m_WdiRunled, Task_WdiRunled, WdiRunled_reloadVal, WdiRunled_offset);
TimeSliceOffset_Register(&m_refreshRegister, Task_refreshRegister,
refreshRegister_reloadVal, refreshRegister_offset);
@ -105,6 +108,13 @@ void Task_WdiRunled(void)
GPIO_WriteBit(WDI_INPUT_GPIO, WDI_INPUT_PIN, SET);
GPIO_WriteBit(WDI_INPUT_GPIO, WDI_INPUT_PIN, RESET);
// if (USART_RbufferLen != 0) {
// printf("%s\n", USART_Rbuffer);
// memset(USART_Rbuffer, 0, sizeof(USART_Rbuffer));
// USART_RbufferLen = 0;
//
// }
// printf(" vBattery : %d/100 \n", (int)(g_otherParameter.Battery_Voltage * 100));
uart_dev_write(g_bat485_uart3_handle, " \n", sizeof(" \n"));
@ -192,7 +202,7 @@ void Task_refreshRegister(void)
g_otherParameter.Solar_In_Circuit_Voltage = get_PV1_VOLT_IN();
g_otherParameter.HighSideMos_Temperature = get_MOSFET_Temper();
if (g_controlParameter.dutyRatio == 0) {
if (g_controlParameter.dutyRatio == 0 && g_collectOpenCircuitVoltageFlag == 0) {
g_otherParameter.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
}
@ -456,7 +466,8 @@ void Task_dataJudgment(void)
/* 有电池,太阳能输出功率大,同时回路阻抗未测试或需要重新测试 */
if ((g_otherParameter.impedanceStart == 1 || g_controlParameter.loopImpedance == 0.0)
&& g_otherParameter.batteryState == 1 && (g_otherParameter.Charg_Current > 3.0)) {
&& g_otherParameter.batteryState == 1 && (g_otherParameter.Charg_Current > 3.0)
&& g_otherParameter.Output_Voltage > 9 && g_otherParameter.Solar_In_Circuit_Voltage > 14) {
TimeSliceOffset_Register(&m_impedanceCalculation, Task_impedanceCalculation
, impedanceCalculation_reloadVal, impedanceCalculation_reloadVal);
}
@ -659,22 +670,24 @@ void Task_uartConfigFile(void)
*
*/
STR_TimeSliceOffset g_collectOpenCircuitVoltage;
uint8_t g_collectOpenCircuitVoltageFlag = 0;
void Task_collectOpenCircuitVoltage(void)
{
static uint8_t flag = 0;
g_otherParameter.collectOpenCircuitVoltageNUM++;
if (g_otherParameter.collectOpenCircuitVoltageNUM == g_controlParameter.collectOpenCircuitVoltageTime) {
if (g_otherParameter.batteryState) {
TIM_Cmd(TIM3, DISABLE);
Delay_Ms(1);
TIM_SetCompare4(TIM4, 0);
g_controlParameter.dutyRatio = 0;
flag = 1;
g_collectOpenCircuitVoltageFlag = 1;
g_collectOpenCircuitVoltage.count = 500;
}
}
if (flag) {
flag = 0;
if (g_collectOpenCircuitVoltageFlag) {
g_collectOpenCircuitVoltageFlag = 0;
g_otherParameter.Solar_Open_Circuit_Voltage = get_PV1_VOLT_IN();
TimeSliceOffset_Register(&m_softStart, Task_softStart, softStart_reloadVal, softStart_offset);
}

View File

@ -29,4 +29,7 @@ void USARTx_SendByte(USART_TypeDef* pUSARTx, uint8_t data);
void USARTx_ITSendstr(USART_TypeDef* pUSARTx, char *str, int len);
//extern uint8_t USART_Rbuffer[100];
//extern uint8_t USART_RbufferLen;
#endif /* HARDWARE_INC_RS485_H_ */

View File

@ -22,6 +22,9 @@ void USART4_IRQHandler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
/* 接收缓冲区数组 */
uint8_t USART3_Rbuffer[1] = {0x00};
uint8_t USART4_Rbuffer[1] = {0x00};
//uint8_t USART_Rbuffer[100] = {0x00};
//uint8_t USART_RbufferLen = 0;
///* 发送 */
//uint8_t USART3_Tbuffer_Num = 0;
//uint8_t USART3_Tbuffer_Len = 0;
@ -59,8 +62,9 @@ void GW_485_Init(int baud)
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; //设置PB1为浮空输入
GPIO_Init(GPIOB, &GPIO_InitStructure);
// USART_InitStructure.USART_BaudRate = baud;
USART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_BaudRate = baud;
// USART_InitStructure.USART_BaudRate = 9600;
// USART_InitStructure.USART_BaudRate = 115200;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
USART_InitStructure.USART_StopBits = USART_StopBits_1;
USART_InitStructure.USART_Parity = USART_Parity_No;
@ -300,9 +304,12 @@ void USART4_IRQHandler(void)
// c = USART4_Rbuffer[0];
// log_info("%x ", (USART4_Rbuffer[0] & 0xff));
// USART_Rbuffer[USART_RbufferLen++] = USART_ReceiveData(USART4); //½ÓÊÕÊý¾Ý
USART4_Rbuffer[0] = USART_ReceiveData(USART4); //接收数据
// printf("%x \r\n", USART4_Rbuffer[0]);
uart_device_info *dev = (uart_device_info *)g_gw485_uart4_handle;
// log_info("%x ", (USART4_Rbuffer[0] & 0xff));
//// log_info("%x ", (USART4_Rbuffer[0] & 0xff));
if(!RingQueueFull(&dev->uart_ring_queue))
InRingQueue(&dev->uart_ring_queue, USART4_Rbuffer[0]);
}

View File

@ -36,8 +36,10 @@ int main(void)
SystemCoreClockUpdate();
Delay_Init();
USART_Printf_Init(115200);
printf("SystemClk:%d\r\n", SystemCoreClock);
printf( "ChipID:%08x\r\n", DBGMCU_GetCHIPID());
debug("SystemClk:%d\r\n", SystemCoreClock);
debug("ChipID:%08x\r\n", DBGMCU_GetCHIPID());
// printf("SystemClk:%d\r\n", SystemCoreClock);
// printf("ChipID:%08x\r\n", DBGMCU_GetCHIPID());
// Delay_Ms(10000);

View File

@ -20,7 +20,7 @@
#define SYSCLK_FREQ_48MHz_HSE 48000000
//#define SYSCLK_FREQ_56MHz_HSE 56000000
//#define SYSCLK_FREQ_72MHz_HSE 72000000
//#define SYSCLK_FREQ_96MHz_HSE 960000+
//#define SYSCLK_FREQ_96MHz_HSE 96000000
//#define SYSCLK_FREQ_48MHz_HSI 48000000
//#define SYSCLK_FREQ_56MHz_HSI 56000000
//#define SYSCLK_FREQ_72MHz_HSI 72000000

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff