-
-
Notifications
You must be signed in to change notification settings - Fork 2
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(encoder): 値が飛ぶバグを修正 #19
Conversation
値が counter period 分、飛ぶバグを修正
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.
条件式をちょっと変えました。等価だと思いますが、試してもらえると嬉しいです
tim/encoder.cpp
Outdated
if (__HAL_TIM_IS_TIM_COUNTING_DOWN(htim)) { | ||
count -= __HAL_TIM_GET_AUTORELOAD(htim); | ||
} else { | ||
if ((int32_t)(rawCount - lastRawCount) < (int32_t) - __HAL_TIM_GET_AUTORELOAD(htim) / 2) { |
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.
if ((int32_t)(rawCount - lastRawCount) < (int32_t) - __HAL_TIM_GET_AUTORELOAD(htim) / 2) { | |
if (((int32_t) (lastRawCount - rawCount)) > ((int32_t) (__HAL_TIM_GET_AUTORELOAD(htim) / 2))) { // overflow |
値が counter period 分、飛ぶバグを修正 原因: 想定していないタイミングで FLAG が立ち、 CLEAR されていたこと 解決策: FLAG を使って overflow / underflow を検知するのを辞めた
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.
確認遅れて申し訳ないです。インクルード消して問題なさそうなら消してほしいです。
tim/encoder.cpp
Outdated
@@ -1,6 +1,7 @@ | |||
#ifndef CONFIG_DISABLE_MODULE_TIM | |||
|
|||
#include "tim/encoder.hpp" | |||
#include <cmath> |
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.
#include <cmath> |
cmath 使ってなさそう
cmath を削除し、build が通ること、書き込んで実行できることを確かめました。 |
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.
大丈夫です、問題ないと思います
値が counter period 分、飛ぶバグを修正しました。
(原因は1周期の間に複数回TIM_FLAGが立っていたときに、それを感知できなかったことだと思われます。)