增加比例阀控制电流调试接口
authorkyz <kongyuzhong@google.com>
Tue, 19 Aug 2025 02:46:01 +0000 (10:46 +0800)
committerkyz <kongyuzhong@google.com>
Tue, 19 Aug 2025 03:23:50 +0000 (11:23 +0800)
tools_v2/test.py
tools_v2/test.ui
user/user.h
user/user_app.c
user/user_cdc_rx_2.c
user/user_lfs.c
user/user_valve_ctrl.c

index ac875b5700e3dd48d61e884fbf9b876afbafca95..75b2411ae9be48fb454908bf8d74f64732ce5db7 100644 (file)
@@ -45,7 +45,7 @@ class App( QDialog, ui_welding.Ui_Dialog ):
     def __init__( self ):
         super().__init__()
         self.setupUi(self)
-        self.setWindowTitle( u"焊接控制器调试工具 V0.10")
+        self.setWindowTitle( u"焊接控制器调试工具 V1.0")
 
         self.trigger_rx_pkt.connect( self.on_rx_pkt )
         self.trigger_ctrl_write.connect( self.on_ctrl_write_signal )
@@ -66,6 +66,11 @@ class App( QDialog, ui_welding.Ui_Dialog ):
         #self.btn_download.released.connect( lambda:self.on_btn_connect(3))
         self.btn_connect_update.released.connect( lambda:self.on_btn_connect(3))
 
+        self.cb_debug_valve_curr.stateChanged.connect( self.on_cb_debug_valve_curr )
+        self.btn_debug_valve_curr.released.connect( self.on_btn_debug_write )
+        self.btn_debug_valve_curr.setEnabled(0)
+        self.slider_debug_valve_curr.valueChanged.connect( lambda value:self.line_debug_valve_curr.setText( str(value) ))
+        self.slider_debug_welding_curr.valueChanged.connect( lambda value:self.lineEdit_debug_value.setText( str(value) ))
         ###self.cbx_debug.release
         #self.cbx_debug.stateChanged.connect( lambda:self.on_cbx_debug() )
         self.cb_weld_curr_debug.stateChanged.connect( self.on_cb_weld_curr_debug )
@@ -464,16 +469,30 @@ class App( QDialog, ui_welding.Ui_Dialog ):
             self.close_debug_mode()
             self.btn_debug_write.setEnabled(0)
             self.debug_mode = 0
+
+    def on_cb_debug_valve_curr(self):
+        if self.cb_debug_valve_curr.isChecked():
+            self.btn_debug_valve_curr.setEnabled(1)
+            self.debug_mode = 2
+        else:
+            self.close_debug_mode()
+            self.btn_debug_valve_curr.setEnabled(0)
+            self.debug_mode = 0
+        self.btn_debug_valve_curr.setStyleSheet( "background-color: green" if self.debug_mode==2 else "background-color: lightgray" )
+
     def on_btn_debug_write( self ):
         if self.ser_opened:
-            curr = int( self.lineEdit_debug_value.text() )
-            print( 'curr', curr, 'debug_mode', self.debug_mode )
             if self.debug_mode == 1:
+                curr = int( self.lineEdit_debug_value.text() )
+                print( 'tx welding curr', curr, 'debug_mode', self.debug_mode )
                 cmd = self.wrap_welding_curr_pkt( curr )
                 self.ser.write( cmd  )
             elif self.debug_mode == 2:
-                cmd = self.wrap_valve_curr_pkt( curr )
-                self.ser.write( cmd  )
+                curr_ma = int( self.line_debug_valve_curr.text() )
+                if curr_ma >= 0 and curr_ma <= 200:
+                    print( 'tx valve curr', curr_ma, 'mA, debug_mode', self.debug_mode )
+                    cmd = self.wrap_valve_curr_pkt( curr_ma )
+                    self.ser.write( cmd  )
 
     def on_table_select( self, index ):
         print( "on table select ", index )
