-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
{ | ||
driver_state.error.hall[i] += 6; | ||
} | ||
if (driver_state.error.hall[i] > 12) |
There was a problem hiding this comment.
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の倍数から崩れることがない?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
たしかに
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
元々、エラーが出続けてカウンタ(8bit)がオーバーフローしたときに小さい値になってエラー状態が解除されるのを防ぐためにカウントの上限を付けているんだった
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
tfrog-motordriver/controlPWM.c
Outdated
if (driver_state.error.hall[i] > 12) | ||
{ | ||
motor[i].error_state |= ERROR_HALL_SEQ; | ||
printf("PWM:static hall err (%x)\n\r", hall[i]); |
There was a problem hiding this comment.
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するようにすることで不具合を防げる
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.