zhunk 3 miesięcy temu
rodzic
commit
a9db343414

+ 73 - 56
Application_cbd_apm32f1/applications/control.c

@@ -52,15 +52,23 @@ rt_event_t event_485_play;
 extern eMBMasterReqErrCode _485_play(USHORT *Buffer,USHORT NREGS);
 extern eMBMasterReqErrCode _485_play(USHORT *Buffer,USHORT NREGS);
 
 
 
 
-const uint8_t open_Led[] = {0x02,0x06,0x00,0x32,0x00,0x01,0xE9,0xF6};   //02 06 00 32 00 01 E9 F6
-const uint8_t close_Led[] = {0x02,0x06,0x00,0x32,0x00,0x00,0x28,0x36};   //02 06 00 32 00 01 E9 F6
-const uint8_t motor1_Forword[] = {0x02,0x06,0x00,0x00,0x00,0x01,0x48,0x39};   //02 06 00 00 00 01 48 39
-const uint8_t motor1_Backward[] = {0x02,0x06,0x00,0x00,0x00,0x02,0x08,0x38};   //02 06 00 00 00 01 48 39
-const uint8_t motor1_Stop[] = {0x02,0x06,0x00,0x00,0x00,0x00,0x89,0xF9};   //02 06 00 00 00 01 48 39
-const uint8_t motor2_Forword[] = {0x02,0x06,0x00,0x00,0x00,0x10,0x88,0x35};   //02 06 00 00 00 01 48 39
-const uint8_t motor2_Backward[] = {0x02,0x06,0x00,0x00,0x00,0x20,0x88,0x31};   //02 06 00 00 00 01 48 39
-const uint8_t motor2_Stop[] = {0x02,0x06,0x00,0x00,0x00,0x00,0x89,0xF9};   //02 06 00 00 00 01 48 39
-const uint8_t get_status[] = {0x02,0x03,0x00,0x00,0x00,0x01,0x84,0x39};     //02 03 02 00 00 FC 44
+const uint8_t DAM0808_Read[] = {0x01,0x02,0x00,0x00,0x00,0x08,0x79,0xCC};
+const uint8_t DAM0808_OUT1_OPEN[] = {0x01,0x05,0x00,0x00,0xFF,0x00,0x8C,0x3A};     //发送:01 05 00 00 FF 00 8C 3A
+const uint8_t DAM0808_OUT1_CLOSE[] = {0x01,0x05,0x00,0x00,0x00,0x00,0xCD,0xCA};    //发送:01 05 00 00 00 00 CD CA
+const uint8_t DAM0808_OUT2_OPEN[] = {0x01,0x05,0x00,0x01,0xFF,0x00,0xDD,0xFA};     //发送:01 05 00 01 FF 00 DD FA
+const uint8_t DAM0808_OUT2_CLOSE[] = {0x01,0x05,0x00,0x01,0x00,0x00,0x9C,0x0A};    //发送:01 05 00 01 00 00 9C 0A
+const uint8_t DAM0808_OUT3_OPEN[] = {0x01,0x05,0x00,0x02,0xFF,0x00,0x2D,0xFA};     //发送:01 05 00 02 FF 00 2D FA
+const uint8_t DAM0808_OUT3_CLOSE[] = {0x01,0x05,0x00,0x02,0x00,0x00,0x6C,0x0A};    //发送:01 05 00 02 00 00 6C 0A
+const uint8_t DAM0808_OUT4_OPEN[] = {0x01,0x05,0x00,0x03,0xFF,0x00,0x7C,0x3A};     //发送:01 05 00 03 FF 00 7C 3A
+const uint8_t DAM0808_OUT4_CLOSE[] = {0x01,0x05,0x00,0x03,0x00,0x00,0x3D,0xCA};    //发送:01 05 00 03 00 00 3D CA
+const uint8_t DAM0808_OUT5_OPEN[] = {0x01,0x05,0x00,0x04,0xFF,0x00,0xCD,0xFB};     //发送:01 05 00 04 FF 00 CD FB
+const uint8_t DAM0808_OUT5_CLOSE[] = {0x01,0x05,0x00,0x04,0x00,0x00,0x8C,0x0B};    //发送:01 05 00 04 00 00 8C 0B
+const uint8_t DAM0808_OUT6_OPEN[] = {0x01,0x05,0x00,0x05,0xFF,0x00,0x9C,0x3B};     //发送:01 05 00 05 FF 00 9C 3B
+const uint8_t DAM0808_OUT6_CLOSE[] = {0x01,0x05,0x00,0x05,0x00,0x00,0xDD,0xCB};    //发送:01 05 00 05 00 00 DD CB
+const uint8_t DAM0808_OUT7_OPEN[] = {0x01,0x05,0x00,0x06,0xFF,0x00,0x6C,0x3B};     //发送:01 05 00 06 FF 00 6C 3B
+const uint8_t DAM0808_OUT7_CLOSE[] = {0x01,0x05,0x00,0x06,0x00,0x00,0x2D,0xCB};    //发送:01 05 00 06 00 00 2D CB
+const uint8_t DAM0808_OUT8_OPEN[] = {0x01,0x05,0x00,0x07,0xFF,0x00,0x3D,0xFB};     //发送:01 05 00 07 FF 00 3D FB
+const uint8_t DAM0808_OUT8_CLOSE[] = {0x01,0x05,0x00,0x07,0x00,0x00,0x7C,0x0B};    //发送:01 05 00 07 00 00 7C 0B
 
 
 /***************************************************************************/
 /***************************************************************************/
 int thread_delete_workloop(void)
 int thread_delete_workloop(void)
