zhunk 7 mesi fa
parent
commit
8e64ba7189

+ 4 - 4
Application_CBD/applications/control.h

@@ -26,12 +26,12 @@
     #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
     #define VERSION_HK          "1.(3ledV9).41(HK)"      //4.0海康-三色光源
     #define VERSION_HK_2000W    "1.3led0.40(2000W)"       //水稻
     #define VERSION_HK_2000W    "1.3led0.40(2000W)"       //水稻
 #else
 #else
-    #define VERSION_HK          "1.65.41(HK)"            //4.0海康-1200W
-    #define VERSION_HK_2000W    "1.65.40(2000W)"         //4.0水稻
+    #define VERSION_HK          "1.66.41(HK)"            //4.0海康-1200W
+    #define VERSION_HK_2000W    "1.66.40(2000W)"         //4.0水稻
 #endif
 #endif
 
 
-#define VERSION_ZP          "1.65.1(ZP)"            //1.0转盘
-#define VERSION_GK          "1.65.1(GK)"            //1.0高空
+#define VERSION_ZP          "1.66.1(ZP)"            //1.0转盘
+#define VERSION_GK          "1.66.1(GK)"            //1.0高空
 
 
 #define VERSION_XCT         "1.13.6(HK)"            //吸虫塔-海康
 #define VERSION_XCT         "1.13.6(HK)"            //吸虫塔-海康
 #define VERSION_Robot       "1.0(robot)"            //展厅机器人
 #define VERSION_Robot       "1.0(robot)"            //展厅机器人

+ 4 - 0
Application_CBD/applications/dtu_uart2.c

@@ -1065,6 +1065,10 @@ void upload_sys_monitor_info(void)
         return;
         return;
     }
     }
 
 
+    if (!cJSON_AddNumberToObject(proot, "rain_value", system_status.rain_value)) {
+        cJSON_Delete(proot);
+        return;
+    }
     char* temp = makeJsonRpc2_0("sys_monitor", proot, 1);
     char* temp = makeJsonRpc2_0("sys_monitor", proot, 1);
     if(temp){
     if(temp){
         DTU_Write(temp);
         DTU_Write(temp);

+ 50 - 65
Application_CBD/applications/sht30_collect.c

@@ -16,6 +16,7 @@
 #include "control.h"
 #include "control.h"
 #include "hmi.h"
 #include "hmi.h"
 #include "math.h"
 #include "math.h"
+#include "sys_monitor.h"
 #define DBG_ENABLE
 #define DBG_ENABLE
 #define DBG_COLOR
 #define DBG_COLOR
 #define DBG_TAG "control"
 #define DBG_TAG "control"
@@ -44,7 +45,7 @@
 
 
 
 
 Device_Status_typedef device_status;
 Device_Status_typedef device_status;
-
+System_stats_t system_status;
 
 
 rt_device_t serial_485;   /*串口设备句柄*/
 rt_device_t serial_485;   /*串口设备句柄*/
 struct  serial_configure uart_config_485 = RT_SERIAL_CONFIG_DEFAULT;  /*初始化配置参数*/
 struct  serial_configure uart_config_485 = RT_SERIAL_CONFIG_DEFAULT;  /*初始化配置参数*/
@@ -125,51 +126,25 @@ int UART_485_INIT(void)
 }
 }
 
 
 /* 入口函数 */
 /* 入口函数 */