index 536354e36da13f3565c2ee8403d1f56ca0c1b5bb..93e370227525baa77d0a378e6783e0c69c627ee2 100644 (file)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1352</width>
+    <width>1333</width>
     <height>862</height>
    </rect>
   </property>
     </property>
     <widget class="QWidget" name="tab">
      <attribute name="title">
-      <string>Tab 1</string>
+      <string>设备状态</string>
      </attribute>
      <widget class="QFrame" name="frame_curr">
       <property name="geometry">
         <string>80</string>
        </property>
       </widget>
-      <widget class="QSlider" name="horizontalSlider">
+      <widget class="QSlider" name="slider_debug_welding_curr">
        <property name="geometry">
         <rect>
          <x>230</x>
          <height>31</height>
         </rect>
        </property>
+       <property name="maximum">
+        <number>600</number>
+       </property>
+       <property name="pageStep">
+        <number>10</number>
+       </property>
+       <property name="value">
+        <number>0</number>
+       </property>
        <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
        <rect>
         <x>90</x>
         <y>0</y>
-        <width>441</width>
+        <width>381</width>
         <height>61</height>
        </rect>
       </property>
     </widget>
     <widget class="QWidget" name="tab_2">
      <attribute name="title">
-      <string>Tab 2</string>
+      <string>焊接电流调试</string>
      </attribute>
      <widget class="QFrame" name="frame_curr_raw">
       <property name="geometry">
     </widget>
     <widget class="QWidget" name="tab_3">
      <attribute name="title">
-      <string>页</string>
+      <string>固件更新</string>
      </attribute>
      <widget class="QGroupBox" name="groupBox_3">
       <property name="geometry">
     </widget>
     <widget class="QWidget" name="tab_4">
      <attribute name="title">
-      <string>页</string>
+      <string>参数</string>
      </attribute>
      <widget class="QPushButton" name="btn_debug_write_2">
       <property name="geometry">
           </rect>
          </property>
          <property name="text">
-          <string>99.9</string>
+          <string>0</string>
          </property>
          <property name="alignment">
           <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
           <x>490</x>
           <y>40</y>
           <width>421</width>
-          <height>131</height>
+          <height>91</height>
          </rect>
         </property>
         <property name="title">
          <property name="geometry">
           <rect>
            <x>10</x>
-           <y>60</y>
+           <y>30</y>
            <width>71</width>
            <height>31</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>90</x>
-           <y>60</y>
+           <y>30</y>
            <width>141</width>
            <height>31</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>330</x>
-           <y>40</y>
+           <y>10</y>
            <width>81</width>
            <height>71</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>250</x>
-           <y>40</y>
+           <y>10</y>
            <width>81</width>
            <height>71</height>
           </rect>
         <property name="geometry">
          <rect>
           <x>490</x>
-          <y>190</y>
+          <y>140</y>
           <width>421</width>
-          <height>131</height>
+          <height>91</height>
          </rect>
         </property>
         <property name="title">
          <property name="geometry">
           <rect>
            <x>10</x>
-           <y>60</y>
+           <y>30</y>
            <width>71</width>
            <height>31</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>90</x>
-           <y>60</y>
+           <y>30</y>
            <width>141</width>
            <height>31</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>330</x>
-           <y>40</y>
+           <y>10</y>
            <width>81</width>
            <height>71</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>250</x>
-           <y>40</y>
+           <y>10</y>
            <width>81</width>
            <height>71</height>
           </rect>
         <property name="geometry">
          <rect>
           <x>490</x>
-          <y>340</y>
+          <y>240</y>
           <width>421</width>
-          <height>151</height>
+          <height>111</height>
          </rect>
         </property>
         <property name="title">
          <property name="geometry">
           <rect>
            <x>20</x>
-           <y>90</y>
+           <y>70</y>
            <width>51</width>
            <height>31</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>20</x>
-           <y>40</y>
+           <y>20</y>
            <width>71</width>
            <height>31</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>330</x>
-           <y>40</y>
+           <y>20</y>
            <width>81</width>
            <height>71</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>250</x>
-           <y>40</y>
+           <y>20</y>
            <width>81</width>
            <height>71</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>100</x>
