From: kyz Date: Wed, 21 Jan 2026 10:06:15 +0000 (+0800) Subject: 内置压力区间范围参数,按区间计算压力值 X-Git-Url: http://kyz.pub/gitweb/?a=commitdiff_plain;h=1a2e5ba215eac9135bd5401c4ba8ac373f01206c;p=yn%2Fyn-qdbs.git 内置压力区间范围参数,按区间计算压力值 --- diff --git a/QiDong/APP/inc/model.h b/QiDong/APP/inc/model.h index b18aebe..9525e6e 100644 --- a/QiDong/APP/inc/model.h +++ b/QiDong/APP/inc/model.h @@ -73,7 +73,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); diff --git a/QiDong/APP/src/model.c b/QiDong/APP/src/model.c index e30c930..5cdc928 100644 --- a/QiDong/APP/src/model.c +++ b/QiDong/APP/src/model.c @@ -16,222 +16,51 @@ /*********************************************************************************************************/ + ///uint16_t productKind = 0; uint8_t gearKind = 0 ; TorquePattern TorquePatternVar[50] = {0}; GearPattern GearPatternVar[70] = {0}; +#define TOR_RANGE_DEBUG 1 -#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); - } +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)) - 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"); - } -} - -#endif +#endif /* @@ -348,27 +177,48 @@ uint32_t getOutDutyData(float press) */ } - - - -/* -************************************************************************** -* º¯ Êý Ãû: getPressValue -* ¹¦ÄÜ˵Ã÷: ·µ»ØÑ¹Á¦Öµ¡£À©´ó10Íò±¶,°´ÕÕbarµÄ±ê×¼ -* ÐÎ ²Î: factor²úƷϵÊý - torquevalue:É趨µÄŤ¾ØÖµ -* ·µ »Ø Öµ: É趨µÄŤ¾ØÖµ¶ÔÓ¢µÄѹÁ¦,bar -************************************************************************** -*/ -float getPressValue(uint32_t factor,uint32_t torquevalue) +float pressure_threshold( float pressure ) { - return (torquevalue*100000/factor); -// return (torquevalue * 100000); + //¸ù¾ÝÊäÈëµÄѹÁ¦Öµ£¬²éÕÒ¶ÔӦѹÁ¦ãÐÖµ°Ù·Ö±È + int i; + float percent; + + 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; } //Ť¾Ø»»Ëã³ÉѹÁ¦£¬°´²ÎÊý±í²éÕÒ×îСŤ¾Ø/ѹÁ¦ºÍ×î´óŤ¾ØÑ¹Á¦£¬½«ÊäÈë²ÎÊýŤ¾Ø»»Ëã³ÉѹÁ¦·µ»Ø float tor_to_pressure(uint32_t tor) { +#if 1 + //Æô¶¯³å»÷µ÷ÊÔ¹¦ÄÜ + //¸ù¾ÝÊäÈëµÄŤ¾ØÖµ£¬²éÕÒ¶ÔӦѹÁ¦Öµ + 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 +251,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 } /* ************************************************************************** diff --git a/QiDong/APP/src/screen_app.c b/QiDong/APP/src/screen_app.c index 217c853..47ce7f2 100644 --- a/QiDong/APP/src/screen_app.c +++ b/QiDong/APP/src/screen_app.c @@ -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) { diff --git a/QiDong/BSP/src/bsp_host.c b/QiDong/BSP/src/bsp_host.c index 9cf758f..479a2e1 100644 --- a/QiDong/BSP/src/bsp_host.c +++ b/QiDong/BSP/src/bsp_host.c @@ -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= ROTATE_START_NUM_5MS) @@ -197,9 +218,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 +231,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 +246,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 +257,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);//¼ÓÉϵÍѹָʾ @@ -572,7 +593,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 }