增加焊接气体流量锁定参数,支持远程修改
authorkyz <kongyuzhong@google.com>
Thu, 6 Jun 2024 08:02:33 +0000 (16:02 +0800)
committerkyz <kongyuzhong@google.com>
Thu, 6 Jun 2024 08:08:23 +0000 (16:08 +0800)
Drivers/BSP/Components/lan8742/lan8742.c
tools_v2/test.py
tools_v2/test.ui
user/user.h
user/user_app.c
user/user_cdc_rx_2.c
user/user_report.c
user/user_valve_ctrl.c

index aacddbc511b035008edb8414e503b8f45f3466c3..3378b96c41cfa8b5db6a620da50ef95d11cf0c1a 100644 (file)
@@ -20,7 +20,7 @@
 
 /* Includes ------------------------------------------------------------------*/
 #include "lan8742.h"
-
+#include "user.h"
 /** @addtogroup BSP
   * @{
   */
@@ -150,6 +150,7 @@ int32_t  LAN8742_RegisterBusIO(lan8742_Object_t *pObj, lan8742_IOCtx_t *ioctx)
      /* Wait for 2s to perform initialization */
      while((pObj->IO.GetTick() - tickstart) <= LAN8742_INIT_TO)
      {
+                osDelay(100);
      }
      pObj->Is_Initialized = 1;
    }
index c3b2172bf2122eb9642ea87a4b432d4795f592bd..ad76a90c7660194268313e72eaa2fd15813fe2f9 100644 (file)
@@ -43,7 +43,7 @@ class App( QDialog, ui_welding.Ui_Dialog ):
     def __init__( self ):
         super().__init__()
         self.setupUi(self)
-        self.setWindowTitle( u"焊接控制器调试工具 V0.6")
+        self.setWindowTitle( u"焊接控制器调试工具 V0.7")
 
         self.trigger_rx_pkt.connect( self.on_rx_pkt )
         self.trigger_ctrl_write.connect( self.on_ctrl_write_signal )
@@ -138,7 +138,7 @@ class App( QDialog, ui_welding.Ui_Dialog ):
         if item == "timer":
             self.tx_cmd( cmd = 0x00B6, wait=False )
         else:
-            #B6   read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, 气路选择掉电保存
+            #B6   read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, 气路选择掉电保存, fix_target_flow_x10
             method = factor = prev = comp = coeff = bypass_save = bypass = 0x7FFFFFFF
             if item == "method" :
                 method = 0 if action == "tig" else  1 if action=="mig" else 2
@@ -210,7 +210,7 @@ class App( QDialog, ui_welding.Ui_Dialog ):
         if self.connected != 0 or self.ser_opened:
             return
         if cfg == 1 or cfg == 2:
-            #B6   read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypass_save 4B, bypass 4B
+            #B6   read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypass_save 4B, bypass 4B, fix_target_flow_x10 4B
             cmd = 0x00B6
         elif cfg == 3:
             cmd = 0x00B8
@@ -227,7 +227,13 @@ class App( QDialog, ui_welding.Ui_Dialog ):
         if cfg == 1:
             #B6   read cfg, 节气因子4B,工艺4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, 气路选择掉电保存
             cmd = 0x00B7
-            d = struct.pack( '>LLLlLLL', 
+            try:
+                fix_target_flow_x10 = int( float( self.lineEdit_fix_target_flow.text())*10 )
+                if fix_target_flow_x10 <0 or fix_target_flow_x10 >500:
+                    fix_target_flow_x10 = 0x7FFFFFFF
+            except:
+                fix_target_flow_x10 = 0x7FFFFFFF
+            d = struct.pack( '>LLLlLLLL', 
                                #int(self.lineEdit_cfg_method.text()), 
                                self.cb_cfg_method.currentIndex(),
                                int(self.lineEdit_cfg_factor.text()), 
@@ -235,8 +241,10 @@ class App( QDialog, ui_welding.Ui_Dialog ):
                                0x7FFFFFFF, #填无效值  comp
                                0x7FFFFFFF,  #填无效值  coeff 修正系数
                                1 if self.cb_path_save.isChecked() else 0,
-                               0x7FFFFFFF #填无效值 bypass
-                               )
+                               0x7FFFFFFF, #填无效值 bypass
+                               fix_target_flow_x10
+                            )
+            print( "----------write fix target flow:", fix_target_flow_x10 )
             print( "write cfg cmd:%04X"%cmd, d.hex())
         elif cfg == 2:
             cmd = 0x00B7
