Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DFOC_M0_set_Velocity_Angle 代码bug #2

Open
Tony607 opened this issue Jul 30, 2023 · 0 comments
Open

DFOC_M0_set_Velocity_Angle 代码bug #2

Tony607 opened this issue Jul 30, 2023 · 0 comments

Comments

@Tony607
Copy link

Tony607 commented Jul 30, 2023

DFOC_M0_set_Velocity_Angle函数中DFOC_M0_VEL_PID函数的输入应该是DFOC_M0_ANGLE_PID的输出(即期望的速度)减去当前的速度,这样才是正确的双环控制策略。
因此,DFOC_M0_set_Velocity_Angle函数可以修改为如下形式:

void DFOC_M0_set_Velocity_Angle(float Target)
{
  float sensor_angle = DFOC_M0_Angle();
  float sensor_vel = DFOC_M0_Velocity();
  float target_vel = DFOC_M0_ANGLE_PID((Target - sensor_angle)*180/PI);
  setTorque(DFOC_M0_VEL_PID(target_vel - sensor_vel), _electricalAngle());
}

函数首先计算出当前的角度和速度,然后将角度误差输入到角度环PID控制器,得到期望的速度。再将期望的速度和当前的速度做差,得到速度误差,再输入到速度环PID控制器,得到最终的输出。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant