brake.h.bak 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /************************************************************************
  2. Project: Welling Motor Control Paltform
  3. Filename: brake.h
  4. Partner Filename: brake.c
  5. Description: The header file of brake.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. WLBDM_M4_SR_201809071-new FSM1.1, by mz, create this file;
  15. ************************************************************************/
  16. #include "typedefine.h"
  17. /************************************************************************
  18. Beginning of File, do not put anything above here except notes
  19. Compiler Directives:
  20. *************************************************************************/
  21. #ifndef BRAKE_H
  22. #define BRAKE_H
  23. /************************************************************************
  24. Compiler Directives (N/A)
  25. *************************************************************************/
  26. #ifdef _BRAKE_C_
  27. #define BRAKE_EXT
  28. #else
  29. #define BRAKE_EXT extern
  30. #endif
  31. #include "typedefine.h"
  32. /************************************************************************
  33. Definitions & Macros
  34. *************************************************************************/
  35. #define BRAKE_COF_DEFAULT \
  36. { \
  37. 20154, 20400, 237, 8704, -320, -4480, 2048, 10, 10, 1365 \
  38. } // Default value of DBC_CALC_COF (410V,390V,Q14(0.15),Q14(1),Q14(6.8),Q14(0.25),Q14(3.5))
  39. #define BRAKE_OUT_DEFAULT \
  40. { \
  41. 0, 0, 0, 0, FALSE \
  42. } // Default value of DBC_CALC_OUT (Q14(0),Q14(0),FALSE)
  43. /************************************************************************
  44. Typedefs & Structure Defines
  45. *************************************************************************/
  46. typedef struct // Input of " cvb_stBrakeCoef "
  47. {
  48. UWORD uwVdcCvbVt; // Real Value, unit:0.1V, Voltage to keep for constant voltage braking
  49. SWORD swIqRefMaxAp; // Real Value, unit:0.01A, Iq limit max value
  50. SWORD swIdRefMaxAp; // Real Value, unit:0.01A, Id reference max value
  51. SWORD swIdRefMinAp; // Real Value, unit:0.01A, Id reference min value
  52. UWORD uwVBaseVt; // Real Value, unit:0.1V, Voltage Base
  53. UWORD uwIBaseAp; // Real Value, unit:0.01A, Current Base
  54. UWORD uwFBaseHz; // Real Value, unit:Hz, Frequence Base
  55. UWORD uwMotorPairs; // Real Value, unit:1, Motor Pairs
  56. UWORD uwLowSpdRpm; // Real Value, unit:rpm, Low speed without Id
  57. } BRAKE_COFIN;
  58. typedef struct // Input of " cvb_stBrakeOut "
  59. {
  60. UWORD uwVdcLpfPu; // Q14, unit:Pu, DC bus voltage
  61. SWORD swSpdPu; // Q15, unit:Pu, Current speed
  62. UWORD uwSpdLpfAbsPu; // Q15, unit:Pu, Abs of Current speed feedback
  63. SWORD swIqRefPu; // Q14, unit:Pu, Current Iq Reference
  64. SWORD swIdRefPu; // Q14, unit:Pu, Current Id Reference
  65. SWORD uwAngelPu; // Q15, unit:Pu, Obs angle
  66. UWORD uwSpdState;
  67. } BRAKE_IN;
  68. typedef struct // Input of " cvb_stBrakeOut "
  69. {
  70. UWORD uwVdcCvbPu; // Q14, unit:Pu, Voltage to keep for constant voltage braking
  71. UWORD uwVdcLagAngelPu; // Q14, unit:Pu, Voltage to lag angle constant voltage braking
  72. UWORD uwVdcStartCvbPu; // Q14, unit:Pu, Voltage to start iq limit of constant voltage braking
  73. UWORD uwKAnglePu; // Q8, unit:Pu, Coefficient of delta Angle
  74. SWORD swIqLimMaxPu; // Q14, unit:Pu, Iq limit max value
  75. SWORD swIdRefMaxPu; // Q14, unit:Pu, Id reference max value
  76. SWORD swIdRefMinPu; // Q14, unit:Pu, Id reference min value
  77. SWORD swKcvb; // Q14, unit:Pu, Constant voltage braking cofficient
  78. SWORD swIdDrpPu; // Q14, unit:Pu, delta Id drop
  79. SWORD swIdRcyPu; // Q14, unit:Pu, delta Id recovery
  80. UWORD uwLowSpdPu; // Q15, unit:Pu, Low speed without Id
  81. } BRAKE_COF;
  82. typedef struct // Output of " cvb_stBrakeOut "
  83. {
  84. SWORD swIqRefPu; // Q14, unit:Pu, Q axis current reference
  85. SWORD swIqLimPu; // Q14, unit:Pu, Q axis current limit
  86. SWORD swIdRefPu; // Q14, unit:Pu, D axis current reference
  87. SWORD uwAngelPu; // Q15, unit:Pu, Obs angle after brake lag
  88. BOOL blCvbFlg; // Bool, constant voltage braking flag
  89. } BRAKE_OUT;
  90. /************************************************************************
  91. Exported Variables
  92. *************************************************************************/
  93. #ifdef _BRAKE_C_
  94. BRAKE_EXT BRAKE_COF cvb_stBrakeCoef = BRAKE_COF_DEFAULT;
  95. BRAKE_EXT BRAKE_OUT cvb_stBrakeOut = BRAKE_OUT_DEFAULT;
  96. #else
  97. BRAKE_EXT BRAKE_COF cvb_stBrakeCoef;
  98. BRAKE_EXT BRAKE_OUT cvb_stBrakeOut;
  99. #endif
  100. /************************************************************************
  101. RAM ALLOCATION (N/A)
  102. *************************************************************************/
  103. #define cvb_stBrakeIn (*(BRAKE_IN *)TBC_BUFFER)
  104. #define cvb_stBrakeCoefIn (*(BRAKE_COFIN *)MN_BUFFER)
  105. /************************************************************************
  106. Exported Function Call Prototypes
  107. *************************************************************************/
  108. #ifdef _BRAKE_C_
  109. BRAKE_EXT void cvb_voBrake(BRAKE_IN *in, BRAKE_COF *coef, BRAKE_OUT *out);
  110. BRAKE_EXT void cvb_voBrakeCoef(BRAKE_COFIN *in, BRAKE_COF *out);
  111. BRAKE_EXT void cvb_voBrakeInit();
  112. #else
  113. BRAKE_EXT void cvb_voBrake(BRAKE_IN *in, BRAKE_COF *coef, BRAKE_OUT *out);
  114. BRAKE_EXT void cvb_voBrakeCoef(BRAKE_COFIN *in, BRAKE_COF *out);
  115. BRAKE_EXT void cvb_voBrakeInit();
  116. #endif
  117. /************************************************************************
  118. Local Function Call Prototypes (N/A)
  119. *************************************************************************/
  120. /************************************************************************
  121. Flag Define (N/A)
  122. *************************************************************************/
  123. #endif
  124. /************************************************************************
  125. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  126. All rights reserved.
  127. *************************************************************************
  128. End of this File (EOF)!
  129. Do not put anything after this part!
  130. *************************************************************************/