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(encoder): 値が飛ぶバグを修正 #19

Merged
merged 5 commits into from
Dec 8, 2023

Conversation

wakky-alcedo
Copy link
Collaborator

値が counter period 分、飛ぶバグを修正しました。
(原因は1周期の間に複数回TIM_FLAGが立っていたときに、それを感知できなかったことだと思われます。)

値が counter period 分、飛ぶバグを修正
@wakky-alcedo wakky-alcedo marked this pull request as ready for review November 16, 2023 11:20
@sya-ri sya-ri self-requested a review November 16, 2023 13:02
Copy link
Owner

@sya-ri sya-ri left a 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) {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
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

tim/encoder.cpp Outdated Show resolved Hide resolved
@sya-ri sya-ri mentioned this pull request Nov 22, 2023
13 tasks
値が counter period 分、飛ぶバグを修正
原因: 想定していないタイミングで FLAG が立ち、 CLEAR されていたこと
解決策: FLAG を使って overflow / underflow を検知するのを辞めた
Copy link
Owner

@sya-ri sya-ri left a 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>
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
#include <cmath>

cmath 使ってなさそう

@wakky-alcedo
Copy link
Collaborator Author

cmath を削除し、build が通ること、書き込んで実行できることを確かめました。
環境がすぐ用意できないため、エンコーダが使えるかどうかは確かめていません。
必要であれば確認しますが、いかがいたしますか?

Copy link
Owner

@sya-ri sya-ri left a comment

Choose a reason for hiding this comment

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

大丈夫です、問題ないと思います

@sya-ri sya-ri merged commit ce3f1ae into sya-ri:dev Dec 8, 2023
@sya-ri sya-ri deleted the fix/encoder_bug branch December 8, 2023 13:07
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