-static void sht30_collect_thread_entry(void *parameter)
+static void adc_collect_thread_entry(void *parameter)
 {
 {
-
-    sht3x_device_t  sht3x_device;
     static int checklightnum = 0;
     static int checklightnum = 0;
     static int checknightnum = 0;
     static int checknightnum = 0;
-    sht3x_device = sht3x_init("i2c1", 0x44);
-    //此处需要短暂的延时,否则会出现连续读取失败的问题
-    rt_thread_mdelay(150);
+    static int checkrain_num = 0;
+    static int checkrain_unlock = 0;
+    static unsigned int rain_value = 0;
+    static unsigned int light_value = 0;
+    const unsigned int log_freq = 100;  //100ms
+    static unsigned log_cnt = 0;
     while (1)
     while (1)
     {
     {
-        if(sht3x_device)
-        {
-            if(RT_EOK == sht3x_read_singleshot(sht3x_device))
-            {
-                hum_value = sht3x_device->humidity;
-                tem_value = sht3x_device->temperature;
-                if(hum_value!=0)
-                {
-                    rt_sprintf(device_status.humidity,"%d.%d",(int)sht3x_device->humidity, (uint)(sht3x_device->humidity * 10) % 10);
-                    rt_sprintf(device_status.tempture,"%d.%d",(int)sht3x_device->temperature, (uint)(sht3x_device->temperature * 10) % 10);
-                }
-                else {
-                    rt_kprintf("sht3x_read_singleshot eRR:%d",hum_value);
-                }
-            }
-            else {
-                sht3x_softreset(sht3x_device);
-            }
-////          rt_kprintf("sht30 humidity   : %d.%d  ", (int)sht3x_device->humidity, (int)(sht3x_device->humidity * 10) % 10);
-////          rt_kprintf("temperature: %d.%d\n", (int)sht3x_device->temperature, (int)(sht3x_device->temperature * 10) % 10);
-        }
-        else
-        {
-
-            rt_kprintf("read sht3x fail.\r\n");
-            //重新初始化
-            sht3x_deinit(sht3x_device);
-            sht3x_device = sht3x_init("i2c1", 0x44);
-            rt_thread_mdelay(150);
-        }
-        if(Read_Light_Voltage()>500||atoi(device_status.lux)>500)
+        log_cnt ++;
+        rain_value= Read_Rain_Voltage();
+        light_value= Read_Light_Voltage();
+        if(light_value>500||atoi(device_status.lux)>500)
         {
         {
             checklightnum++;
             checklightnum++;
-            if(checklightnum==20)
+            if(checklightnum==1000)     //100s
             {
             {
                 device_status.sun_status = 1;
                 device_status.sun_status = 1;
                 checklightnum =0;
                 checklightnum =0;
@@ -180,7 +155,7 @@ static void sht30_collect_thread_entry(void *parameter)
             {
             {
                 checknightnum ++;
                 checknightnum ++;
             }
             }
-            if(checknightnum==20)
+            if(checknightnum==1000)     //100s
             {
             {
                 device_status.sun_status = 0;
                 device_status.sun_status = 0;
                 checknightnum = 0;
                 checknightnum = 0;
@@ -194,13 +169,43 @@ static void sht30_collect_thread_entry(void *parameter)
         else if(atoi(device_status.tempture)>=(device_status.tpl+5)&&atoi(device_status.tempture)<=(device_status.tph-10)) {
         else if(atoi(device_status.tempture)>=(device_status.tpl+5)&&atoi(device_status.tempture)<=(device_status.tph-10)) {
             device_status.temp_status = 0;
             device_status.temp_status = 0;
         }
         }
-        LOG_I("光控计数:%d-%d",checklightnum,checknightnum);
-        rt_thread_mdelay(5000);
+        //雨控
+        if(rain_value>250&&device_status.selfcheck_ws==0)
+        {
+            checkrain_num++;
+            if(checkrain_num>=10){
+                system_status.rain_value = rain_value;
+                system_status.rain_control_triggers +=1;
+                device_status.rain_status = 1;
+                ctr_lamp(OFF,1);
+                ctr_lamp(OFF,2);
+                ctr_lamp(OFF,3);
+                device_status.ctr_up_motor = 2; //关闭上仓门
+                checkrain_num = 0;
+                checkrain_unlock = 0;
+            }
+        }
+        else {
+            checkrain_unlock++;
+            checkrain_num = 0;
+            //雨控消抖,5分钟
+            if(checkrain_unlock==10*60*60)
+            {
+                checkrain_unlock = 0;
+                device_status.rain_status = 0;
+            }
+        }
+        if(log_cnt==50){   //每5s打印
+            log_cnt = 0;
+            LOG_I("光控计数:light:%d-night:%d",checklightnum,checknightnum);
+            LOG_I("雨控计数:有:%d-无:%d",checkrain_num,checkrain_unlock);
+            LOG_I("雨控ADC值:%d 光控ADC值:%d",rain_value,light_value);
+        }
+        rt_thread_mdelay(log_freq);
     }
     }
 }
 }
 static void Power_ReadCheck(void *parameter)
 static void Power_ReadCheck(void *parameter)
 {
 {
-    rt_uint32_t rain_cnt = 0;
     int bat_cnt = 0;
     int bat_cnt = 0;
     int RV;
     int RV;
     MovingAverageFilter* filter = moving_average_filter_init(10);
     MovingAverageFilter* filter = moving_average_filter_init(10);
@@ -286,26 +291,6 @@ static void Power_ReadCheck(void *parameter)
                     device_status.heattem = 25;
                     device_status.heattem = 25;
                 }
                 }
             }
             }
-            //雨控
-            if(Read_Rain_Voltage()>250&&device_status.selfcheck_ws==0)
-            {
-                device_status.rain_status = 1;
-                ctr_lamp(OFF,1);
-                ctr_lamp(OFF,2);
-                ctr_lamp(OFF,3);
-                device_status.ctr_up_motor = 2; //关闭上仓门
-                rain_cnt = 0;
-            }
-            else {
-                rain_cnt++;
-                //雨控消抖,5分钟
-                if(rain_cnt>3000*6&&Read_Rain_Voltage()<250)
-                {
-                    LOG_D("雨控触发:%d",Read_Rain_Voltage());
-                    rain_cnt = 0;
-                    device_status.rain_status = 0;
-                }
-            }
             //LOG_D("rain_cnt:%d-value:%d",rain_cnt,Read_Rain_Voltage());
             //LOG_D("rain_cnt:%d-value:%d",rain_cnt,Read_Rain_Voltage());
         }
         }
         if(bat_cnt>=100){  //持续10s
         if(bat_cnt>=100){  //持续10s
@@ -427,7 +412,7 @@ int Read_Light_Voltage(void)
        adc10_rain = rt_adc_read(adc_dev,ADC_DEV_CHANNLE_2);
        adc10_rain = rt_adc_read(adc_dev,ADC_DEV_CHANNLE_2);
        rt_adc_disable(adc_dev, ADC_DEV_CHANNLE_2);
        rt_adc_disable(adc_dev, ADC_DEV_CHANNLE_2);
        HAL_ADCEx_Calibration_Start(adc_dev->parent.user_data);
        HAL_ADCEx_Calibration_Start(adc_dev->parent.user_data);
-       LOG_I("read light value:%d",adc10_rain);
+//       LOG_I("read light value:%d",adc10_rain);
        return adc10_rain;
        return adc10_rain;
 }
 }
 //获取内部温度传感器值
 //获取内部温度传感器值
@@ -554,7 +539,7 @@ int Read_Ntc_Voltage(void)
 int sht30_collect(void)
 int sht30_collect(void)
 {
 {
     /* 创建线程*/
     /* 创建线程*/
-    tid1 = rt_thread_create("sht30_collect_thread",sht30_collect_thread_entry, RT_NULL,THREAD_STACK_SIZE,THREAD_PRIORITY, THREAD_TIMESLICE);
+    tid1 = rt_thread_create("adc_thread",adc_collect_thread_entry, RT_NULL,THREAD_STACK_SIZE,THREAD_PRIORITY, THREAD_TIMESLICE);
     tid2 = rt_thread_create("Power Check thread", Power_ReadCheck, RT_NULL, P_THREAD_STACK_SIZE, P_THREAD_PRIORITY, P_THREAD_TIMESCLICE);
     tid2 = rt_thread_create("Power Check thread", Power_ReadCheck, RT_NULL, P_THREAD_STACK_SIZE, P_THREAD_PRIORITY, P_THREAD_TIMESCLICE);
     /* 如果获得线程控制块,启动这个线程 */
     /* 如果获得线程控制块,启动这个线程 */
     if (tid1 != RT_NULL)
     if (tid1 != RT_NULL)

+ 2 - 1
Application_CBD/applications/sys_monitor.c

@@ -67,7 +67,8 @@ static void sys_monitor_thread_entry(void *parameter)
 
 
             LOG_D("灯管累计运行:%d S",system_status.lamp_running_time/RT_TICK_PER_SECOND);
             LOG_D("灯管累计运行:%d S",system_status.lamp_running_time/RT_TICK_PER_SECOND);
             LOG_D("加热累计运行:%d S",system_status.heater_running_time/RT_TICK_PER_SECOND);
             LOG_D("加热累计运行:%d S",system_status.heater_running_time/RT_TICK_PER_SECOND);
-
+            LOG_D("雨控触发值:%d",system_status.rain_value);
+            LOG_D("雨控触发次数:%d",system_status.rain_control_triggers);
         }
         }
     }
     }
 }
 }

