| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #ifndef _Encoder_H__
- #define _Encoder_H__
- #include "foc/core/PI_Controller.h"
- typedef struct {
- bool b_index_found; //I 对齐
- float enc_offset;
- u32 enc_count_off;
- u8 motor_poles;
- float pwm_angle;
- u32 pwm_count;
- float abi_angle;
- float cali_angle;
- float interpolation;
- float pll_bandwidth_shadow;
- float pll_bandwidth;
- float position;
- PLL_t est_pll;
- bool b_timer_ov;
- bool b_lock_pos;
- bool b_cali_err;
- s16 cpr;
- s16 last_cnt;
- s16 align_cnt; //z 中断的时候的cnt数,需要计算角度的是时候处理这个align
- s16 align_step;
- s16 z_index_cnt;
- u32 last_us;
- s8 direction; //motor running dir, 逆时针 正,顺时针负
- float est_vel_counts; //每秒多少个计数
- float est_vel_cnt_filter;
- float est_angle_counts;
- float rpm;
- //u8 *encoder_off_count;
- //s16 *encoder_off_map;
- bool produce_error;
- s16 last_delta_cnt;
- u32 start_dianostic_cnt;
- u8 enc_maybe_err;
- u32 pwm_time_ms;
- }encoder_t;
- #define ENCODER_NO_ERR 0
- #define ENCODER_PWM_ERR 1
- #define ENCODER_AB_ERR 2
- void encoder_init(void);
- void encoder_init_clear(void);
- float encoder_get_theta(void);
- float encoder_get_speed(void);
- void encoder_set_direction(s8 direction);
- float encoder_get_vel_count(void);
- void encoder_lock_position(bool enable);
- float encoder_get_pwm_angle(void);
- float encoder_zero_phase_detect(float *enc_off);
- bool ENC_Check_error(void);
- float encoder_get_abi_angle(void);
- float encoder_get_position(void);
- void encoder_clear_cnt_offset(void);
- u32 encoder_get_cnt_offset(void);
- bool encoder_get_cali_error(void);
- void encoder_epm_pll_band(bool epm);
- void encoder_produce_error(bool error);
- u8 encoder_may_error(void);
- #endif /* _Encoder_H__ */
|