气动冲击扳手,使用固定气压区间参数调试用
authorkyz <kongyuzhong@google.com>
Wed, 21 Jan 2026 10:06:15 +0000 (18:06 +0800)
committerkyz <kongyuzhong@google.com>
Thu, 22 Jan 2026 01:11:54 +0000 (09:11 +0800)
QiDong/APP/inc/model.h
QiDong/APP/src/model.c
QiDong/APP/src/screen_app.c
QiDong/BSP/src/bsp_host.c
QiDong/System/WrenchManage.c

index b18aebeaa4423e72a9e383afe488bc7265236af3..4aef788b3214e6b852888ca5c502e0bad5915a96 100644 (file)
@@ -8,6 +8,10 @@
 #include "screen_driver.h"
 //#include "dflashm.h"
 
+
+//ÊÇ·ñ¿ªÆôŤ¾Ø·¶Î§µ÷ÊÔ ¿ªÆôµ÷ÊÔʹÓù̶¨µÄ²ÎÊý±íת»»Å¤¾Øµ½ÆøÑ¹£¬ºÍ°´²ÎÊý±íÖвÎÊýÉ趨Æô¶¯ãÐÖµ
+#define  TOR_RANGE_DEBUG  1
+
 /**********************************************************************************************************/
 ///extern uint16_t productKind ;
 extern uint8_t gearKind;
@@ -73,7 +77,6 @@ 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);
 float setTargetTorqueValVarFlag1(uint8_t TorqueUint,uint32_t *targetTorVal)  ;
 extern float setTargetTorqueValVarFlag(uint8_t TorqueUint,uint32_t *targetTorVal);
 extern uint32_t setSensorPresetTorValVarFlag(uint8_t Unit,uint32_t* presetvalue);
index e30c930729372439c37e2df29b5948dee2a26491..0db1368804b18644c00acd50a32c3e2d06f9b34e 100644 (file)
@@ -16,6 +16,7 @@
 
 /*********************************************************************************************************/
 
+
 ///uint16_t productKind = 0;
 uint8_t gearKind = 0 ;
 
@@ -23,215 +24,42 @@ TorquePattern TorquePatternVar[50] = {0};
 GearPattern GearPatternVar[70] = {0};
 
 