-           <y>40</y>
+           <y>20</y>
            <width>131</width>
            <height>31</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>100</x>
-           <y>90</y>
+           <y>70</y>
            <width>131</width>
            <height>31</height>
           </rect>
         <property name="geometry">
          <rect>
           <x>490</x>
-          <y>510</y>
+          <y>360</y>
           <width>421</width>
-          <height>151</height>
+          <height>111</height>
          </rect>
         </property>
         <property name="title">
          <property name="geometry">
           <rect>
            <x>330</x>
-           <y>40</y>
+           <y>30</y>
            <width>81</width>
            <height>71</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>250</x>
-           <y>40</y>
+           <y>30</y>
            <width>81</width>
            <height>71</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>120</x>
-           <y>80</y>
+           <y>70</y>
            <width>111</width>
            <height>31</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>10</x>
-           <y>30</y>
+           <y>20</y>
            <width>131</width>
            <height>31</height>
           </rect>
          <property name="geometry">
           <rect>
            <x>140</x>
-           <y>30</y>
+           <y>20</y>
            <width>101</width>
            <height>31</height>
           </rect>
         <property name="geometry">
          <rect>
           <x>490</x>
-          <y>670</y>
+          <y>470</y>
           <width>421</width>
           <height>61</height>
          </rect>
        <widget class="QGroupBox" name="groupBox_25">
         <property name="geometry">
          <rect>
-          <x>20</x>
-          <y>660</y>
+          <x>490</x>
+          <y>540</y>
           <width>421</width>
           <height>101</height>
          </rect>
     </widget>
     <widget class="QWidget" name="tab_9">
      <attribute name="title">
-      <string>页</string>
+      <string>在线操作</string>
      </attribute>
      <widget class="QGroupBox" name="groupBox_20">
       <property name="geometry">
        </property>
       </widget>
      </widget>
+     <widget class="QGroupBox" name="groupBox_debug_valve_curr">
+      <property name="geometry">
+       <rect>
+        <x>290</x>
+        <y>30</y>
+        <width>231</width>
+        <height>201</height>
+       </rect>
+      </property>
+      <property name="title">
+       <string>控制电流调试</string>
+      </property>
+      <widget class="QPushButton" name="btn_debug_valve_curr">
+       <property name="geometry">
+        <rect>
+         <x>150</x>
+         <y>10</y>
+         <width>71</width>
+         <height>51</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>写入</string>
+       </property>
+      </widget>
+      <widget class="QLineEdit" name="line_debug_valve_curr">
+       <property name="geometry">
+        <rect>
+         <x>80</x>
+         <y>20</y>
+         <width>41</width>
+         <height>41</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>200</string>
+       </property>
+      </widget>
+      <widget class="QSlider" name="slider_debug_valve_curr">
+       <property name="geometry">
+        <rect>
+         <x>10</x>
+         <y>70</y>
+         <width>211</width>
+         <height>31</height>
+        </rect>
+       </property>
+       <property name="maximum">
+        <number>200</number>
+       </property>
+       <property name="value">
+        <number>100</number>
+       </property>
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+      <widget class="QLabel" name="label_debug_curr_unit_4">
+       <property name="geometry">
+        <rect>
+         <x>130</x>
+         <y>20</y>
+         <width>21</width>
+         <height>41</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>mA</string>
+       </property>
+      </widget>
+      <widget class="QCheckBox" name="cb_debug_valve_curr">
+       <property name="geometry">
+        <rect>
+         <x>10</x>
+         <y>20</y>
+         <width>51</width>
+         <height>41</height>
+        </rect>
+       </property>
+       <property name="text">
+        <string>启用</string>
+       </property>
+      </widget>
+     </widget>
     </widget>
     <widget class="QWidget" name="tab_10">
      <attribute name="title">
index f45495a3c9ffe4e25362603c7e360f9ebeb7144d..8eac30d1efc766d4f57f0195f59ad24aaf7d44e9 100644 (file)
@@ -33,6 +33,8 @@
 #define HW_V3  3
 #define HW_V4  4
 
