dbc.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /************************************************************************
  2. Project: Welling Motor Control Paltform
  3. Filename: dbc.h
  4. Partner Filename: dbc.c
  5. Description: The header file of dbc.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 DBC_H
  21. #define DBC_H
  22. /************************************************************************
  23. Compiler Directives (N/A)
  24. *************************************************************************/
  25. #ifdef _DBC_C_
  26. #define DBC_EXT
  27. #else
  28. #define DBC_EXT extern
  29. #endif
  30. /************************************************************************
  31. Definitions & Macros
  32. *************************************************************************/
  33. #define DBC_CALC_COF_DEFAULT \
  34. { \
  35. 0, 0, 77 \
  36. } // Default value of DBC_CALC_COF
  37. #define DBC_CALC_OUT_DEFAULT \
  38. { \
  39. 0, 0 \
  40. } // Default value of DBC_CALC_OUT
  41. /************************************************************************
  42. Typedefs & Structure Defines
  43. *************************************************************************/
  44. typedef struct // Input of " dbc_voDBCompCoef "
  45. {
  46. UWORD uwPosSwOnTimeNs; // Real Value, unit:ns, IPM switch-on time at positive current
  47. UWORD uwPosSwOffTimeNs; // Real Value, unit:ns, IPM switch-off time at positive current
  48. UWORD uwNegSwOnTimeNs; // Real Value, unit:ns, IPM switch-on time at negative current
  49. UWORD uwNegSwOffTimeNs; // Real Value, unit:ns, IPM switch-off time at negative current
  50. UWORD uwDeadBandTimeNs; // Real Value, unit:ns, Dead band time
  51. ULONG ulPWMPerUs; // Real Value, unit:0.1us, PWM period
  52. UWORD uwKcoefVtPerAp; // Real Value, unit:0.1V/A, Deadband compensation slope coefficient,
  53. UWORD uwVBaseVt; // Real Value, unit:0.1V, Voltage Base
  54. UWORD uwIBaseAp; // Real Value, unit:0.01A, Current Base
  55. } DBC_COF_IN;
  56. typedef struct // Output of " dbc_voDBCompCoef "
  57. {
  58. UWORD uwPosLostVoltDuty; // Q14, Duty ratio of dead-time for positive current
  59. UWORD uwNegWinVoltDuty; // Q14, Duty ratio of dead-time for for negtive current
  60. UWORD uwKcoef; // Q12, Deadband compensation slope coefficient
  61. } DBC_CALC_COF;
  62. typedef struct // Input of " dbc_voDBComp "
  63. {
  64. UWORD uwVdcPu; // Q14, unit:Pu, Busbar voltage
  65. SWORD swIaPu; // Q14, unit:Pu, Phase A current
  66. SWORD swIbPu; // Q14, unit:Pu, Phase B current
  67. SWORD swIcPu; // Q14, unit:Pu, Phase C current
  68. SWORD swWsPu; // Q15, unit:Pu, speed feedback, electric angle speed rad/s
  69. } DBC_CALC_IN;
  70. typedef struct // Output of " dbc_voDBComp "
  71. {
  72. SWORD swUalphaCompPu; // Q14, Ualpha compensation
  73. SWORD swUbetaCompPu; // Q14, Ubeta compensation
  74. } DBC_CALC_OUT;
  75. /************************************************************************
  76. Exported Variables
  77. *************************************************************************/
  78. #ifdef _DBC_C_
  79. DBC_EXT DBC_CALC_COF dbc_stDbCompCoef = DBC_CALC_COF_DEFAULT;
  80. DBC_EXT DBC_CALC_OUT dbc_stDbCompOut = DBC_CALC_OUT_DEFAULT;
  81. #else
  82. DBC_EXT DBC_CALC_COF dbc_stDbCompCoef;
  83. DBC_EXT DBC_CALC_OUT dbc_stDbCompOut;
  84. #endif
  85. /************************************************************************
  86. RAM ALLOCATION (N/A)
  87. *************************************************************************/
  88. //#define dbc_stDbCompCoefIn (*(DBC_COF_IN *)MN_BUFFER)
  89. DBC_EXT DBC_COF_IN dbc_stDbCompCoefIn;
  90. #define dbc_stDbCompIn (*(DBC_CALC_IN *)TBC_BUFFER)
  91. /************************************************************************
  92. Exported Function Call Prototypes
  93. *************************************************************************/
  94. #ifdef _DBC_C_
  95. DBC_EXT void dbc_voDBComp(DBC_CALC_IN *IN, DBC_CALC_COF *COF, DBC_CALC_OUT *OUT);
  96. DBC_EXT void dbc_voDBCompCoef(DBC_COF_IN *IN, DBC_CALC_COF *COF);
  97. DBC_EXT void dbc_voDBCompInit(void);
  98. #else
  99. DBC_EXT void dbc_voDBComp(DBC_CALC_IN *IN, DBC_CALC_COF *COF, DBC_CALC_OUT *OUT);
  100. DBC_EXT void dbc_voDBCompCoef(DBC_COF_IN *IN, DBC_CALC_COF *COF);
  101. DBC_EXT void dbc_voDBCompInit(void);
  102. #endif
  103. /************************************************************************
  104. Flag Define (N/A)
  105. *************************************************************************/
  106. #endif
  107. /************************************************************************
  108. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  109. All rights reserved.
  110. *************************************************************************
  111. End of this File (EOF)!
  112. Do not put anything after this part!
  113. *************************************************************************/