-#if 0
-
-/*
-*********************************************************************************************************
-*      º¯ Êý Ãû: AdjustTorqueMode
-*      ¹¦ÄÜ˵Ã÷: 
-*      ÐΠ   ²Î: ¿Õ
-*      ·µ »Ø Öµ: ¿Õ 
-*********************************************************************************************************
-*/
-void AdjustTorqueMode(void)
-{
-       SetScreen(1);
-
-       if(ModifyVarStructVar.TorqueUint == 0)
-       {
-               SetTextInt32(1,3, ModifyVarStructVar.TartorVal_TorMode,0,0); 
-               SetTextValue(1,4,(uint8_t*)"N.m");  
-       }                               
-       else
-       {
-               SetTextValue(1,4,(uint8_t*)"ft.lbs"); 
-               SetTextInt32(1,3, ROUND_TO_UINT32(ModifyVarStructVar.TartorVal_TorMode/1.3549),0,0); 
-       }
-
-       switch(ModifyVarStructVar.pressUint)
-       {
-               case 0: SetTextValue(1,5,(uint8_t*)"Bar");break;
-               case 1: SetTextValue(1,5,(uint8_t*)"Mpa");break; 
-               case 2: SetTextValue(1,5,(uint8_t*)"Psi");break;
-       }
-
-       SetTextValue(1,1,(uint8_t*)TorquePatternVar[ModifyVarStructVar.fabricName-1].ProductType);   //ÏÔʾ²úÆ·Ãû³Æ     
-       ModifyVarStructVar.MaxtorVal_TorMode = TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*MAXMPA ;        
-
-       if(ModifyVarStructVar.TorqueUint == 0)
-       {
-               SetTextValue(1,2,(uint8_t*)"N.m");
-               SetTextInt32(1,6, ModifyVarStructVar.MaxtorVal_TorMode,0,0);
-       }
-       else
-       {
-               SetTextValue(1,2,(uint8_t*)"ft.lbs");
-               SetTextInt32(1,6, ROUND_TO_UINT32(ModifyVarStructVar.MaxtorVal_TorMode/1.3549),0,0);
-       }       
-}
- 
-
- 
- /*
-*********************************************************************************************************
-*      º¯ Êý Ãû: AdjustBoltMode
-*      ¹¦ÄÜ˵Ã÷: 
-*      ÐΠ   ²Î: ¿Õ
-*      ·µ »Ø Öµ: ¿Õ
-*********************************************************************************************************
-*/
-void AdjustBoltMode(void)
-{
-       SetScreen(2);
-
-       if(ModifyVarStructVar.ChartType == 0)
-       {
-               SetTextValue(2,2,(uint8_t*)      ModifyVarStructVar.BoltDiameterArr);
-               SetTextValue(2,3,(uint8_t*)      ModifyVarStructVar.BoltGardeArr);
-       }
-       if(ModifyVarStructVar.ChartType == 1)
-       {
-               SetTextValue(2,2,(uint8_t*)      ModifyVarStructVar.BoltDiameterArr_M);
-               SetTextValue(2,3,(uint8_t*)      ModifyVarStructVar.BoltGardeArr_M);
-       }
-
-       if(ModifyVarStructVar.TorqueUint == 0)
-       {
-               SetTextInt32(2,5,        ModifyVarStructVar.TartorVal_BoltMode,0,0);
-               SetTextValue(2,4,(uint8_t*)"N.m"); 
-       }
-       if(ModifyVarStructVar.TorqueUint == 1)
-       {
-               SetTextInt32(2,5,        ROUND_TO_UINT32(ModifyVarStructVar.TartorVal_BoltMode/1.3549),0,0);
-               SetTextValue(2,4,(uint8_t*)"ft.lbs"); 
-       }
-
-       SetTextValue(2,1,(uint8_t*)TorquePatternVar[ModifyVarStructVar.fabricName-1].ProductType);   //ÏÔʾ²úÆ·Ãû³Æ             
-
-}
-       
-/*
-*********************************************************************************************************
-*      º¯ Êý Ãû: AdjustGearMode
-*      ¹¦ÄÜ˵Ã÷: 
-*      ÐΠ   ²Î: ¿Õ
-*      ·µ »Ø Öµ: ¿Õ
-*********************************************************************************************************
-*/
-void AdjustGearMode(void)
-{
-       SetScreen(4);
-
-       SetTextValue(4,1,(uint8_t*)TorquePatternVar[ModifyVarStructVar.fabricName-1].ProductType);   //ÏÔʾ²úÆ·Ãû³Æ
-       switch(ModifyVarStructVar.pressUint)
-       {
-               case 0: SetTextValue(4,4,(uint8_t*)"Bar");break;
-               case 1: SetTextValue(4,4,(uint8_t*)"Mpa");break; 
-               case 2: SetTextValue(4,4,(uint8_t*)"Psi");break;
-       }
-
-       SetTextInt32(4,2,  GearPatternVar[ModifyVarStructVar.gear-1].gear,0,0);
-
-       if(ModifyVarStructVar.TorqueUint == 0)
-       {
-               SetTextInt32(4,5,  ModifyVarStructVar.geartor,0,0);
-               SetTextValue(4,3,(uint8_t*)"N.m");
-       }
-       else
-       {
-               SetTextValue(4,3,(uint8_t*)"ft.lbs");
-               SetTextInt32(4,5, ROUND_TO_UINT32(ModifyVarStructVar.geartor/1.3549),0,0);
-       }
-}
-
-
-/*
-*********************************************************************************************************
-*      º¯ Êý Ãû: AdjustAngleMode
-*      ¹¦ÄÜ˵Ã÷: 
-*      ÐΠ   ²Î: ¿Õ
-*      ·µ »Ø Öµ: ¿Õ
-*********************************************************************************************************
-*/
-void AdjustAngleMode(void)
-{
-       SetScreen(3);
-       SetTextInt32(3,4,ModifyVarStructVar.Angle,0,0);              //
-
-       switch(ModifyVarStructVar.pressUint)
-       {
-               case 0: SetTextValue(3,5,(uint8_t*)"Bar");break;
-               case 1: SetTextValue(3,5,(uint8_t*)"Mpa");break; 
-               case 2: SetTextValue(3,5,(uint8_t*)"Psi");break;
-       }
-
-       SetTextValue(3,1,(uint8_t*)TorquePatternVar[ModifyVarStructVar.fabricName-1].ProductType);   //ÏÔʾ²úÆ·Ãû³Æ     
-
-       ModifyVarStructVar.MaxtorVal_TorMode = TorquePatternVar[ModifyVarStructVar.fabricName-1].Factor*MAXMPA ;
-
-       if(ModifyVarStructVar.TorqueUint==0)
-       {
-               SetTextInt32(3,2,ModifyVarStructVar.MaxtorVal_TorMode,0,0);
-               SetTextValue(3,3,(uint8_t*)"N.m");
-       }
-       else
-       {
-               SetTextInt32(3,2,ROUND_TO_UINT32(ModifyVarStructVar.MaxtorVal_TorMode/1.3549),0,0);
-               SetTextValue(3,3,(uint8_t*)"ft.lbs");
-       }                       
-}
-
+#if TOR_RANGE_DEBUG
 /*
-*********************************************************************************************************
-*      º¯ Êý Ãû: AdjustSensorMode
-*      ¹¦ÄÜ˵Ã÷: 
-*      ÐΠ   ²Î: ¿Õ
-*      ·µ »Ø Öµ: ¿Õ
-*********************************************************************************************************
+2026/1/21 ¿Í»§Ìṩ²âÊÔ²ÎÊý
+Æø¶¯³å»÷°âÊÖ 
+Ť¾Ø      Éè¶¨ÆøÑ¹      ¿ÕÔØ       ¶ÂÆøÆøÑ¹  ¶ÂÆø/É趨=±ÈÀý
+45        1.25          1.1       1.16      0.93
+72        2             1.76      1.89      0.95
+90        2.5           2.2       2.35      0.94
+109       3             2.7       2.8       0.93
+127       3.5           3.1       3.34      0.95
+145       4             3.2       3.8       0.95
+163       4.5           3.5       4.27      0.95
+181       5             3.8       4.5       0.90
+200       5.5           3.8       4.5       0.82
 */
-void AdjustSensorMode(void)
-{
-       SetScreen(5);
-
-       switch(ModifyVarStructVar.pressUint)
-       {
-               case 0: SetTextValue(5,6,(uint8_t*)"Bar");break;
-               case 1: SetTextValue(5,6,(uint8_t*)"Mpa");break; 
-               case 2: SetTextValue(5,6,(uint8_t*)"Psi");break;
-       }
-
-       if(ModifyVarStructVar.TorqueUint==0)
-       {
-               SetTextValue(5,3,(uint8_t*)"N.m");  
-               SetTextInt32(5,2,ModifyVarStructVar.presettor_sensor,0,0);   
-       }
-       else
-       {
-               SetTextValue(5,3,(uint8_t*)"ft.lbs");  
-               SetTextInt32(5,2,ROUND_TO_UINT32(ModifyVarStructVar.presettor_sensor/1.3549),0,0);      
-       }
-
-       if(ModifyVarStructVar.fabricName==0)
-       {
-               ModifyVarStructVar.fabricName = 1;
-       }
-       SetTextValue(5,1,(uint8_t*)TorquePatternVar[ModifyVarStructVar.fabricName-1].ProductType);   //ÏÔʾ²úÆ·Ãû³Æ
-       ModifyVarStructVar.tartor_sensor = TorquePatternVar[ModifyVarStructVar.fabricName-1].SensorTor;
-
-       if(ModifyVarStructVar.TorqueUint==0)
-       {
-               SetTextInt32(5,4,ModifyVarStructVar.tartor_sensor,0,0);
-               SetTextValue(5,5,(uint8_t*)"N.m");
-       }
-
-       if(ModifyVarStructVar.TorqueUint==1)
-       {
-               SetTextInt32(5,4,ROUND_TO_UINT32(ModifyVarStructVar.tartor_sensor/1.3549),0,0);
-               SetTextValue(5,5,(uint8_t*)"ft.lbs");
-       }
-}
+typedef struct {
+               uint16_t torque;
+               float press;
+               float threshold;
+}tor_para_t;
+
+tor_para_t     debg_tor_para[9] = {
+               {45,1.25,0.93},
+               {72,2.0,0.95},
+               {90,2.5,0.94},
+               {109,3.0,0.93},
+               {127,3.5,0.95},
+               {145,4.0,0.95},
+               {163,4.5,0.95},
+               {181,5.0,0.90},
+               {200,5.5,0.82}
+};
+
+#define TORQUE_PARA_MUN  (sizeof(debg_tor_para)/sizeof(tor_para_t))
 
-#endif 
+#endif
 
 
 /*
@@ -299,76 +127,51 @@ uint32_t setSensorPresetTorValVarFlag1(uint8_t Unit,uint32_t* presetvalue)
        return press;
 }
 
-/*
-**************************************************************************
-*      º¯ Êý Ãû: getOutDutyData
-*      ¹¦ÄÜ˵Ã÷: DACÊä³öѹÁ¦¶ÔÓ¦µÄÕ¼¿Õ±È
-*      ÐΠ   ²Î: press£ºÑ¹Á¦Öµ,bar
-*      ·µ »Ø Öµ: Ð´ÈëDACÊý¾Ý¼Ä´æÆ÷µÄÊý¾ÝÖµ
-*    Press: 10bar = 1Mpa = 145 Psi   1 Bar = 14.5 Psi       1 bar¶ÔÓ¦1V
-*       V:     0¡ª¡ª10V
-*       Duty:  0¡ª¡ª100%
-*      
-**************************************************************************
-*/
+#if TOR_RANGE_DEBUG
 
-/*
-10KHZ = 10000
-10V  10000
-0.01   100
-
-
-(uint16_t)press 
-*/
-
-#define Period_Cnt    1000
-#define xishi    0.01
-//10 Period_Cnt    xishi  Y                                                                                          
-uint32_t getOutDutyData(float press)
+float pressure_threshold( float pressure )
 {
-#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£¬
-               pwmÖÜÆÚ1000£¬±È½ÏÆ÷ccr2 ÉèÖõ½1000¾ÍÊÇ10Bar£¬ ÕâÀïÏÞÖÆ×î´óÉèÖõ½625¶ÔÓ¦6.25Bar
-               Èç¹ûÄ¿±êŤ¾ØÊÇ6.25Bar£¬ÄÇôÊäÈëpressÊÇ6.25/6.25*100000£¬ÕâÀïccr2±È½ÏÆ÷ÉèÖÃ625¿ØÖÆÑ¹Á¦·§Êä³ö6.25Bar
-               Èç¹ûÄ¿±êŤ¾ØÊÇ3.125Bar£¬ÄÇôÊäÈëpressÊÇ3.125/6.25*100000£¬ÕâÀïccr2±È½ÏÆ÷ÉèÖÃ313¿ØÖÆÑ¹Á¦·§Êä³ö3.13Bar
-
-               getPressValue()º¯Êý,·µ»ØµÄÊǸö±ÈÀýÖµ£¬²»¹»Ö±¹Û£¬Ó¦µ±»»Ëã³ÉѹÁ¦Öµ£¬ÕâÑùºóÃæÒ×ÓÚʹÓôúÂëÒ²ÈÝÒ×Àí½â
-               2025/12/29
-
-       */
-}
-
-
-
+       //¸ù¾ÝÊäÈëµÄѹÁ¦Öµ£¬²éÕÒ¶ÔӦѹÁ¦ãÐÖµ°Ù·Ö±È
+       int i;
+       float percent;
 
-/*
-**************************************************************************
-*      º¯ Êý Ãû: getPressValue
-*      ¹¦ÄÜ˵Ã÷: ·µ»ØÑ¹Á¦Öµ¡£À©´ó10Íò±¶,°´ÕÕbarµÄ±ê×¼
-*      ÐΠ   ²Î: factor²úƷϵÊý
-                                               torquevalue:É趨µÄŤ¾ØÖµ
-*      ·µ »Ø Öµ: É趨µÄŤ¾ØÖµ¶ÔÓ¢µÄѹÁ¦,bar
-**************************************************************************
-*/
-float getPressValue(uint32_t factor,uint32_t torquevalue)
-{
-    return (torquevalue*100000/factor);
-//     return (torquevalue * 100000);
+       percent = debg_tor_para[TORQUE_PARA_MUN-1].threshold;
+       for( i = 1; i < TORQUE_PARA_MUN; i++)
+       {
+               if(pressure < debg_tor_para[i].press )
+               {
+                       percent = debg_tor_para[i-1].threshold;
+                       break;
+               }
+       }
+       return pressure * percent;
 }
