修复部分电机停转和反转的bug

This commit is contained in:
kai
2024-04-30 16:41:08 +08:00
parent 6029d10698
commit 71086bb71e
5 changed files with 11 additions and 8 deletions

View File

@@ -121,7 +121,7 @@ HTMotorInstance *HTMotorInit(Motor_Init_Config_s *config)
Daemon_Init_Config_s conf = {
.callback = HTMotorLostCallback,
.owner_id = motor,
.reload_count = 5, // 20ms
.reload_count = 5, // 50ms
};
motor->motor_daemon = DaemonRegister(&conf);
@@ -155,6 +155,9 @@ __attribute__((noreturn)) void HTMotorTask(void const *argument)
while (1)
{
pid_ref = motor->pid_ref;
if (setting->motor_reverse_flag == MOTOR_DIRECTION_REVERSE)
pid_ref *= -1;
if ((setting->close_loop_type & ANGLE_LOOP) && setting->outer_loop_type == ANGLE_LOOP)
{
if (setting->angle_feedback_source == OTHER_FEED)
@@ -186,8 +189,6 @@ __attribute__((noreturn)) void HTMotorTask(void const *argument)
}
set = pid_ref;
if (setting->motor_reverse_flag == MOTOR_DIRECTION_REVERSE)
set *= -1;
LIMIT_MIN_MAX(set, T_MIN, T_MAX);
tmp = float_to_uint(set, T_MIN, T_MAX, 12);

View File

@@ -11,6 +11,7 @@
#define CURRENT_SMOOTH_COEF 0.9f
#define SPEED_BUFFER_SIZE 5
#define HT_SPEED_BIAS -0.0109901428f // 电机速度偏差,单位rad/s
#define TORQUE_COEF_HT 3.5 // 扭矩系数,单位N.m/A
#define P_MIN -95.5f // Radians
#define P_MAX 95.5f