diff --git a/.gitignore b/.gitignore
index fe9c9c5..5981417 100644
--- a/.gitignore
+++ b/.gitignore
@@ -99,3 +99,12 @@ JLinkLog.txt
 
 # Other Files
 
+# Log files
+*.log
+*.log.lock
+
+# JSON files
+*.json
+
+# uVision Options
+*.uvoptx
diff --git a/Core/Src/gpio.c b/Core/Src/gpio.c
index 59f14c6..b618657 100644
--- a/Core/Src/gpio.c
+++ b/Core/Src/gpio.c
@@ -121,7 +121,7 @@ void MX_GPIO_Init(void)
   /*Configure GPIO pin : PtPin */
   GPIO_InitStruct.Pin = STOP_Pin;
   GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
-  GPIO_InitStruct.Pull = GPIO_PULLUP;
+  GPIO_InitStruct.Pull = GPIO_NOPULL;
   HAL_GPIO_Init(STOP_GPIO_Port, &GPIO_InitStruct);
 
   /*Configure GPIO pin : PtPin */
diff --git a/MDK-ARM/.vscode/keil-assistant.log b/MDK-ARM/.vscode/keil-assistant.log
index c3bdeca..b3c05a0 100644
--- a/MDK-ARM/.vscode/keil-assistant.log
+++ b/MDK-ARM/.vscode/keil-assistant.log
@@ -22,3 +22,35 @@
 
 [info] Log at : 2025/4/16|16:20:32|GMT+0800
 
+[info] Log at : 2025/4/19|19:27:22|GMT+0800
+
+[info] Log at : 2025/4/19|21:14:34|GMT+0800
+
+[info] Log at : 2025/4/19|23:02:49|GMT+0800
+
+[info] Log at : 2025/4/20|14:28:49|GMT+0800
+
+[info] Log at : 2025/4/20|15:44:16|GMT+0800
+
+[info] Log at : 2025/4/20|16:25:11|GMT+0800
+
+[info] Log at : 2025/4/21|17:04:22|GMT+0800
+
+[info] Log at : 2025/4/22|10:54:46|GMT+0800
+
+[info] Log at : 2025/4/22|19:20:19|GMT+0800
+
+[info] Log at : 2025/4/23|14:36:25|GMT+0800
+
+[info] Log at : 2025/4/23|17:15:10|GMT+0800
+
+[info] Log at : 2025/4/24|22:10:33|GMT+0800
+
+[info] Log at : 2025/4/24|23:29:19|GMT+0800
+
+[info] Log at : 2025/4/25|18:41:24|GMT+0800
+
+[info] Log at : 2025/4/25|18:59:20|GMT+0800
+
+[info] Log at : 2025/4/26|16:18:23|GMT+0800
+
diff --git a/MDK-ARM/.vscode/settings.json b/MDK-ARM/.vscode/settings.json
index cdb910e..9d1717c 100644
--- a/MDK-ARM/.vscode/settings.json
+++ b/MDK-ARM/.vscode/settings.json
@@ -9,6 +9,8 @@
         "task.h": "c",
         "djimotor.h": "c",
         "nuc.h": "c",
-        "crc_ccitt.h": "c"
+        "crc_ccitt.h": "c",
+        "functional": "cpp",
+        "vofa.h": "c"
     }
 }
\ No newline at end of file
diff --git a/MDK-ARM/.vscode/uv4.log b/MDK-ARM/.vscode/uv4.log
index 84f9363..2ac5c03 100644
--- a/MDK-ARM/.vscode/uv4.log
+++ b/MDK-ARM/.vscode/uv4.log
@@ -1,4 +1,8 @@
 *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'D:\keil\ARM\ARMCC\Bin'
 Build target 'R1-shooter'
+compiling ball.cpp...
+linking...
+Program Size: Code=26644 RO-data=1812 RW-data=240 ZI-data=23520  
+FromELF: creating hex file...
 "R1-shooter\R1-shooter.axf" - 0 Error(s), 0 Warning(s).
