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