mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 13:18:50 +08:00
libs/libdsp/lib_motor.c: refactor
This commit is contained in:
parent
c43ec4283f
commit
15b0ae716c
1 changed files with 10 additions and 6 deletions
|
@ -210,20 +210,24 @@ void motor_angle_e_update(FAR struct motor_angle_f32_s *angle,
|
|||
|
||||
/* Check if we crossed electrical angle boundaries */
|
||||
|
||||
if (dir == DIR_CW &&
|
||||
angle_new - angle->angle_el.angle < -POLE_CNTR_THR)
|
||||
if (dir == DIR_CW)
|
||||
{
|
||||
/* For CW direction - previous angle is greater than current angle */
|
||||
|
||||
angle->i += 1;
|
||||
if (angle_new - angle->angle_el.angle < -POLE_CNTR_THR)
|
||||
{
|
||||
angle->i += 1;
|
||||
}
|
||||
}
|
||||
|
||||
else if (dir == DIR_CCW &&
|
||||
angle_new - angle->angle_el.angle > POLE_CNTR_THR)
|
||||
else if (dir == DIR_CCW)
|
||||
{
|
||||
/* For CCW direction - previous angle is lower than current angle */
|
||||
|
||||
angle->i -= 1;
|
||||
if (angle_new - angle->angle_el.angle > POLE_CNTR_THR)
|
||||
{
|
||||
angle->i -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset pole counter if needed */
|
||||
|
|
Loading…
Reference in a new issue