nv_storage.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_maxIdq;
  10. float s_minIdq;
  11. float s_maxiDC;
  12. float s_maxvDC;
  13. float s_maxRPM;
  14. float s_maxEpmRPM;
  15. float s_maxTorque;
  16. float s_maxBrkCurrent;
  17. float s_LimitiDC;
  18. float n_modulation;
  19. float n_PhaseFilterCeof;
  20. float n_currentBand; //电流环带宽
  21. u8 n_brkShutPower;
  22. pid_conf_t pid_conf[PID_Max_id];
  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. s32 hall_table[8];
  33. float offset;
  34. float est_pll_band; //normal工作模式下的pll带宽
  35. float pos_lock_pll_band; //电机锁定模式下的pll带宽
  36. u16 crc16;
  37. }motor_params_t;
  38. #define MAX_TRQ_POINTS 60
  39. #define MAX_SPD_POINTS 100
  40. typedef struct {
  41. s16 d[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  42. s16 q[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  43. u16 crc16;
  44. }torque_lut_t;
  45. #pragma pack(pop)
  46. #define motorParam_idx_0 3
  47. #define motorParam_idx_1 (motorParam_idx_0 + 1)
  48. #define focParam_idx_0 (motorParam_idx_0 + 2)
  49. #define focParam_idx_1 (motorParam_idx_0 + 3)
  50. void nv_storage_init(void);
  51. motor_params_t *nv_get_motor_params(void);
  52. foc_params_t *nv_get_foc_params(void);
  53. void nv_save_angle_offset(float offset);
  54. void nv_save_motor_params(void);
  55. void nv_read_motor_params(void);
  56. void nv_save_foc_params(void);
  57. void nv_read_foc_params(void);
  58. void nv_save_hall_table(s32 *hall_table);
  59. void nv_set_pid(u8 id, pid_conf_t *pid);
  60. void nv_get_pid(u8 id, pid_conf_t *pid);
  61. #endif /* _NV_Storage_H__ */