+#endif //TOR_RANGE_DEBUG
 
 //Ť¾Ø»»Ëã³ÉѹÁ¦£¬°´²ÎÊý±í²éÕÒ×îСŤ¾Ø/ѹÁ¦ºÍ×î´óŤ¾ØÑ¹Á¦£¬½«ÊäÈë²ÎÊýŤ¾Ø»»Ëã³ÉѹÁ¦·µ»Ø
 float tor_to_pressure(uint32_t tor)
 {
+#if TOR_RANGE_DEBUG
+       //Æô¶¯³å»÷µ÷ÊÔ¹¦ÄÜ
+       //¸ù¾ÝÊäÈëµÄŤ¾ØÖµ£¬²éÕÒ¶ÔӦѹÁ¦Öµ
+       int i;
+       float pressure = 0;
+
+       if( tor < debg_tor_para[0].torque )
+               return debg_tor_para[0].press;
+       else if( tor >= debg_tor_para[TORQUE_PARA_MUN-1].torque )
+               return debg_tor_para[TORQUE_PARA_MUN-1].press;
+
+       for( i = 1; i < TORQUE_PARA_MUN; i++)
+       {
+               if(tor < debg_tor_para[i].torque )
+               {
+                       pressure = debg_tor_para[i-1].press + (debg_tor_para[i].press - debg_tor_para[i-1].press) * (tor - debg_tor_para[i-1].torque) / (debg_tor_para[i].torque - debg_tor_para[i-1].torque);
+                       break;
+               }
+       }
+       return pressure;
+#else
        //ÊäÈëtor²ÎÊýÊÇN.m£¬·µ»ØÖµµ¥Î»ÊÇBar
 
        uint32_t tor_min, tor_max;
@@ -401,6 +204,8 @@ float tor_to_pressure(uint32_t tor)
                return 0;
 
        return  press_min + (press_max - press_min) * (tor - tor_min) / (tor_max - tor_min);
+
+#endif
 }
 /*
 **************************************************************************
index 217c853b7e35808b1ec66ff0d692b51105d27b64..47ce7f2bdfb1c8400a20bbe37146ffe178721768 100644 (file)
@@ -1889,8 +1889,7 @@ void MemuFour(void)
 
        if(ResetPress.SetPress_Gear==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);
                PressMem = 1;   
                if(SaveFlag[ScreenMem] == 0)
                {
index 9cf758f72d0fb1f39365ce172528f7f8f3827067..479a2e1e10bc4fc95f6ab4d0f1e965f4e0a8cd9b 100644 (file)
@@ -1729,13 +1729,9 @@ int handle_host_cmd( pkt_t *pkt )
 */
 void Host_SetCmd(void)
 {
-       unsigned char i = 0,j = 0;
-       unsigned int crc = 0;
-       unsigned char crch = 0,crcl = 0;
-       u16 len = 0,cnt = 0;
+       u16 len = 0;
        u8 buf[2048] = {0};
-       u32 Cmd_adress = 0;
-       //      printf("hello \r\n");
+
        if(flagFrame)            //Ö¡½ÓÊÕÍê³É±êÖ¾£¬¼´½ÓÊÕµ½Ò»Ö¡ÐÂÊý¾Ý
        {
                flagFrame=0;                          //Ö¡½ÓÊÕÍê³É±êÖ¾ÇåÁã
@@ -1759,315 +1755,6 @@ void Host_SetCmd(void)
                        }
                        return;
                }
