齿轮传动

This commit is contained in:
起床就犯困 2025-08-11 10:20:44 +08:00
parent 284f3ec2a6
commit 8ac2a3efbe
3 changed files with 51 additions and 23 deletions

View File

@ -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_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 #define PTZ_VERT_VR_MAX 1999
///垂直电机调速模拟电压最小值 ///垂直电机调速模拟电压最小值
@ -114,11 +114,11 @@
///垂直电机最小转速 ///垂直电机最小转速
#define PTZ_VERT_MOTOR_MIN_SPEED 400.0//600.0 #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
//电机磁极对数 //电机磁极对数

View File

@ -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_h123_count = g_ptz.hori_pid.hall_h1_count +
g_ptz.hori_pid.hall_h2_count + g_ptz.hori_pid.hall_h2_count +
g_ptz.hori_pid.hall_h3_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) 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 = g_ptz.hori_pid.hall_h123_motor_speed =
60000.0 * (float)(g_ptz.hori_pid.hall_h123_count/* - 1*/) / 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,15 +1200,27 @@ 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_h123_count = g_ptz.vert_pid.hall_h1_count +
g_ptz.vert_pid.hall_h2_count + g_ptz.vert_pid.hall_h2_count +
g_ptz.vert_pid.hall_h3_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) 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 = g_ptz.vert_pid.hall_h123_motor_speed =
60000.0 * (float)(g_ptz.vert_pid.hall_h123_count /*-1*/) / 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; g_ptz.vert_motor_speed_hall_actual = g_ptz.vert_pid.hall_h123_motor_speed;
/* ********************************** */ /* ********************************** */

View File

@ -360,21 +360,21 @@ void h_bldc_six_step()
H_Hall_state.Hall_value = h_hall_senser_value_get(); H_Hall_state.Hall_value = h_hall_senser_value_get();
if((H_Hall_state.Hall_value <= 6)&&(H_Hall_state.Hall_value >= 1)) if((H_Hall_state.Hall_value <= 6)&&(H_Hall_state.Hall_value >= 1))
{ {
// if(g_ptz.hori_direction_set == PTZ_HORI_DIR_RIGHT) if(g_ptz.hori_direction_set == PTZ_HORI_DIR_RIGHT)
// {//电机正转- 1 {//电机正转- 1
// h_six_step_commu[(7-H_Hall_state.Hall_value) -1](); h_six_step_commu[(7-H_Hall_state.Hall_value) -1]();
// }else{//电机反转 }else{//电机反转
// h_six_step_commu[H_Hall_state.Hall_value -1](); h_six_step_commu[H_Hall_state.Hall_value -1]();
// } }
//直齿云台转向 //直齿云台转向
if(g_ptz.hori_direction_set == PTZ_HORI_DIR_RIGHT) // if(g_ptz.hori_direction_set == PTZ_HORI_DIR_RIGHT)
{//电机正转- 1 // {//电机正转- 1
h_six_step_commu[H_Hall_state.Hall_value -1](); // h_six_step_commu[H_Hall_state.Hall_value -1]();
}else{//电机反转 // }else{//电机反转
h_six_step_commu[(7-H_Hall_state.Hall_value) -1](); // 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(); V_Hall_state.Hall_value = v_hall_senser_value_get();
if((V_Hall_state.Hall_value <= 6)&&(V_Hall_state.Hall_value >= 1)) 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) if(g_ptz.vert_direction_set == PTZ_VERT_DIR_UP)
{//电机正转- 1 {//电机正转- 1
v_six_step_commu[V_Hall_state.Hall_value -1]();
}else{//电机反转
v_six_step_commu[(7-V_Hall_state.Hall_value) -1](); v_six_step_commu[(7-V_Hall_state.Hall_value) -1]();
}else{//电机反转
v_six_step_commu[V_Hall_state.Hall_value -1]();
} }