@@ -638,6 +646,12 @@ class App( QDialog, ui_welding.Ui_Dialog ):
                     break
             self.cb_path_save.setChecked( bypass_save == 1 )
 
+            if len(data) >= 32:
+                fix_target_flow_x10 = struct.unpack( '>L', data[28:32] )[0]
+                self.lineEdit_fix_target_flow.setText( "%0.1f"%(fix_target_flow_x10/10) )
+            else:
+                self.lineEdit_fix_target_flow.setText( "" )
+
         elif cmd == 0x00B8 and len(data)>=128+16: #参数读取
             print( "B8 resp:", data.hex() )
             #SSID 128B,passwd 16B
index ee61b7c3207c673775b083a4854b1951460c85a3..1375eb30f14e7de5983c75695ea3b49fe087a347 100644 (file)
@@ -6,8 +6,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1333</width>
-    <height>845</height>
+    <width>1352</width>
+    <height>862</height>
    </rect>
   </property>
   <property name="windowTitle">
      </rect>
     </property>
     <property name="currentIndex">
-     <number>3</number>
+     <number>5</number>
     </property>
     <widget class="QWidget" name="tab">
      <attribute name="title">
         <property name="geometry">
          <rect>
           <x>20</x>
-          <y>30</y>
+          <y>10</y>
           <width>421</width>
-          <height>171</height>
+          <height>201</height>
          </rect>
         </property>
         <property name="title">
           <string>气路选择断电保存</string>
          </property>
         </widget>
+        <widget class="QLineEdit" name="lineEdit_fix_target_flow">
+         <property name="geometry">
+          <rect>
+           <x>200</x>
+           <y>160</y>
+           <width>41</width>
+           <height>31</height>
+          </rect>
+         </property>
+         <property name="text">
+          <string>99.9</string>
+         </property>
+         <property name="alignment">
+          <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+         </property>
+         <property name="readOnly">
+          <bool>false</bool>
+         </property>
+        </widget>
+        <widget class="QLabel" name="label_23">
+         <property name="geometry">
+          <rect>
+           <x>40</x>
+           <y>160</y>
+           <width>151</width>
+           <height>31</height>
+          </rect>
+         </property>
+         <property name="text">
+          <string>焊接目标流量锁定(0-50.0)</string>
+         </property>
+        </widget>
+        <widget class="QLabel" name="label_36">
+         <property name="geometry">
+          <rect>
+           <x>240</x>
+           <y>160</y>
+           <width>41</width>
+           <height>31</height>
+          </rect>
+         </property>
+         <property name="text">
+          <string>(L/min)</string>
+         </property>
+        </widget>
        </widget>
        <widget class="QGroupBox" name="groupBox_12">
         <property name="geometry">
index 195fb15b8a1d8a79fd65c5792785da3da2851c47..f12a4075f5aebf4eb9ed35bb5e87ff98a995752e 100644 (file)
@@ -173,7 +173,8 @@ typedef struct{
        uint8_t  bl;       //0-4  5级
        uint32_t offline_max_time;   //0:离线不锁定; >0:允许离线时间 秒   //使用RTC获取时间
        uint32_t offline_start_time; //0:未开始计时; >0:离线开始时间点 秒 //使用RTC获取时间
-       uint8_t reserved[16];
+       uint32_t fix_flow_x10;  //固定流量值单位0.1L, 大于0 小于50L,焊接时忽略焊接电流,固定按这个值供气。
+       uint8_t reserved[12];
        uint8_t flag;
 }dev_cfg_v2_t;
 
