nv_storage.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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_maxDCVol;
  13. float s_minDCVol;
  14. float s_maxRPM;
  15. float s_maxEpmRPM;
  16. float s_maxTorque;
  17. float s_PhaseCurreBrkLim;
  18. float s_iDCeBrkLim;
  19. float s_LimitiDC;
  20. float n_modulation;
  21. float n_PhaseFilterCeof;
  22. float n_currentBand; //电流环带宽
  23. float n_minThroVol;
  24. float n_maxThroVol;
  25. u8 n_brkShutPower;
  26. pid_conf_t pid_conf[PID_Max_id];
  27. u16 crc16;
  28. }foc_params_t;
  29. typedef struct {
  30. u8 poles;
  31. float r;
  32. float ld;
  33. float lq;
  34. float flux_linkage;
  35. float back_emf;
  36. s32 hall_table[8];
  37. float offset;
  38. float est_pll_band; //normal工作模式下的pll带宽
  39. float pos_lock_pll_band; //电机锁定模式下的pll带宽
  40. u16 crc16;
  41. }motor_params_t;
  42. #define MAX_TRQ_POINTS 60
  43. #define MAX_SPD_POINTS 100
  44. typedef struct {
  45. s16 d[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  46. s16 q[MAX_TRQ_POINTS][MAX_SPD_POINTS];
  47. u16 crc16;
  48. }torque_lut_t;
  49. #pragma pack(pop)
  50. #define motorParam_idx_0 3
  51. #define motorParam_idx_1 (motorParam_idx_0 + 1)
  52. #define focParam_idx_0 (motorParam_idx_0 + 2)
  53. #define focParam_idx_1 (motorParam_idx_0 + 3)
  54. void nv_storage_init(void);
  55. motor_params_t *nv_get_motor_params(void);
  56. foc_params_t *nv_get_foc_params(void);
  57. void nv_save_angle_offset(float offset);
  58. void nv_save_motor_params(void);
  59. void nv_read_motor_params(void);
  60. void nv_save_foc_params(void);
  61. void nv_read_foc_params(void);
  62. void nv_save_hall_table(s32 *hall_table);
  63. void nv_set_pid(u8 id, pid_conf_t *pid);
  64. void nv_get_pid(u8 id, pid_conf_t *pid);
  65. void nv_set_hwbrake_mode(u8 mode);
  66. void nv_set_throttle_vol(float min, float max);
  67. void nv_set_ebrake_current(float phase_curr, float dc_curr);
  68. #endif /* _NV_Storage_H__ */