pwrlim.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /************************************************************************
  2. Project: Welling Motor Control Paltform
  3. Filename: pwrlim.h
  4. Partner Filename: pwrlim.c
  5. Description: The header file of pwrlim.c
  6. Complier: IAR Embedded Workbench for ARM 7.80, IAR Systems.
  7. CPU TYPE : GD32F3x0
  8. *************************************************************************
  9. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  10. All rights reserved.
  11. *************************************************************************
  12. *************************************************************************
  13. Revising History (ECL of this file):
  14. Fjy create this file;
  15. ************************************************************************/
  16. /************************************************************************
  17. Beginning of File, do not put anything above here except notes
  18. Compiler Directives:
  19. *************************************************************************/
  20. #ifndef PWRLIM_H
  21. #define PWRLIM_H
  22. /************************************************************************
  23. Compiler Directives (N/A)
  24. ************************************************************************/
  25. #ifdef _PWRLIM_C_
  26. #define _PWRLIM_EXT
  27. #else
  28. #define _PWRLIM_EXT extern
  29. #endif
  30. /************************************************************************
  31. Definitions & Macros
  32. ************************************************************************/
  33. #define PWRLIM_COF_DEFAULT \
  34. { \
  35. 0, 0, 0, 0, 0, 0, 0, 0 \
  36. } // Default value of PWRLIM_COF
  37. #define PWRLIM_OUT_DEFAULT \
  38. { \
  39. 0 \
  40. } // Default value of PWRLIM_OUT
  41. #define PWRLIM_START_BATCAP 20
  42. #define PWRLIM_END_BATCAP 5
  43. /************************************************************************
  44. TypeDefs & Structure Defines
  45. ************************************************************************/
  46. typedef struct // Input of " pwr_voPwrLimCof "
  47. {
  48. SWORD swPwrLimW; /**< 功率限制值,单位:W */
  49. UWORD uwPwrErrW; /**< 功率开始限制值与功率限制值差值,单位:W */
  50. SWORD swIqMaxAp; /**< q轴电流最大值,单位:0.01A */
  51. UWORD uwIBaseAp; /**< 电流基值,单位:0.01A */
  52. UWORD uwUbVt; /**< 电压基值,单位:0.1V */
  53. UWORD uwPwrLimPIKp; /**< PI功率限制Kp,PuQ15 */
  54. UWORD uwPwrLimPIKi; /**< PI功率限制Ki,PuQ15 */
  55. UWORD uwPwrLimSTARTCe; /**< 开始限制功率的PCB温度,单位:摄氏度 */
  56. UWORD uwPwrLimENDCe; /**< 结束限制功率的PCB温度,单位:摄氏度 */
  57. UWORD uwPwrLimMotTempSTARTCe; /**< 开始限制功率的MOTOR温度,单位:摄氏度 */
  58. UWORD uwPwrLimMotTempENDCe; /**< 结束限制功率的MOTOR温度,单位:摄氏度 */
  59. UWORD uwPwrLimStartBatCap; /**< 开始限制功率的电量,单位:% */
  60. UWORD uwPwrLimEndBatCap; /**< 结束限制功率的电量,单位:% */
  61. } PWRLIM_COFIN;
  62. typedef struct // Output of " pwr_voPwrLimCof "
  63. {
  64. UWORD uwPwrLimKp; /**< 根据功率线性限制电流系数,PuQ5 */
  65. UWORD uwPwrLimPIKp; /**< 根据功率PI限制电流系数Kp,PuQ15 */
  66. UWORD uwPwrLimPIKi; /**< 根据功率PI限制电流系数Ki,PuQ15 */
  67. SWORD swIqMaxPu; /**< q轴电流最大值,PuQ14 */
  68. SWORD swMotorPwrLimitPu; /**< 功率限制值,PuQ15 */
  69. SWORD swPwrLimStartThresholdTemp; /**< 开始限制功率的PCB温度,单位:摄氏度 */
  70. SWORD swPwrLimENDThresholdTemp; /**< 结束限制功率的PCB温度,单位:摄氏度 */
  71. SWORD swCurLimTempGain; /**< 根据PCB温度线性限制电流系数,PuQ14 */
  72. SWORD swPwrLimTempGain; /**< 根据PCB温度线性限制功率系数,PuQ15 */
  73. SWORD swPwrLimMotorStartThresholdTemp; /**< 开始限制功率的MOTOR温度,单位:摄氏度 */
  74. SWORD swPwrLimMotorENDThresholdTemp; /**< 结束限制功率的MOTOR温度,单位:摄氏度 */
  75. SWORD swCurLimMotorTempGain; /**< 根据MOTOR温度线性限制电流系数,PuQ14 */
  76. UWORD uwPwrLimStartBatCap; /**< 开始限制功率的电池电量,单位:100% */
  77. UWORD uwPwrLimEndBatCap; /**< 结束限制功率的电池电量,单位:100% */
  78. UWORD uwPwrlimBatCapCof; /**< 根据电量线性限制功率系数,PuQ15 */
  79. } PWRLIM_COF;
  80. typedef struct // Input of " pwr_voPwrLim "
  81. {
  82. SWORD swSpdPu; /**< 电机转速,PuQ15 */
  83. SWORD swMotorPwrPu; /**< 电机计算功率,PuQ15 */
  84. SWORD swPCBTemp; /**< PCB温度,单位:摄氏度 */
  85. SWORD swMotorTemp; /**< MOTOR温度,单位:摄氏度 */
  86. UWORD uwBatCap; /**< 电池电量 */
  87. } PWRLIM_IN;
  88. typedef struct // Output of " pwr_voPwrLim "
  89. {
  90. SWORD swMotorPwrLimitActualPu; /**< 实际功率限制值,PuQ15 */
  91. SWORD swIqLimPu; /**< q轴电流限制值,PuQ14 */
  92. SWORD swErrorZ1; /**< 功率限制值与功率间的误差,PuQ15 */
  93. SLONG slIqLimDetaSum; /**< q轴电流限制减小值,PuQ30 */
  94. SWORD swIqLimDetaSum; /**< q轴电流限制减小值,PuQ14 */
  95. } PWRLIM_OUT;
  96. /************************************************************************
  97. Constant Table
  98. *************************************************************************/
  99. /************************************************************************
  100. Exported Variables
  101. ************************************************************************/
  102. #ifdef _PWRLIM_C_
  103. _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut = PWRLIM_OUT_DEFAULT;
  104. _PWRLIM_EXT PWRLIM_COF pwr_stPwrLimCof = PWRLIM_COF_DEFAULT;
  105. _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut2 = PWRLIM_OUT_DEFAULT;
  106. #else
  107. _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut;
  108. _PWRLIM_EXT PWRLIM_COF pwr_stPwrLimCof;
  109. _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut2;
  110. #endif
  111. /************************************************************************
  112. RAM ALLOCATION:
  113. ************************************************************************/
  114. #define pwr_stPwrLimIn (*(PWRLIM_IN *)TBC_BUFFER)
  115. #define pwr_stPwrLimCofIn (*(PWRLIM_COFIN *)MN_BUFFER)
  116. /************************************************************************
  117. Exported Function Call Prototypes (N/A)
  118. ************************************************************************/
  119. #ifdef _PWRLIM_C_
  120. _PWRLIM_EXT void pwr_voPwrLimInit(void);
  121. _PWRLIM_EXT void pwr_voPwrLimCof(PWRLIM_COFIN *in, PWRLIM_COF *out);
  122. _PWRLIM_EXT void pwr_voPwrLim(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
  123. _PWRLIM_EXT void pwr_voPwrLimPI(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
  124. #else
  125. _PWRLIM_EXT void pwr_voPwrLimInit(void);
  126. _PWRLIM_EXT void pwr_voPwrLimCof(PWRLIM_COFIN *in, PWRLIM_COF *out);
  127. _PWRLIM_EXT void pwr_voPwrLim(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
  128. _PWRLIM_EXT void pwr_voPwrLimPI(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
  129. #endif
  130. /************************************************************************
  131. Flag Define (N/A)
  132. ************************************************************************/
  133. /***********************************************************************/
  134. #endif
  135. /************************************************************************
  136. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  137. All rights reserved.
  138. *************************************************************************
  139. End of this File (EOF):
  140. Do not put anything after this part!
  141. ************************************************************************/