修改拧紧启动判断压力阈值为目标压力值
authorkyz <kongyuzhong@google.com>
Wed, 14 Jan 2026 05:57:28 +0000 (13:57 +0800)
committerkyz <kongyuzhong@google.com>
Wed, 14 Jan 2026 05:57:28 +0000 (13:57 +0800)
QiDong/APP/src/model.c
QiDong/BSP/src/bsp.c
QiDong/BSP/src/bsp_usart.c
QiDong/System/WrenchManage.c
QiDong/debug_tools/main.py

index ca6275b540e615d911649f10a61a3ccffa173d56..16babed9849dc9d5dea4d7c0515497b03330493f 100644 (file)
@@ -379,7 +379,15 @@ uint32_t setSensorPresetTorValVarFlag1(uint8_t Unit,uint32_t* presetvalue)
 //10 Period_Cnt    xishi  Y                                                                                          
 uint32_t getOutDutyData(float press)
 {
+#if 1
+       uint32_t duty;
+
+       duty = (press/10000/0.01*MAXMPA);  //Êä³ö¶ÔÓ¦µçѹµÄÕ¼¿Õ±È×°ÔØÖµ
+       duty += duty*5/100;  //TODO: ¹Ì¶¨¼Ó%5²¹³¥ÓÃÓÚ²âÊÔ£¬ ºóÃæ°´ÐèÒª¸Ä³É²ÎÊý¿ÉÅäÖÃ, 2026/1/13
+       return duty;
+#else
        return (press/10000/0.01*MAXMPA);  //Êä³ö¶ÔÓ¦µçѹµÄÕ¼¿Õ±È×°ÔØÖµ
+#endif
 
        /* ´úÂëÀí½â£º
                °´Ö®Ç°getPressValue¼ÆË㣬ÊäÈëµÄ²ÎÊýpressÊÇÄ¿±êŤ¾Ø/×î´óŤ¾Ø*10Íò£¬×î´óŤ¾Ø¶ÔÓ¦µ½Ñ¹Á¦6.25Bar£¬
@@ -533,7 +541,21 @@ uint32_t setBoltGradeValVarFlag (uint8_t*GardeNum,uint8_t*DiamNum,Computer_BoltD
                                strncpy((char*)ModifyVarStructVar.BoltGardeArr_M,(char*)Data->Metric_Grade[j],12);
                        }
                }       
+#if 1
+               //TODO: ¼ì²é¶ÔÓ¦²úÆ·ÐͺŵÄ×î´óÖµºÍ×îСֵ£¬³¬³ö·¶Î§µÄ·µ»Ø0
+               BoltTorqueVal = Data->Metric_parameter[*GardeNum-1][*DiamNum-1];  //µÃµ½Ö±¾¶ºÍµÈ¼¶¶ÔÓ¦µÄŤ¾ØÖµ
+               //range: [SpannerType[k].TorqueMinDate  SpannerType[k].TorqueMaxDate]
+               if( BoltTorqueVal < SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate
+                               || BoltTorqueVal > SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate ){
+
+                       printf( "BoltTorqueVal %d /(%d,%d)  -> 0\n", BoltTorqueVal,
+                                       SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate,
+                                       SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate );
+                       BoltTorqueVal = 0;
+               }
+#else
                BoltTorqueVal = Data->Metric_parameter[*GardeNum-1][*DiamNum-1];  //µÃµ½Ö±¾¶ºÍµÈ¼¶¶ÔÓ¦µÄŤ¾ØÖµ
+#endif
                return BoltTorqueVal;
        } 
        return BoltTorqueVal;
index d8e5694e8c250bbe3e721373f5bafc72851ae1ec..5ed7fcb2166878c62a3beda9a887c146089f1bf3 100644 (file)
@@ -249,7 +249,7 @@ static void test_5msTask(void)
        WrenchManage_MainTask();//°âÊÖ²Ù×÷ÈÎÎñ
        LED_5msMainFunction();//ledÈÎÎñ
        Beep_5msMainFunction();//·äÃùÆ÷ÈÎÎñ
-       if(turn_flag == 0)
+//     if(turn_flag == 0)
        {
                Screen_Sleep();
        }
index 0ca0519eb42923e7851285364880b16e20296416..5ba3c5ab1b5cf724364ca445f3e8c77d98403855 100644 (file)
@@ -501,7 +501,7 @@ u16 USART2Read(u8 *buf, u16 len)
 u8 USART2Write(u8 *buf ,u16 len)                                                           //·¢ËÍ
 {
        u16 i=0; 
-       for(i=0;i<=len;i++)
+       for(i=0;i<len;i++)
        {
                USART_SendData(USART2,buf[i]);                               //ͨ¹ýUSARTxÍâÉè·¢Ë͵¥¸öÊý¾Ý
 //             printf("%c",buf[i]);
index 7ac48c759b8a7dd8c15a3ba3b8e8908f1dc0b5f2..62d09bd7345d31acec9c421f3ac8ba3fd561a008 100644 (file)
@@ -13,8 +13,9 @@
 #define FLOW_COVERT_VALUE  4.6154      //ѹÁ¦ÓëÆøÁ¿µÄת»»ÏµÊý   1.3bar-6m3/h      6.5bar-30m3/h     30/6.5Ô¼=4.6154
 //#define ENABLE_FLOW    //Çø·Ö²úÆ·ÊÇ·ñ´øÆøÁ¿´«¸ÐÆ÷£¬
 /**********************************************************************************************************/
-static uint8_t machine_step = 0;
-static float compareFac = 0.90;
+static uint8_t machine_step = 8;
+//static float compareFac = 0.90;
+#define compareFac  0.85 // ¸Ä³É85%£¬ 2026/1/13
 float temppress = 0 ;
 float firstpress = 0;
 float ADCGetPress[10] = {0.0};
@@ -215,10 +216,38 @@ static void Machine_DoPress(void)                                     //״̬
        static uint16_t delay_cnt = 0;
        ADCGetPress[0] = GetPress();                            //ADC²»¶Ï²É¼¯Ñ¹Á¦
        ADCGetFlow[0] = GetFlow(); 
+       qiya = ADCGetPress[0]*10000;
+
        switch(machine_step)
        {
+               case 8:
+                       //ÆøÑ¹µÍµÈ´ýÆøÑ¹»Ö¸´×´Ì¬
+                       if( qiya > temppress * compareFac ){
+                               Matchine_SetMachine(0);
+                       }
+                       break;
+
                case 0: 
-                       ADCGetPress[0] = GetPress();
+
+#if 1
+                       if(qiya < (temppress) * compareFac && SleepState == 1 && niujupress == 0 && Adjusting_torque_flag == 1) //°âÊÖ°´Ï  ÕâÀïÈç¹ûÏÖ³¡ÆøÑ¹Ò»Ö±±È½ÏµÍ£¬ÉèÖõÄѹÁ¦Èç¹û¸ß  ¾ÍûÓа취¼ì²âµ½°âÊÖ°´ÏµÄ״̬
+                       {
+                               turn_flag = 1;
+                               if(wrench_device.rotate_start_count++ >= ROTATE_START_NUM_5MS)
+                               {
+                                       LED_SetLedStatus(LED_ID_DETECT_WORK,1);      //LED¼ì²â¹¤×÷״̬µÆÁÁ
+                                       Beep_SetbeepStatus(BEEP_ID_DETECT_WORK,1);   //·äÃùÆ÷¼ì²â¹¤×÷״̬Ïì
+                                       Matchine_SetMachine(1);                      //Çл»×´Ì¬»úÒ³Ãæ
+                                       wrench_device.rotate_start_count = 0;
+                                       wrench_device.rotate_work_timeout_count = 0;
+                               }
+                       }
+                       else
+                       {
+                               wrench_device.rotate_start_count = 0;
+                               turn_flag = 0;
+                       }
+#else
                        if(temppress > 20000)
                        {
                                qiya = ADCGetPress[0]*10000;
@@ -283,6 +312,8 @@ static void Machine_DoPress(void)                                     //״̬
                                }
                                //printf("state machine:%d\r\n",machine_step);
                        }
+               
+#endif
                        break; 
                        
                case 1:  
@@ -441,7 +472,7 @@ static void Machine_DoPress(void)                                     //״̬
                        if(delay_cnt ++ >= 600)
                        {
                                delay_cnt = 0;
-                               Matchine_SetMachine(0);
+                               Matchine_SetMachine(8);
                                wrench_device.wrench_device_status = DEVICE_STANDBY;
                                //printf("state machine:%d\r\n",machine_step);
                                turn_flag = 0;
@@ -748,7 +779,9 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                        Ret = 1;
 
                                }
-                       }break;
+                       }
+
+                       break;
 
                case 2: 
                        if(First[2] == 0)                           //ÂÝ˨ģʽ
