扭矩压力计算扭矩范围判断等功能修改
authorkyz <kongyuzhong@google.com>
Wed, 21 Jan 2026 08:39:56 +0000 (16:39 +0800)
committerkyz <kongyuzhong@google.com>
Wed, 21 Jan 2026 08:39:56 +0000 (16:39 +0800)
QiDong/APP/inc/model.h
QiDong/APP/src/menu.c
QiDong/APP/src/model.c
QiDong/APP/src/screen_app.c
QiDong/System/WrenchManage.c

index 85e20ae0182cac1500246fc3e10e3b540dbd08ee..b18aebeaa4423e72a9e383afe488bc7265236af3 100644 (file)
@@ -70,6 +70,7 @@ void AdjustGearMode(void);
 void AdjustAngleMode(void);
 void AdjustSensorMode(void);
 
+float tor_to_pressure(uint32_t tor);
 
 extern uint32_t getOutDutyData(float press);
 extern float getPressValue(uint32_t factor,uint32_t torquevalue);
index 0ba583b134e41f82ee2a61f1b2034e1dc230c050..f1ee63b1c2e25d795ee4a5072664b85a1504935e 100644 (file)
@@ -558,8 +558,7 @@ void KEY_MENU3_Bolt_Var(uint8_t Flag, e_Var_Modify VariableMode)
                                SetTextInt32(2,5,        ROUND_TO_UINT32(ModifyVarStructVar.TartorVal_BoltMode/COEFFICIENT),0,0);
                                SetTextValue(2,4,(uint8_t*)"ft.lbs"); 
                        }
-//                     ResetPress.SetPress_Bolt = getPressValue(TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor,ModifyVarStructVar.TartorVal_BoltMode);  //ÂÝ˨ģʽĿ±êŤ¾ØÖµµÃµ½Ä¿±êѹÁ¦Öµ
-                   ResetPress.SetPress_Bolt = getPressValue(SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate,ModifyVarStructVar.TartorVal_BoltMode);
+                       ResetPress.SetPress_Bolt = tor_to_pressure( ModifyVarStructVar.TartorVal_BoltMode );
                        break;
                                                                                                                                        
        /*------------------------µ÷ÕûÂÝ˨ǿ¶ÈµÈ¼¶£º---------------------------------------------------------*/                                                                                                                                 
@@ -607,7 +606,7 @@ void KEY_MENU3_Bolt_Var(uint8_t Flag, e_Var_Modify VariableMode)
                                SetTextInt32(2,5,ROUND_TO_UINT32(ModifyVarStructVar.TartorVal_BoltMode/COEFFICIENT),0,0);
                                SetTextValue(2,4,(uint8_t*)"ft.lbs"); 
                        }
-                       ResetPress.SetPress_Bolt = getPressValue(SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate,ModifyVarStructVar.TartorVal_BoltMode);
+                       ResetPress.SetPress_Bolt = tor_to_pressure( ModifyVarStructVar.TartorVal_BoltMode );
                        break;
 
        /*------------------------µ÷ÕûÂÝ˨Ŀ±êŤ¾Øµ¥Î»£º-------------------------------------------------------*/                               
@@ -729,10 +728,7 @@ void KEY_MENU4_Gear_Var(uint8_t Flag, e_Var_Modify VariableMode)
                                SetTextValue(4,3,(uint8_t*)"ft.lbs");
                                SetTextInt32(4,5, ROUND_TO_UINT32(ModifyVarStructVar.geartor/COEFFICIENT),0,0);
                        }
-                       
-                       ///ResetPress.SetPress_Gear = ModifyVarStructVar.gearpress*10;
-                       ResetPress.SetPress_Gear = getPressValue(SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate,ModifyVarStructVar.geartor);
-                       
+                       ResetPress.SetPress_Gear = tor_to_pressure( ModifyVarStructVar.geartor );
                        break;                                                          
        /*------------------------µ÷ÕûµµÎ»Ä£Ê½µÄÄ¿±êŤ¾Øµ¥Î»£º----------------------------------------------------*/                                                                                                                            
            case GearTargetTorUintValFlag : 
index a5130fcef7d9fe5d203f47b6162e6be5bb299f06..e30c930729372439c37e2df29b5948dee2a26491 100644 (file)
@@ -246,49 +246,19 @@ void AdjustSensorMode(void)
 float setTargetTorqueValVarFlag(uint8_t TorqueUint,uint32_t *targetTorVal)  
 {
        float press = 0;
-       #ifdef MYOLD
-//     if(*targetTorVal < (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*0.125))              //µ÷½Ú²úƷŤ¾ØÖµ
-       if(*targetTorVal < (SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate))
-       {
-//             *targetTorVal = (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*0.125);
-               *targetTorVal = SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate;
-       }
-//     if(*targetTorVal > (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*MAXMPA))   
-       if(*targetTorVal > (SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate))
-       {
-//             *targetTorVal = (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*MAXMPA);
-               *targetTorVal = SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate;
-       }                       
-       #endif
 
-       #ifdef MYNEW
        if(*targetTorVal < (SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate))
        {
-//             *targetTorVal = (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*0.125);
                *targetTorVal = SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate ;
        }
-//     if(*targetTorVal > (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*MAXMPA))   
        if(*targetTorVal > (SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate))
        {
-//             *targetTorVal = (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*MAXMPA);
                *targetTorVal = SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate ;
        }
-//     if(*targetTorVal >= (SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate) && *targetTorVal <= (SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate))
-//     {
-//             *targetTorVal = *targetTorVal * (MAXMPA);
-//             
-//     }
-       
-       #endif
-//     press = getPressValue(TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor,*targetTorVal);  //Ť¾ØÄ£Ê½É趨Ŀ±êŤ¾ØÖµµÃµ½Ä¿±êѹÁ¦Öµ
-       press = getPressValue(SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate,*targetTorVal);
-       
+       press = tor_to_pressure( *targetTorVal );
        return press;                                                   
 }      
 