@@ -79,7 +87,49 @@ int thread_restart_workloop(void)
     result = Work_Loop_Task();
     result = Work_Loop_Task();
     return result;
     return result;
 }
 }
-/**************************1.0定制2000W*************************************/
+
+void ctr_rain_motor(uint8_t ws)
+{
+    {
+        /* 发送 Modbus RTU 获取电机状态 */
+        uart5_rx_flag = 0;   /* 先清除上次的接收标志 */
+        Uart5_Write_Bin(DAM0808_Read, sizeof(DAM0808_Read));   /* 必须用_Bin,%s会截断0x00字节 */
+
+        /* 等待回复,超时2秒上报预警 */
+        rt_tick_t status_start = rt_tick_get();
+        uint8_t status_timeout = 1;  /* 默认超时 */
+        while(rt_tick_get() - status_start < 2 * RT_TICK_PER_SECOND) {
+            if(uart5_rx_flag) {
+                status_timeout = 0;   /* 收到回复 */
+                LOG_I("电机状态查询有回复");
+                break;
+            }
+            rt_thread_delay(50);   /* 每50ms轮询一次 */
+        }
+        if(status_timeout) {
+            LOG_W("电机状态查询超时,发送预警!");
+            char *warn = makeJson_Warn("485_motor_timeout", "get_status");
+            if(warn) {
+                DTU_Write("%s", warn);
+                rt_free(warn);
+            }
+        }
+        uart5_rx_flag = 0;   /* 重置标志,供下次使用 */
+
+    }
+    Uart5_Write_Bin(DAM0808_OUT5_CLOSE, sizeof(DAM0808_OUT5_CLOSE));   //推杆停止
+    Uart5_Write_Bin(DAM0808_OUT6_CLOSE, sizeof(DAM0808_OUT6_CLOSE));   //推杆停止
+    Uart5_Write_Bin(DAM0808_OUT7_CLOSE, sizeof(DAM0808_OUT7_CLOSE));   //推杆停止
+    Uart5_Write_Bin(DAM0808_OUT8_CLOSE, sizeof(DAM0808_OUT8_CLOSE));   //推杆停止
+
+    if(ws==OPEN){
+        Uart5_Write_Bin(DAM0808_OUT5_OPEN, sizeof(DAM0808_OUT5_OPEN));    //推杆停止
+        Uart5_Write_Bin(DAM0808_OUT7_OPEN, sizeof(DAM0808_OUT7_OPEN));    //推杆停止
+    }else if(ws==CLOSE){
+        Uart5_Write_Bin(DAM0808_OUT6_OPEN, sizeof(DAM0808_OUT6_OPEN));    //推杆停止
+        Uart5_Write_Bin(DAM0808_OUT8_OPEN, sizeof(DAM0808_OUT8_OPEN));    //推杆停止
+    }
+}
 
 
 
 
 /****************************5.0***********************************/
 /****************************5.0***********************************/
