CodePara.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /************************************************************************
  2. Project: Welling Motor Control Paltform
  3. Filename: CodePara.h
  4. Partner Filename: CodePara.c
  5. Description: The header file of CodePara.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. Miaozhou create this file;
  15. ************************************************************************/
  16. /************************************************************************
  17. Beginning of File, do not put anything above here except notes
  18. Compiler Directives:
  19. *************************************************************************/
  20. #ifndef CODE_PARA_H
  21. #define CODE_PARA_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif // __cplusplus
  25. /************************************************************************
  26. Definitions & Macros
  27. *************************************************************************/
  28. #define InitPos 0 // Sample using single resistance
  29. #define VFContorl 1
  30. #define IFContorl 2
  31. #define ClZLOOP 3
  32. #define CityBIKE 4
  33. #define MountainBIKE 5
  34. #define ANG_OBSERVER 0 // Angle from observer
  35. #define ANG_RESOLVER 1 // Angle from resolver
  36. #define ANG_SWITCHHALL 2
  37. #define SINGLERESISITANCE 0 // Sample using single resistance
  38. #define RDSON 1 // Sample using Rdson
  39. #define COMBINATION 2
  40. #define ForwardRotate 0 // Sample using single resistance
  41. #define BackwardRotate 1 // Sample using Rdson
  42. #define CP_FLG_DEFAULT \
  43. { \
  44. 0, 0, FALSE, ClZLOOP, ANG_RESOLVER, COMBINATION, ForwardRotate, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE \
  45. }
  46. #define CP_MOTOR_PARA_DEFAULT \
  47. { \
  48. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
  49. } // Default value of ACR_CURPI_COFCP_MOTOR_BIKE_PARA
  50. #define CP_CONTROL_PARA_DEFAULT \
  51. { \
  52. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
  53. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
  54. 0, 0, 0, 0, 0, 0, 0, 0, 0 \
  55. } // Default value of TCP_CONTROL_PARA
  56. #define CP_HISTORY_PARA_DEFAULT \
  57. { \
  58. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
  59. } // Default value of TCP_CONTROL_PARA
  60. /************************************************************************
  61. TypeDefs & Structure Defines
  62. *************************************************************************/
  63. typedef struct
  64. {
  65. UWORD ParaFirstSetFlg;
  66. UWORD SpiOffsetFirstSetFlg;
  67. UWORD SpiOffsetFirstSetFinishFlg;
  68. UWORD RunModelSelect;
  69. UWORD ThetaGetModelSelect;
  70. UWORD CurrentSampleModelSelect;
  71. UWORD RotateDirectionSelect;
  72. BOOL RunPermitFlg;
  73. BOOL ParaUseEEFlg;
  74. BOOL ParaUseEEFinishFlg;
  75. BOOL ParaSaveEEFlg;
  76. BOOL ParaSaveEEFinishFlg;
  77. BOOL ParaHistorySaveEEFinishFlg;
  78. BOOL ParaUpdateFlg;
  79. BOOL ParaMInfoUpdateFlg;
  80. BOOL ParaBikeInfoUpdateFlg;
  81. BOOL ParaMCInfoUpdateFlg;
  82. BOOL ParaSensorInfoUpdateFlg;
  83. BOOL ParaAInfoUpdateFlg;
  84. BOOL TestParaInfoUpdateFlg;
  85. BOOL ParaMotorDriveUpdateFinishFlg;
  86. BOOL ParaAssistUpdateFinishFlg;
  87. } CP_FLG;
  88. typedef struct
  89. {
  90. SWORD swMotrPolePairs;
  91. SWORD swRsOhm;
  92. SWORD swLdmH;
  93. SWORD swLqmH;
  94. SWORD swJD;
  95. SWORD swFluxWb;
  96. SWORD swIdMaxA;
  97. SWORD swIdMinA;
  98. SWORD swIpeakMaxA;
  99. SWORD swRSpeedRpm;
  100. SWORD swRPwrWt;
  101. SWORD swRIarmsA;
  102. SWORD swRUdcV;
  103. SWORD swTorMax;
  104. } CP_MOTOR_PARA;
  105. typedef struct
  106. {
  107. SWORD swIPMTurnOnNs;
  108. SWORD swIPMTurnOffNs;
  109. SWORD swIPMDeadTimeNs;
  110. SWORD swIPMHvicChrgMs;
  111. SWORD swAlmOverCurrentVal;
  112. SWORD swAlmOverCurrentTM;
  113. SWORD swAlmPhsLossVal;
  114. SWORD swAlmPhsLossTM;
  115. SWORD swAlmAdcDetectHighVal;
  116. SWORD swAlmAdcDetectLowVal;
  117. SWORD swAlmRotorLockK;
  118. SWORD swAlmRotorLockTM;
  119. SWORD swAlmRotorLockCurVal;
  120. SWORD swAlmRotorLockSpdVal;
  121. SWORD swAlmOverVolVal1;
  122. SWORD swAlmOverVolTM1;
  123. SWORD swAlmOverVolVal2;
  124. SWORD swAlmOverVolTM2;
  125. SWORD swAlmOverVolVal3;
  126. SWORD swAlmOverVolTM3;
  127. SWORD swAlmUnderVolVal1;
  128. SWORD swAlmUnderVolTM1;
  129. SWORD swAlmUnderVolVal2;
  130. SWORD swAlmUnderVolTM2;
  131. SWORD swAlmOverSpdVal;
  132. SWORD swAlmOverSpdTM;
  133. SWORD swAlmOverHeatCeVal;
  134. SWORD swAlmOverHeatTM;
  135. SWORD swAlmPwrLimitStartTempVal;
  136. SWORD swAlmThrPhsShrtFrcTM;
  137. SWORD swAlmPWMOffTM;
  138. SWORD swAlmPWMOffShrtsw1TM;
  139. SWORD swAlmThrPhsShrtNormTM;
  140. SWORD swAlmShrtPWMOffswTM;
  141. SWORD swAlmIPMOverCurStopTM;
  142. SWORD swAlmRecAllTM;
  143. SWORD swAlmRecOCTM;
  144. SWORD swAlmRecOVVal;
  145. SWORD swAlmRecOVTM;
  146. SWORD swAlmRecOVTM1;
  147. SWORD swAlmRecUVVal;
  148. SWORD swAlmRecUVTM;
  149. SWORD swAlmRecUVTM1;
  150. SWORD swAlmRecOHeatVal;
  151. SWORD swAlmRecOHeatTM;
  152. SWORD swAlmRecOHeatTM1;
  153. SWORD swStartMode;
  154. SWORD swInitPosMode;
  155. SWORD swAlignCurAp;
  156. SWORD swAlignRampTMms;
  157. SWORD swAlignHoldTMms;
  158. SWORD swAlignAngInitDeg;
  159. SWORD swDragCurAp;
  160. SWORD swDragVolAp;
  161. SWORD swDragSpdHz;
  162. SWORD swDragSpdRampTMms;
  163. SWORD swOpen2ClzRampTMms;
  164. SWORD swStopSpdRefRpm;
  165. SWORD swObsSpdPLLM;
  166. SWORD swObsSpdPLLBandWidthHz;
  167. SWORD swObsFluxPIDampratio;
  168. SWORD swObsFluxPICrossfreHz;
  169. SWORD swAcrPIBandwidth;
  170. SWORD swAcrCurFbLpfFre;
  171. UWORD uwAcrCurOutLim;
  172. SWORD swAcrRaCoef;
  173. UWORD uwAcrUdcpOutLim;
  174. SWORD swAsrPIBandwidth;
  175. SWORD swAsrPIM;
  176. SWORD swAsrSpdFbLPFFre;
  177. SWORD swAsrSpdInerRate;
  178. SWORD swSpeedAccRate;
  179. SWORD swSpeedDccRate;
  180. SWORD swPWMMaxDuty;
  181. SWORD swPWM7to5Duty;
  182. SWORD swPWMMinSampleDuty1;
  183. SWORD swPWMMinSampleDuty2;
  184. SWORD swPWMMinSampleDuty3;
  185. SWORD swPWMSampleToSteady;
  186. SWORD swPWMSampleSigR;
  187. SWORD swPWM1STSampleCnt;
  188. SWORD swPWM2NDSampleCnt;
  189. SWORD swPWMMinEffVectorCnt;
  190. SWORD swPWMMinEffVectorPu;
  191. SWORD swPWMOverMdlMode;
  192. SWORD swFwVdcMinCalTMms;
  193. SWORD swFwVdcLPFFre;
  194. SWORD swFwPWMMaxDuty;
  195. SWORD swFwIdPIOutMin;
  196. SWORD swFwIdMinLimRatio;
  197. SWORD swFwIdKpPu;
  198. SWORD swFwIdKiPu;
  199. SWORD swFwCharCurCrossFre;
  200. SWORD swFwCharCurDampRatio;
  201. SWORD swCvbConstantVolBrakeV;
  202. SWORD swCvbConstantSpdLowRpm;
  203. SWORD swPwrLimitValWt;
  204. SWORD swPwrLimitErrWt;
  205. SWORD swPwrLimitLPFFre;
  206. SWORD swPwrLimitKpPu;
  207. SWORD swPwrLimitKiPu;
  208. SWORD swDbcK;
  209. SWORD swUartType;
  210. } CP_CONTROL_PARA;
  211. typedef struct
  212. {
  213. UWORD uwOpenTimes;
  214. ULONG ulUsedTime;
  215. UWORD uwNTCTempMaxCe;
  216. UWORD uwNTCTempMinCe;
  217. UWORD uwAlamHOcurTimes;
  218. UWORD uwAlamSOcurTimes;
  219. UWORD uwAlamOHeatTimes;
  220. UWORD uwAlamRotorLockTimes;
  221. UWORD uwAlamPhsLossTimes;
  222. UWORD uwAlamOVolTimes;
  223. UWORD uwAlamUVolTimes;
  224. UWORD uwAlamComOTimeTimes;
  225. UWORD uwG1AvgPwrConsumption;
  226. UWORD uwG2AvgPwrConsumption;
  227. UWORD uwG3AvgPwrConsumption;
  228. UWORD uwG4AvgPwrConsumption;
  229. UWORD uwG5AvgPwrConsumption;
  230. ULONG ulODOTrip;
  231. ULONG ulODOTime;
  232. ULONG ulTripSum;
  233. ULONG ulTripSumTime;
  234. UWORD uwTorSensorAlamTimes;
  235. UWORD uwCadSensorAlamTimes;
  236. UWORD uwBikeSpdSensorAlamTimes;
  237. UWORD uwPosSensorAlamTimes;
  238. } CP_HISTORY_PARA;
  239. typedef struct
  240. {
  241. UWORD uwBikeGear;
  242. UWORD uwBikeGearLast;
  243. BOOL blGearStUpdate;
  244. ULONG ulRiTime;
  245. UWORD BikeSpeedKmH;
  246. UWORD BMSRestChargeNow;
  247. UWORD BMSRestChargeLast;
  248. UWORD uwCruisDis;
  249. UWORD uwLightSwitch;
  250. UWORD uwPowerPerKm;
  251. UWORD uwAvePowerPerKm;
  252. UWORD uwPowerPerKmSum;
  253. UWORD uwPowerPerKmBuf[32];
  254. UWORD uwAvePowerCNT;
  255. } CP_BIKERUNINFO_PARA;
  256. /*************************************************************************/
  257. /************************************************************************
  258. Exported Variables:
  259. *************************************************************************/
  260. /************************************************************************
  261. Exported Variables
  262. *************************************************************************/
  263. extern CP_MOTOR_PARA cp_stMotorPara;
  264. extern CP_CONTROL_PARA cp_stControlPara;
  265. extern CP_HISTORY_PARA cp_stHistoryPara;
  266. extern CP_BIKERUNINFO_PARA cp_stBikeRunInfoPara;
  267. extern CP_FLG cp_stFlg;
  268. extern ULONG cp_ulSystickCnt;
  269. /************************************************************************
  270. Exported Function Call Prototypes
  271. *************************************************************************/
  272. void CodeParaInit(void);
  273. /************************************************************************
  274. Flag Define (N/A)
  275. *************************************************************************/
  276. #ifdef __cplusplus
  277. }
  278. #endif // __cplusplus
  279. #endif
  280. /************************************************************************
  281. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  282. All rights reserved.
  283. *************************************************************************
  284. End of this File (EOF):
  285. Do not put anything after this part!
  286. *************************************************************************/