-
-
-
 /*
 **************************************************************************
 *      º¯ Êý Ãû: setSensorPresetTorValVarFlag
@@ -300,38 +270,15 @@ float setTargetTorqueValVarFlag(uint8_t TorqueUint,uint32_t *targetTorVal)
 uint32_t setSensorPresetTorValVarFlag(uint8_t Unit,uint32_t* presetvalue)
 {
        uint32_t press = 0;
-       #ifdef MYOLD
-//     if(*targetTorVal < (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*0.125))              //µ÷½Ú²úƷŤ¾ØÖµ
-       if(*presetvalue < (SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate))
-       {
-//             *targetTorVal = (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*0.125);
-               *presetvalue = SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate;
-       }
-//     if(*targetTorVal > (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*MAXMPA))   
-       if(*presetvalue > (SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate))
-       {
-//             *targetTorVal = (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*MAXMPA);
-               *presetvalue = SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate;
-       }       
-       #endif
-       
-       #ifdef MYNEW
        if(*presetvalue < (SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate))
        {
-//             *targetTorVal = (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*0.125);
                *presetvalue = SpannerType[ModifyVarStructVar.fabricName-1].TorqueMinDate;
        }
-//     if(*targetTorVal > (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*MAXMPA))   
        if(*presetvalue > (SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate ))
        {
-//             *targetTorVal = (TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*MAXMPA);
                *presetvalue = SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate ;
        }       
-       #endif
-
-//     press = getPressValue(TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor,*targetTorVal);  //Ť¾ØÄ£Ê½É趨Ŀ±êŤ¾ØÖµµÃµ½Ä¿±êѹÁ¦Öµ
-       press = getPressValue(ModifyVarStructVar.TartorVal_TorMode,*presetvalue);
-       
+       press = tor_to_pressure( *presetvalue );
        return press;
 }
  
@@ -347,7 +294,7 @@ uint32_t setSensorPresetTorValVarFlag1(uint8_t Unit,uint32_t* presetvalue)
                *presetvalue = SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate;
        }
        
-       press = getPressValue(ModifyVarStructVar.TartorVal_TorMode,*presetvalue);
+       press = tor_to_pressure( *presetvalue );
        
        return press;
 }
@@ -419,6 +366,42 @@ float getPressValue(uint32_t factor,uint32_t torquevalue)
 //     return (torquevalue * 100000);
 }
 
+//Ť¾Ø»»Ëã³ÉѹÁ¦£¬°´²ÎÊý±í²éÕÒ×îСŤ¾Ø/ѹÁ¦ºÍ×î´óŤ¾ØÑ¹Á¦£¬½«ÊäÈë²ÎÊýŤ¾Ø»»Ëã³ÉѹÁ¦·µ»Ø
+float tor_to_pressure(uint32_t tor)
+{
+       //ÊäÈëtor²ÎÊýÊÇN.m£¬·µ»ØÖµµ¥Î»ÊÇBar
+
+       uint32_t tor_min, tor_max;
+       float press_min, press_max;
+       SpannerType_t *spanner;
+       int i;
+
+       if( tor == 0 )
+               return 0.0;
+
+       spanner = &SpannerType[ModifyVarStructVar.fabricName-1];
+
+       tor_max = spanner->TorqueMaxDate;
+       tor_min  = spanner->TorqueMinDate;
+       press_min = 6.25* spanner->TorqueMinDate/spanner->TorqueMaxDate;
+       press_max = 6.25;
+
+       for( i = 0; i < TORQUE_POINT_MUN; i++)
+       {
+               if( spanner->TorqueDate[i] == tor_max )
+               {
+                       press_max = spanner->WorkingMedium[i]/1000;
+               }else if( spanner->TorqueDate[i] == tor_min )
+               {
+                       press_min = spanner->WorkingMedium[i]/1000;
+               }
+       }
+
+       if( tor < tor_min || tor > tor_max )
+               return 0;
+
+       return  press_min + (press_max - press_min) * (tor - tor_min) / (tor_max - tor_min);
+}
 /*
 **************************************************************************
 *      º¯ Êý Ãû: setBoltGradeValVarFlag
index 685c1d908439e9888cb3bd60d847e86b6208fe06..217c853b7e35808b1ec66ff0d692b51105d27b64 100644 (file)
@@ -1552,7 +1552,8 @@ void MemuThree(void)
                SetTextValue(2,3,(uint8_t*)ModifyVarStructVar.BoltGardeArr_M);
        }
 
-       ResetPress.SetPress_Bolt = getPressValue(SpannerType[ModifyVarStructVar.fabricName-1].TorqueMaxDate,ModifyVarStructVar.TartorVal_BoltMode);
+       ResetPress.SetPress_Bolt = tor_to_pressure( ModifyVarStructVar.TartorVal_BoltMode );
+
        PressMem = 1;   
        if(SaveFlag[ScreenMem] == 0)
        {
index 510f5477558764e8add0421afae208d049c32767..23517ee9e511e25f625756d00c4e3770e4c440c5 100644 (file)
@@ -59,8 +59,9 @@ float getMaxPressure( void )
 }
 
 /*¼ÆËãѹÁ¦·§Êä³öÖµ¶ÔÓ¦pwmÕ¼¿Õ±È*/
