CodePara.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. #include "typedefine.h"
  23. #include "board_config.h"
  24. typedef _Bool BOOL;
  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 CadAssist 4
  33. #define TorqAssist 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 SINGLE_RESISITANCE // Sample using single resistance
  38. #define RDSON MOS_RESISITANCE // Sample using Rdson
  39. #define COMBINATION COMBIN_MOSSING
  40. #define DOUBLERESISTANCE DOUBLE_RESISITANCE // Sample using double resistance
  41. #define ForwardRotate 0 // Sample using single resistance
  42. #define BackwardRotate 1 // Sample using Rdson
  43. #define CP_FLG_DEFAULT \
  44. { \
  45. 0, 0, FALSE, ClZLOOP, ANG_RESOLVER, COMBINATION, ForwardRotate, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE \
  46. }
  47. #define CP_MOTOR_PARA_DEFAULT \
  48. { \
  49. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \
  50. } // Default value of ACR_CURPI_COFCP_MOTOR_BIKE_PARA
  51. #define CP_CONTROL_PARA_DEFAULT \
  52. { \
  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, 0, \
  54. 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, \
  55. 0, 0, 0, 0, 0 \
  56. } // Default value of TCP_CONTROL_PARA
  57. #define CP_HISTORY_PARA_DEFAULT \
  58. { \
  59. 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 \
  60. } // Default value of TCP_CONTROL_PARA
  61. /************************************************************************
  62. TypeDefs & Structure Defines
  63. *************************************************************************/
  64. typedef struct
  65. {
  66. UWORD ParaFirstSetFlg;
  67. UWORD SpiOffsetFirstSetFlg;
  68. UWORD SpiOffsetFirstSetFinishFlg;
  69. UWORD RunModelSelect;
  70. UWORD ThetaGetModelSelect;
  71. UWORD CurrentSampleModelSelect;
  72. UWORD RotateDirectionSelect;
  73. UWORD ErrorSaveFlg;
  74. BOOL ErrorSave2FlashFlg;
  75. BOOL RunPermitFlg;
  76. BOOL ParaUseEEFlg;
  77. BOOL ParaUseEEFinishFlg;
  78. BOOL ParaSaveEEFlg;
  79. BOOL ParaSaveEEFinishFlg;
  80. BOOL ParaHistorySaveEEFinishFlg;
  81. BOOL ParaUpdateFlg;
  82. BOOL ParaMInfoUpdateFlg;
  83. BOOL ParaBikeInfoUpdateFlg;
  84. BOOL ParaMCInfoUpdateFlg;
  85. BOOL ParaSensorInfoUpdateFlg;
  86. BOOL ParaAInfoUpdateFlg;
  87. BOOL TestParaInfoUpdateFlg;
  88. BOOL ParaRideInfoUpdateFlg;
  89. BOOL ParaBikeInfo2UpdateFlg;
  90. BOOL ParaMotorDriveUpdateFinishFlg;
  91. BOOL ParaAssistUpdateFinishFlg;
  92. } CP_FLG;
  93. typedef struct
  94. {
  95. SWORD swMotrPolePairs;
  96. SWORD swRsOhm;
  97. UWORD uwLdmH;
  98. UWORD uwLqmH;
  99. SWORD swJD;
  100. SWORD swFluxWb;
  101. SWORD swIdMaxA;
  102. SWORD swIdMinA;
  103. SWORD swIpeakMaxA;
  104. SWORD swRSpeedRpm;
  105. SWORD swRPwrWt;
  106. SWORD swRIarmsA;
  107. SWORD swRUdcV;
  108. SWORD swTorMax;
  109. } CP_MOTOR_PARA;
  110. typedef struct
  111. {
  112. SWORD swIPMTurnOnNs;
  113. SWORD swIPMTurnOffNs;
  114. SWORD swIPMDeadTimeNs;
  115. SWORD swIPMHvicChrgMs;
  116. SWORD swAlmOverCurrentVal;
  117. SWORD swAlmOverCurrentTM;
  118. SWORD swAlmPhsLossVal;
  119. SWORD swAlmPhsLossTM;
  120. SWORD swAlmAdcDetectHighVal;
  121. SWORD swAlmAdcDetectLowVal;
  122. SWORD swAlmRotorLockK;
  123. SWORD swAlmRotorLockTM;
  124. SWORD swAlmRotorLockCurVal;
  125. SWORD swAlmRotorLockSpdVal;
  126. SWORD swAlmOverVolVal1;
  127. SWORD swAlmOverVolTM1;
  128. SWORD swAlmUnderVolVal1;
  129. SWORD swAlmUnderVolTM1;
  130. SWORD swAlmOverSpdVal;
  131. SWORD swAlmOverSpdTM;
  132. SWORD swAlmOverHeatCeVal;
  133. SWORD swAlmOverHeatTM;
  134. SWORD swAlmPwrLimitStartTempVal;
  135. SWORD swAlmMotorOverHeatCeVal;
  136. SWORD swAlmMotorOverHeatTM;
  137. SWORD swAlmPwrLimitMotorStartTempVal;
  138. UWORD uwControlFunEN;
  139. SWORD swAlmThrPhsShrtFrcTM;
  140. SWORD swAlmPWMOffTM;
  141. SWORD swAlmPWMOffShrtsw1TM;
  142. SWORD swAlmThrPhsShrtNormTM;
  143. SWORD swAlmShrtPWMOffswTM;
  144. SWORD swAlmIPMOverCurStopTM;
  145. SWORD swAlmRecAllTM;
  146. SWORD swAlmRecOCTM;
  147. SWORD swAlmRecOVVal;
  148. SWORD swAlmRecOVTM;
  149. SWORD swAlmRecUVVal;
  150. SWORD swAlmRecUVTM;
  151. SWORD swAlmRecOHeatVal;
  152. SWORD swAlmRecOHeatTM;
  153. SWORD swAlmRecOHeatTM1;
  154. SWORD swAlmMotorRecOHeatVal;
  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 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 swPwrLimitValWtCALC;
  205. SWORD swPwrLimitErrWt;
  206. SWORD swPwrLimitLPFFre;
  207. SWORD swPwrLimitKpPu;
  208. SWORD swPwrLimitKiPu;
  209. SWORD swDbcK;
  210. SWORD swUartType;
  211. } CP_CONTROL_PARA;
  212. typedef struct
  213. {
  214. UWORD uwOpenTimes;
  215. ULONG ulUsedTime;
  216. SWORD swNTCTempMaxCe;
  217. SWORD swNTCTempMinCe;
  218. UWORD uwAlamHOcurTimes;
  219. UWORD uwAlamSOcurTimes;
  220. UWORD uwAlamOHeatTimes;
  221. UWORD uwAlamRotorLockTimes;
  222. UWORD uwAlamPhsLossTimes;
  223. UWORD uwAlamOVolTimes;
  224. UWORD uwAlamUVolTimes;
  225. UWORD uwAlamComOTimeTimes;
  226. UWORD uwG1AvgPwrConsumption;
  227. UWORD uwG2AvgPwrConsumption;
  228. UWORD uwG3AvgPwrConsumption;
  229. UWORD uwG4AvgPwrConsumption;
  230. UWORD uwG5AvgPwrConsumption;
  231. ULONG ulODOTrip;
  232. ULONG ulODOTime;
  233. ULONG ulTripSum;
  234. ULONG ulTripSumTime;
  235. UWORD uwTorSensorAlamTimes;
  236. UWORD uwCadSensorAlamTimes;
  237. UWORD uwBikeSpdSensorAlamTimes;
  238. UWORD uwPosSensorAlamTimes;
  239. ULONG ulRealODOTrip;
  240. ULONG ulRealODOTime;
  241. } CP_HISTORY_PARA;
  242. typedef struct
  243. {
  244. UWORD uwBikeGear;
  245. UWORD uwBikeGearLast;
  246. BOOL blGearStUpdate;
  247. ULONG ulRiTime;
  248. ULONG ulRiTirpTime;
  249. ULONG ulRealODOTime;
  250. UWORD BikeSpeedKmH; //Unit 0.1Km/h
  251. UWORD BMSRestChargeNow;
  252. UWORD BMSRestChargeLast;
  253. UWORD uwCruisDis;
  254. UWORD uwLightSwitch;
  255. UWORD uwPowerPerKm;
  256. UWORD uwAvePowerPerKm;
  257. UWORD uwPowerPerKmSum;
  258. UWORD uwPowerPerKmBuf[32];
  259. UWORD uwAvePowerCNT;
  260. } CP_BIKERUNINFO_PARA;
  261. /*************************************************************************/
  262. /************************************************************************
  263. Exported Variables:
  264. *************************************************************************/
  265. /************************************************************************
  266. Exported Variables
  267. *************************************************************************/
  268. extern CP_MOTOR_PARA cp_stMotorPara;
  269. extern CP_CONTROL_PARA cp_stControlPara;
  270. extern CP_HISTORY_PARA cp_stHistoryPara;
  271. extern CP_BIKERUNINFO_PARA cp_stBikeRunInfoPara;
  272. extern CP_FLG cp_stFlg;
  273. extern ULONG cp_ulSystickCnt;
  274. extern UWORD TimingDelay;
  275. /************************************************************************
  276. Exported Function Call Prototypes
  277. *************************************************************************/
  278. void CodeParaInit(void);
  279. void CodeHistoryParaDelete(void);
  280. void CPHistoryInfoCalTiming(void);
  281. /************************************************************************
  282. Flag Define (N/A)
  283. *************************************************************************/
  284. #endif
  285. /************************************************************************
  286. Copyright (c) 2018 Welling Motor Technology(Shanghai) Co. Ltd.
  287. All rights reserved.
  288. *************************************************************************
  289. End of this File (EOF):
  290. Do not put anything after this part!
  291. *************************************************************************/