asr.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /************************************************************************
  2. Project: Welling Motor Control Paltform
  3. Filename: asr.h
  4. Partner Filename: asr.c
  5. Description: The header file of asr.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. ************************************************************************/
  15. #include "typedefine.h"
  16. /************************************************************************
  17. Beginning of File, do not put anything above here except notes
  18. Compiler Directives:
  19. *************************************************************************/
  20. #ifndef ASR_H
  21. #define ASR_H
  22. /************************************************************************
  23. Compiler Directives (N/A)
  24. *************************************************************************/
  25. #ifdef _ASR_C_
  26. #define _ASR_EXT
  27. #else
  28. #define _ASR_EXT extern
  29. #endif
  30. /************************************************************************
  31. Definitions & Macros (#define ...)
  32. *************************************************************************/
  33. #define ASR_SPDPI_COF_DEFAULT \
  34. { \
  35. 0, 0, 0 \
  36. } // Default value of ASR_SPDPI_COF
  37. #define ASR_SPDPI_OUT_DEFAULT \
  38. { \
  39. 0, 0, 0, 0 \
  40. } // Default value of ASR_SPDPI_OUT
  41. #define MOTOR_SPEED_OUT_DEFAULT \
  42. { \
  43. 0,0 \
  44. }// Default value of MOTOR_SPEED_OUT
  45. #define MOTOR_SPEED_IN_DEFAULT \
  46. { \
  47. 0,0,5000,5000 \
  48. } // Default value of MOTOR_SPEED_IN
  49. /************************************************************************
  50. global varibles Macros (#define ...)
  51. *************************************************************************/
  52. /************************************************************************
  53. TypeDefs & Structure defines
  54. *************************************************************************/
  55. typedef struct // Input of "asr_voSpdPI"
  56. {
  57. SWORD swSpdRefPu; // Q15, Speed reference
  58. SWORD swSpdFdbPu; // Q15, Speed feedback
  59. SWORD swIqMaxPu; // Q14, Iq output maximum limit
  60. SWORD swIqMinPu; // Q14, Iq output minimum limit
  61. } ASR_SPDPI_IN;
  62. typedef struct // Output of "asr_voSpdPI"
  63. {
  64. SLONG slIqiPu; // Q30, Integration of previous step
  65. SLONG slIqSumPu; // Q21, PI output before limitation
  66. SLONG slIqRefPu; // Q21, PI output after limitation
  67. SWORD swIqRefPu; // Q14, PI output after limitation
  68. SWORD swErrZ1Pu; // Q15, Error recorder
  69. } ASR_SPDPI_OUT;
  70. typedef struct // Input of "asr_voSpdPI"
  71. {
  72. UWORD uwKpPu; // Q4, Kp
  73. UWORD uwKitPu; // Q15, Kit
  74. UWORD uwKbPu; // Q8, Kb
  75. } ASR_SPDPI_COF;
  76. /************************************************************************
  77. TypeDefs & Structure defines
  78. *************************************************************************/
  79. typedef struct
  80. {
  81. UWORD uwRatioJm; // Q0, Ratio of load inertia and motor inertia
  82. UWORD uwMcoef; // Q0, Damping factor
  83. UWORD uwMtJm; // Motor rotational inertia
  84. UWORD uwMtFlxWb; // unit: 0.01mWb, Flux linkage
  85. UWORD uwUbVt; // unit: 0.1V, Voltage base
  86. UWORD uwIbAp; // unit: 0.01A, Current base
  87. UWORD uwFbHz; // unit: Hz, Frequency base
  88. UWORD uwFTbsHz; // TBS frequency
  89. UWORD uwPairs; // Pole pairs base
  90. UWORD uwWvcHz; // unit: Hz, Speed loop bandwidth
  91. } ASR_SPDPI_COFIN;
  92. /************************************************************************
  93. TypeDefs & Structure defines
  94. *************************************************************************/
  95. /************************************************************************
  96. Constant Table
  97. *************************************************************************/
  98. /************************************************************************
  99. Exported Variables:
  100. *************************************************************************/
  101. #ifdef _ASR_C_
  102. _ASR_EXT ASR_SPDPI_OUT asr_stSpdPIOut = ASR_SPDPI_OUT_DEFAULT;
  103. _ASR_EXT ASR_SPDPI_COF asr_stSpdPICoef = ASR_SPDPI_COF_DEFAULT;
  104. #else
  105. _ASR_EXT ASR_SPDPI_OUT asr_stSpdPIOut;
  106. _ASR_EXT ASR_SPDPI_COF asr_stSpdPICoef;
  107. #endif
  108. /************************************************************************
  109. RAM ALLOCATION:
  110. *************************************************************************/
  111. #define asr_stSpdPICoefIn (*(ASR_SPDPI_COFIN *)MN_BUFFER)
  112. #define asr_stSpdPIIn (*(ASR_SPDPI_IN *)TBS_BUFFER)
  113. /************************************************************************
  114. Exported Function Call Prototypes (N/A)
  115. *************************************************************************/
  116. #ifdef _ASR_C_
  117. _ASR_EXT void asr_voSpdPI(ASR_SPDPI_IN *in, ASR_SPDPI_COF *coef, ASR_SPDPI_OUT *out);
  118. _ASR_EXT void asr_voSpdPICoef(ASR_SPDPI_COFIN *in, ASR_SPDPI_COF *out);
  119. _ASR_EXT void asr_voSpdPIInit(void);
  120. #else
  121. _ASR_EXT void asr_voSpdPI(ASR_SPDPI_IN *in, ASR_SPDPI_COF *coef, ASR_SPDPI_OUT *out);
  122. _ASR_EXT void asr_voSpdPICoef(ASR_SPDPI_COFIN *in, ASR_SPDPI_COF *out);
  123. _ASR_EXT void asr_voSpdPIInit(void);
  124. #endif
  125. /************************************************************************
  126. Flag Define (N/A)
  127. *************************************************************************/
  128. #endif
  129. /************************************************************************
  130. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  131. All rights reserved.
  132. *************************************************************************
  133. End of this File (EOF)!
  134. Do not put anything after this part!
  135. *************************************************************************/