encoder.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #ifndef _Encoder_H__
  2. #define _Encoder_H__
  3. #include "bsp/enc_intf.h"
  4. #include "foc/core/PI_Controller.h"
  5. typedef struct {
  6. bool b_index_found; //I 对齐
  7. float enc_offset;
  8. u32 enc_count_off;
  9. u8 motor_poles;
  10. float pwm_angle;
  11. u32 pwm_count;
  12. float abi_angle;
  13. float cali_angle;
  14. float interpolation;
  15. float pll_bandwidth_shadow;
  16. float pll_bandwidth;
  17. float position;
  18. PLL_t est_pll;
  19. bool b_timer_ov;
  20. bool b_lock_pos;
  21. bool b_cali_err;
  22. u32 cpr;
  23. u32 last_cnt;
  24. u32 b_index_cnt;
  25. u32 last_us;
  26. s8 direction; //motor running dir, 逆时针 正,顺时针负
  27. float est_vel_counts; //每秒多少个计数
  28. float est_angle_counts;
  29. float rpm;
  30. u8 *encoder_off_count;
  31. s16 *encoder_off_map;
  32. }encoder_t;
  33. void encoder_init(void);
  34. void encoder_init_clear(void);
  35. float encoder_get_theta(void);
  36. float encoder_get_speed(void);
  37. void encoder_detect_offset(float angle);
  38. void encoder_set_direction(s8 direction);
  39. float encoder_get_vel_count(void);
  40. void encoder_lock_position(bool enable);
  41. bool encoder_detect_finish(void);
  42. float encoder_get_pwm_angle(void);
  43. float encoder_zero_phase_detect(float *enc_off);
  44. bool ENC_Check_error(void);
  45. float encoder_get_abi_angle(void);
  46. float encoder_get_position(void);
  47. void encoder_detect_upload(void);
  48. void encoder_clear_cnt_offset(void);
  49. u32 encoder_get_cnt_offset(void);
  50. bool encoder_get_cali_error(void);
  51. #endif /* _Encoder_H__ */