asr_new.h 5.8 KB

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