nv_storage.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef _NV_Storage_H__
  2. #define _NV_Storage_H__
  3. #include "os/os_types.h"
  4. #pragma pack (push,1)
  5. typedef struct {
  6. float s_maxIdq;
  7. float s_minIdq;
  8. float s_maxiDC;
  9. float s_maxvDC;
  10. float s_maxRPM;
  11. float s_maxTorque;
  12. float s_maxBrkCurrent;
  13. float n_modulation;
  14. float n_PhaseFilterCeof;
  15. float n_currentBand; //电流环带宽
  16. float spd_kp;
  17. float spd_ki;
  18. float trq_kp;
  19. float trq_ki;
  20. float fw_baseSpd; //弱磁基速
  21. float fw_kp;
  22. float fw_ki;
  23. u16 crc16;
  24. }foc_params_t;
  25. typedef struct {
  26. u8 poles;
  27. float r;
  28. float ld;
  29. float lq;
  30. float flux_linkage;
  31. float back_emf;
  32. s16 hall_offset;
  33. s32 hall_table[8];
  34. float encoder_offset;
  35. float est_pll_band; //normal工作模式下的pll带宽
  36. float pos_lock_pll_band; //电机锁定模式下的pll带宽
  37. u16 crc16;
  38. }motor_params_t;
  39. #define MAX_TRQ_POINTS 60
  40. #define MAX_SPD_POINTS 100
  41. typedef struct {
  42. s16 d[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  43. s16 q[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  44. u16 crc16;
  45. }torque_lut_t;
  46. #pragma pack(pop)
  47. #define motorParam_idx_0 3
  48. #define motorParam_idx_1 (motorParam_idx_0 + 1)
  49. #define focParam_idx_0 (motorParam_idx_0 + 2)
  50. #define focParam_idx_1 (motorParam_idx_0 + 3)
  51. void nv_storage_init(void);
  52. motor_params_t *nv_get_motor_params(void);
  53. foc_params_t *nv_get_foc_params(void);
  54. void nv_save_hall_offset(s16 offset);
  55. void nv_save_motor_params(void);
  56. void nv_read_motor_params(void);
  57. void nv_save_foc_params(void);
  58. void nv_read_foc_params(void);
  59. void nv_save_hall_table(s32 *hall_table);
  60. #endif /* _NV_Storage_H__ */