index 4c64f042981706fb7add2ea662384b15b7fb789b..c779e8d5027b1ebd4ea31961d5f5d1ca96cb3be7 100644 (file)
@@ -322,6 +322,7 @@ int32_t dev_cfg_v2_load( dev_cfg_v2_t *cfg )
         cfg->bl  = 10;
         cfg->flag = DEV_CFG_V2_FLAG;
                cfg->offline_max_time = 0; //0为默认禁用(平台协议下发值-1禁用)
+               cfg->fix_flow_x10 = 0;
     }
 
     //检查参数
@@ -339,7 +340,9 @@ int32_t dev_cfg_v2_load( dev_cfg_v2_t *cfg )
     if( cfg->offline_max_time == 0xffffffff ){
                cfg->offline_max_time = 0;
        }
-
+       if( cfg->fix_flow_x10 > 500 ){
+               cfg->fix_flow_x10 = 0;
+       }
     return 0;
 }
 
index 6dceaa93174db59838bd53df54f0a7d7820cb9e1..be5f01424b5658dd84140e1ed116b0e979947baf 100644 (file)
@@ -501,7 +501,7 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt )
         case 0xB5: //焊接数据清0
             break;
         case 0xB6: //设备参数读取
-                                               //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypas断电保存 4B bypass 4B
+                                               //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypas断电保存 4B bypass 4B,目标流量固定值4B
                                          put_u32_big( &resp[0], g_dev.cfg.welding_method );
                                          put_u32_big( &resp[4], g_dev.cfg.save_gas_factor );
             put_u32_big( &resp[8], g_dev.cfg.valve_open_default );
@@ -509,10 +509,11 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt )
             put_u32_big( &resp[16], g_dev.cfg.cal.flow_coeff_x1000 );
                                    put_u32_big( &resp[20], g_dev.cfg.bypass_save );
                                                put_u32_big( &resp[24], g_dev.cfg.bypass );
-                                   tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 28 );
+                                               put_u32_big( &resp[28], g_dev.cfg2.fix_flow_x10 );
+                                   tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 32 );
             break;
         case 0xB7: //设备参数写入
-                                               //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypas断电保存 4B, bypass 4B
+                                               //工艺4B,节气因子4B,前气开度4B,流量计补偿值4B,流量计气体修正系数4B, bypas断电保存 4B, bypass 4B, 目标流量固定值4B
                                {
                                          uint32_t method = get_u32_big( &pkt->pdata[0] );
                                          uint32_t factor = get_u32_big( &pkt->pdata[4] );
@@ -521,6 +522,7 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt )
                                          uint32_t coeff = get_u32_big( &pkt->pdata[16] );
                                          uint32_t bypass_save = get_u32_big( &pkt->pdata[20] );
                                          uint32_t bypass = get_u32_big( &pkt->pdata[24] );
+                                         uint32_t fix_flow_x10 = get_u32_big( &pkt->pdata[28] );
 
                                          if( !g_dev.has_bypass ){
                                                        bypass = 0;
@@ -540,9 +542,13 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt )
                                                        g_dev.cfg.bypass_save = bypass_save;
                                                if( bypass == 1 || bypass == 0 )
                                                        g_dev.cfg.bypass = bypass;
-                                               
                                                dev_cfg_store( &g_dev.cfg );
                                                ui_cfg_remote_update();
+                                               
+                                               if( pkt->data_len >= 32 && fix_flow_x10 <= 500 ){
+                                                       g_dev.cfg2.fix_flow_x10 = fix_flow_x10;
+                                                       dev_cfg_v2_store( &g_dev.cfg2 );
+                                               }
 
                                          put_u32_big( &resp[0], g_dev.cfg.welding_method );
                                          put_u32_big( &resp[4], g_dev.cfg.save_gas_factor );