-Build Time Elapsed:  00:00:01
+Build Time Elapsed:  00:00:03
diff --git a/MDK-ARM/.vscode/uv4.log.lock b/MDK-ARM/.vscode/uv4.log.lock
index 8787f84..e1bf9c5 100644
--- a/MDK-ARM/.vscode/uv4.log.lock
+++ b/MDK-ARM/.vscode/uv4.log.lock
@@ -1 +1 @@
-2025/4/13 22:09:19
\ No newline at end of file
+2025/4/26 16:32:18
\ No newline at end of file
diff --git a/MDK-ARM/R1-shooter.uvoptx b/MDK-ARM/R1-shooter.uvoptx
index 6ae841a..a3a851b 100644
--- a/MDK-ARM/R1-shooter.uvoptx
+++ b/MDK-ARM/R1-shooter.uvoptx
@@ -103,7 +103,7 @@
         <bEvRecOn>1</bEvRecOn>
         <bSchkAxf>0</bSchkAxf>
         <bTchkAxf>0</bTchkAxf>
-        <nTsel>6</nTsel>
+        <nTsel>3</nTsel>
         <sDll></sDll>
         <sDllPa></sDllPa>
         <sDlgDll></sDlgDll>
@@ -114,9 +114,14 @@
         <tDlgDll></tDlgDll>
         <tDlgPa></tDlgPa>
         <tIfile></tIfile>
-        <pMon>STLink\ST-LINKIII-KEIL_SWO.dll</pMon>
+        <pMon>BIN\CMSIS_AGDI.dll</pMon>
       </DebugOpt>
       <TargetDriverDllRegistry>
+        <SetRegEntry>
+          <Number>0</Number>
+          <Key>CMSIS_AGDI</Key>
+          <Name>-X"Any" -UAny -O206 -S8 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC1000 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
+        </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>
           <Key>ARMRTXEVENTFLAGS</Key>
@@ -135,7 +140,7 @@
         <SetRegEntry>
           <Number>0</Number>
           <Key>DLGUARM</Key>
-          <Name>(105=-1,-1,-1,-1,0)</Name>
+          <Name></Name>
         </SetRegEntry>
         <SetRegEntry>
           <Number>0</Number>
@@ -145,7 +150,7 @@
         <SetRegEntry>
           <Number>0</Number>
           <Key>ST-LINKIII-KEIL_SWO</Key>