-static uint16_t  getOutDutyData_from_pressure(float press_ratio )
+static uint16_t  getOutDutyData_from_pressure(float press )
 {
+#if 0
        /*¸ù¾ÝѹÁ¦Öµ¼ÆËãpwmÕ¼¿Õ±È, TIM4 CH2 ÖÜÆÚ1000£¬Êä³öccr Êä³ö×î´óÖµ1000 ¶ÔÓ¦10.0Bar£¬ Êä³ö 625 Ôò¶ÔÓ¦6.26Bar*/
        /* ÊäÈë²ÎÊýÊÇÄ¿±êŤ¾Ø¶ÔÓ¦×î´óŤ¾ØµÄ±ÈÀýÖµ*/
        float max_pressure;
@@ -78,6 +79,16 @@ static uint16_t  getOutDutyData_from_pressure(float press_ratio )
        //duty CCR£º ccr/1000 = Ä¿±êѹÁ¦/10bar£¬ ccr = Ä¿±êѹÁ¦*1000/10bar
        duty = target_pressure*1000.0/10.0;
 
+#else
+       //Êä³ö²ÎÊýΪѹÁ¦Öµ£¬µ¥Î»Bar
+       uint32_t duty;
+
+       if( press > 10.0 )
+               return 0;
+
+       duty = press/10.0 *1000;
+#endif
+
        //TODO: ¹Ì¶¨¼Ó%5²¹³¥ÓÃÓÚ²âÊÔ£¬ ºóÃæ°´ÐèÒª¸Ä³É²ÎÊý¿ÉÅäÖÃ, 2026/1/13
        duty += duty*5/100;
        return duty;
@@ -99,19 +110,19 @@ void Sys_setpress(uint8_t mode)
                        TIM_SetCompare2(TIM4, 0);
                break;
                case 1:
-                       TIM_SetCompare2(TIM4, getOutDutyData_from_pressure(ResetPress.SetPress_Torque/100000.0));
+                       TIM_SetCompare2(TIM4, getOutDutyData_from_pressure(ResetPress.SetPress_Torque));
                break;
                case 2:
-                       TIM_SetCompare2(TIM4, getOutDutyData_from_pressure(ResetPress.SetPress_Bolt/100000.0));
+                       TIM_SetCompare2(TIM4, getOutDutyData_from_pressure(ResetPress.SetPress_Bolt));
                break;
                case 3:
-                       TIM_SetCompare2(TIM4, getOutDutyData_from_pressure(ResetPress.SetPress_Gear/100000.0));
+                       TIM_SetCompare2(TIM4, getOutDutyData_from_pressure(ResetPress.SetPress_Gear));
                break;
                case 4:
-                       TIM_SetCompare2(TIM4, getOutDutyData_from_pressure(ResetPress.SetPress_Angle/100000.0));
+                       TIM_SetCompare2(TIM4, getOutDutyData_from_pressure(ResetPress.SetPress_Angle));
                break;
                case 5:
-                       TIM_SetCompare2(TIM4, getOutDutyData_from_pressure(ResetPress.SetPress_Sensor/100000.0));
+                       TIM_SetCompare2(TIM4, getOutDutyData_from_pressure(ResetPress.SetPress_Sensor));
                break;
        }
 }
@@ -128,102 +139,6 @@ void Matchine_SetMachine(uint8_t step)
 {
     machine_step = step;
 }
