CodePara.h 10.0 KB

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