encoder.h 905 B

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