@@ -354,7 +404,8 @@ uint8_t ctr_cangmen_up(uint8_t status_up)
    if(status_up==OFF)
    if(status_up==OFF)
    {
    {
 #if JINGJIKUAN == 1
 #if JINGJIKUAN == 1
-       Uart5_Write_Bin(motor1_Stop, sizeof(motor1_Stop));   //推杆停止
+       Uart5_Write_Bin(DAM0808_OUT1_CLOSE, sizeof(DAM0808_OUT1_CLOSE));   //推杆停止
+       Uart5_Write_Bin(DAM0808_OUT2_CLOSE, sizeof(DAM0808_OUT2_CLOSE));   //推杆停止
 #endif
 #endif
        rt_pin_write(Collect_fan_R,ON);
        rt_pin_write(Collect_fan_R,ON);
        rt_pin_write(Collect_fan_L,ON);
        rt_pin_write(Collect_fan_L,ON);
@@ -375,7 +426,8 @@ uint8_t ctr_cangmen_up(uint8_t status_up)
        rt_pin_write(Collect_fan_L,ON);
        rt_pin_write(Collect_fan_L,ON);
 #endif
 #endif
 #if JINGJIKUAN == 1
 #if JINGJIKUAN == 1
-       Uart5_Write_Bin(motor1_Forword, sizeof(motor1_Forword));   //推杆打开
+       Uart5_Write_Bin(DAM0808_OUT1_OPEN, sizeof(DAM0808_OUT1_OPEN));   //推杆打开
+       Uart5_Write_Bin(DAM0808_OUT2_CLOSE, sizeof(DAM0808_OUT2_CLOSE));   //推杆关闭
 #endif
 #endif
    }
    }
 
 
@@ -392,7 +444,8 @@ uint8_t ctr_cangmen_up(uint8_t status_up)
        rt_pin_write(Collect_fan_L,OFF);
        rt_pin_write(Collect_fan_L,OFF);
 #endif
 #endif
 #if JINGJIKUAN == 1
 #if JINGJIKUAN == 1
-       Uart5_Write_Bin(motor1_Backward, sizeof(motor1_Backward));   //推杆关闭
+       Uart5_Write_Bin(DAM0808_OUT2_OPEN, sizeof(DAM0808_OUT2_OPEN));
+       Uart5_Write_Bin(DAM0808_OUT1_CLOSE, sizeof(DAM0808_OUT1_CLOSE));
 #endif
 #endif
    }
    }
    return device_status.up_status;
    return device_status.up_status;
@@ -405,7 +458,8 @@ uint8_t ctr_cangmen_down(uint8_t status_down)
     if(status_down==OFF)
     if(status_down==OFF)
        {
        {
 #if JINGJIKUAN == 1
 #if JINGJIKUAN == 1
-           Uart5_Write_Bin(motor2_Stop, sizeof(motor2_Stop));   //推杆关闭
+        Uart5_Write_Bin(DAM0808_OUT3_CLOSE, sizeof(DAM0808_OUT3_CLOSE));   //推杆停止
+        Uart5_Write_Bin(DAM0808_OUT4_CLOSE, sizeof(DAM0808_OUT4_CLOSE));   //推杆停止
 #endif
 #endif
            rt_pin_write(C_DOWN_R,ON);
            rt_pin_write(C_DOWN_R,ON);
            rt_pin_write(C_DOWN_L,ON);
            rt_pin_write(C_DOWN_L,ON);
@@ -420,7 +474,8 @@ uint8_t ctr_cangmen_down(uint8_t status_down)
            rt_pin_write(C_DOWN_R,ON);
            rt_pin_write(C_DOWN_R,ON);
            rt_pin_write(C_DOWN_L,OFF);
            rt_pin_write(C_DOWN_L,OFF);
 #if JINGJIKUAN == 1
 #if JINGJIKUAN == 1
-           Uart5_Write_Bin(motor2_Forword, sizeof(motor2_Forword));   //推杆关闭
+           Uart5_Write_Bin(DAM0808_OUT4_CLOSE, sizeof(DAM0808_OUT4_CLOSE));   //推杆关闭
+           Uart5_Write_Bin(DAM0808_OUT3_OPEN, sizeof(DAM0808_OUT3_OPEN));   //推杆关闭
 #endif
 #endif
 
 
        }
        }
@@ -432,7 +487,8 @@ uint8_t ctr_cangmen_down(uint8_t status_down)
            rt_pin_write(C_DOWN_R,OFF);
            rt_pin_write(C_DOWN_R,OFF);
            rt_pin_write(C_DOWN_L,ON);
            rt_pin_write(C_DOWN_L,ON);
 #if JINGJIKUAN == 1
 #if JINGJIKUAN == 1
-           Uart5_Write_Bin(motor2_Backward, sizeof(motor2_Backward));   //推杆关闭
+           Uart5_Write_Bin(DAM0808_OUT3_CLOSE, sizeof(DAM0808_OUT3_CLOSE));   //推杆关闭
+           Uart5_Write_Bin(DAM0808_OUT4_OPEN, sizeof(DAM0808_OUT4_OPEN));   //推杆关闭
 #endif
 #endif
 
 
        }
        }