-          <Name>-U-O142 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
+          <Name>-U00160029510000164E574E32 -O2254 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(2BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD20000000 -FC800 -FN1 -FF0STM32F4xx_1024.FLM -FS08000000 -FL0100000 -FP0($$Device:STM32F407IGHx$CMSIS\Flash\STM32F4xx_1024.FLM)</Name>
         </SetRegEntry>
       </TargetDriverDllRegistry>
       <Breakpoint/>
@@ -218,22 +223,22 @@
         <Ww>
           <count>13</count>
           <WinNumber>1</WinNumber>
-          <ItemText>abc,0x0A</ItemText>
+          <ItemText>\\R1_shooter\../User/task/ballTask.cpp\ball,0x0A</ItemText>
         </Ww>
         <Ww>
           <count>14</count>
           <WinNumber>1</WinNumber>
-          <ItemText>\\R1_shooter\../User/task/ballTask.cpp\ball,0x0A</ItemText>
+          <ItemText>currentState1</ItemText>
         </Ww>
         <Ww>
           <count>15</count>
           <WinNumber>1</WinNumber>
-          <ItemText>speedm,0x0A</ItemText>
+          <ItemText>abc,0x0A</ItemText>
         </Ww>
         <Ww>
           <count>16</count>
           <WinNumber>1</WinNumber>
-          <ItemText>abc,0x0A</ItemText>
+          <ItemText>ball_state,0x0A</ItemText>
         </Ww>
         <Ww>
           <count>17</count>
@@ -243,7 +248,12 @@
         <Ww>
           <count>18</count>
           <WinNumber>1</WinNumber>
-          <ItemText>ball_state,0x0A</ItemText>
+          <ItemText>triggerCount,0x0A</ItemText>
+        </Ww>
+        <Ww>
+          <count>19</count>
+          <WinNumber>1</WinNumber>
+          <ItemText>last_ball_state,0x0A</ItemText>
         </Ww>
       </WatchWindow1>
       <WatchWindow2>
@@ -261,7 +271,7 @@
         <periodic>1</periodic>
         <aLwin>1</aLwin>
         <aCover>0</aCover>
-        <aSer1>0</aSer1>
+        <aSer1>1</aSer1>
         <aSer2>0</aSer2>
         <aPa>0</aPa>
         <viewmode>1</viewmode>
diff --git a/R1-shooter.ioc b/R1-shooter.ioc
index 2091ec3..9332e11 100644
--- a/R1-shooter.ioc
+++ b/R1-shooter.ioc
@@ -260,7 +260,7 @@ PE14.Locked=true
 PE14.Signal=GPIO_Output
 PE9.GPIOParameters=GPIO_PuPd,GPIO_Label
 PE9.GPIO_Label=STOP
-PE9.GPIO_PuPd=GPIO_PULLUP
+PE9.GPIO_PuPd=GPIO_PULLDOWN
 PE9.Locked=true
 PE9.Signal=GPIO_Input
 PF6.GPIOParameters=GPIO_Speed,GPIO_Label
diff --git a/User/bsp/can_init.c b/User/bsp/can_init.c
index 27b0c5e..e1830be 100644
--- a/User/bsp/can_init.c
+++ b/User/bsp/can_init.c
@@ -32,3 +32,30 @@ void can_filter_init(void)
     HAL_CAN_ActivateNotification(&hcan2, CAN_IT_RX_FIFO1_MSG_PENDING);
    
 }