-#if 0
-               if((buf[0]==0x5A)&&(buf[1]==0xA5))    //ÅжϵØÖ·ÊDz»ÊÇÖ¡Í·
-               {
-                       crc=GetCRC16(buf,len-2);          //¼ÆËãCRCУÑéÖµ£¬³öÈ¥CRCУÑéÖµ
-                       crch=crc>>8;                                              //crc¸ßλ
-                       crcl=crc&0xFF;                                            //crcµÍλ
-
-                       if((buf[len-2]==crch)&&(buf[len-1]==crcl))  //ÅжÏCRCУÑéÊÇ·ñÕýÈ·
-                       {
-                               if(buf[4]!=0x0c)
-                               {
-                                       USART2Write(buf,len);  //·¢ËÍÏìÓ¦Ö¡
-                                       OSTimeDly(1);
-                               }
-                               
-                               switch (buf[4])            //°´¹¦ÄÜÂëÖ´ÐвÙ×÷
-                               {
-                                       case 0x01:   //ÉèÖÃʱ¼ä
-                                                       RTC_EnterConfigMode();
-                                                       calendar.w_year = PTR2U16(&buf[7]);
-                                                       calendar.w_month = buf[9];
-                                                       calendar.w_date = buf[10];
-                                                       calendar.hour = buf[11];
-                                                       calendar.min = buf[12];
-                                                       calendar.sec = buf[13] + 1;
-                                                       RTC_Set(calendar.w_year,calendar.w_month,calendar.w_date,calendar.hour,calendar.min,calendar.sec);
-                                                       RTC_ExitConfigMode();           //Í˳öÅäÖÃģʽ 
-                                                       break;
-                                       case 0x02:
-                                                       len -= 2;
-                                                       break;
-                                       case 0x03:   //ÉèÖóö³§±àºÅ
-                                                       memset(TmsKeyData.FactoryNumber,0,sizeof(TmsKeyData.FactoryNumber));
-                                                       TmsKeyData.FactoryNumberLen =  PTR2U16(&buf[5]);    //»ñÈ¡É豸Ãû³ÆÊý¾Ý³¤¶È
-                                                       for(i = 0;i<TmsKeyData.FactoryNumberLen ;i++)       //»ñÈ¡³ö³§±àºÅ
-                                                       {
-                                                               TmsKeyData.FactoryNumber[i] = buf[i+7];
-                                                       }
-                                                       if(SaveFlag[appearanceNumberMem] == 0)
-                                                       {
-                                                           Memory  = appearanceNumberMem; 
-                                                               SaveFlag[appearanceNumberMem] = 1;
-                                                                 
-                                                       }
-                                                       break;
-                                       case 0x04:
-                                                       len -= 2;
-                                                       break;
-                                       case 0x05:   //ÉèÖÃÉ豸Ãû³Æ
-                                                       memset(TmsKeyData.DeviceName,0,sizeof(TmsKeyData.DeviceName));
-                                                       TmsKeyData.DeviceNameLen = PTR2U16(&buf[5]);        //»ñÈ¡É豸Ãû³ÆÊý¾Ý³¤¶È
-                                                       for(i = 0;i<TmsKeyData.DeviceNameLen ;i++)          //»ñÈ¡ÉèÖÃÉ豸Ãû³Æ
-                                                       {
-                                                               TmsKeyData.DeviceName[i] = buf[i+7];
-                                                       } 
-                                                       if(SaveFlag[UserEquipNameMem] == 0)
-                                                       {
-                                                           Memory = UserEquipNameMem;
-                                                               SaveFlag[UserEquipNameMem] = 1;
-                                                                                                                               
-                                                       }
-                                                       break;
-                                       case 0x06:
-                                                       break;
-                                       case 0x07:   // ÉèÖÃÉ豸±àºÅ
-                                                       memset(TmsKeyData.UserEquipmentNumber,0,sizeof(TmsKeyData.UserEquipmentNumber));
-                                                       TmsKeyData.UserEquipmentNumberLen = PTR2U16(&buf[5]);//»ñÈ¡É豸±àºÅÊý¾Ý³¤¶È
-                                                       for(i = 0;i<TmsKeyData.UserEquipmentNumberLen ;i++)  //»ñÈ¡ÉèÖÃÉ豸±àºÅ
-                                                       {
-                                                               TmsKeyData.UserEquipmentNumber[i] = buf[i+7];
-                                                       }
-                                                       if(SaveFlag[UserEquipNumberMem] == 0)
-                                                       {
-                                                           Memory =  UserEquipNumberMem; 
-                                                               SaveFlag[UserEquipNumberMem] = 1;
-                                                                 
-                                                       }
-                                                       break;
-                                       case 0x08:
-                                                       break;
-                                       case 0x09:    //ÉèÖÃËø¶¨×´Ì¬
-                                                       TmsKeyData.UnlockPasswordLen = PTR2U16(&buf[5]) - 1; //»ñÈ¡É豸±àºÅÊý¾Ý³¤¶È
-                                                       for(i = 0;i<TmsKeyData.UnlockPasswordLen ;i++)       //»ñÈ¡ÉèÖÃÉ豸±àºÅ
-                                                       {       
-                                                               TmsKeyData.UnlockPassword[i] = buf[i+8];     
-                                                       }
-                                                       if(SaveFlag[PassWordMem] == 0)
-                                                       {
-                                                           Memory = PassWordMem; 
-                                                               SaveFlag[PassWordMem] = 1;
-                                                                                                                               
-                                                       }
-                                                       break;    
-
-                                       case 0x0A:    //ÉèÖÃʹÓÃÃÜÂë
-                                                       TmsKeyData.PasswordLen  = PTR2U16(&buf[5]);          //»ñÈ¡É豸±àºÅÊý¾Ý³¤¶È
-                                                       for(i = 0;i<TmsKeyData.PasswordLen ;i++)             //»ñÈ¡ÉèÖÃÉ豸±àºÅ
-                                                       {
-                                                               TmsKeyData.Password[i] = buf[i+7];     
-                                                       }
-                                                       if(SaveFlag[PassWordMem] == 0)
-                                                       {
-                                                           Memory = PassWordMem; 
-                                                               SaveFlag[PassWordMem] = 1;
-                                                                                                                               
-                                                       }
-                                                       break;
-                                       case 0x0B:    //ÉèÖÃʹÓôÎÊý
-                                                       TmsKeyData.UsageLimit = PTR2U32(&buf[7]); 
-                                                       SetTextInt32(0,9,TmsKeyData.UsageLimit,0,0);
-                                                       if(SaveFlag[UsingTimesMem] == 0)
-                                                       {
-                                                           Memory = UsingTimesMem; 
-                                                               SaveFlag[UsingTimesMem] = 1;
-                                                       }
-                                                       break; 
-
-                                       case 0x0E:                                              //ÉèÖûØÍËÐÅÏ¢  
-                                                       break;          
-                               
-                                       case 0x10:
-                                                       break;
-                                       case 0x12: //ÂÝ˨ģʽ
-                                                       if(buf[7] == 0x00)      // ¹«ÖÆ
-                                                       {
-                                                               Computer_BoltDate.GBolt_Num = buf[8];
-                                                               // ¹«ÖÆÂÝ˨ֱ¾¶
-                                                               for (i = 0; i <Computer_BoltDate. GBolt_Num; i++)
-                                                               {
-                                                                       strncpy((char*)Computer_BoltDate.Computer_Metric_Diameter[i], (char*)&buf[i*10+9], 10);
-                                                               }
-                                                               // ¹«ÖƵȼ¶Ãû³Æ
-                                                               Computer_BoltDate.GGrade_Num = buf[279];
-                                                               for ( i =0; i < METRIC_BOLT_GRADE; i++)
-                                                               {
-                                                                       strncpy((char*)Computer_BoltDate.Computer_Metric_Grade[i], (char*)&buf[10+(Computer_BoltDate.GBolt_Num+i)*10], 10);
-                                                               }
-                                                               // ÂÝ˨Ť¾Ø
-                                                               for(i = 0; i < METRIC_BOLT_GRADE; i++)
-                                                               {
-                                                                       for(j = 0;j < Computer_BoltDate.GBolt_Num; j++)
-                                                                       {
-                                                                               Computer_BoltDate.Computer_Metric_parameter[i][j] = 
-                                                                               PTR2U32(&buf[10 + (Computer_BoltDate.GBolt_Num + METRIC_BOLT_GRADE) * 10 + (i * Computer_BoltDate.GBolt_Num + j) * 4]); 
-                                                                       }
-                                                               }
-                                                       }
-                                                       // Ó¢ÖÆÆðʼλÖÃ
-                                                       Cmd_adress = 10 + (Computer_BoltDate.GBolt_Num + METRIC_BOLT_GRADE) * 10 + (Computer_BoltDate.GBolt_Num * METRIC_BOLT_GRADE)*4; 
-                                               
-                                                       if (buf[Cmd_adress] ==0x01)
-                                                       {
-                                                               Computer_BoltDate.IBolt_Num = buf[Cmd_adress+1];
-                                                               // Ó¢ÖÆÂÝ˨ֱ¾¶
-                                                               for(i = 0;i < Computer_BoltDate.IBolt_Num;i++)
-                                                               {
-                                                                       strncpy((char*)Computer_BoltDate.Computer_Imperial_Diameter[i],(char*)&buf[i*10+Cmd_adress+2],10);
-                                                               }
-                                                               // Ó¢ÖƵȼ¶Ãû³Æ
-                                                               Computer_BoltDate.IGrade_Num = buf[1112];
-                                                               for(i = 0;i < IMPERIAL_BOLT_GRADE;i++)
-                                                               {
-                                                                       strncpy((char*)Computer_BoltDate.Computer_Imperial_Grade[i],(char*)&buf[Cmd_adress+3+Computer_BoltDate.IBolt_Num*10+i*10],10);
-                                                               }
-                            // ÂÝ˨Ť¾Ø
-                                                               for(i = 0;i < IMPERIAL_BOLT_GRADE;i++)
-                                                               {
-                                                                       for(j = 0;j < Computer_BoltDate.IBolt_Num;j++)
-                                                                       {
-                                                                               Computer_BoltDate.Computer_Imperial_parameter[i][j] = 
-                                                                               PTR2U32(&buf[Cmd_adress + 3 + (IMPERIAL_BOLT_GRADE + Computer_BoltDate.IBolt_Num)*10 + (i * Computer_BoltDate.IBolt_Num + j) * 4]);
-                                                                       }
-                                                               }
-                                                       }
-                                                       displayInRangeValues(); //´ÓComputer_BoltDateͬ²½Êý¾Ýµ½BlotData
-                                                       if(SaveFlag[BoltStructMem] == 0)
-                                                       {
-                                                           Memory = BoltStructMem;
-                                                               SaveFlag[BoltStructMem] = 1;
-                                                       }
-                                                       break;
-
-                                       case 0x13:
-                                                       TmsKeyData.AngleLimit = PTR2U16(&buf[7]);   // »ñÈ¡×î´ó½Ç¶ÈÖµ
-                                                       if(SaveFlag[AngleMemMem] == 0)
-                                                       {
-                                                           Memory = AngleMemMem; 
-                                                               SaveFlag[AngleMemMem] = 1;                                                              
-                                                       }
-                                                       break;
-                                                       
-                                       case 0x14:   //µ²Î»¸öÊýÇåÁã 
-                                                       TmsKeyData.GearLevelLen = buf[7];           //»ñÈ¡µµÎ»¸öÊý
-                                                       getGear(GearData,TmsKeyData.GearLevelLen,buf); 
-                                                       for(i = 0; i< TmsKeyData.GearLevelLen/2; i++)
-                                                       {
-                                                               //»ñÈ¡µ²Î»µÈ¼¶£¨1×Ö½Ú£©
-                                                               GearData[i].GearLevels = buf[i * 10 + 8];
-                                                               //»ñÈ¡µµÎ»Å¤¾Ø£¨4×Ö½Ú£©
-                                                               GearData[i].GearParameter = PTR2U32(&buf[i * 10 + 9]);
-                                                               //II »ñÈ¡µ²Î»Å¤¾Ø£¨4×Ö½Ú£©
-                                                               GearData[i].GearParameter2 = PTR2U32(&buf[i * 10 + 14]);
-                                                       } 
-                                                       if(SaveFlag[GearMem] == 0)
-                                                       {
-                                                               Memory = GearMem; 
-                                                               SaveFlag[GearMem] = 1;
-                                                       }
-                                                       break;
-
-                                       case 21:
-                                                       break;
-                                       case 0x16:
-                                                       sendBasic_information();                                        //ÉÏ·¢°âÊÖÀàÐͺÍÎļþ°æ±¾
-                                                       len = 0;
-                                                       break;
-
-                                       case 0x0F:       
-                                                       memset(TmsKeyData.OperatorName,0,sizeof(TmsKeyData.OperatorName));
-                                                       TmsKeyData.OperatorNameLen = PTR2U16(&buf[5]);      //»ñÈ¡É豸Ãû³ÆÊý¾Ý³¤¶È
-                                                       for(i = 0;i<TmsKeyData.OperatorNameLen ;i++)        //»ñÈ¡ÉèÖÃÉ豸Ãû³Æ
-                                                       {
-                                                               TmsKeyData.OperatorName[i] = buf[i+7];
-                                                       } 
-                                                       if(SaveFlag[UserNameMem] == 0)
-                                                       {
-                                                           Memory = UserNameMem;
-                                                               SaveFlag[UserNameMem] = 1;
-                                                                                                                       
-                                                       }
-                                                       break;
-                                       case 0x17:
-                                                       TmsKeyData.SpannerTypener = PTR2U16(&buf[7]);  //»ñÈ¡°âÊÖÀàÐÍ
-                                                       TmsKeyData.Versionnumber = PTR2U16(&buf[9]);
-                                                       if(SaveFlag[UserNameMem] == 0)
-                                                       {
-                                                           Memory = UserNameMem;
-                                                               SaveFlag[UserNameMem] = 1;
-                                                                                                                       
-                                                       }
-                                                       break;
-                                       case 0x18: //Çå³ý»ù´¡Êý¾Ý
-                                                       break;
-                                       case 0x19:
-                                                       sendPCBA_Value();                                                               //ÉÏ·¢PCBAУ׼ֵ
-                                                       break;
-                                       case 0x1A:              //»ñÈ¡PCBAУ׼ֵ
-                                                       TmsKeyData.FactoryCalcRefVoltage = buf[7];
-                                                       if(SaveFlag[UserNameMem] == 0)
-                                                       {
-                                                           Memory = UserNameMem;
-                                                               SaveFlag[UserNameMem] = 1;
-                                                                                                                       
-                                                       }
-                                                       break;
-                                       case 0x1B:  //ÉÏ·¢Å¤¾ØÐ£×¼Öµ
-                                                       sendTorque_Value();             
-                                                       break;
-                                       case 0x1C:              //»ñȡŤ¾ØÐ£×¼Öµ
-                                                       TmsKeyData.FactoryCalcTorque = buf[7];
-                                                       {
-                                                           Memory = UserNameMem;
-                                                               SaveFlag[UserNameMem] = 1;
-                                                                                                                       
-                                                       }
-                                                       break;
-                                       case 0x1D:
-                                                       TmsKeyData.SpannerNumber = PTR2U16(&buf[7]);                //µ¼ÈëŤ¾ØÄ£Ê½µÄÊý¾Ý
-                                                       for(cnt = 0; cnt < TmsKeyData.SpannerNumber; cnt++)
-                                                       {
-                                                               // ÉèÖðâÊÖÐͺÅ
-                                                               strncpy(SpannerType[cnt].SpannerName,(char*)&buf[cnt * 58 + 9], 10);
-                                                               SpannerType[cnt].TorqueMaxDate = PTR2U32(&buf[cnt * 58 + 19]);
-                                                               SpannerType[cnt].TorqueMinDate = PTR2U32((&buf[cnt * 58 + 23])); 
-                                                               for (i = 0; i < TORQUE_POINT_MUN; i++)
-                                                               {
-                                                                       // ÉèÖÃÎåµã¶ÔӦŤ¾ØÖµ
-                                                                       SpannerType[cnt].TorqueDate[i] = PTR2U32((&buf[(cnt * 58)+(i * 8) + 27]));
-                                                                       // ÉèÖÃÎåµãŤ¾ØÖµ¶ÔÓ¦µÄµçÁ÷,ÆøÑ¹,ÓÍѹ
-                                                                       SpannerType[cnt].WorkingMedium[i] = PTR2U32(&buf[(cnt * 58)+(i * 8) + 31]);
-                                                               }
-                                                       }
-                                                       if(SaveFlag[productMem] == 0)
-                                                       {
-                                                               Memory = productMem;
-                                                               SaveFlag[productMem] = 1;
-                                                                                                                               
-                                                       }
-                                                       break;
-                                       case 17:   //½«²úÆ·¸öÊýÇåÁã
-                                                       break;
-                                                       
-                                       case 0x0C:    //»ñÈ¡Îļþ¼Ç¼                       
-                                                       TmsKeyData.DataTransferState = 1;
-                                                       break;
-#if HOST_DEBUG
-                                       case 0xF1:
-                                       {
-                                               int host_debug_enable( float *debug_press );
-                                               host_debug_enable( (float*)&buf[7]);
-                                       }
-                                               break;
-#endif
-                                       default:
-                                                       break;
-                               }
-                   }
-           }
-#endif
        }
 }
 