+#define REPORT_POWER_ON_TOTAL_TIME  0  //统计和报告开机总时长
+
 #define WELDING_START_CURRENT     15.0f    //15A为启动电流
 
 #define VOL            0.01f
@@ -254,7 +256,7 @@ typedef struct {
 
        //调试功能
        uint32_t debug_report; //主动上报数据, 0:关闭, 1:上报控制信息, 2:上报焊接电流信息
-       uint32_t debug_curr;    //模拟数据, 0:关闭, 1:模拟焊接电流
+       uint32_t debug_curr;    //模拟数据, 0:关闭, 1:模拟焊接电流, 2,比例阀控制电流调试输出
        float debug_welding_curr; //模拟焊接电流 A
 
        uint32_t wifi_connected; //0:disconnect, 1:wifi connected, 2:tcp connected
@@ -268,6 +270,8 @@ typedef struct {
 
        uint32_t offline_secs; //offline time; 没有rtc电池,计算的离线累计通电时间,1分钟保存一次
        uint32_t offline_locked; //0:unlocked, 1:locked
+
+       float debug_valve_curr; //0--0.2A 调试输出比例阀输出电流
 }dev_info_t;
 
 extern TIM_HandleTypeDef htim2;   //htim2 用于触发DMA ADC采集
index 3fdf1b97d2893733d6ab2bd54c98726ec58bb68b..52b0d26ce287f2792e5c5fbd8b52a85898578a74 100644 (file)
@@ -702,7 +702,9 @@ uint32_t hw_ver_read( void )
     }
 }
 
-void device_poweron_total_time_update( uint32_t secs ){
+void device_poweron_total_time_update( uint32_t secs )
+{
+#if REPORT_POWER_ON_TOTAL_TIME
        static int n = 0;
        static int welding = 0;
        n++;
@@ -717,4 +719,5 @@ void device_poweron_total_time_update( uint32_t secs ){
                n = 0;
                lfs_store_all_time(g_dev.all_time_total);
        }
+#endif //REPORT_POWER_ON_TOTAL_TIME
 }
\ No newline at end of file
index 859545787e751aa3ed00f7d766b1f648570fbbb6..35b07a7bd5e9f216933b33e3199e3397d819bffb 100644 (file)
@@ -361,9 +361,9 @@ int32_t handle_cdc_pkt( cdc_pkt_t *pkt )
             g_dev.debug_curr = 1;
             break;
         case 0x00f2:
-            //写比例阀控制电流, 取消
-            //g_dev.debug_valve_curr = get_u32_big( pkt->pdata )/1000.0f;
-            //g_dev.debug_curr = 2;
+            //写比例阀控制电流
+            g_dev.debug_valve_curr = get_u32_big( pkt->pdata )/1000.0f;
+            g_dev.debug_curr = 2;
             break;
         case 0x0022:
             if( pkt->data_len >=4 ){
index 350c0e488fd665a617512cd8980269e9f3018c10..e4375e8327e0e0e138cae4570359e84ca6282527 100644 (file)
@@ -207,9 +207,11 @@ int32_t lfs_store_device_serial( char *sn )
 uint32_t lfs_load_all_time(void)
 {
        uint32_t secs = 0;
+#if REPORT_POWER_ON_TOTAL_TIME
        if( user_lfs_read( ALL_TIME_PATH, (uint8_t*)&secs, sizeof( secs ) ) == sizeof( secs ) ){
         
     }
+#endif
     return secs;
 }
 
index cab668e793e88f4d76cd09759a17d7869be0c77f..c742f2fcb578d515e8de81cddb8d67c4b40933da 100644 (file)
@@ -635,6 +635,12 @@ void user_valve_ctrl_task( void* unused )
                                                }
                                }
 
+#if 1
+               //"调试比例阀驱动电流调节"
+               if( g_dev.debug_curr == 2 ){
+                       g_dev.valve_curr_out = g_dev.debug_valve_curr;
+               }
+#endif
         //更新比例阀驱动电流
         user_valve_set_current( g_dev.valve_curr_out );