-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencCounter.h
More file actions
43 lines (31 loc) · 2.02 KB
/
encCounter.h
File metadata and controls
43 lines (31 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/********************************************************************/
/* Description: GPT位相計数モードを用いたAB相エンコーダカウンタの設定 */
/* File: encCounter.h */
/* Date: 2024/10/10 */
/* Author: Takashi YOSHIOKA */
/********************************************************************/
/********************************************************************/
/* 多重インクルード防止 */
/********************************************************************/
#ifndef _ENCCOUNTER_H_
#define _ENCCOUNTER_H_
/********************************************************************/
/* ヘッダファイルのインクルード */
/********************************************************************/
#include <Arduino.h>
#include <math.h>
#include "motorVar.h"
/********************************************************************/
/* 各種定数定義 */
/********************************************************************/
static constexpr uint16_t ENC_COEFF = ENC_PULSE*ENC_MUL; // [count/rev] エンコーダ係数
static constexpr uint16_t ENC_COEFF_ELEC = ENC_COEFF/MTR_POLE_PAIR; // [count/rev] 電気角あたりのエンコーダ係数
static constexpr float ENC_TO_OMEGAE = 2.0f*M_PI*1000000.0f / ((float)PERIOD_ASR*ENC_COEFF_ELEC); // 2π[rad/rev]*p[-]*1000000/(Tasr[us]*ENC[count/rev])
static constexpr uint16_t DIFF_ERR_THRESH = 1000; // エンコーダ差分値のひげ対策の閾値
/********************************************************************/
/* 外部公開関数のプロトタイプ宣言 */
/********************************************************************/
void setup_enc_counter(void);
uint16_t get_enc_count(void);
void get_enc_pos_speed(void);
#endif /* END _ENCCOUNTER_H_ */