encoder.h 885 B

12345678910111213141516171819202122232425262728293031323334353637
  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. float pwm_angle;
  9. u32 pwm_count;
  10. float abi_angle;
  11. float interpolation;
  12. float pll_bandwidth_shadow;
  13. float pll_bandwidth;
  14. PLL_t est_pll;
  15. bool b_timer_ov;
  16. u32 cpr;
  17. u32 last_cnt;
  18. u32 b_index_cnt;
  19. u32 last_us;
  20. s8 enc_dir; //encoder count dir UP or DOWN
  21. s8 direction; //motor running dir, 逆时针 正,顺时针负
  22. u16 p_dir_cnt;
  23. u16 n_dir_cnt;
  24. float est_vel_counts; //每秒多少个计数
  25. float est_angle_counts;
  26. float rpm;
  27. }encoder_t;
  28. void encoder_init(void);
  29. void encoder_init_clear(s8 direction);
  30. float encoder_get_theta(void);
  31. float encoder_get_speed(void);
  32. void encoder_detect_offset(float angle);
  33. void encoder_set_direction(s8 direction);
  34. #endif /* _Encoder_H__ */