nv_storage.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef _NV_Storage_H__
  2. #define _NV_Storage_H__
  3. #include "os/os_types.h"
  4. #include "foc/core/PMSM_FOC_Core.h"
  5. #include "foc/commands.h"
  6. #pragma pack (push,1)
  7. typedef struct {
  8. float s_PhaseCurrLim;
  9. float s_maxDCVol;
  10. float s_minDCVol;
  11. float s_maxRPM;
  12. float s_maxEpmRPM;
  13. float s_maxEpmPhaseCurrLim;
  14. float s_maxTorque;
  15. float s_PhaseCurreBrkLim;
  16. float s_iDCeBrkLim;
  17. float s_LimitiDC;
  18. float n_modulation;
  19. float n_PhaseFilterCeof;
  20. float n_currentBand; //电流环带宽
  21. float n_minThroVol;
  22. float n_maxThroVol;
  23. u8 n_brkShutPower;
  24. pid_conf_t pid_conf[PID_Max_id];
  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. #define TBL_TRQ_INTVAL 10
  43. #define TBL_SPD_INTVAL 100
  44. struct lut_dq {
  45. s16 d;
  46. s16 q;
  47. };
  48. typedef struct {
  49. struct lut_dq dq[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  50. u16 magic;
  51. u16 crc16;
  52. }torque_lut_t;
  53. #pragma pack(pop)
  54. #define motorParam_idx_0 3
  55. #define motorParam_idx_1 (motorParam_idx_0 + 1)
  56. #define focParam_idx_0 (motorParam_idx_0 + 2)
  57. #define focParam_idx_1 (motorParam_idx_0 + 3)
  58. #define trq_Tbl_idx (focParam_idx_1 + 1)
  59. #define trq_Tbl_size (30)
  60. void nv_storage_init(void);
  61. motor_params_t *nv_get_motor_params(void);
  62. foc_params_t *nv_get_foc_params(void);
  63. void nv_save_angle_offset(float offset);
  64. void nv_save_motor_params(void);
  65. void nv_read_motor_params(void);
  66. void nv_save_foc_params(void);
  67. void nv_read_foc_params(void);
  68. void nv_save_hall_table(s32 *hall_table);
  69. void nv_set_pid(u8 id, pid_conf_t *pid);
  70. void nv_get_pid(u8 id, pid_conf_t *pid);
  71. void nv_set_hwbrake_mode(u8 mode);
  72. void nv_set_throttle_vol(float min, float max);
  73. void nv_set_ebrake_current(float phase_curr, float dc_curr);
  74. torque_lut_t *nv_get_trq_tlb(void);
  75. #endif /* _NV_Storage_H__ */