nv_storage.h 1.5 KB

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