From 0457b01ab7cd3bb4c5f2c1234e2f4604d85f0e85 Mon Sep 17 00:00:00 2001 From: kyz Date: Fri, 6 Dec 2024 18:08:54 +0800 Subject: [PATCH] =?utf8?q?=E5=A2=9E=E5=8A=A0=E7=8E=AF=E5=A2=83=E6=B8=A9?= =?utf8?q?=E6=B9=BF=E5=BA=A6=E8=AF=BB=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 修改风机电流阈值 修改PTC判断阈值 增加环境温湿度数据读取上报 修复2路开入检测判断 --- STM32/code/app/App_ADC.c | 8 +-- STM32/code/app/App_ADC.h | 2 +- STM32/code/app/App_RS485_1.c | 84 +++++++++++++++++++++++++++-- STM32/code/app/app_ver.h | 7 +++ STM32/code/app/main_task.c | 7 ++- STM32/code/debug_usart/test_main.c | 5 ++ STM32/code/flat/yx.c | 6 ++- STM32/code/mcu_com/mcu_com.c | 8 +-- STM32/code/mcu_com/mcu_com_energy.c | 15 +++++- 9 files changed, 126 insertions(+), 16 deletions(-) create mode 100644 STM32/code/app/app_ver.h diff --git a/STM32/code/app/App_ADC.c b/STM32/code/app/App_ADC.c index 26945fd2..cf2fabeb 100644 --- a/STM32/code/app/App_ADC.c +++ b/STM32/code/app/App_ADC.c @@ -475,19 +475,19 @@ void PtcAdc_V( VOID ) for(int i=0; i<2; i++) { - if(AD_slip_valx16[ADC_CH_PTC_1+i] > 4000) //¶Ï· + if(AD_slip_valx16[ADC_CH_PTC_1+i] > 4070) //¶Ï· { ptc_state[i] = PTC_HARD_BAD; } - else if(AD_slip_valx16[ADC_CH_PTC_1+i] < 3200) //¶Ì· + else if(AD_slip_valx16[ADC_CH_PTC_1+i] < 2000) //¶Ì· { ptc_state[i] = PTC_HARD_BAD; } - else if(AD_slip_valx16[ADC_CH_PTC_1+i] < 3400) //Õý³£¹¤×÷״̬ + else if(AD_slip_valx16[ADC_CH_PTC_1+i] < 4020) //Õý³£¹¤×÷״̬ //20¶Èʵ²â¶ÁÈ¡ADÖµ3600 { ptc_state[i] = PTC_INACTIVE; } - else if(AD_slip_valx16[ADC_CH_PTC_1+i] > 3680 && AD_slip_valx16[ADC_CH_PTC_1+i] < 3870) //³¬Î£¬·Ç¹¤×÷״̬ + else if(AD_slip_valx16[ADC_CH_PTC_1+i] > 3800 && AD_slip_valx16[ADC_CH_PTC_1+i] < 4070) //³¬Î£¬·Ç¹¤×÷״̬ { ptc_state[i] = PTC_ACTIVE; } diff --git a/STM32/code/app/App_ADC.h b/STM32/code/app/App_ADC.h index 36e634a6..8d4b05b8 100644 --- a/STM32/code/app/App_ADC.h +++ b/STM32/code/app/App_ADC.h @@ -81,7 +81,7 @@ enum /* PT100 ADC²ÉÑùÖµ³¬¹ýÉÏÏÂÏÞÖµ¼´ÈÏΪ̽ͷ¹ÊÕÏ */ #define ADC_PT100x16_LIMIT_MAX (260) #define ADC_PT100x16_LIMIT_MIN (-60) -#define FAN_Fault 110 // ·ç»úÆô¶¯ADÊý¾Ý +#define FAN_Fault 10 //110 // ·ç»úÆô¶¯ADÊý¾Ý #define BATTERY_LOW_V (4.7) // ¹©µç×îµÍÖµ diff --git a/STM32/code/app/App_RS485_1.c b/STM32/code/app/App_RS485_1.c index aff01af6..5ece7b64 100644 --- a/STM32/code/app/App_RS485_1.c +++ b/STM32/code/app/App_RS485_1.c @@ -18,11 +18,12 @@ uint8_t pD645AckBuff[200] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20, /* RS485-1¶Ë¿Ú¼ÓÔØ¹æÔ¼ */ + void Task_RS485_1_sProtocol() { BYTE *frame; WORD len; - +#if 0 /* RS485-1¼ÓÔØ698¹æÔ¼ */ if (Port_Get_One_Rx_Frame(PORT_UART_IFACE_RS4851, &frame, &len)) // ²éѯ»ñÈ¡RS-4851¶Ë¿ÚFIFOÖеÄÊý¾Ý { @@ -44,7 +45,7 @@ void Task_RS485_1_sProtocol() { len = 4+frame[LEN+4]+1+LEN+2; memcpy(pD645AckBuff, frame+4, len-4); - + //send ack to host app Port_tran_One_Frame(PORT_UART_IFACE_RS4851, pD645AckBuff, len-4); } @@ -61,6 +62,83 @@ void Task_RS485_1_sProtocol() } } +#else + +#endif - +} + +uint8_t send_bf=0; +typedef struct +{ + float temp; + float hum; +} TempHum_s; +TempHum_s gTempHum; + +float get_ambient_temperature( void ) +{ + return gTempHum.temp; +} +float get_ambient_humidity( void ) +{ + return gTempHum.hum; +} + +void Task_RS485_1_tem_sProtocol( void ) +{ + BYTE *frame; + WORD len; + uint32_t now; + uint32_t xyz; + uint16_t cal_crc = 0; + uint16_t DataLen = 0; + + static uint32_t last_tick = 0; + static uint8_t txBuff[16]; + static uint8_t rxBuff[16]; + + if(send_bf==1) + { + if (Port_Get_One_Rx_Frame(PORT_UART_IFACE_RS4851, &frame, &len)) + { + memcpy(rxBuff, frame, 13); + + len=13; + //DataLen = len - sizeof(cal_crc); + DataLen = rxBuff[2]+3; + cal_crc = ModBusCRC16(rxBuff,DataLen); + + if (rxBuff[0] == 1 && rxBuff[1] == 3 && rxBuff[11] == (cal_crc&0xff) && rxBuff[12] == (cal_crc>>8)) + { + xyz= ((uint32_t)rxBuff[3]<<24) + ((uint32_t)rxBuff[4]<<16) + ((uint32_t)rxBuff[5]<<8) + rxBuff[6]; + memcpy(&gTempHum.temp, &xyz, 4); + xyz= ((uint32_t)rxBuff[7]<<24) + ((uint32_t)rxBuff[8]<<16) + ((uint32_t)rxBuff[9]<<8) + rxBuff[10]; + memcpy(&gTempHum.hum, &xyz, 4); + } + } + send_bf=0; + } + + now = HAL_GetTick(); + if ((now - last_tick) < 2000) + return; + + last_tick= now; + + txBuff[0] = 1; + txBuff[1] = 3; + txBuff[2] = 0; + txBuff[3] = 2; + txBuff[4] = 0; + txBuff[5] = 4; + len = 8; + DataLen = len - sizeof(cal_crc); + cal_crc = ModBusCRC16(txBuff,DataLen); + txBuff[6] = cal_crc&0xff; + txBuff[7] = cal_crc>>8; + + Port_tran_One_Frame(PORT_UART_IFACE_RS4851, txBuff, len); + send_bf=1; + } diff --git a/STM32/code/app/app_ver.h b/STM32/code/app/app_ver.h new file mode 100644 index 00000000..1db1670c --- /dev/null +++ b/STM32/code/app/app_ver.h @@ -0,0 +1,7 @@ +#ifndef __APP_VER_H__ +#define __APP_VER_H__ + +#define SW_VER_MAJOR 2 +#define SW_VER_MINOR 0 + +#endif //__APP_VER_H__ diff --git a/STM32/code/app/main_task.c b/STM32/code/app/main_task.c index 2614b1d1..7d76bc4c 100644 --- a/STM32/code/app/main_task.c +++ b/STM32/code/app/main_task.c @@ -144,6 +144,10 @@ extern int32_t Run_RN2026_Task( void ); extern void Debug_temctrl( void ); //for debug extern void IRIG_B_Time_Task( void ); +extern float get_ambient_temperature( void ); +extern float get_ambient_humidity( void ); +extern void Task_RS485_1_tem_sProtocol( void ); + void Task_main() { @@ -170,7 +174,8 @@ void Task_main() /// Run_RN8302B_Task(); Run_RN2026_Task(); - Task_RS485_1_sProtocol(); /* RS485-1´Ó¹æÔ¼(GDW698/MODBUS) */ + //Task_RS485_1_sProtocol(); /* RS485-1´Ó¹æÔ¼(GDW698/MODBUS) */ + Task_RS485_1_tem_sProtocol(); //»·¾³ÎÂʪ¶È¼ì²â #if 0 Task_RS485_2_3_mProtocol(); /* RS485-2/3Ö÷¶¯¹æÔ¼(MODBUS) */ diff --git a/STM32/code/debug_usart/test_main.c b/STM32/code/debug_usart/test_main.c index a1064a2a..8580a4d6 100644 --- a/STM32/code/debug_usart/test_main.c +++ b/STM32/code/debug_usart/test_main.c @@ -44,6 +44,9 @@ short userShellRead(char *data, unsigned short len) } extern int32_t rn2026_init( void ); + +#include "app_ver.h" + int32_t Init_Test( void ) { shell.write = userShellWrite; @@ -51,6 +54,8 @@ int32_t Init_Test( void ) shellInit(&shell, shellBuffer, sizeof( shellBuffer)); + printf( "ZD: Version:%d.%d\n", SW_VER_MAJOR, SW_VER_MINOR ); + return 0; } diff --git a/STM32/code/flat/yx.c b/STM32/code/flat/yx.c index 678f1c6b..cc5c672d 100644 --- a/STM32/code/flat/yx.c +++ b/STM32/code/flat/yx.c @@ -89,6 +89,10 @@ void Gat_YX_LedBzzer_state(Len_Yx_State_t *State) /* Ò£ÐÅÈÎÎñ */ + +const uint32_t yx_alarm_st[YX_CH_MAX] = { 1<<0, 1<<5, 1<<11, 1<<12 }; +const uint8_t yx_alarm_sw[YX_CH_MAX] = { SW_ALARM_8, SW_ALARM_9, 0, 0 }; + void Task_Yx() { BYTE YX; @@ -110,8 +114,6 @@ void Task_Yx() { Yx_state_delay[i] = 0; } - const char yx_alarm_st[YX_CH_MAX] = { 1<<0, 1<<5, 1<<11, 1<<12 }; - const char yx_alarm_sw[YX_CH_MAX] = { SW_ALARM_8, SW_ALARM_9, 0, 0 }; if ((Yx_pro_now&(1<