pwrlim.h 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. SWORD swMotoriqref; /**< MOTOR温度,单位:摄氏度 */
  88. SWORD swMotoriqfdb; /**< MOTOR温度,单位:摄氏度 */
  89. } PWRLIM_IN;
  90. typedef struct // Output of " pwr_voPwrLim "
  91. {
  92. SWORD swMotorPwrLimitActualPu; /**< 实际功率限制值,PuQ15 */
  93. SWORD swIqLimPu; /**< q轴电流限制值,PuQ14 */
  94. SWORD swErrorZ1; /**< 功率限制值与功率间的误差,PuQ15 */
  95. SLONG slIqLimDetaSum; /**< q轴电流限制减小值,PuQ30 */
  96. SWORD swIqLimDetaSum; /**< q轴电流限制减小值,PuQ14 */
  97. UWORD uwfisrttime;
  98. UWORD Mortor_time;
  99. } PWRLIM_OUT;
  100. /************************************************************************
  101. Constant Table
  102. *************************************************************************/
  103. /************************************************************************
  104. Exported Variables
  105. ************************************************************************/
  106. #ifdef _PWRLIM_C_
  107. _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut = PWRLIM_OUT_DEFAULT;
  108. _PWRLIM_EXT PWRLIM_COF pwr_stPwrLimCof = PWRLIM_COF_DEFAULT;
  109. _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut2 = PWRLIM_OUT_DEFAULT;
  110. #else
  111. _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut;
  112. _PWRLIM_EXT PWRLIM_COF pwr_stPwrLimCof;
  113. _PWRLIM_EXT PWRLIM_OUT pwr_stPwrLimOut2;
  114. #endif
  115. /************************************************************************
  116. RAM ALLOCATION:
  117. ************************************************************************/
  118. #define pwr_stPwrLimIn (*(PWRLIM_IN *)TBC_BUFFER)
  119. #define pwr_stPwrLimCofIn (*(PWRLIM_COFIN *)MN_BUFFER)
  120. /************************************************************************
  121. Exported Function Call Prototypes (N/A)
  122. ************************************************************************/
  123. #ifdef _PWRLIM_C_
  124. _PWRLIM_EXT void pwr_voPwrLimInit(void);
  125. _PWRLIM_EXT void pwr_voPwrLimCof(PWRLIM_COFIN *in, PWRLIM_COF *out);
  126. _PWRLIM_EXT void pwr_voPwrLim(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
  127. _PWRLIM_EXT void pwr_voPwrLimPI(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
  128. #else
  129. _PWRLIM_EXT void pwr_voPwrLimInit(void);
  130. _PWRLIM_EXT void pwr_voPwrLimCof(PWRLIM_COFIN *in, PWRLIM_COF *out);
  131. _PWRLIM_EXT void pwr_voPwrLim(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
  132. _PWRLIM_EXT void pwr_voPwrLimPI(PWRLIM_IN *in, PWRLIM_COF *cof, PWRLIM_OUT *out);
  133. #endif
  134. /************************************************************************
  135. Flag Define (N/A)
  136. ************************************************************************/
  137. /***********************************************************************/
  138. #endif
  139. /************************************************************************
  140. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  141. All rights reserved.
  142. *************************************************************************
  143. End of this File (EOF):
  144. Do not put anything after this part!
  145. ************************************************************************/