@@ -551,7 +557,8 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt )
             put_u32_big( &resp[16], g_dev.cfg.cal.flow_coeff_x1000 );
                                    put_u32_big( &resp[20], g_dev.cfg.bypass_save );
                                                put_u32_big( &resp[24], g_dev.cfg.bypass );
-                                   tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 28 );
+                                               put_u32_big( &resp[28], g_dev.cfg2.fix_flow_x10 );
+                                   tx_n = wrap_resp_pkt( tx_pkt, pkt->cmd, resp, 32 );
                                          break;
                                }
         case 0xB8: //WIFI参数读取
index 8a58c18e3c9004b0451c078c159b138fabd1831d..6ce62bde80291f9228f9aa2d811990221361715d 100644 (file)
@@ -249,6 +249,15 @@ char * lock_resp_str( void )
        "offLineTime":100
     }
 }
+//焊接时气体流量固定
+{
+    "action":"updateGasFlow",
+    "timeStamp":1716445485381,
+    "data":{
+       "mac":"123",
+       "gasFlow":1.1  // 气体流量 范围0-50, 0:焊接时气体流量按电流调节, 大于0: 焊接时气体流量固定到这个值
+    }
+}
 //设备回应,原包返回
 #endif
 
@@ -261,6 +270,7 @@ int32_t iot_cmd_parse( uint32_t link, char *cmd )
        cJSON * gasPathType;
        cJSON * solarTermFactor;
        cJSON * offLineTime;
+       cJSON * item;
        
        
                        int32_t act = 0;
@@ -316,6 +326,20 @@ int32_t iot_cmd_parse( uint32_t link, char *cmd )
                                                                        act = 4; //原包回发。
                                                                }
                                                        }
+                                       }else if( strcmp( action->valuestring, "updateGasFlow" )== 0 ){
+                                                       data = cJSON_GetObjectItem( root, "data" );
+                                                       if(data){
+                                                               mac = cJSON_GetObjectItem( data, "mac" );
+                                                               item = cJSON_GetObjectItem( data, "gasFlow" );
+                                                               if( mac && item && strcasecmp( mac->valuestring, g_mac_str ) == 0 ){
+                                                                       if( item->valuedouble >= 0 && item->valuedouble <= 50 ){
+                                                                               debug_printf( "fix gasFlow: %d -->%d\n", g_dev.cfg2.fix_flow_x10, item->valuedouble );
+                                                                               g_dev.cfg2.fix_flow_x10 = (uint32_t)(item->valuedouble * 10);
+                                                                               dev_cfg_v2_store( &g_dev.cfg2 );
+                                                                               act = 4; //原包回发。
+                                                                       }
+                                                               }
+                                                       }
                                        }else if( strcmp( action->valuestring, "unlockDevice" )== 0 ){
                                                debug_printf( "unlockdevice %d->0\n", g_dev.cfg.remote_locked );
                                                g_dev.cfg.remote_locked = 0;
index e81d33501cdad5f420b96f1170b96fd394f4cd02..b81685b78f145977a7672d25900a70a8ec3998fc 100644 (file)
@@ -544,7 +544,10 @@ void user_valve_ctrl_task( void* unused )
                 g_dev.welding_time += 100; //0.1秒扫描一次
             }
 
-            if( calc_target_flow( &target_flowspeed )== 0 ){
+                       if( g_dev.cfg2.fix_flow_x10 > 0 ){
+                               //按参数设定值作为目标流量,不考虑焊接电流
+                               g_dev.target_flowspeed = g_dev.cfg2.fix_flow_x10/10.0f;
+                       }else if( calc_target_flow( &target_flowspeed )== 0 ){
                 //控制流量输出, 按焊接电流和节气因子计算目标流量
                 g_dev.target_flowspeed = target_flowspeed;
             }