CodePara.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  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 ParaRideInfoUpdateFlg;
  86. BOOL ParaBikeInfo2UpdateFlg;
  87. BOOL ParaMotorDriveUpdateFinishFlg;
  88. BOOL ParaAssistUpdateFinishFlg;
  89. } CP_FLG;
  90. typedef struct
  91. {
  92. SWORD swMotrPolePairs;
  93. SWORD swRsOhm;
  94. SWORD swLdmH;
  95. SWORD swLqmH;
  96. SWORD swJD;
  97. SWORD swFluxWb;
  98. SWORD swIdMaxA;
  99. SWORD swIdMinA;
  100. SWORD swIpeakMaxA;
  101. SWORD swRSpeedRpm;
  102. SWORD swRPwrWt;
  103. SWORD swRIarmsA;
  104. SWORD swRUdcV;
  105. SWORD swTorMax;
  106. } CP_MOTOR_PARA;
  107. typedef struct
  108. {
  109. SWORD swIPMTurnOnNs;
  110. SWORD swIPMTurnOffNs;
  111. SWORD swIPMDeadTimeNs;
  112. SWORD swIPMHvicChrgMs;
  113. SWORD swAlmOverCurrentVal;
  114. SWORD swAlmOverCurrentTM;
  115. SWORD swAlmPhsLossVal;
  116. SWORD swAlmPhsLossTM;
  117. SWORD swAlmAdcDetectHighVal;
  118. SWORD swAlmAdcDetectLowVal;
  119. SWORD swAlmRotorLockK;
  120. SWORD swAlmRotorLockTM;
  121. SWORD swAlmRotorLockCurVal;
  122. SWORD swAlmRotorLockSpdVal;
  123. SWORD swAlmOverVolVal1;
  124. SWORD swAlmOverVolTM1;
  125. SWORD swAlmOverVolVal2;
  126. SWORD swAlmOverVolTM2;
  127. SWORD swAlmOverVolVal3;
  128. SWORD swAlmOverVolTM3;
  129. SWORD swAlmUnderVolVal1;
  130. SWORD swAlmUnderVolTM1;
  131. SWORD swAlmUnderVolVal2;
  132. SWORD swAlmUnderVolTM2;
  133. SWORD swAlmOverSpdVal;
  134. SWORD swAlmOverSpdTM;
  135. SWORD swAlmOverHeatCeVal;
  136. SWORD swAlmOverHeatTM;
  137. SWORD swAlmPwrLimitStartTempVal;
  138. SWORD swAlmThrPhsShrtFrcTM;
  139. SWORD swAlmPWMOffTM;
  140. SWORD swAlmPWMOffShrtsw1TM;
  141. SWORD swAlmThrPhsShrtNormTM;
  142. SWORD swAlmShrtPWMOffswTM;
  143. SWORD swAlmIPMOverCurStopTM;
  144. SWORD swAlmRecAllTM;
  145. SWORD swAlmRecOCTM;
  146. SWORD swAlmRecOVVal;
  147. SWORD swAlmRecOVTM;
  148. SWORD swAlmRecOVTM1;
  149. SWORD swAlmRecUVVal;
  150. SWORD swAlmRecUVTM;
  151. SWORD swAlmRecUVTM1;
  152. SWORD swAlmRecOHeatVal;
  153. SWORD swAlmRecOHeatTM;
  154. SWORD swAlmRecOHeatTM1;
  155. SWORD swStartMode;
  156. SWORD swInitPosMode;
  157. SWORD swAlignCurAp;
  158. SWORD swAlignRampTMms;
  159. SWORD swAlignHoldTMms;
  160. SWORD swAlignAngInitDeg;
  161. SWORD swDragCurAp;
  162. SWORD swDragVolAp;
  163. SWORD swDragSpdHz;
  164. SWORD swDragSpdRampTMms;
  165. SWORD swOpen2ClzRampTMms;
  166. SWORD swStopSpdRefRpm;
  167. SWORD swObsSpdPLLM;
  168. SWORD swObsSpdPLLBandWidthHz;
  169. SWORD swObsFluxPIDampratio;
  170. SWORD swObsFluxPICrossfreHz;
  171. SWORD swAcrPIBandwidth;
  172. SWORD swAcrCurFbLpfFre;
  173. UWORD uwAcrCurOutLim;
  174. SWORD swAcrRaCoef;
  175. UWORD uwAcrUdcpOutLim;
  176. SWORD swAsrPIBandwidth;
  177. SWORD swAsrPIM;
  178. SWORD swAsrSpdFbLPFFre;
  179. SWORD swAsrSpdInerRate;
  180. SWORD swSpeedAccRate;
  181. SWORD swSpeedDccRate;
  182. SWORD swPWMMaxDuty;
  183. SWORD swPWM7to5Duty;
  184. SWORD swPWMMinSampleDuty1;
  185. SWORD swPWMMinSampleDuty2;
  186. SWORD swPWMMinSampleDuty3;
  187. SWORD swPWMSampleToSteady;
  188. SWORD swPWMSampleSigR;
  189. SWORD swPWM1STSampleCnt;
  190. SWORD swPWM2NDSampleCnt;
  191. SWORD swPWMMinEffVectorCnt;
  192. SWORD swPWMMinEffVectorPu;
  193. SWORD swPWMOverMdlMode;
  194. SWORD swFwVdcMinCalTMms;
  195. SWORD swFwVdcLPFFre;
  196. SWORD swFwPWMMaxDuty;
  197. SWORD swFwIdPIOutMin;
  198. SWORD swFwIdMinLimRatio;
  199. SWORD swFwIdKpPu;
  200. SWORD swFwIdKiPu;
  201. SWORD swFwCharCurCrossFre;
  202. SWORD swFwCharCurDampRatio;
  203. SWORD swCvbConstantVolBrakeV;
  204. SWORD swCvbConstantSpdLowRpm;
  205. SWORD swPwrLimitValWt;
  206. SWORD swPwrLimitErrWt;
  207. SWORD swPwrLimitLPFFre;
  208. SWORD swPwrLimitKpPu;
  209. SWORD swPwrLimitKiPu;
  210. SWORD swDbcK;
  211. SWORD swUartType;
  212. } CP_CONTROL_PARA;
  213. typedef struct
  214. {
  215. UWORD uwOpenTimes;
  216. ULONG ulUsedTime;
  217. UWORD uwNTCTempMaxCe;
  218. UWORD uwNTCTempMinCe;
  219. UWORD uwAlamHOcurTimes;
  220. UWORD uwAlamSOcurTimes;
  221. UWORD uwAlamOHeatTimes;
  222. UWORD uwAlamRotorLockTimes;
  223. UWORD uwAlamPhsLossTimes;
  224. UWORD uwAlamOVolTimes;
  225. UWORD uwAlamUVolTimes;
  226. UWORD uwAlamComOTimeTimes;
  227. UWORD uwG1AvgPwrConsumption;
  228. UWORD uwG2AvgPwrConsumption;
  229. UWORD uwG3AvgPwrConsumption;
  230. UWORD uwG4AvgPwrConsumption;
  231. UWORD uwG5AvgPwrConsumption;
  232. ULONG ulODOTrip;
  233. ULONG ulODOTime;
  234. ULONG ulTripSum;
  235. ULONG ulTripSumTime;
  236. UWORD uwTorSensorAlamTimes;
  237. UWORD uwCadSensorAlamTimes;
  238. UWORD uwBikeSpdSensorAlamTimes;
  239. UWORD uwPosSensorAlamTimes;
  240. ULONG ulRealODOTrip;
  241. ULONG ulRealODOTime;
  242. } CP_HISTORY_PARA;
  243. typedef struct
  244. {
  245. UWORD uwBikeGear;
  246. UWORD uwBikeGearLast;
  247. BOOL blGearStUpdate;
  248. ULONG ulRiTime;
  249. UWORD BikeSpeedKmH;
  250. UWORD BMSRestChargeNow;
  251. UWORD BMSRestChargeLast;
  252. UWORD uwCruisDis;
  253. UWORD uwLightSwitch;
  254. UWORD uwPowerPerKm;
  255. UWORD uwAvePowerPerKm;
  256. UWORD uwPowerPerKmSum;
  257. UWORD uwPowerPerKmBuf[32];
  258. UWORD uwAvePowerCNT;
  259. } CP_BIKERUNINFO_PARA;
  260. /*************************************************************************/
  261. /************************************************************************
  262. Exported Variables:
  263. *************************************************************************/
  264. /************************************************************************
  265. Exported Variables
  266. *************************************************************************/
  267. extern CP_MOTOR_PARA cp_stMotorPara;
  268. extern CP_CONTROL_PARA cp_stControlPara;
  269. extern CP_HISTORY_PARA cp_stHistoryPara;
  270. extern CP_BIKERUNINFO_PARA cp_stBikeRunInfoPara;
  271. extern CP_FLG cp_stFlg;
  272. extern ULONG cp_ulSystickCnt;
  273. /************************************************************************
  274. Exported Function Call Prototypes
  275. *************************************************************************/
  276. void CodeParaInit(void);
  277. /************************************************************************
  278. Flag Define (N/A)
  279. *************************************************************************/
  280. #ifdef __cplusplus
  281. }
  282. #endif // __cplusplus
  283. #endif
  284. /************************************************************************
  285. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  286. All rights reserved.
  287. *************************************************************************
  288. End of this File (EOF):
  289. Do not put anything after this part!
  290. *************************************************************************/