@@ -1487,6 +1543,7 @@ void ResetInit(void)
                LOG_W("欠压!");
                LOG_W("欠压!");
                return;
                return;
            }
            }
+           ctr_rain_motor(OPEN);
            //7.关闭上仓门
            //7.关闭上仓门
            device_status.ctr_up_motor = 2;
            device_status.ctr_up_motor = 2;
 //           while(device_status.ctr_up_motor!=0)
 //           while(device_status.ctr_up_motor!=0)
@@ -2033,46 +2090,6 @@ static void Work_Loop_thread_entry(void *parameter)
             if((tm_tg_run.tm_hour)==alarm_h&&(tm_tg_run.tm_min==alarm_m)&&(tm_tg_run.tm_sec>=alarm_s))
             if((tm_tg_run.tm_hour)==alarm_h&&(tm_tg_run.tm_min==alarm_m)&&(tm_tg_run.tm_sec>=alarm_s))
             {
             {
                 LOG_W("预制执行 开始!");
                 LOG_W("预制执行 开始!");
-                {
-                    /* 发送 Modbus RTU 获取电机状态 */
-                    uart5_rx_flag = 0;   /* 先清除上次的接收标志 */
-                    Uart5_Write_Bin(get_status, sizeof(get_status));   /* 必须用_Bin,%s会截断0x00字节 */
-
-                    /* 等待回复,超时2秒上报预警 */
-                    rt_tick_t status_start = rt_tick_get();
-                    uint8_t status_timeout = 1;  /* 默认超时 */
-                    while(rt_tick_get() - status_start < 2 * RT_TICK_PER_SECOND) {
-                        if(uart5_rx_flag) {
-                            status_timeout = 0;   /* 收到回复 */
-                            LOG_I("电机状态查询有回复");
-                            break;
-                        }
-                        rt_thread_delay(50);   /* 每50ms轮询一次 */
-                    }
-                    if(status_timeout) {
-                        LOG_W("电机状态查询超时,发送预警!");
-                        char *warn = makeJson_Warn("485_motor_timeout", "get_status");
-                        if(warn) {
-                            DTU_Write("%s", warn);
-                            rt_free(warn);
-                        }
-                    }
-                    uart5_rx_flag = 0;   /* 重置标志,供下次使用 */
-
-                    Uart5_Write_Bin(motor1_Forword, sizeof(motor1_Forword));   //推杆打开
-                    rt_thread_delay(20000);
-                    Uart5_Write_Bin(motor2_Forword, sizeof(motor2_Forword));   //震动
-                    ctr_Collect_Fan(ON);
-                    for(uint8_t i = 0; i < 30; i++){
-                        rt_thread_delay(1000);
-                        LOG_I("等待震动完成:%d",i);
-                    }
-                    Uart5_Write_Bin(motor2_Stop, sizeof(motor2_Stop));   //关闭震动
-                    ctr_Collect_Fan(OFF);
-                    rt_thread_delay(2000);
-                    Uart5_Write_Bin(motor1_Backward, sizeof(motor1_Backward));   //推杆关闭
-                    rt_thread_delay(1000);
-                }
                 char *temp_s =makeJson_Warn("执行完成", "预制模式");
                 char *temp_s =makeJson_Warn("执行完成", "预制模式");
                 DTU_Write("%s",temp_s);
                 DTU_Write("%s",temp_s);
                 rt_free(temp_s);
                 rt_free(temp_s);

+ 3 - 1
Application_cbd_apm32f1/applications/control.h

@@ -44,7 +44,7 @@
 #if JINGJIKUAN == 0
 #if JINGJIKUAN == 0
     #define VERSION_HK_2000W    "2.41.4(2000W)"         //4.0水稻
     #define VERSION_HK_2000W    "2.41.4(2000W)"         //4.0水稻
 #else
 #else
-    #define VERSION_HK_2000W    "2.41.4(jjk)"           //经济款
+    #define VERSION_HK_2000W    "2.42.4(jjk)"           //经济款
 #endif
 #endif
     #else
     #else
     #if MATCH_DEVICE == 1
     #if MATCH_DEVICE == 1
@@ -352,4 +352,6 @@ int thread_restart_workloop(void);
 /*******************************************************/
 /*******************************************************/
 void RTU_Power_Off_Safe(void);
 void RTU_Power_Off_Safe(void);
 void RTU_Power_On_Restore(void);
 void RTU_Power_On_Restore(void);
+
+void ctr_rain_motor(uint8_t ws);
 #endif /* APPLICATIONS_INC_CONTROL_H_ */
 #endif /* APPLICATIONS_INC_CONTROL_H_ */

+ 2 - 1
Application_cbd_apm32f1/applications/dtu_uart2.c

@@ -147,7 +147,7 @@ static int DTU_uart5_init(void)
         rt_device_close(serial_485);
         rt_device_close(serial_485);
 #ifdef  RT_USING_SERIAL_V2
 #ifdef  RT_USING_SERIAL_V2
         /*修改串口配置参数*/
         /*修改串口配置参数*/
-        dtuconfig.baud_rate = BAUD_RATE_115200;  //修改波特率9600
+        dtuconfig.baud_rate = BAUD_RATE_9600;  //修改波特率9600
         dtuconfig.data_bits = DATA_BITS_8;     //数据位8c
         dtuconfig.data_bits = DATA_BITS_8;     //数据位8c
         dtuconfig.stop_bits = STOP_BITS_1;     //停止位1
         dtuconfig.stop_bits = STOP_BITS_1;     //停止位1
         #ifdef RT_USING_SERIAL_V2
         #ifdef RT_USING_SERIAL_V2
@@ -221,6 +221,7 @@ void Uart5_Write_Bin(const uint8_t *data, uint16_t len)
 {
 {
     if(data == RT_NULL || len == 0) return;
     if(data == RT_NULL || len == 0) return;
     rt_device_write(serial_485, 0, data, len);
     rt_device_write(serial_485, 0, data, len);
+    rt_thread_delay(50);
 }
 }
 
 
 
 

+ 16 - 3
Application_cbd_apm32f1/applications/hmi.c

@@ -1569,7 +1569,8 @@ static void Ctr_Mortor_entry(void* parameter)
    static rt_uint16_t mock_uart2_timer_cnt = 0;
    static rt_uint16_t mock_uart2_timer_cnt = 0;
    static rt_uint16_t route_off_t = 0;
    static rt_uint16_t route_off_t = 0;
    device_status.route_off_t = 0;
    device_status.route_off_t = 0;
-
+   static uint8_t is_rain = 0;
+   static uint8_t isnot_rain = 0;
    rt_pin_mode(CTR_UPC_LIMIT, PIN_MODE_INPUT);
    rt_pin_mode(CTR_UPC_LIMIT, PIN_MODE_INPUT);
     while(1)
     while(1)
     {
     {
@@ -1598,7 +1599,6 @@ static void Ctr_Mortor_entry(void* parameter)
         #endif
         #endif
         if(device_status.ctr_up_motor==1)
         if(device_status.ctr_up_motor==1)
         {
         {
-            ctr_Cold(ON);
             ctr_cangmen_up(OPEN);
             ctr_cangmen_up(OPEN);
             num_up_open--;
             num_up_open--;
             if (num_up_open == 0)
             if (num_up_open == 0)
@@ -1611,7 +1611,6 @@ static void Ctr_Mortor_entry(void* parameter)
         }
         }
         else if(device_status.ctr_up_motor==2)
         else if(device_status.ctr_up_motor==2)
         {
         {
-            ctr_Cold(OFF);
             ctr_cangmen_up(CLOSE);
             ctr_cangmen_up(CLOSE);
             num_up_close --;
             num_up_close --;
             if (num_up_close == 0)
             if (num_up_close == 0)
@@ -1726,6 +1725,20 @@ static void Ctr_Mortor_entry(void* parameter)
                 route_off_t = 0;
                 route_off_t = 0;
             }
             }
         }
         }
+        if(device_status.rain_status==1){
+            isnot_rain = 0;
+            if(is_rain==0){
+                ctr_rain_motor(CLOSE);
+                is_rain = 1;
+            }
+        }else{
+            is_rain = 0;
+            if(isnot_rain == 0){
+                ctr_rain_motor(OPEN);
+                isnot_rain = 1;
+            }
+        }
+
         rt_thread_delay(100);
         rt_thread_delay(100);
     }
     }
 }
 }

+ 3 - 0
Application_cbd_apm32f1/readme.md

@@ -1,3 +1,6 @@
+# 2026-07-28
+	#define VERSION_HK_2000W    "2.42.4(jjk)"           //经济款
+	1、适配DAM0808D数采控制器、用于3路球阀控制,替换上下仓门,增加雨控电机;
 # 2026-07-13
 # 2026-07-13
 	#define VERSION_HK_2000W    "2.41.4(2000W)"         //4.0水稻
 	#define VERSION_HK_2000W    "2.41.4(2000W)"         //4.0水稻
 	1、easyflash配置ENV_AREA_SIZE 调整为4096*256
 	1、easyflash配置ENV_AREA_SIZE 调整为4096*256