+ 1 - 1
Application_CBD/applications/sys_monitor.h

@@ -64,7 +64,7 @@ typedef struct
     /* 8. 时间戳信息(可选) */
     /* 8. 时间戳信息(可选) */
     time_sec_t  last_reset_time;       // 上次重置时间戳
     time_sec_t  last_reset_time;       // 上次重置时间戳
     uint32_t    reset_count;           // 系统重置次数
     uint32_t    reset_count;           // 系统重置次数
-
+    uint32_t    rain_value;            // 雨控值
 
 
 } System_stats_t;
 } System_stats_t;
 
 

+ 6 - 0
Application_CBD/readme.md

@@ -1,3 +1,9 @@
+# 2026-04-09 更新说明
+	#define VERSION_HK          "1.66.41(HK)"            //4.0海康-1200W
+    #define VERSION_HK_2000W    "1.66.40(2000W)"         //4.0水稻
+	#define VERSION_ZP          "1.66.1(ZP)"            //1.0转盘
+	#define VERSION_GK          "1.66.1(GK)"            //1.0高空
+	1、雨控检测频率降低,增加检测及日志输出;
 # 2026-03-23 更新说明
 # 2026-03-23 更新说明
     1. 收到关闭补光灯指令后,不再关闭拍照
     1. 收到关闭补光灯指令后,不再关闭拍照
 # 2026-03-12 更新说明
 # 2026-03-12 更新说明