index 23517ee9e511e25f625756d00c4e3770e4c440c5..8100cf57f35cd5b31033225adc7a7a9b87161870 100644 (file)
@@ -7,6 +7,12 @@
 #include "bsp_timer.h"
 #include "DflashM.h"
 
+#if TOR_RANGE_DEBUG
+extern float pressure_threshold(float pressure);
+#else
+#define pressure_threshold(pressure) (pressure * compareFac)
+#endif //TOR_RANGE_DEBUG
+
 /***********************Macro Definition*******************************************************************/
 #define   S_COUNT_10     (10000/5)  
 #define   MS_COUNT_200    (200/5)   
@@ -38,6 +44,7 @@ uint8_t PWM_Flag;
 float qiya = 0;
 wrench_status_struct wrench_device;
 
+
 #define NEW
 
 /*»ñÈ¡×î´óѹÁ¦Öµ*/
@@ -172,7 +179,7 @@ static void Machine_DoPress(void)                                     //״̬
                        }
                        break;
                case 1:
-                       if(qiya < (temppress) * compareFac && SleepState == 1 && niujupress == 0 && Adjusting_torque_flag == 1) //°âÊÖ°´Ï  ÕâÀïÈç¹ûÏÖ³¡ÆøÑ¹Ò»Ö±±È½ÏµÍ£¬ÉèÖõÄѹÁ¦Èç¹û¸ß  ¾ÍûÓа취¼ì²âµ½°âÊÖ°´ÏµÄ״̬
+                       if(qiya < pressure_threshold(temppress) && SleepState == 1 && niujupress == 0 && Adjusting_torque_flag == 1) //°âÊÖ°´Ï  ÕâÀïÈç¹ûÏÖ³¡ÆøÑ¹Ò»Ö±±È½ÏµÍ£¬ÉèÖõÄѹÁ¦Èç¹û¸ß  ¾ÍûÓа취¼ì²âµ½°âÊÖ°´ÏµÄ״̬
                        {
                                turn_flag = 1;
                                if(wrench_device.rotate_start_count++ >= ROTATE_START_NUM_5MS)
@@ -197,9 +204,9 @@ static void Machine_DoPress(void)                                     //״̬
                                ucCount200ms = 0;                            //ÇåÁã
                 //Èç¹ûADC²É¼¯Ñ¹Á¦´óµÈÓÚÓû§É趨ѹÁ¦µÄ0.9 ²¢ÇҲɼ¯µÄÁ÷Á¿´óÓÚÉèÖõÄÁ÷Á¿µÄX%
 #ifdef ENABLE_FLOW                             
-                               if(((ADCGetPress[0])>= temppress*compareFac) &&  ((ADCGetFlow[0]*10000) >=UserSetFlow) )    
+                               if(((ADCGetPress[0])>= pressure_threshold(temppress)) &&  ((ADCGetFlow[0]*10000) >=UserSetFlow) )    
 #else
-                               if(((ADCGetPress[0])>= temppress*compareFac))    
+                               if(((ADCGetPress[0])>= pressure_threshold(temppress)))    
 #endif                         
                                {
                                        //ÒÔϼÆÊýROTATE_STOP_NUM_5MS Ëƺõ²»Õý³££¬ÒòÎªÇ°Ãæ»¹Óиö¼ÆÊýÆ÷MS_COUNT_200
@@ -210,7 +217,7 @@ static void Machine_DoPress(void)                                     //״̬
                                                //Flash_RecordData();
                                                printf("upUsingStructVar.UsingTimeupUsingStructVar.UsingTime\r\n");
                                                SysMemoryParaVar.tigresult = 1;  //±íʾš½ôÁË
-                                               SysMemoryParaVar.WorkPress = temppress *compareFac *100;
+                                               SysMemoryParaVar.WorkPress = pressure_threshold(temppress) *100;
 
                                                if(SaveFlag[UsingTimesMem] == 0)
                                                {
@@ -225,7 +232,7 @@ static void Machine_DoPress(void)                                     //״̬
                                else
                                {
                                        SysMemoryParaVar.tigresult = 0;
-                                       SysMemoryParaVar.WorkPress = ADCGetPress[0] *compareFac *100; //δš½ô£¬È¡µ±Ç°Ñ¹Á¦ÖµÓÃÓÚ´æ´¢¡£
+                                       SysMemoryParaVar.WorkPress = ADCGetPress[0] *100; //δš½ô£¬È¡µ±Ç°Ñ¹Á¦ÖµÓÃÓÚ´æ´¢¡£
 //                                     LED_SetLedStatus(LED_ID_LOWER_FLOW,1);          
 //                                     Beep_SetbeepStatus(BEEP_ID_LOWER_FLOW,1);//¼ÓÉϵÍѹָʾ
                                }                                                                       
@@ -236,7 +243,7 @@ static void Machine_DoPress(void)                                     //״̬
                                        wrench_device.rotate_work_timeout_count = 0;    
                     SysMemoryParaVar.tigresult = 0;//³¬¹ý10SûÓдﵽĿ±ê ¾Í²»ºÏ¸ñ
                                        printf("disqualification!!!\r\n");
-                     if(ADCGetPress[0]< temppress*compareFac)
+                     if(ADCGetPress[0]< pressure_threshold(temppress))
                                         {
                                                LED_SetLedStatus(LED_ID_LOWER_FLOW,1);          
                                                Beep_SetbeepStatus(BEEP_ID_LOWER_FLOW,1);//¼ÓÉϵÍѹָʾ
@@ -322,7 +329,6 @@ static void Machine_DoPress(void)                                     //״̬
 */
 static uint8_t WrenchMode_Select(uint8_t mode)
 {
-       uint8_t i = 0;
        static uint8_t First[6] = {0};
        static uint8_t StartCaiji[6] = {0};
        static uint8_t Ret = 0;
@@ -358,7 +364,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                Ret = 0;
                                StartCaiji[1] = 1;
                                niujupress = 0;
-                               Sys_setpress(1);
+                               Sys_setpress( mode );
                        }
                
                        if(StartCaiji[1] == 1)
@@ -396,7 +402,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                Ret = 0;
                                StartCaiji[2] = 1;
                                niujupress = 0;
-                               Sys_setpress(2);
+                               Sys_setpress( mode );
                        }
                        
                        if(StartCaiji[2] == 1)
@@ -431,7 +437,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                        Ret = 0;
                                        StartCaiji[3] = 1;
                                        niujupress = 0;
-                                       Sys_setpress(3);
+                                       Sys_setpress( mode );
                                }
                        
                                if(StartCaiji[3] == 1)
@@ -466,10 +472,7 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                Ret = 0;
                                StartCaiji[4] = 1;
                                niujupress = 0;
-                               for(i = 0; i< 10; i++) 
-                               {
-                                       TIM_SetCompare2(TIM4, getOutDutyData(ResetPress.SetPress_Angle));
-                               }
+                               Sys_setpress( mode );
                        }
                
                        if(StartCaiji[4] == 1)
@@ -494,17 +497,14 @@ static uint8_t WrenchMode_Select(uint8_t mode)
                                niujupress = 1;
                                First[5] = 1;
                                First[4] = 0;
-                               for(i = 0; i< 10; i++) 
-                               {
-                                       TIM_SetCompare2(TIM4, getOutDutyData(ResetPress.SetPress_Sensor));
-                               }
+                               Sys_setpress(mode);
                        }
                        if(niujupress ==1)  //Óû§É趨ʱŤ¾Ø·¢Éú±ä»¯
                        {
                                Ret = 0;
                                StartCaiji[5] = 1;
                                niujupress = 0;
-                               Sys_setpress(5);
+                               Sys_setpress( mode );
                        }
                
                        if(StartCaiji[5] == 1)
@@ -572,7 +572,7 @@ void WrenchManage_MainTask(void)                              //״̬
        #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, temppress*compareFac, ADCGetPress[0], TIM_GetCapture2(TIM4));
+                       host_debug_send_info( machine_step, temppress, pressure_threshold(temppress), ADCGetPress[0], TIM_GetCapture2(TIM4));
                }
        #endif
 }