@@ -909,6 +942,22 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                }
                        }break;                          
        }
+#if 1
+       {
+               //ÆôÍ£ãÐÖµÐÞ¸ÄΪĿ±êŤ¾Ø¶ÔÓ¦µÄѹÁ¦
+               //SetPress_TorqueÊǶÔÓ¦×î´óŤ¾ØµÄѹÁ¦6.25BarµÄ±ÈÀýÖµ*100000£¬ÕâÀï x 6.25Bar ¼ÆËãµÃµ½Ä¿±êѹÁ¦Öµ
+               //ºóÃæ±È½ÏµÄÖµÊÇadc¶ÁÈ¡µ½Ñ¹Á¦ÓÖ³ËÒÔ10000£¬ ËùÒÔÕâÀïºóÃæÓÖ³ËÒÔ10000.
+               if( mode == 1 ){
+                               temppress = ResetPress.SetPress_Torque/100000 * 6.25 * 10000;
+               }else if( mode == 2 ){
+                               temppress = ResetPress.SetPress_Bolt/100000 * 6.25 * 10000;
+               }else if( mode == 3 ){
+                               temppress = ResetPress.SetPress_Gear/100000 * 6.25 * 10000;
+               }else {
+
+               }
+       }
+#endif
        return Ret;
 }
 
index 614dc50aecc9c201760bc40a5b6be78a7d6389ed..9f77cd855447b7979131194bfc6724ad5a0f5214 100644 (file)
@@ -250,7 +250,7 @@ class page_devst( QWidget, ui_devst.Ui_Form):
 
             if self.ui_update_counter >= self.ui_update_interval or (current_time - self.last_update_time > 0.1):
                 # 更新表格
-                step_str = [u"0.待机",u"1.启动", u"2.", u"3.", u"4.", u"5.",u"6.通知", u"7.结束"]
+                step_str = [u"0.待机",u"1.启动", u"2.", u"3.", u"4.", u"5.",u"6.通知", u"7.结束", u"8.其他"]
                 self.tableWidget_devinfo.item(0, 0).setText(f"{tick*5/1000:.3f}")
                 self.tableWidget_devinfo.item(0, 1).setText(f"{target/10.0*6.25:.3f}")
                 self.tableWidget_devinfo.item(0, 2).setText(f"{thresold:.3f}")