From 8ac2a3efbec81c17ad0f6e6663626fff3bfb996e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B7=E5=BA=8A=E5=B0=B1=E7=8A=AF=E5=9B=B0?= <11730503+psx123456@user.noreply.gitee.com> Date: Mon, 11 Aug 2025 10:20:44 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BD=BF=E8=BD=AE=E4=BC=A0=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- APP/Common/ptz_default_value.h | 10 ++++---- APP/Device/Device_speed/speed_to_bldc.c | 30 +++++++++++++++++++--- BSP/Driver/full_bridge/full_bridge.c | 34 +++++++++++++++---------- 3 files changed, 51 insertions(+), 23 deletions(-) diff --git a/APP/Common/ptz_default_value.h b/APP/Common/ptz_default_value.h index 0a13ff6..ec642a3 100644 --- a/APP/Common/ptz_default_value.h +++ b/APP/Common/ptz_default_value.h @@ -98,11 +98,11 @@ /**********************************************************/ ///磁编码器和电机之间的减速比 - #define PTZ_VERT_MOTOR_RATIO 75.0 //75.0//(50.0 * (52.0 / 35.0))//20.0 + #define PTZ_VERT_MOTOR_RATIO 35.15 //75.0//(50.0 * (52.0 / 35.0))//20.0 ///磁编码器与云台轴之间的减速比 #define PTZ_VERT_BIG_GEAR_RATIO 80.0//54.00 ///垂直总减速比 - #define PTZ_VERT_RATIO 6000.0 //6000.0//4011.429//1080.0 + #define PTZ_VERT_RATIO 2812.0 //6000.0//4011.429//1080.0 ///垂直电机调速模拟电压最大值 #define PTZ_VERT_VR_MAX 1999 ///垂直电机调速模拟电压最小值 @@ -114,11 +114,11 @@ ///垂直电机最小转速 #define PTZ_VERT_MOTOR_MIN_SPEED 400.0//600.0 ///垂直云台最大转速 - #define PTZ_VERT_MAX_SPEED 0.5 //0.5//0.74//2.7 + #define PTZ_VERT_MAX_SPEED 1.0 //0.5//0.74//2.7 ///垂直云台最小转速 - #define PTZ_VERT_MIN_SPEED 0.07 //0.07//0.1//0.15//0.5 + #define PTZ_VERT_MIN_SPEED 0.15 //0.07//0.1//0.15//0.5 ///垂直云台默认最佳速度 - #define PTZ_VERT_BEST_SPEED 0.4 //0.4//0.7//2.0 + #define PTZ_VERT_BEST_SPEED 0.75 //0.4//0.7//2.0 //电机磁极对数 diff --git a/APP/Device/Device_speed/speed_to_bldc.c b/APP/Device/Device_speed/speed_to_bldc.c index 913f112..2c34a0a 100644 --- a/APP/Device/Device_speed/speed_to_bldc.c +++ b/APP/Device/Device_speed/speed_to_bldc.c @@ -549,12 +549,22 @@ static void ptz_hori_pid_task() g_ptz.hori_pid.hall_h123_count = g_ptz.hori_pid.hall_h1_count + g_ptz.hori_pid.hall_h2_count + g_ptz.hori_pid.hall_h3_count; - + static uint32_t time, lastTime, horiTime; + time = OSTimeGet(); + horiTime = time - lastTime; + if (horiTime < 0) { + continue; + } + lastTime = time; + if(g_ptz.hori_pid.hall_h123_count >= 2) { + // g_ptz.hori_pid.hall_h123_motor_speed = + // 60000.0 * (float)(g_ptz.hori_pid.hall_h123_count/* - 1*/) / + // (float)PTZ_HORI_PID_T / PTZ_HORI_ONE_CYCLE_HALL_NUM; g_ptz.hori_pid.hall_h123_motor_speed = 60000.0 * (float)(g_ptz.hori_pid.hall_h123_count/* - 1*/) / - (float)PTZ_HORI_PID_T / PTZ_HORI_ONE_CYCLE_HALL_NUM; + (float)horiTime / PTZ_HORI_ONE_CYCLE_HALL_NUM; } @@ -1190,14 +1200,26 @@ static void ptz_vert_pid_task() g_ptz.vert_pid.hall_h123_count = g_ptz.vert_pid.hall_h1_count + g_ptz.vert_pid.hall_h2_count + g_ptz.vert_pid.hall_h3_count; - + static uint32_t time, lastTime, vertTime; + time = OSTimeGet(); + vertTime = time - lastTime; + if (vertTime < 0) { + continue; + } + lastTime = time; + if(g_ptz.vert_pid.hall_h123_count >= 2) { + // g_ptz.vert_pid.hall_h123_motor_speed = + // 60000.0 * (float)(g_ptz.vert_pid.hall_h123_count /*-1*/) / + // (float)PTZ_VERT_PID_T / PTZ_VERT_ONE_CYCLE_HALL_NUM; + g_ptz.vert_pid.hall_h123_motor_speed = 60000.0 * (float)(g_ptz.vert_pid.hall_h123_count /*-1*/) / - (float)PTZ_VERT_PID_T / PTZ_VERT_ONE_CYCLE_HALL_NUM; + (float)vertTime / PTZ_VERT_ONE_CYCLE_HALL_NUM; } + g_ptz.vert_motor_speed_hall_actual = g_ptz.vert_pid.hall_h123_motor_speed; diff --git a/BSP/Driver/full_bridge/full_bridge.c b/BSP/Driver/full_bridge/full_bridge.c index 842787f..84427d2 100644 --- a/BSP/Driver/full_bridge/full_bridge.c +++ b/BSP/Driver/full_bridge/full_bridge.c @@ -360,21 +360,21 @@ void h_bldc_six_step() H_Hall_state.Hall_value = h_hall_senser_value_get(); if((H_Hall_state.Hall_value <= 6)&&(H_Hall_state.Hall_value >= 1)) { -// if(g_ptz.hori_direction_set == PTZ_HORI_DIR_RIGHT) -// {//电机正转- 1 -// h_six_step_commu[(7-H_Hall_state.Hall_value) -1](); -// }else{//电机反转 -// h_six_step_commu[H_Hall_state.Hall_value -1](); -// } + if(g_ptz.hori_direction_set == PTZ_HORI_DIR_RIGHT) + {//电机正转- 1 + h_six_step_commu[(7-H_Hall_state.Hall_value) -1](); + }else{//电机反转 + h_six_step_commu[H_Hall_state.Hall_value -1](); + } //直齿云台转向 - if(g_ptz.hori_direction_set == PTZ_HORI_DIR_RIGHT) - {//电机正转- 1 + // if(g_ptz.hori_direction_set == PTZ_HORI_DIR_RIGHT) + // {//电机正转- 1 - h_six_step_commu[H_Hall_state.Hall_value -1](); - }else{//电机反转 - h_six_step_commu[(7-H_Hall_state.Hall_value) -1](); + // h_six_step_commu[H_Hall_state.Hall_value -1](); + // }else{//电机反转 + // h_six_step_commu[(7-H_Hall_state.Hall_value) -1](); - } + // } } } @@ -395,11 +395,17 @@ void v_bldc_six_step() V_Hall_state.Hall_value = v_hall_senser_value_get(); if((V_Hall_state.Hall_value <= 6)&&(V_Hall_state.Hall_value >= 1)) { + // if(g_ptz.vert_direction_set == PTZ_VERT_DIR_UP) + // {//电机正转- 1 + // v_six_step_commu[V_Hall_state.Hall_value -1](); + // }else{//电机反转 + // v_six_step_commu[(7-V_Hall_state.Hall_value) -1](); + // } if(g_ptz.vert_direction_set == PTZ_VERT_DIR_UP) {//电机正转- 1 - v_six_step_commu[V_Hall_state.Hall_value -1](); - }else{//电机反转 v_six_step_commu[(7-V_Hall_state.Hall_value) -1](); + }else{//电机反转 + v_six_step_commu[V_Hall_state.Hall_value -1](); }