From: kyz Date: Tue, 19 Aug 2025 02:46:01 +0000 (+0800) Subject: 增加比例阀控制电流调试接口 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=83611d9adc2be49ced4684265e246ba72346c7e5;p=yn%2Fweldingcontroller.git 增加比例阀控制电流调试接口 --- diff --git a/tools_v2/test.py b/tools_v2/test.py index ac875b5..75b2411 100644 --- a/tools_v2/test.py +++ b/tools_v2/test.py @@ -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 ) diff --git a/tools_v2/test.ui b/tools_v2/test.ui index 536354e..93e3702 100644 --- a/tools_v2/test.ui +++ b/tools_v2/test.ui @@ -6,7 +6,7 @@ 0 0 - 1352 + 1333 862 @@ -209,7 +209,7 @@ - Tab 1 + 设备状态 @@ -422,7 +422,7 @@ 80 - + 230 @@ -431,6 +431,15 @@ 31 + + 600 + + + 10 + + + 0 + Qt::Horizontal @@ -467,7 +476,7 @@ 90 0 - 441 + 381 61 @@ -533,7 +542,7 @@ - Tab 2 + 焊接电流调试 @@ -603,7 +612,7 @@ - 页 + 固件更新 @@ -915,7 +924,7 @@ - 页 + 参数 @@ -2045,7 +2054,7 @@ - 99.9 + 0 Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter @@ -2412,7 +2421,7 @@ 490 40 421 - 131 + 91 @@ -2422,7 +2431,7 @@ 10 - 60 + 30 71 31 @@ -2435,7 +2444,7 @@ 90 - 60 + 30 141 31 @@ -2451,7 +2460,7 @@ 330 - 40 + 10 81 71 @@ -2464,7 +2473,7 @@ 250 - 40 + 10 81 71 @@ -2478,9 +2487,9 @@ 490 - 190 + 140 421 - 131 + 91 @@ -2490,7 +2499,7 @@ 10 - 60 + 30 71 31 @@ -2503,7 +2512,7 @@ 90 - 60 + 30 141 31 @@ -2519,7 +2528,7 @@ 330 - 40 + 10 81 71 @@ -2532,7 +2541,7 @@ 250 - 40 + 10 81 71 @@ -2546,9 +2555,9 @@ 490 - 340 + 240 421 - 151 + 111 @@ -2558,7 +2567,7 @@ 20 - 90 + 70 51 31 @@ -2571,7 +2580,7 @@ 20 - 40 + 20 71 31 @@ -2584,7 +2593,7 @@ 330 - 40 + 20 81 71 @@ -2597,7 +2606,7 @@ 250 - 40 + 20 81 71 @@ -2610,7 +2619,7 @@ 100 - 40 + 20 131 31 @@ -2654,7 +2663,7 @@ 100 - 90 + 70 131 31 @@ -2694,9 +2703,9 @@ 490 - 510 + 360 421 - 151 + 111 @@ -2706,7 +2715,7 @@ 330 - 40 + 30 81 71 @@ -2719,7 +2728,7 @@ 250 - 40 + 30 81 71 @@ -2732,7 +2741,7 @@ 120 - 80 + 70 111 31 @@ -2748,7 +2757,7 @@ 10 - 30 + 20 131 31 @@ -2761,7 +2770,7 @@ 140 - 30 + 20 101 31 @@ -2775,7 +2784,7 @@ 490 - 670 + 470 421 61 @@ -2826,8 +2835,8 @@ - 20 - 660 + 490 + 540 421 101 @@ -2919,7 +2928,7 @@ - 页 + 在线操作 @@ -3125,6 +3134,90 @@ + + + + 290 + 30 + 231 + 201 + + + + 控制电流调试 + + + + + 150 + 10 + 71 + 51 + + + + 写入 + + + + + + 80 + 20 + 41 + 41 + + + + 200 + + + + + + 10 + 70 + 211 + 31 + + + + 200 + + + 100 + + + Qt::Horizontal + + + + + + 130 + 20 + 21 + 41 + + + + mA + + + + + + 10 + 20 + 51 + 41 + + + + 启用 + + + diff --git a/user/user.h b/user/user.h index f45495a..8eac30d 100644 --- a/user/user.h +++ b/user/user.h @@ -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采集 diff --git a/user/user_app.c b/user/user_app.c index 3fdf1b9..52b0d26 100644 --- a/user/user_app.c +++ b/user/user_app.c @@ -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 diff --git a/user/user_cdc_rx_2.c b/user/user_cdc_rx_2.c index 8595457..35b07a7 100644 --- a/user/user_cdc_rx_2.c +++ b/user/user_cdc_rx_2.c @@ -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 ){ diff --git a/user/user_lfs.c b/user/user_lfs.c index 350c0e4..e4375e8 100644 --- a/user/user_lfs.c +++ b/user/user_lfs.c @@ -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; } diff --git a/user/user_valve_ctrl.c b/user/user_valve_ctrl.c index cab668e..c742f2f 100644 --- a/user/user_valve_ctrl.c +++ b/user/user_valve_ctrl.c @@ -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 );