+// void can_filter_init(void)
+// {
+
+//     CAN_FilterTypeDef can_filter_st;
+//     can_filter_st.FilterActivation = ENABLE;
+//     can_filter_st.FilterMode = CAN_FILTERMODE_IDMASK;
+//     can_filter_st.FilterScale = CAN_FILTERSCALE_32BIT;
+//     can_filter_st.FilterIdHigh = 0x0000;
+//     can_filter_st.FilterIdLow = 0x0000;
+//     can_filter_st.FilterMaskIdHigh = 0x0000;
+//     can_filter_st.FilterMaskIdLow = 0x0000;
+//     can_filter_st.FilterBank = 0;
+//     can_filter_st.FilterFIFOAssignment = CAN_RX_FIFO0;
+//     HAL_CAN_ConfigFilter(&hcan1, &can_filter_st);
+//     HAL_CAN_Start(&hcan1);
+//     HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING);
+
+
+//     can_filter_st.SlaveStartFilterBank = 14;
+//     can_filter_st.FilterBank = 14;
+//     HAL_CAN_ConfigFilter(&hcan2, &can_filter_st);
+//     HAL_CAN_Start(&hcan2);
+//     HAL_CAN_ActivateNotification(&hcan2, CAN_IT_RX_FIFO1_MSG_PENDING);
+
+
+
+// }
diff --git a/User/device/detect.c b/User/device/detect.c
index 2775d38..90b75ed 100644
--- a/User/device/detect.c
+++ b/User/device/detect.c
@@ -24,7 +24,7 @@ void detect_init(void)
 {
 
     BSP_GPIO_RegisterCallback(KEY_Pin, detect_exit);
-    //BSP_GPIO_RegisterCallback(ext_up_Pin, detect_led);
+   // BSP_GPIO_RegisterCallback(ext_up_Pin, detect_led);
     // 注册按键中断回调函数
     if (BSP_GPIO_RegisterCallback(KEY_Pin, detect_exit) != BSP_OK) {
         // 错误处理
diff --git a/User/device/djiMotor.c b/User/device/djiMotor.c
index eb2fc65..e2042c4 100644
--- a/User/device/djiMotor.c
+++ b/User/device/djiMotor.c
@@ -160,6 +160,7 @@ void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
 }
 #else
 static osEventFlagsId_t eventReceive;
+static osThreadId_t thread_alert;
 /**
   * @brief          自定义大疆电机回调函数
   * @param[in]      none
@@ -169,8 +170,8 @@ void Dji_Motor_CB()
 {
   HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &dji_rx_header, dji_rx_data);
 
-  
-  osEventFlagsSet(eventReceive, EVENT_CAN);
+  osThreadFlagsSet(thread_alert, EVENT_CAN);
+ // osEventFlagsSet(eventReceive, EVENT_CAN);
 }
 void can2_Motor_CB(void)
 {
@@ -184,6 +185,7 @@ void can2_Motor_CB(void)
 */
 void djiInit(void)
 {
+  thread_alert = osThreadGetId();
   BSP_CAN_RegisterCallback(BSP_CAN_1, HAL_CAN_RX_FIFO0_MSG_PENDING_CB,
                           Dji_Motor_CB);
   BSP_CAN_RegisterCallback(BSP_CAN_2, HAL_CAN_RX_FIFO1_MSG_PENDING_CB,
@@ -197,8 +199,11 @@ void djiInit(void)
 */
 uint32_t waitNewDji() 
 {
-  return osEventFlagsWait(
-				eventReceive, EVENT_CAN,osFlagsWaitAny, osWaitForever);
+  // return osEventFlagsWait(
+	// 			eventReceive, EVENT_CAN,osFlagsWaitAny, osWaitForever);
+  return osThreadFlagsWait(
+    EVENT_CAN, osFlagsWaitAll, osWaitForever);
+
 }
 #endif
 
diff --git a/User/device/vofa.c b/User/device/vofa.c
index 5d06c50..2a044de 100644
--- a/User/device/vofa.c
+++ b/User/device/vofa.c
@@ -32,11 +32,11 @@ void vofa_tx_main(float *data)
 	//用dma用不了
 
 	//HAL_UART_Transmit_DMA(&huart6, ( uint8_t *)fdata, sizeof(fdata));
-	HAL_UART_Transmit(&huart6, ( uint8_t *)fdata, sizeof(fdata),0xFFFF);                    //发送第一组数据
+	HAL_UART_Transmit(&huart1, ( uint8_t *)fdata, sizeof(fdata),0xFFFF);                    //发送第一组数据
 	osDelay(1);
 	//HAL_UART_Transmit_DMA(&huart6, tail, 4);
-	HAL_UART_Transmit(&huart6, tail, 4,0xFFFF);                    //发送第二组数据
-   osDelay(1);
+	HAL_UART_Transmit(&huart1, tail, 4,0xFFFF);                    //发送第二组数据
+    osDelay(1);
 
     //用虚拟串口c板开启不了
 	//  CDC_Transmit_FS( ( uint8_t *)fdata, sizeof(fdata));
diff --git a/User/device/vofa.h b/User/device/vofa.h
index 8f83b9a..3f454fd 100644
--- a/User/device/vofa.h
+++ b/User/device/vofa.h
@@ -1,6 +1,8 @@
 #ifndef   _VOFA_H_
 #define   _VOFA_H_
-
+#ifdef __cplusplus
+extern "C"{
+#endif
 
 
 
@@ -12,6 +14,9 @@ void vofa_tx_main(float *data);
 
 extern float vofa_send[8];
 
+#ifdef __cplusplus
+}
+#endif
 
 #endif
 
diff --git a/User/module/ball.cpp b/User/module/ball.cpp
index 05bc2ef..d51f707 100644
--- a/User/module/ball.cpp
+++ b/User/module/ball.cpp
@@ -14,7 +14,7 @@ int speedm1=0;
 
 #define MOTOR_SPEED 1000
 
-const fp32 Ball:: M3508_speed_PID[3] = {5, 0, 0};
+const fp32 Ball:: M3508_speed_PID[3] = {5, 0.01, 0};
 
 //PE11 气缸
 
@@ -29,7 +29,7 @@ Ball ::Ball()
     if(i <=3)
     {
         hand_Motor[i]->type = M3508;//设置电机类型
-        PID_init(&speed_pid[i],PID_POSITION,M3508_speed_PID,16000, 6000);//pid初始化
+        PID_init(&speed_pid[i],PID_POSITION,M3508_speed_PID,16000, 10000);//pid初始化
     }  
     result[i] = 0;
     speedSet[i] = 0;    
@@ -37,29 +37,25 @@ Ball ::Ball()
      
 }
 
+#if HANDLING3 == 1
+
 void Ball ::Spin(float speed,float speed2)
 {
 
     speedSet[MOTOR_1] = -speed;
     result[MOTOR_1] = PID_calc(&speed_pid[MOTOR_1],hand_Motor[MOTOR_1]->speed_rpm,speedSet[MOTOR_1]);
 
-    speedSet[MOTOR_2] = speed2;
+    speedSet[MOTOR_2] = speed;
     result[MOTOR_2] = PID_calc(&speed_pid[MOTOR_2],hand_Motor[MOTOR_2]->speed_rpm,speedSet[MOTOR_2]);
 
-    speedSet[MOTOR_3] = speed;
+    speedSet[MOTOR_3] = speed2;
     result[MOTOR_3] = PID_calc(&speed_pid[MOTOR_3],hand_Motor[MOTOR_3]->speed_rpm,speedSet[MOTOR_3]);
 
-    // for(int i = 1;i < MOTOR_NUM;i ++)
-    // {
-    //     speedSet[i] = speed;
-    //     result[i] = PID_calc(&speed_pid[i],hand_Motor[i]->speed_rpm,speedSet[i]);
-
-    // }
-
 }
 
 	int flag =0;
 	int ball_state = 0;
+   
 void Ball::ballHadling(void)
 {
 
@@ -71,16 +67,16 @@ void Ball::ballHadling(void)
         if (key > 0) // 检测按键是否被按下
         {
             speedm=-4500;
-            speedm1=-3500;
+            speedm1=-4500;
             currentState1 = BALL_FORWARD; // 切换到正转状态
         }
         break;
 
     case BALL_FORWARD:
 
-        if (  hand_Motor[MOTOR_1]->speed_rpm >= 4480&&hand_Motor[MOTOR_1]->speed_rpm <= 4520 &&
-              hand_Motor[MOTOR_2]->speed_rpm <= -2980-500&&hand_Motor[MOTOR_2]->speed_rpm >= -3020-500 &&          
-              hand_Motor[MOTOR_3]->speed_rpm <= -4480&&hand_Motor[MOTOR_3]->speed_rpm >= -4020-1000 )
+        if (  hand_Motor[MOTOR_1]->speed_rpm >= 4480&&hand_Motor[MOTOR_1]->speed_rpm <= 4530 &&
+              hand_Motor[MOTOR_2]->speed_rpm <= -4480&&hand_Motor[MOTOR_2]->speed_rpm >= -4530 &&          
+              hand_Motor[MOTOR_3]->speed_rpm <= -4480&&hand_Motor[MOTOR_3]->speed_rpm >= -4530 )
         {
             HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_SET);// 打开气缸
             currentState1 = BALL_DROP; // 切换到球下落状态
@@ -92,8 +88,8 @@ void Ball::ballHadling(void)
         if (ball_state == 1) //读光电 有球 0  无球 1
         {
             osDelay(200); // 延时200ms
-            speedm=3000;
-            speedm1=3000;
+            speedm=4500;
+            speedm1=4500;
             currentState1 = BALL_REVERSE; // 切换到反转状态
         }
         
@@ -104,7 +100,7 @@ void Ball::ballHadling(void)
         if (ball_state == 0) 
         {
             
-            flag=2;   //抽象的计次
+            //flag=2;   //抽象的计次
             speedm=0; // 停止电机
             speedm1=0;
             currentState1 = BALL_CLOSE; // 切换到完成状态
@@ -113,21 +109,26 @@ void Ball::ballHadling(void)
      break;
 
     case BALL_CLOSE:
-        osDelay(200); // 延时50ms
-        if (flag == 2) 
-        {
-            if(ball_state == 0)
-            {
-                HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
-                currentState1 = BALL_FINISH; // 切换到完成状态
-            }
+       // osDelay(200); // 延时50ms
+       if(ball_state == 0)
+       {
+           HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
+           currentState1 = BALL_FINISH; // 切换到完成状态
+       }
+        // if (flag == 2) 
+        // {
+        //     if(ball_state == 0)
+        //     {
+        //         HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET);
+        //         currentState1 = BALL_FINISH; // 切换到完成状态
+        //     }
           
-        }
+        // }
         break;    
 
     case BALL_FINISH:
         osDelay(200); // 延时50ms
-        key = 0; // 重置按键状态
+        key=0; // 重置按键状态
         flag=0;
         speedm=0;
         speedm1=0;
@@ -144,6 +145,140 @@ void Ball::ballHadling(void)
 void Ball::Send_control()
 {
     CAN_cmd_200(result[MOTOR_1],result[MOTOR_2],result[MOTOR_3],0,&hcan1);
+    osDelay(2);
 
 }
 
+#else
+int flag =0;
+int ball_state = 0;
+// void Ball::ballHadling(void)
+// {
+//     ball_state =HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin);//有球 0 无球 1
+//     switch (currentState1)
+//     {
+//     case BALL_IDLE:
+    
+//     if (key > 0) // 检测按键是否被按下
+//      {
+//         currentState1 = BALL_FORWARD; // 切换到正转状态
+        
+//      }
+//         break;
+
+//     case BALL_FORWARD:
+//     HAL_GPIO_WritePin(PAW_GPIO_Port, PAW_Pin, GPIO_PIN_SET);
+//     osDelay(50); 
+//     HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_SET);
+
+//     currentState1 = BALL_DROP; // 切换到球下落状态
+//         break;
+
+//     case BALL_DROP:
+//     osDelay(100); // 
+//     HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET);
+//     currentState1 = BALL_CLOSE; // 切换到反转状态
+//      break;
+
+//     case BALL_CLOSE:
+//         osDelay(100);
+//         if(ball_state == 0)
+//         {
+//            HAL_GPIO_WritePin(PAW_GPIO_Port, PAW_Pin, GPIO_PIN_RESET); 
+//            currentState1 = BALL_REVERSE; // 切换到反转状态 
+//         }
+     
+     
+
+//     break;
+
+//     case BALL_REVERSE:
+//      osDelay(50); // 延时200ms
+//      HAL_GPIO_WritePin(PAW_GPIO_Port, PAW_Pin, GPIO_PIN_RESET);
+//      HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET);
+//      key=0; // 重置按键状态
+//      currentState1 = BALL_IDLE; // 回到空闲状态
+//      break;
+    
+//      default:
+//       currentState1 = BALL_IDLE; // 默认回到空闲状态
+//       break;
+//   }
+    
+// }    
+ int triggerCount = 0; // 光电传感器触发计数
+ int last_ball_state = 1; // 上一次的光电状态
+void Ball::ballHadling(void)
+{
+  
+    ball_state = HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin); // 读取光电状态(有球 0,无球 1)
+
+    switch (currentState1)
+    {
+    case BALL_IDLE:
+        HAL_GPIO_WritePin(CLOSE_GPIO_Port, CLOSE_Pin, GPIO_PIN_RESET); // 确保气缸闭合
+        if (key > 0) // 检测按键是否被按下
+        {
+            key = 0; // 重置按键状态
+            triggerCount = 0; // 重置触发计数
+            currentState1 = BALL_FORWARD; // 切换到正转状态
+        }
+        break;
+
+    case BALL_FORWARD:
+        HAL_GPIO_WritePin(PAW_GPIO_Port, PAW_Pin, GPIO_PIN_SET); // 打开气缸爪子
+        osDelay(10); 
+        HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_SET); // 打开下气缸
+        currentState1 = BALL_DROP; // 切换到球下落状态
+        break;
+
+        case BALL_DROP:
+        osDelay(100); // 延时 100ms
+        HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 关闭下气缸
+        if (ball_state == 0 && last_ball_state == 1) // 检测到状态从无球变为有球
+        {
+            //osDelay(10); // 延时去抖动
+            triggerCount++; // 增加触发计数
+            if (triggerCount == 1) // 第一次触发
+            {
+                currentState1 = BALL_FLAG; // 切换到等待第二次触发状态
+            }
+        }
+        last_ball_state = ball_state; // 更新上一次的状态
+        break;
+
+        case BALL_FLAG:
+        osDelay(10); // 延时 50ms
+        if (triggerCount == 1 && ball_state == 0 && last_ball_state == 1) // 第二次检测到球
+        {
+            triggerCount++; // 增加触发计数
+            currentState1 = BALL_CLOSE; // 切换到闭合气缸状态
+        }
+        last_ball_state = ball_state; // 更新上一次的状态
+        break;
+
+    case BALL_CLOSE:
+        if (triggerCount == 2) // 确保是第二次触发
+        {
+            //osDelay(10); // 延时去抖
+            HAL_GPIO_WritePin(PAW_GPIO_Port, PAW_Pin, GPIO_PIN_RESET); // 闭合气缸爪子
+            currentState1 = BALL_REVERSE; // 切换到反转状态
+        }
+        break;
+
+    case BALL_REVERSE:
+        osDelay(50); // 延时 50ms
+        HAL_GPIO_WritePin(PAW_GPIO_Port, PAW_Pin, GPIO_PIN_RESET); // 确保气缸爪子闭合
+        HAL_GPIO_WritePin(DOWN_GPIO_Port, DOWN_Pin, GPIO_PIN_RESET); // 确保下气缸关闭
+        key = 0; // 重置按键状态
+        triggerCount = 0; // 重置触发计数
+        currentState1 = BALL_IDLE; // 回到空闲状态
+        break;
+
+    default:
+        currentState1 = BALL_IDLE; // 默认回到空闲状态
+        break;
+    }
+}   
+ #endif
+
diff --git a/User/module/ball.hpp b/User/module/ball.hpp
index ab4c7b6..d880f97 100644
--- a/User/module/ball.hpp
+++ b/User/module/ball.hpp
@@ -7,12 +7,15 @@
 #include "djiMotor.h"
 #include "pid.h"
 
+#define HANDLING3  0
+
 // 定义状态枚举
 typedef enum {
     BALL_IDLE,         // 空闲状态
     BALL_FORWARD,      // 正转状态
     BALL_DROP,         // 球下落状态
     BALL_REVERSE,      // 反转状态
+    BALL_FLAG,
     BALL_CLOSE,         // 关闭状态
     BALL_FINISH        // 完成状态
 } BallState_t;
diff --git a/User/task/ballTask.cpp b/User/task/ballTask.cpp
index 972153a..a4fadf6 100644
--- a/User/task/ballTask.cpp
+++ b/User/task/ballTask.cpp
@@ -5,8 +5,10 @@
 #include <cmsis_os2.h>
 #include "ball.hpp"
 #include "remote_control.h"
+#include "vofa.h"
 extern RC_ctrl_t rc_ctrl;
 Ball ball;
+float vofa[8];
 
 int abc=0;
 extern int speedm;
@@ -16,8 +18,8 @@ void FunctionBall(void *argument)
 {
     (void)argument; /* 未使用argument,消除警告 */
 
-    const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_BALL;
-    uint32_t tick = osKernelGetTickCount();
+    // const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_BALL;
+    // uint32_t tick = osKernelGetTickCount();
 		
     while(1)
     {
@@ -25,12 +27,22 @@ void FunctionBall(void *argument)
      task_struct.stack_water_mark.ball = osThreadGetStackSpace(osThreadGetId());  
 #endif          
        abc=HAL_GPIO_ReadPin(up_ball_GPIO_Port, up_ball_Pin);
+       //abc=HAL_GPIO_ReadPin(STOP_GPIO_Port, STOP_Pin);
 
        ball.ballHadling(); // 处理摩擦轮转动
-       ball.Spin(speedm,speedm1);
-       ball.Send_control(); 
+//			speedm=4000;
+//			speedm1=4000;
+//       ball.Spin(speedm,speedm1);
+//       ball.Send_control();
 
-        tick += delay_tick; /* 计算下一个唤醒时刻 */
-        osDelayUntil(tick);
+//       vofa[0] = speedm; // 发送电机角度数据
+//       vofa[1] = -ball.hand_Motor[0]->speed_rpm; // 发送电机角度数据
+//       vofa[2] = ball.hand_Motor[1]->speed_rpm; // 发送电机速度数据
+//       vofa[3] = ball.hand_Motor[2]->speed_rpm; // 发送电机速度数据
+
+//       vofa_tx_main(vofa); // 发送数据到虚拟串口
+
+        // tick += delay_tick; /* 计算下一个唤醒时刻 */
+        // osDelayUntil(tick);
     }
 }
diff --git a/User/task/encodeCan.cpp b/User/task/encodeCan.cpp
index 261904d..2791a76 100644
--- a/User/task/encodeCan.cpp
+++ b/User/task/encodeCan.cpp
@@ -15,11 +15,11 @@ void FunctionCan(void *argument)
 {
     (void)argument; /* 未使用argument,消除警告 */
 
-    const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CAN;
+    //const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CAN;
 
     djiInit();
 
-    uint32_t tick = osKernelGetTickCount();
+    //uint32_t tick = osKernelGetTickCount();
     while(1)
     {
   #ifdef DEBUG
@@ -30,7 +30,7 @@ void FunctionCan(void *argument)
         djiMotorEncode();
         can2MotorEncode();
 
-        tick += delay_tick; /* 计算下一个唤醒时刻 */
-        osDelayUntil(tick);
+        // tick += delay_tick; /* 计算下一个唤醒时刻 */
+        // osDelayUntil(tick);
     }
 }
diff --git a/User/task/nucTask.cpp b/User/task/nucTask.cpp
index 5f3497a..901a127 100644
--- a/User/task/nucTask.cpp
+++ b/User/task/nucTask.cpp
@@ -4,6 +4,7 @@
 #include "TopDefine.h"//事件组的一些东西
 #include "FreeRTOS.h"
 #include <cmsis_os2.h>
+#include <stdio.h>
 
 #ifdef DEBUG
 
@@ -21,6 +22,7 @@ void Function_nuc(void *argument)
 
     NUC_Init(&cmd_fromnuc);
     
+
    uint32_t tick = osKernelGetTickCount();
 
     while(1)
@@ -31,8 +33,8 @@ void Function_nuc(void *argument)
         NUC_StartReceiving();
 
         NUC_RawParse(&cmd_fromnuc);
-        
-        NUC_SendPacket(&send, sizeof(send)); // 发送数据包
+      
+        //NUC_SendPacket(&send, sizeof(send)); // 发送数据包
 //掉线处理有空写 
         // if(NUC_WaitDmaCplt())
         // {
diff --git a/User/task/userTask.c b/User/task/userTask.c
index 3282ca4..0d66988 100644
--- a/User/task/userTask.c
+++ b/User/task/userTask.c
@@ -24,7 +24,7 @@ const osThreadAttr_t attr_take = {
 const osThreadAttr_t attr_can = {
     .name = "can",
     .priority = osPriorityRealtime,
-    .stack_size = 128 * 6,
+    .stack_size = 128 * 8,
 };
 
 const osThreadAttr_t attr_rc = {
@@ -36,7 +36,7 @@ const osThreadAttr_t attr_rc = {
 const osThreadAttr_t attr_ball = {
     .name = "ball",
     .priority = osPriorityRealtime,
-    .stack_size = 128 * 4,
+    .stack_size = 128 * 8,
 };
 const osThreadAttr_t attr_nuc = {
     .name = "nuc",