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

Fix static hall signal error detection #105

Merged
merged 6 commits into from
Jul 31, 2024

Conversation

at-wat
Copy link
Member

@at-wat at-wat commented Jul 25, 2024

No description provided.

@at-wat at-wat self-assigned this Jul 25, 2024
@at-wat at-wat requested a review from seiga-k July 25, 2024 01:55
{
driver_state.error.hall[i] += 6;
}
if (driver_state.error.hall[i] > 12)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

連続でホール素子がこの状態になったとすると、 driver_state.error.hall[i] は0->6->12と変化するのでここのifはtrueにならなさそう。
一度値が変化しないと L468 に飛ばないので6の倍数から崩れることがない?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

たしかに

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

元々、エラーが出続けてカウンタ(8bit)がオーバーフローしたときに小さい値になってエラー状態が解除されるのを防ぐためにカウントの上限を付けているんだった

Copy link

@seiga-k seiga-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if (driver_state.error.hall[i] > 12)
{
motor[i].error_state |= ERROR_HALL_SEQ;
printf("PWM:static hall err (%x)\n\r", hall[i]);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この条件は継続して発生するため、ここでprintfすると制御周期でprintfし続けることになり処理が間に合わなくなる。

if ((motor[i].error_state & ERROR_HALL_SEQ) == 0)
  printf("PWM:static hall err (%x)\n\r", hall[i]);
motor[i].error_state |= ERROR_HALL_SEQ;

のように、初めてこのエラーになるときだけprintfするようにすることで不具合を防げる

@seiga-k
Copy link

seiga-k commented Jul 30, 2024

@at-wat at-wat requested a review from seiga-k July 31, 2024 01:03
Copy link

@seiga-k seiga-k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@at-wat at-wat merged commit 3d2e877 into master Jul 31, 2024
1 check passed
@at-wat at-wat deleted the fix-static-hall-signal-error-detection branch July 31, 2024 07:24
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

Successfully merging this pull request may close these issues.

2 participants