nv_storage.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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_maxEpmRPM;
  12. float s_maxTorque;
  13. float s_maxBrkCurrent;
  14. float s_LimitiDC;
  15. float n_modulation;
  16. float n_PhaseFilterCeof;
  17. float n_currentBand; //电流环带宽
  18. float n_TrqVelLimGain;
  19. float spd_kp;
  20. float spd_ki;
  21. float trq_kp;
  22. float trq_ki;
  23. float fw_baseSpd; //弱磁基速
  24. float fw_kp;
  25. float fw_ki;
  26. u16 crc16;
  27. }foc_params_t;
  28. typedef struct {
  29. u8 poles;
  30. float r;
  31. float ld;
  32. float lq;
  33. float flux_linkage;
  34. float back_emf;
  35. s32 hall_table[8];
  36. float offset;
  37. float est_pll_band; //normal工作模式下的pll带宽
  38. float pos_lock_pll_band; //电机锁定模式下的pll带宽
  39. u16 crc16;
  40. }motor_params_t;
  41. #define MAX_TRQ_POINTS 60
  42. #define MAX_SPD_POINTS 100
  43. typedef struct {
  44. s16 d[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  45. s16 q[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  46. u16 crc16;
  47. }torque_lut_t;
  48. #pragma pack(pop)
  49. #define motorParam_idx_0 3
  50. #define motorParam_idx_1 (motorParam_idx_0 + 1)
  51. #define focParam_idx_0 (motorParam_idx_0 + 2)
  52. #define focParam_idx_1 (motorParam_idx_0 + 3)
  53. void nv_storage_init(void);
  54. motor_params_t *nv_get_motor_params(void);
  55. foc_params_t *nv_get_foc_params(void);
  56. void nv_save_angle_offset(float offset);
  57. void nv_save_motor_params(void);
  58. void nv_read_motor_params(void);
  59. void nv_save_foc_params(void);
  60. void nv_read_foc_params(void);
  61. void nv_save_hall_table(s32 *hall_table);
  62. #endif /* _NV_Storage_H__ */