-/*
-************************************************************************
-*      º¯ Êý Ãû: 
-*      ¹¦ÄÜ˵Ã÷: 
-*      ÐΠ   ²Î: ¿Õ
-*      ·µ »Ø Öµ: ¿Õ
-************************************************************************
-*/
-
-#ifdef NEW
-
-void Wrench_ErrCheck(void)
-{
-       ADCGetPress[0] = GetPress();                            //ADC²»¶Ï²É¼¯Ñ¹Á¦
-       ADCGetFlow[0] = GetFlow(); 
-       //error check
-    if(wrench_device.wrench_device_status == DEVICE_STANDBY && SleepState==1 ) //2025/12/30 Ôö¼ÓSleepState==1ÅжÏ
-       {
-
-               //press low check
-               if((ADCGetPress[0]*10000) < temppress)
-                       wrench_device.low_press_check_count++;
-               else
-                       wrench_device.low_press_check_count = 0;
-
-               if(wrench_device.low_press_check_count >= PRESS_ERR_NUM_5MS)
-               {
-                       wrench_device.low_press_check_count = 0;
-                       wrench_device.err_code |= DEVICE_PRESS_LOW_ERROR;
-               }
-#ifdef ENABLE_FLOW                             
-               //flow weakage check
-               if(ADCGetFlow[0] > temppress)
-                       wrench_device.leakage_flow_check_count++;
-               else
-                       wrench_device.leakage_flow_check_count = 0;
-
-               if(wrench_device.leakage_flow_check_count >= PRESS_ERR_NUM_5MS)
-               {
-                       wrench_device.leakage_flow_check_count = 0;
-                       wrench_device.err_code |= DEVICE_FLOW_LEAKAGE_ERROR;
-               }
-#endif
-               if(wrench_device.err_code != DEVICE_OK){
-                       if( wrench_device.wrench_device_status != DEVICE_ERROR ){
-                               printf( "----------------- wrench_device_status( errcode:%d ) --> DEVICE_ERROR\n", wrench_device.err_code );
-                       }
-                       wrench_device.wrench_device_status = DEVICE_ERROR;
-               }
-       }
-       
-       //State recovery
-       else if(wrench_device.wrench_device_status == DEVICE_ERROR && (wrench_device.err_code == DEVICE_PRESS_LOW_ERROR || wrench_device.err_code == DEVICE_FLOW_LEAKAGE_ERROR))
-       {
-
-               if((ADCGetPress[0]*10000) >= temppress)
-                       wrench_device.ok_press_check_count++;
-               else
-                       wrench_device.ok_press_check_count = 0;
-               if(wrench_device.ok_press_check_count >= PRESS_ERR_NUM_5MS)
-               {
-                       wrench_device.ok_press_check_count = 0;
-                       wrench_device.err_code &= (~DEVICE_PRESS_LOW_ERROR);
-                       wrench_device.wrench_device_status = DEVICE_STANDBY;
-               }
-#ifdef ENABLE_FLOW                             
-               //flow weakage check
-               if(ADCGetFlow[0] <= temppress)
-                       wrench_device.ok_flow_check_count++;
-               else
-                       wrench_device.ok_flow_check_count = 0;
-
-               if(wrench_device.ok_flow_check_count >= PRESS_ERR_NUM_5MS)
-               {
-                       wrench_device.ok_flow_check_count = 0;
-                       wrench_device.err_code &= (~DEVICE_FLOW_LEAKAGE_ERROR);
-               }
-#endif
-               if(wrench_device.err_code == DEVICE_OK)
-                       wrench_device.wrench_device_status = DEVICE_STANDBY;
-       }
-       else
-       {
-               wrench_device.low_press_check_count = 0;
-               wrench_device.ok_press_check_count = 0;
-               wrench_device.leakage_flow_check_count = 0;
-               wrench_device.ok_flow_check_count = 0;
-               
-               // restore state 2025/12/30 added by kyz.
-               if(wrench_device.err_code == DEVICE_OK && wrench_device.wrench_device_status == DEVICE_ERROR)
-                       wrench_device.wrench_device_status = DEVICE_STANDBY;
-       }
-
-}
-
-
 
 /*
 ************************************************************************
@@ -244,7 +159,7 @@ static void Machine_DoPress(void)                                     //״̬
        static uint16_t delay_cnt = 0;
        ADCGetPress[0] = GetPress();                            //ADC²»¶Ï²É¼¯Ñ¹Á¦
        ADCGetFlow[0] = GetFlow(); 
-       qiya = ADCGetPress[0]*10000;
+       qiya = ADCGetPress[0];
 
        switch(machine_step)
        {
@@ -282,9 +197,9 @@ static void Machine_DoPress(void)                                     //״̬
                                ucCount200ms = 0;                            //ÇåÁã
                 //Èç¹ûADC²É¼¯Ñ¹Á¦´óµÈÓÚÓû§É趨ѹÁ¦µÄ0.9 ²¢ÇҲɼ¯µÄÁ÷Á¿´óÓÚÉèÖõÄÁ÷Á¿µÄX%
 #ifdef ENABLE_FLOW                             
-                               if(((ADCGetPress[0]*10000)>= temppress*compareFac) &&  ((ADCGetFlow[0]*10000) >=UserSetFlow) )    
+                               if(((ADCGetPress[0])>= temppress*compareFac) &&  ((ADCGetFlow[0]*10000) >=UserSetFlow) )    
 #else
-                               if(((ADCGetPress[0]*10000)>= temppress*compareFac))    
+                               if(((ADCGetPress[0])>= temppress*compareFac))    
 #endif                         
                                {
                                        //ÒÔϼÆÊýROTATE_STOP_NUM_5MS Ëƺõ²»Õý³££¬ÒòÎªÇ°Ãæ»¹Óиö¼ÆÊýÆ÷MS_COUNT_200
@@ -295,7 +210,7 @@ static void Machine_DoPress(void)                                     //״̬
                                                //Flash_RecordData();
                                                printf("upUsingStructVar.UsingTimeupUsingStructVar.UsingTime\r\n");
                                                SysMemoryParaVar.tigresult = 1;  //±íʾš½ôÁË
-                                               SysMemoryParaVar.WorkPress = temppress /10000 *compareFac *100;
+                                               SysMemoryParaVar.WorkPress = temppress *compareFac *100;
 
                                                if(SaveFlag[UsingTimesMem] == 0)
                                                {
@@ -321,7 +236,7 @@ static void Machine_DoPress(void)                                     //״̬
                                        wrench_device.rotate_work_timeout_count = 0;    
                     SysMemoryParaVar.tigresult = 0;//³¬¹ý10SûÓдﵽĿ±ê ¾Í²»ºÏ¸ñ
                                        printf("disqualification!!!\r\n");
-                     if(ADCGetPress[0]*10000< temppress*compareFac)
+                     if(ADCGetPress[0]< temppress*compareFac)
                                         {
                                                LED_SetLedStatus(LED_ID_LOWER_FLOW,1);          
                                                Beep_SetbeepStatus(BEEP_ID_LOWER_FLOW,1);//¼ÓÉϵÍѹָʾ
@@ -396,226 +311,6 @@ static void Machine_DoPress(void)                                     //״̬
                        break;
        }
 }
-#else
-
-static void Machine_DoPress(void)                                     //״̬»ú²É¼¯Ñ¹Á¦
-{
-       static uint8_t ucCount200ms  = 0 ;
-       static uint16_t usCount10s = 0;
-       static uint8_t ucTrueCount = 0;
-       uint8_t led_buff[6];
-       uint8_t beep_buff[6];
-       
-       static uint16_t delay_cnt = 0;
-       switch(machine_step)
-       {
-               case 0: 
-                       //temppress-5000
-                       ADCGetPress[0] = GetPress();                //ADC²»¶Ï²É¼¯Ñ¹Á¦
-                       if(ADCGetPress[0] > 2)
-                       {
-                               if((ADCGetPress[0]*10000) < (temppress)*0.95  && SleepState == 1 && niujupress == 0 && Adjusting_torque_flag == 1)  //°âÊÖ°´Ï  ÕâÀïÈç¹ûÏÖ³¡ÆøÑ¹Ò»Ö±±È½ÏµÍ£¬ÉèÖõÄѹÁ¦Èç¹û¸ß  ¾ÍûÓа취¼ì²âµ½°âÊÖ°´ÏµÄ״̬
-                               { 
-                                       turn_flag = 1;
-                                       LED_SetLedStatus(LED_ID_DETECT_WORK,1);      //LED¼ì²â¹¤×÷״̬µÆÁÁ
-                                       Beep_SetbeepStatus(BEEP_ID_DETECT_WORK,1);   //·äÃùÆ÷¼ì²â¹¤×÷״̬Ïì
-                                       Matchine_SetMachine(1);                      //Çл»×´Ì¬»úÒ³Ãæ
-                               }
-                               else
-                               {
-                                       turn_flag = 0;
-                               }
-                               printf("state machine:%d\r\n",machine_step);
-                       }
-                       else if(ADCGetPress[0] <= 2)
-                       {
-                               if((ADCGetPress[0]*10000) < (temppress) * 0.9 && SleepState == 1 && niujupress == 0 && Adjusting_torque_flag == 1) //°âÊÖ°´Ï  ÕâÀïÈç¹ûÏÖ³¡ÆøÑ¹Ò»Ö±±È½ÏµÍ£¬ÉèÖõÄѹÁ¦Èç¹û¸ß  ¾ÍûÓа취¼ì²âµ½°âÊÖ°´ÏµÄ״̬
-                               { 
-                                       turn_flag = 1;
-                                       LED_SetLedStatus(LED_ID_DETECT_WORK,1);      //LED¼ì²â¹¤×÷״̬µÆÁÁ 1s
-                                       Beep_SetbeepStatus(BEEP_ID_DETECT_WORK,1);   //·äÃùÆ÷¼ì²â¹¤×÷״̬Ïì 1s
-                                       Matchine_SetMachine(1);                      //Çл»×´Ì¬»úÒ³Ãæ
-                               }
-                               else
-                               {
-                                       turn_flag = 0;
-                               }
-                       }
-                       break; 
-               case 1:
-                         ADCGetPress[0] = GetPress();                //ADC²»¶Ï²É¼¯Ñ¹Á¦
-                       //ѹÁ¦ºÍÁ÷Á¿Ò»Æð´¦Àí 
-                         ADCGetFlow[0] = GetFlow(); 
-                       if(ucCount200ms++ >= MS_COUNT_200)                  //¼ÆÊýµ½´ï200ms
-                       {
-                               ucCount200ms = 0;                            //ÇåÁã
-                //Èç¹ûADC²É¼¯Ñ¹Á¦´óµÈÓÚÓû§É趨ѹÁ¦µÄ0.9 ²¢ÇҲɼ¯µÄÁ÷Á¿´óÓÚÉèÖõÄÁ÷Á¿µÄX%
-#ifdef ENABLE_FLOW                             
-                               if(((ADCGetPress[0]*10000)>= temppress*compareFac) &&  ((ADCGetFlow[0]*10000) >=UserSetFlow) )    
-#else
-                               if(((ADCGetPress[0]*10000)>= temppress*compareFac))    
-#endif                         
-                               {
-                                       if(ucTrueCount++>2)                      //Èç¹û¼ÆÊý³¬¹ý2,¼´Á¬ÐøÈý´Î¶¼´ïµ½Óû§É趨ѹÁ¦µÄ90%±íʾ³É¹¦
-                                       {
-                                               ucTrueCount = 0;                       //ÇåÁã
-                                               //upComputerStructVar.UsingTime +=1;      //ʹÓôÎÊý¼ÓÒ»  
-                                               upUsingStructVar.UsingTime +=1;
-                                               Flash_RecordData();
-                                               printf("upUsingStructVar.UsingTimeupUsingStructVar.UsingTime\r\n");
-                                               SysMemoryParaVar.tigresult = 1;  //±íʾš½ôÁË
-                                               if(SaveFlag[UsingTimesMem] == 0)
-                                               {
-                                                       Memory =  UsingTimesMem;                //´æ´¢Ê¹ÓôÎÊý
-                                                       printf("UsingTimesMemUsingTimesMem\r\n");
-                                                       SaveFlag[UsingTimesMem] = 1;
-                                                       Matchine_SetMachine(2);                  //Çл»×´Ì¬»úÒ³Ãæ
-                                                       printf("state machine state machine:%d\r\n",machine_step);
-                                               }
-                                       }
-                               }
-                               else
-                               {
-                                       ucTrueCount = 0;
-                                       SysMemoryParaVar.tigresult = 0;
-//                                     LED_SetLedStatus(LED_ID_LOWER_FLOW,1);          
-//                                     Beep_SetbeepStatus(BEEP_ID_LOWER_FLOW,1);//¼ÓÉϵÍѹָʾ
-                               }                                                                       
-                       }  
-                       
-                       if(usCount10s++ >= S_COUNT_10)
-                       {
-                                       usCount10s = 0; 
-                    SysMemoryParaVar.tigresult = 0;//³¬¹ý10SûÓдﵽĿ±ê ¾Í²»ºÏ¸ñ
-                                       printf("disqualification!!!\r\n");
-                     if(ADCGetPress[0]*10000< temppress*compareFac)
-                                        {
-                                               LED_SetLedStatus(LED_ID_LOWER_FLOW,1);          
-                                               Beep_SetbeepStatus(BEEP_ID_LOWER_FLOW,1);//¼ÓÉϵÍѹָʾ
-                                        }
-                                        else 
-                                        {
-
-                                        }
-#ifdef ENABLE_FLOW     
-                                        if(ADCGetFlow[0]*10000 < UserSetFlow)
-                                        {
-                                               LED_SetLedStatus(LED_ID_LOWER_FLOW,1);          
-                                               Beep_SetbeepStatus(BEEP_ID_LOWER_FLOW,1);
-
-
-                                        }   
-                                        else 
-                                        {
-                                               
-                                        }
-#endif
-                                       Matchine_SetMachine(2);
-                                       printf("state machine:%d\r\n",machine_step);
-                       } 
-               
-                                               
-                       break;
-                       
-               case 2: 
-               
-                       usCount10s = 0;
-                       Matchine_SetMachine(3);                          //¹Ø±ÕÁ÷Á¿Òì³£±¨¾¯
-                       printf("state machine:%d\r\n",machine_step);
-                       break;//
-
-               case 3:
-                       
-                               Beep_GetBeepDataBuff(beep_buff);
-                               LED_GetLedDataBuff(led_buff);
-                               if(((LIB_GET_UINT8_BIT(beep_buff[BEEP_BYTE_IDX0],BEEP_BIT_0) == 0) &&     //Á÷Á¿½â³ý±¨¾¯
-                               (LIB_GET_UINT8_BIT(led_buff[LED_BYTE_IDX0],LED_BIT_0) ==0)) && \
-                               ((LIB_GET_UINT8_BIT(beep_buff[BEEP_BYTE_IDX0],BEEP_BIT_0) == 0) &&        //ѹÁ¦½â³ý±¨¾¯
-                               (LIB_GET_UINT8_BIT(led_buff[LED_BYTE_IDX0],LED_BIT_0) ==0)))
-                               {      
-                                    
-                                       Ordinal += 1;  
-//                                     if(Ordinal > upComputerStructVar.UsingTime)
-//                                     {
-//                                             Ordinal = upComputerStructVar.UsingTime;
-//                                     }
-                                       if(Ordinal > upUsingStructVar.UsingTime)
-                                       {
-                                               Ordinal = upUsingStructVar.UsingTime;
-                                       }
-                               
-                                       MX25L6406_WriteU32(secop(2046),Ordinal); 
-                                       Save_WrenchOperationData(&SysMemoryParaVar);                                     
-                                       if(SaveFlag[SysParaMem] == 0)
-                                       {
-                                               Memory =  SysParaMem;    //Õâ¸ö±äÁ¿±íʾ֪ͨflashÈ¥´æÉÏÃæ¼Ç¼µÄÊý¾Ý      
-                                               SaveFlag[SysParaMem] = 1;       
-                                       }
-                                       TIM_SetCompare2(TIM4, 0);
-                               //OSTimeDly(1000);
-                               
-//                             TIM3_Delayms(1000);
-//                             TIM_SetCompare2(TIM4,getOutDutyData(ResetPress.SetPress_Torque));
-
-
-                               
-                                       Matchine_SetMachine(4);
-                                       printf("state machine:%d\r\n",machine_step);    
-                               }
-                       
-                       
-                       
-                       break;
-
-               case 4: 
-                       
-                       Sys_huiFu(ModifyVarStructVar.WorkMode);    
-                       Matchine_SetMachine(5); 
-                       printf("state machine:%d\r\n",machine_step);
-                       break;
-               
-               case 5: 
-                       
-                       LED_SetLedStatus(LED_ID_END_WORK,1);
-                       Beep_SetbeepStatus(BEEP_ID_END_WORK,1);
-
-               
-                       
-                       Matchine_SetMachine(6);
-                       printf("state machine:%d\r\n",machine_step);
-                       break;
-               
-               case 6:       
-                       
-                       Beep_GetBeepDataBuff(beep_buff);
-                       LED_GetLedDataBuff(led_buff); 
-                       if((LIB_GET_UINT8_BIT(beep_buff[BEEP_BYTE_IDX0],BEEP_BIT_3)==0)&& 
-                       (LIB_GET_UINT8_BIT(led_buff[LED_BYTE_IDX0],LED_BIT_3)==0))
-                       {       
-                               
-                               Matchine_SetMachine(7); 
-//                             TIM_SetCompare2(TIM4,getOutDutyData(ResetPress.SetPress_Torque));
-                               Sys_setpress(ModifyVarStructVar.WorkMode);
-                       }
-                       printf("state machine:%d\r\n",machine_step);
-                       break;
-               case 7:
-                       
-                       if(delay_cnt ++ >= 600)
-                       {
-                               delay_cnt = 0;
-                               Matchine_SetMachine(0);
-                               printf("state machine:%d\r\n",machine_step);
-                               turn_flag = 0;
-                       }
-                                               
-                       break;
-
-       }
-}
-
-#endif
-
 
 /*
 ************************************************************************
@@ -663,11 +358,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                Ret = 0;
                                StartCaiji[1] = 1;
                                niujupress = 0;
-                               for(i = 0; i< 10; i++)   //дһ´Îûд³É¹¦£¬¶àд¼¸´Î
-                               {
-                                       TIM_SetCompare2(TIM4, getOutDutyData(ResetPress.SetPress_Torque));
-
-                               }
+                               Sys_setpress(1);
                        }
                
                        if(StartCaiji[1] == 1)
@@ -678,7 +369,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                        ADCGetPress[0] = GetPress();            //»ñȡѹÁ¦
                                        UserSetFlow = ADCGetPress[0]*FLOW_COVERT_VALUE;     //Ť¾ØÑ¹Á¦¶ÔÓ¦µÄÆøÁ¿
                                        printf("UserSetFlow : %5f\r\n",UserSetFlow);
-                                       temppress = ADCGetPress[0]*10000;                //µÚÒ»´Î²É¼¯ÎªÓû§É趨µçѹ
+                                       temppress = ADCGetPress[0];                //µÚÒ»´Î²É¼¯ÎªÓû§É趨µçѹ
                                        printf("µÚÒ»´Î²É¼¯ÎªÓû§É趨µçѹ:%f\r\n",temppress);
                                        firstpress = ADCGetPress[0];
                                        printf("µÚÒ»´Î²É¼¯ÎªÓû§É趨ѹÁ¦:%f\r\n",firstpress);
@@ -705,10 +396,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                Ret = 0;
                                StartCaiji[2] = 1;
                                niujupress = 0;
-                               for(i = 0; i< 10; i++)
-                               {
-                                       TIM_SetCompare2(TIM4, getOutDutyData(ResetPress.SetPress_Bolt));
-                               }
+                               Sys_setpress(2);
                        }
                        
                        if(StartCaiji[2] == 1)
@@ -720,7 +408,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                        ADCGetPress[0] = GetPress();
                                        UserSetFlow = ADCGetPress[0]*FLOW_COVERT_VALUE;         //ÂÝ˨ѹÁ¦¶ÔÓ¦µÄÆøÁ¿    
                                        printf("UserSetFlow : %5f\r\n",UserSetFlow);
-                                       temppress = ADCGetPress[0]*10000;
+                                       temppress = ADCGetPress[0];
                                        printf("µÚÒ»´Î²É¼¯ÎªÓû§É趨µçѹ:%f\r\n",temppress);
                                        firstpress = ADCGetPress[0];
                                        printf("µÚÒ»´Î²É¼¯ÎªÓû§É趨ѹÁ¦:%f\r\n",firstpress);
@@ -743,10 +431,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                        Ret = 0;
                                        StartCaiji[3] = 1;
                                        niujupress = 0;
-                                       for(i = 0; i< 10; i++) 
-                                       {
-                                               TIM_SetCompare2(TIM4, getOutDutyData(ResetPress.SetPress_Gear));
-                                       }
+                                       Sys_setpress(3);
                                }
                        
                                if(StartCaiji[3] == 1)
@@ -758,7 +443,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                                ADCGetPress[0] = GetPress();   //»ñȡѹÁ¦
                                                UserSetFlow = ADCGetPress[0]*FLOW_COVERT_VALUE;   //»ñÈ¡µÄѹÁ¦×ª»»ÆøÁ¿
                                                printf("UserSetFlow : %5f\r\n",UserSetFlow);
-                                               temppress = ADCGetPress[0]*10000;
+                                               temppress = ADCGetPress[0];
                                                printf("µÚÒ»´Î²É¼¯ÎªÓû§É趨µçѹ:%f\r\n",temppress);
                                                firstpress = ADCGetPress[0];
                                                printf("µÚÒ»´Î²É¼¯ÎªÓû§É趨ѹÁ¦:%f\r\n",firstpress);
@@ -774,10 +459,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                First[4] = 1;
                                First[3] = 0;
                                First[5] = 0;
-                               for(i = 0; i< 10; i++) 
-                               {
-                                       TIM_SetCompare2(TIM4, getOutDutyData(ResetPress.SetPress_Angle));
-                               }
+                               Sys_setpress(4);
                        }
                        if(niujupress ==1)  //Óû§É趨ʱŤ¾Ø·¢Éú±ä»¯
                        {
@@ -798,7 +480,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                        Count2S = 1000;
                                        ADCGetPress[0] = GetPress();   //»ñȡѹÁ¦
                                        UserSetFlow = ADCGetPress[0]*FLOW_COVERT_VALUE;   //»ñÈ¡µÄѹÁ¦×ª»»ÆøÁ¿
-                                       temppress = ADCGetPress[0]*10000;   //*10000ΪÁË·½±ã¼ÆË㣿
+                                       temppress = ADCGetPress[0];   //*10000ΪÁË·½±ã¼ÆË㣿
                                        firstpress = ADCGetPress[0];
                                        printf("µÚÒ»´Î²É¼¯ÎªÓû§É趨ѹÁ¦:%f\r\n",firstpress);
                                        StartCaiji[4] = 0;
@@ -822,10 +504,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                Ret = 0;
                                StartCaiji[5] = 1;
                                niujupress = 0;
-                               for(i = 0; i< 10; i++) 
-                               {
-                                       TIM_SetCompare2(TIM4, getOutDutyData(ResetPress.SetPress_Sensor));
-                               }
+                               Sys_setpress(5);
                        }
                
                        if(StartCaiji[5] == 1)
@@ -836,7 +515,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                        Count2S = 1000;
                                        ADCGetPress[0] = GetPress();   //»ñȡѹÁ¦
                                        UserSetFlow = ADCGetPress[0]*FLOW_COVERT_VALUE;   //»ñÈ¡µÄѹÁ¦×ª»»ÆøÁ¿
-                                       temppress = ADCGetPress[0]*10000;
+                                       temppress = ADCGetPress[0];
                                        firstpress = ADCGetPress[0];
                                        printf("µÚÒ»´Î²É¼¯ÎªÓû§É趨ѹÁ¦:%f\r\n",firstpress);
                                        StartCaiji[5] = 0;
@@ -849,11 +528,11 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                //SetPress_TorqueÊǶÔÓ¦×î´óŤ¾ØµÄѹÁ¦6.25BarµÄ±ÈÀýÖµ*100000£¬ÕâÀï x 6.25Bar ¼ÆËãµÃµ½Ä¿±êѹÁ¦Öµ
                //ºóÃæ±È½ÏµÄÖµÊÇadc¶ÁÈ¡µ½Ñ¹Á¦ÓÖ³ËÒÔ10000£¬ ËùÒÔÕâÀïºóÃæÓÖ³ËÒÔ10000.
                if( mode == 1 ){
-                               temppress = ResetPress.SetPress_Torque/100000 * getMaxPressure() * 10000;
+                               temppress = ResetPress.SetPress_Torque;
                }else if( mode == 2 ){
-                               temppress = ResetPress.SetPress_Bolt/100000 * getMaxPressure() * 10000;
+                               temppress = ResetPress.SetPress_Bolt;
                }else if( mode == 3 ){
-                               temppress = ResetPress.SetPress_Gear/100000 * getMaxPressure() * 10000;
+                               temppress = ResetPress.SetPress_Gear;
                }else {
 
                }
@@ -875,17 +554,10 @@ static uint8_t WrenchMode_Select(uint8_t mode)
 void WrenchManage_MainTask(void)                              //״̬»ú5ºÁÃëÖ÷ÈÎÎñ
 {
        uint8_t ret = 0;                                             //Éϵ磬³õʼ»¯Îª0
-       //uint8_t wrench_state = 0;
+
        ret = WrenchMode_Select(ModifyVarStructVar.WorkMode);        //ģʽѡÔñ 
-       //wrench_state = wrench_device.err_code;
-       //printf("wrench_state:%d\r\n",wrench_state);
-       #ifdef  NEW
-///    Wrench_ErrCheck();
-       #endif
        if(ret ==1 && Interface_Flag == 1)                                               //Èç¹û·µ»ØÖµÎª1£¬½øÐÐģʽѡÔñ
        {
-               if(wrench_device.err_code == DEVICE_OK)
-               {
                        //1ΪŤ¾ØÄ£Ê½    2ΪÂÝ˨ģʽ       3ΪµµÎ»Ä£Ê½
                        if((ModifyVarStructVar.WorkMode == 1) || (ModifyVarStructVar.WorkMode == 2) || (ModifyVarStructVar.WorkMode == 3 ) )
                        {
@@ -895,35 +567,12 @@ void WrenchManage_MainTask(void)                              //״̬
                        {
                                //Machine_DoAngle();                          //״̬»ú²É¼¯½Ç¶È
                        }
-                       else
-                       {
-                               
-                       }
-               }
-               else
-               {
-                       if(wrench_device.err_code&DEVICE_PRESS_LOW_ERROR )
-                       {
-                               if((ADCGetPress[0]*10000) > (temppress*0.9))
-                               {
-                                       wrench_device.err_code = DEVICE_OK;
-                               }
-                       }
-                       
-               }
-       }
-       else
-       {
-               
        }
+
        #if HOST_DEBUG
                {
                        extern int host_debug_send_info( uint8_t step, float target_pressure, float check_pressure, float current_pressure, uint32_t valve_output);
-                       host_debug_send_info( machine_step, temppress/10000, temppress/10000*compareFac, ADCGetPress[0]*10000/10000, TIM_GetCapture2(TIM4));
+                       host_debug_send_info( machine_step, temppress, temppress*compareFac, ADCGetPress[0], TIM_GetCapture2(TIM4));
                }
        #endif
 }
-
-
-
-