encoder.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. u8 motor_poles;
  9. float pwm_angle;
  10. u32 pwm_count;
  11. float abi_angle;
  12. float cali_angle;
  13. float interpolation;
  14. float pll_bandwidth_shadow;
  15. float pll_bandwidth;
  16. float position;
  17. PLL_t est_pll;
  18. bool b_timer_ov;
  19. bool b_lock_pos;
  20. u32 cpr;
  21. u32 last_cnt;
  22. u32 b_index_cnt;
  23. u32 last_us;
  24. s8 direction; //motor running dir, 逆时针 正,顺时针负
  25. float est_vel_counts; //每秒多少个计数
  26. float est_angle_counts;
  27. float rpm;
  28. u8 *encoder_off_count;
  29. s16 *encoder_off_map;
  30. }encoder_t;
  31. void encoder_init(void);
  32. void encoder_init_clear(void);
  33. float encoder_get_theta(void);
  34. float encoder_get_speed(void);
  35. void encoder_detect_offset(float angle);
  36. void encoder_set_direction(s8 direction);
  37. float encoder_get_vel_count(void);
  38. void encoder_lock_position(bool enable);
  39. bool encoder_detect_finish(void);
  40. float encoder_get_pwm_angle(void);
  41. float encoder_zero_phase_detect(void);
  42. bool ENC_Check_error(void);
  43. float encoder_get_abi_angle(void);
  44. float encoder_get_position(void);
  45. void encoder_detect_upload(void);
  46. #endif /* _Encoder_H__ */