motor.c 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199
  1. #include "foc/motor/motor.h"
  2. #include "foc/motor/current.h"
  3. #include "foc/foc_config.h"
  4. #include "foc/mc_error.h"
  5. #include "foc/samples.h"
  6. #include "math/fast_math.h"
  7. #include "bsp/timer_count32.h"
  8. #include "libs/time_measure.h"
  9. #include "bsp/delay.h"
  10. #include "bsp/bsp.h"
  11. #include "bsp/adc.h"
  12. #include "bsp/pwm.h"
  13. #include "bsp/fan_pwm.h"
  14. #include "foc/commands.h"
  15. #include "libs/logger.h"
  16. #include "bsp/sched_timer.h"
  17. #include "foc/core/e_ctrl.h"
  18. #include "foc/samples.h"
  19. #include "foc/motor/motor_param.h"
  20. #include "foc/core/foc_observer.h"
  21. #include "foc/core/thro_torque.h"
  22. #include "app/nv_storage.h"
  23. //#include "foc/core/torque.h"
  24. #include "foc/limit.h"
  25. #ifdef CONFIG_DQ_STEP_RESPONSE
  26. extern float target_d;
  27. extern float target_q;
  28. #endif
  29. static bool mc_is_hwbrake(void);
  30. static bool mc_is_gpio_mlock(void);
  31. static void _pwm_brake_prot_timer_handler(shark_timer_t *);
  32. static shark_timer_t _brake_prot_timer = TIMER_INIT(_brake_prot_timer, _pwm_brake_prot_timer_handler);
  33. static void _autohold_beep_timer_handler(shark_timer_t *);
  34. static shark_timer_t _autohold_beep_timer = TIMER_INIT(_autohold_beep_timer, _autohold_beep_timer_handler);
  35. static void _fan_det_timer_handler(shark_timer_t *);
  36. static shark_timer_t _fan_det_timer1 = TIMER_INIT(_fan_det_timer1, _fan_det_timer_handler);
  37. static shark_timer_t _fan_det_timer2 = TIMER_INIT(_fan_det_timer2, _fan_det_timer_handler);
  38. static void _encoder_zero_off_timer_handler(shark_timer_t *);
  39. static shark_timer_t _encoder_zero_off_timer = TIMER_INIT(_encoder_zero_off_timer, _encoder_zero_off_timer_handler);
  40. static void _led_off_timer_handler(shark_timer_t *);
  41. static shark_timer_t _led_off_timer = TIMER_INIT(_led_off_timer, _led_off_timer_handler);
  42. static motor_t motor = {
  43. .s_direction = POSITIVE,
  44. .n_gear = 0,
  45. .b_is96Mode = false,
  46. .mode = CTRL_MODE_OPEN,
  47. };
  48. static void MC_Check_MosVbusThrottle(void) {
  49. int count = 1000;
  50. float ibus_adc = 0;
  51. float vref_adc = 0;
  52. float vref_5v_adc = 0;
  53. gpio_phase_u_detect(true);
  54. while(count-- > 0) {
  55. task_udelay(20);
  56. sample_uvw_phase();
  57. sample_throttle();
  58. sample_vbus();
  59. vref_adc += adc_get_vref();
  60. vref_5v_adc += adc_get_5v_ref();
  61. }
  62. adc_set_vref_calc(vref_adc/1000.0f);
  63. adc_set_5vref_calc(vref_5v_adc/1000.0f);
  64. sys_debug("5v ref %f\n", vref_5v_adc/1000.0f);
  65. count = 50;
  66. while(count-- >0) {
  67. task_udelay(300);
  68. ibus_adc += adc_get_ibus();
  69. }
  70. u16 offset = ((float)ibus_adc)/50.0f;
  71. sys_debug("ibus offset %d\n", offset);
  72. sample_ibus_offset(offset);
  73. gpio_phase_u_detect(false);
  74. float abc[3];
  75. get_phase_vols(abc);
  76. int vbus_vol = get_vbus_int();
  77. if (vbus_vol > nv_get_foc_params()->s_maxDCVol) {
  78. mc_set_critical_error(FOC_CRIT_OV_Vol_Err);
  79. }
  80. if (vbus_vol <= nv_get_foc_params()->s_minDCVol) {
  81. mc_set_critical_error(FOC_CRIT_UN_Vol_Err);
  82. }
  83. vbus_vol = get_acc_vol();
  84. sys_debug("acc vol %d\n", vbus_vol);
  85. if (vbus_vol >= nv_get_foc_params()->s_maxDCVol) {
  86. mc_set_critical_error(FOC_CRIT_ACC_OV_Err);
  87. }
  88. if (vbus_vol <= nv_get_foc_params()->s_minDCVol) {
  89. mc_set_critical_error(FOC_CRIT_ACC_Un_Err);
  90. }
  91. if ((get_throttle_float() < nv_get_foc_params()->f_minThroVol) || (get_throttle_float() > nv_get_foc_params()->f_maxThroVol)) {
  92. if (!motor.b_ignor_throttle) {
  93. mc_set_critical_error(FOC_CRIT_THRO_Err);
  94. }
  95. }
  96. if (abc[0] > vbus_vol/2 || abc[1] > vbus_vol/2 || abc[2] > vbus_vol/2) {
  97. mc_set_critical_error(FOC_CRIT_H_MOS_Err);
  98. }else if (abc[0] < 0.001f){
  99. mc_set_critical_error(FOC_CRIT_L_MOS_Err);
  100. }else if ((abc[0] > 0.5f) && (abc[1] < 0.001f || abc[2] < 0.001f)) {
  101. mc_set_critical_error(FOC_CRIT_Phase_Conn_Err);
  102. }
  103. sys_debug("phase vol %f, %f, %f\n", abc[0], abc[1], abc[2]);
  104. }
  105. static u32 _self_check_task(void *p) {
  106. if (ENC_Check_error()) {
  107. err_add_record(FOC_CRIT_Encoder_Err, 0);
  108. mc_set_critical_error(FOC_CRIT_Encoder_Err);
  109. }
  110. if (get_tick_ms() < 5000) { //启动后5s内检测锁电机线
  111. if (mc_is_gpio_mlock()) {
  112. mc_lock_motor(true);
  113. }
  114. }
  115. if (motor.b_lock_motor) {
  116. if (!mc_is_gpio_mlock()) {
  117. mc_lock_motor(false);
  118. }
  119. }
  120. if (fan_pwm_is_running()) {
  121. if ((get_delta_ms(motor.fan[0].start_ts) >= 5000) && (motor.fan[0].rpm == 0)) {
  122. mc_set_critical_error(FOC_CRIT_Fan1_Err);
  123. }else if (motor.fan[0].rpm > 0) {
  124. mc_clr_critical_error(FOC_CRIT_Fan1_Err);
  125. }
  126. if ((get_delta_ms(motor.fan[1].start_ts) >= 5000) && (motor.fan[1].rpm == 0)) {
  127. mc_set_critical_error(FOC_CRIT_Fan2_Err);
  128. }else if (motor.fan[1].rpm > 0) {
  129. mc_clr_critical_error(FOC_CRIT_Fan2_Err);
  130. }
  131. }
  132. return 5;
  133. }
  134. static bool mc_detect_vbus_mode(void) {
  135. #ifdef CONFIG_FORCE_96V_MODE
  136. motor.b_is96Mode = true;
  137. return false;
  138. #else
  139. bool is_96mode = motor.b_is96Mode;
  140. motor.b_is96Mode = get_vbus_int() >= CONFIG_96V_MODE_VOL;
  141. return (is_96mode != motor.b_is96Mode);
  142. #endif
  143. }
  144. static void _mc_internal_init(u8 mode, bool start) {
  145. motor.mode = mode;
  146. motor.throttle = 0;
  147. motor.b_start = start;
  148. motor.b_runStall = false;
  149. motor.runStall_time = 0;
  150. motor.b_epm = false;
  151. motor.b_epm_cmd_move = false;
  152. motor.epm_dir = EPM_Dir_None;
  153. motor.n_autohold_time = 0;
  154. motor.b_auto_hold = 0;
  155. motor.b_break = false;
  156. motor.b_wait_brk_release = false;
  157. motor.b_force_run = false;
  158. motor.b_cruise = false;
  159. }
  160. static void _led_off_timer_handler(shark_timer_t *t) {
  161. gpio_led_enable(false);
  162. }
  163. static void mc_gear_vmode_changed(void) {
  164. mc_gear_t *gears = mc_get_gear_config();
  165. //sys_debug("limit %d-%d-%d, mode = %s\n", gears[motor.n_gear].u_maxRPM, gears[motor.n_gear].u_maxIdc, gears[motor.n_gear].u_maxTorque, motor.b_is96Mode?"96V":"48V");
  166. PMSM_FOC_SpeedLimit(gears->n_max_speed);
  167. PMSM_FOC_DCCurrLimit(gears->n_max_idc);
  168. PMSM_FOC_TorqueLimit(gears->n_max_trq);
  169. }
  170. static s16 mc_get_gear_idc_limit(void) {
  171. if (motor.b_is96Mode) {
  172. return nv_get_gear_configs()->gears_96[motor.n_gear].n_max_idc;
  173. }else {
  174. return nv_get_gear_configs()->gears_48[motor.n_gear].n_max_idc;
  175. }
  176. }
  177. void mc_init(void) {
  178. fan_pwm_init();
  179. adc_init();
  180. pwm_3phase_init();
  181. samples_init();
  182. motor_encoder_init();
  183. foc_command_init();
  184. thro_torque_init();
  185. mc_detect_vbus_mode();
  186. PMSM_FOC_CoreInit();
  187. eCtrl_init(CONFIG_ACC_TIME, nv_get_foc_params()->n_dec_time);
  188. mc_gpio_init();
  189. MC_Check_MosVbusThrottle();
  190. sched_timer_enable(CONFIG_SPD_CTRL_US);
  191. shark_task_create(_self_check_task, NULL);
  192. pwm_up_enable(true);
  193. gpio_led_enable(true);
  194. shark_timer_post(&_led_off_timer, 5000);
  195. }
  196. motor_t * mc_params(void) {
  197. return &motor;
  198. }
  199. void mc_need_update(void) {
  200. motor.b_updated = true;
  201. }
  202. mc_gear_t *mc_get_gear_config(void) {
  203. mc_gear_t *gears;
  204. if (motor.b_is96Mode) {
  205. gears = &nv_get_gear_configs()->gears_96[0];
  206. }else {
  207. gears = &nv_get_gear_configs()->gears_48[0];
  208. }
  209. return &gears[motor.n_gear];
  210. }
  211. bool mc_unsafe_critical_error(void) {
  212. u32 err = motor.n_CritiCalErrMask & (~(FOC_Cri_Err_Mask(FOC_CRIT_Fan1_Err)));
  213. err = err & (~(FOC_Cri_Err_Mask(FOC_CRIT_Fan2_Err)));
  214. #ifdef CONFIG_DQ_STEP_RESPONSE
  215. sys_debug("err=0x%x\n", err);
  216. err = err & (~(FOC_Cri_Err_Mask(FOC_CRIT_Encoder_Err)));
  217. err = err & (~(FOC_Cri_Err_Mask(FOC_CRIT_THRO_Err)));
  218. sys_debug("err=0x%x\n", err);
  219. #endif
  220. if (motor.b_ignor_throttle) {
  221. err = err & (~(FOC_Cri_Err_Mask(FOC_CRIT_THRO_Err)));
  222. }
  223. return (err != 0);
  224. }
  225. bool mc_start(u8 mode) {
  226. if (motor.b_start) {
  227. return true;
  228. }
  229. #ifdef CONFIG_DQ_STEP_RESPONSE
  230. mode = CTRL_MODE_CURRENT;
  231. target_d = 0.0f;
  232. target_q = 0.0f;
  233. #endif
  234. mc_detect_vbus_mode();
  235. if (motor.b_lock_motor) {
  236. PMSM_FOC_SetErrCode(FOC_NotAllowed);
  237. return false;
  238. }
  239. MC_Check_MosVbusThrottle();
  240. if (mc_unsafe_critical_error()) {
  241. PMSM_FOC_SetErrCode(FOC_Have_CritiCal_Err);
  242. return false;
  243. }
  244. if (mode > CTRL_MODE_CURRENT) {
  245. PMSM_FOC_SetErrCode(FOC_Param_Err);
  246. return false;
  247. }
  248. if (motor_encoder_get_speed() > CONFIG_ZERO_SPEED_RPM) {
  249. PMSM_FOC_SetErrCode(FOC_NowAllowed_With_Speed);
  250. return false;
  251. }
  252. if (!mc_throttle_released()) {
  253. PMSM_FOC_SetErrCode(FOC_Throttle_Err);
  254. return false;
  255. }
  256. pwm_up_enable(false);
  257. _mc_internal_init(mode, true);
  258. #if 0
  259. torque_reset();
  260. #else
  261. thro_torque_reset();
  262. #endif
  263. eCtrl_init(CONFIG_ACC_TIME, nv_get_foc_params()->n_dec_time);
  264. motor_encoder_start(true);
  265. PMSM_FOC_Start(mode);
  266. PMSM_FOC_RT_LimInit();
  267. pwm_turn_on_low_side();
  268. delay_ms(10);
  269. phase_current_offset_calibrate();
  270. pwm_start();
  271. delay_us(10); //wait for ebrake error
  272. if (mc_unsafe_critical_error()) {
  273. mc_stop();
  274. return false;
  275. }
  276. adc_start_convert();
  277. phase_current_calibrate_wait();
  278. if (phase_curr_offset_check()) {
  279. mc_set_critical_error(FOC_CRIT_CURR_OFF_Err);
  280. mc_stop();
  281. return false;
  282. }
  283. if (mc_is_hwbrake()) {
  284. PMSM_FOC_Brake(true);
  285. }
  286. gpio_beep(200);
  287. return true;
  288. }
  289. bool mc_stop(void) {
  290. if (!motor.b_start) {
  291. return true;
  292. }
  293. if (motor.b_lock_motor) {
  294. PMSM_FOC_SetErrCode(FOC_NotAllowed);
  295. return false;
  296. }
  297. if (motor_encoder_get_speed() > CONFIG_ZERO_SPEED_RPM) {
  298. PMSM_FOC_SetErrCode(FOC_NowAllowed_With_Speed);
  299. return false;
  300. }
  301. if (!mc_throttle_released()) {
  302. PMSM_FOC_SetErrCode(FOC_Throttle_Err);
  303. return false;
  304. }
  305. u32 mask = cpu_enter_critical();
  306. _mc_internal_init(CTRL_MODE_OPEN, false);
  307. adc_stop_convert();
  308. pwm_stop();
  309. PMSM_FOC_Stop();
  310. motor_encoder_start(false);
  311. pwm_up_enable(true);
  312. cpu_exit_critical(mask);
  313. return true;
  314. }
  315. bool mc_set_gear(u8 gear) {
  316. if (gear >= CONFIG_MAX_GEAR_NUM) {
  317. PMSM_FOC_SetErrCode(FOC_Param_Err);
  318. return false;
  319. }
  320. if (motor.n_gear != gear) {
  321. motor.n_gear = gear;
  322. u32 mask = cpu_enter_critical();
  323. mc_gear_vmode_changed();
  324. cpu_exit_critical(mask);
  325. }
  326. return true;
  327. }
  328. u8 mc_get_gear(void) {
  329. if (motor.n_gear == 3){
  330. return 0;
  331. }
  332. return motor.n_gear + 1;
  333. }
  334. bool mc_enable_cruise(bool enable) {
  335. if (enable == motor.b_cruise) {
  336. return true;
  337. }
  338. if (PMSM_FOC_EnableCruise(enable)) {
  339. motor.b_cruise = enable;
  340. motor.cruise_time = enable?shark_get_seconds():0;
  341. motor.cruise_torque = 0.0f;
  342. return true;
  343. }
  344. return false;
  345. }
  346. bool mc_is_cruise_enabled(void) {
  347. return motor.b_cruise;
  348. }
  349. bool mc_set_cruise_speed(bool rpm_abs, float target_rpm) {
  350. bool ret;
  351. if (rpm_abs) {
  352. ret = PMSM_FOC_Set_CruiseSpeed(target_rpm);
  353. }else {
  354. ret = PMSM_FOC_Set_CruiseSpeed(PMSM_FOC_GetSpeed() + target_rpm);
  355. }
  356. if (ret) {
  357. motor.cruise_time = shark_get_seconds();
  358. motor.cruise_torque = 0.0f;
  359. }
  360. return ret;
  361. }
  362. void mc_set_idc_limit(s16 limit) {
  363. s16 g_limit = mc_get_gear_idc_limit();
  364. limit = min(g_limit, limit);
  365. PMSM_FOC_DCCurrLimit(limit);
  366. }
  367. bool mc_set_foc_mode(u8 mode) {
  368. if (mode == motor.mode) {
  369. return true;
  370. }
  371. if (!motor.b_start) {
  372. return false;
  373. }
  374. u32 mask = cpu_enter_critical();
  375. bool ret = false;
  376. if (PMSM_FOC_SetCtrlMode(mode)) {
  377. motor.mode = mode;
  378. if (mode == CTRL_MODE_OPEN || mode == CTRL_MODE_CURRENT) {
  379. PMSM_FOC_Start(motor.mode);
  380. pwm_enable_channel();
  381. }
  382. ret = true;
  383. }
  384. cpu_exit_critical(mask);
  385. return ret;
  386. }
  387. bool mc_start_epm(bool epm) {
  388. if (motor.b_epm == epm) {
  389. return true;
  390. }
  391. if (!motor.b_start) {
  392. PMSM_FOC_SetErrCode(FOC_NotAllowed);
  393. return false;
  394. }
  395. if (motor_encoder_get_speed() > CONFIG_ZERO_SPEED_RPM) {
  396. PMSM_FOC_SetErrCode(FOC_NowAllowed_With_Speed);
  397. return false;
  398. }
  399. if (!mc_throttle_released()) {
  400. PMSM_FOC_SetErrCode(FOC_Throttle_Err);
  401. return false;
  402. }
  403. u32 mask = cpu_enter_critical();
  404. motor.b_epm = epm;
  405. if (epm) {
  406. eCtrl_set_TgtSpeed(0);
  407. motor.mode = CTRL_MODE_SPD;
  408. PMSM_FOC_TorqueLimit(nv_get_foc_params()->s_maxEpmTorqueLim);
  409. PMSM_FOC_SetCtrlMode(CTRL_MODE_SPD);
  410. }else {
  411. motor.epm_dir = EPM_Dir_None;
  412. motor.mode = CTRL_MODE_TRQ;
  413. motor.b_epm_cmd_move = false;
  414. PMSM_FOC_SetCtrlMode(CTRL_MODE_TRQ);
  415. mc_gear_vmode_changed();
  416. }
  417. cpu_exit_critical(mask);
  418. return false;
  419. }
  420. bool mc_is_epm(void) {
  421. return motor.b_epm;
  422. }
  423. bool mc_is_start(void) {
  424. return (motor.b_start || PMSM_FOC_Is_Start());
  425. }
  426. bool mc_start_epm_move(EPM_Dir_t dir, bool is_command) {
  427. if (!motor.b_epm || !motor.b_start) {
  428. PMSM_FOC_SetErrCode(FOC_NotAllowed);
  429. return false;
  430. }
  431. if ((dir == motor.epm_dir) && (is_command == motor.b_epm_cmd_move)) {
  432. return true;
  433. }
  434. u32 mask = cpu_enter_critical();
  435. motor.epm_dir = dir;
  436. if (dir != EPM_Dir_None) {
  437. motor.b_epm_cmd_move = is_command;
  438. if (!PMSM_FOC_Is_Start()) {
  439. PMSM_FOC_Start(motor.mode);
  440. pwm_enable_channel();
  441. }
  442. float rpm = nv_get_foc_params()->s_maxEpmRPM;
  443. if (dir == EPM_Dir_Back) {
  444. rpm = -rpm;
  445. }
  446. sys_debug("rpm %f\n", rpm);
  447. PMSM_FOC_Set_Speed(rpm);
  448. }else {
  449. motor.b_epm_cmd_move = false;
  450. PMSM_FOC_Set_Speed(0);
  451. }
  452. cpu_exit_critical(mask);
  453. return true;
  454. }
  455. void mc_set_fan_duty(u8 duty) {
  456. sys_debug("fan duty %d\n", duty);
  457. if (!fan_pwm_is_running() && duty > 0) {
  458. motor.fan[0].start_ts = get_tick_ms();
  459. motor.fan[1].start_ts = get_tick_ms();
  460. shark_timer_post(&_fan_det_timer1, 5000);
  461. shark_timer_post(&_fan_det_timer2, 5000);
  462. }else if (duty == 0) {
  463. shark_timer_cancel(&_fan_det_timer1);
  464. shark_timer_cancel(&_fan_det_timer2);
  465. }
  466. fan_set_duty(duty);
  467. }
  468. bool mc_command_epm_move(EPM_Dir_t dir) {
  469. return mc_start_epm_move(dir, true);
  470. }
  471. bool mc_throttle_epm_move(EPM_Dir_t dir) {
  472. return mc_start_epm_move(dir, false);
  473. }
  474. void mc_set_throttle_r(bool use, u8 r) {
  475. motor.u_throttle_ration = r;
  476. motor.b_ignor_throttle = use;
  477. if (motor.b_ignor_throttle) {
  478. mc_clr_critical_error(FOC_CRIT_THRO_Err);
  479. }
  480. }
  481. void mc_use_throttle(void) {
  482. motor.b_ignor_throttle = false;
  483. }
  484. void mc_get_running_status(u8 *data) {
  485. data[0] = motor.mode;
  486. data[0] |= (PMSM_FOC_AutoHoldding()?1:0) << 2;
  487. data[0] |= (motor.b_break?1:0) << 3;
  488. data[0] |= (PMSM_FOC_Get()->in.b_cruiseEna?1:0) << 4;
  489. data[0] |= (motor.b_start?1:0) << 5;
  490. data[0] |= (mc_is_epm()?1:0) << 6;
  491. data[0] |= (motor.b_lock_motor) << 7; //motor locked
  492. }
  493. u16 mc_get_running_status2(void) {
  494. u16 data = 0;
  495. data = motor.n_gear;
  496. data |= (PMSM_FOC_AutoHoldding()?1:0) << 2;
  497. data |= (motor.b_break?1:0) << 3;
  498. data |= (PMSM_FOC_Get()->in.b_cruiseEna?1:0) << 4;
  499. data |= (motor.b_start?1:0) << 5;
  500. data |= (mc_is_epm()?1:0) << 6;
  501. data |= (motor.b_lock_motor) << 7; //motor locked
  502. data |= (eCtrl_is_eBrk_Running()?1:0) << 8; //能量回收运行标志
  503. data |= ((motor.n_CritiCalErrMask != 0)?1:0) << 9;
  504. data |= (fan_pwm_is_running()?1:0) << 10; //风扇是否运行
  505. data |= (motor.b_runStall?1:0) << 11; //是否堵转
  506. data |= (PMSM_FOC_iDC_is_Limited()?1:0) << 12; //是否欠压限制母线电流
  507. data |= (PMSM_FOC_Torque_is_Limited()?1:0) << 13; //是否高温限扭矩
  508. data |= (motor.b_is96Mode?1:0) << 14; //是否高压模式
  509. return data;
  510. }
  511. static float _force_angle = 0.0f;
  512. static int _force_wait = 2000;
  513. /* 开环,强制给定电角度和DQ的电压 */
  514. void mc_force_run_open(s16 vd, s16 vq) {
  515. if (motor.b_start || motor.b_force_run) {
  516. if (vd == 0 && vq == 0) {
  517. PMSM_FOC_SetOpenVdq(0, 0);
  518. delay_ms(500);
  519. wdog_reload();
  520. adc_stop_convert();
  521. pwm_stop();
  522. PMSM_FOC_Stop();
  523. pwm_up_enable(true);
  524. motor.b_force_run = false;
  525. motor.b_ignor_throttle = false;
  526. }
  527. return;
  528. }
  529. if (vd == 0 && vq == 0) {
  530. return;
  531. }
  532. motor.b_ignor_throttle = true;
  533. MC_Check_MosVbusThrottle();
  534. if (mc_unsafe_critical_error()) {
  535. PMSM_FOC_SetErrCode(FOC_Have_CritiCal_Err);
  536. }
  537. pwm_up_enable(false);
  538. pwm_turn_on_low_side();
  539. task_udelay(500);
  540. PMSM_FOC_Start(CTRL_MODE_OPEN);
  541. phase_current_offset_calibrate();
  542. pwm_start();
  543. adc_start_convert();
  544. pwm_enable_channel();
  545. phase_current_calibrate_wait();
  546. PMSM_FOC_Set_Angle(0);
  547. PMSM_FOC_SetOpenVdq(vd, 0);
  548. _force_wait = 2000;
  549. motor.b_force_run = true;
  550. }
  551. void mc_encoder_off_calibrate(s16 vd) {
  552. if (motor.b_start || motor.b_calibrate) {
  553. return;
  554. }
  555. motor.b_calibrate = true;
  556. pwm_up_enable(false);
  557. pwm_turn_on_low_side();
  558. task_udelay(500);
  559. PMSM_FOC_Start(CTRL_MODE_OPEN);
  560. phase_current_offset_calibrate();
  561. pwm_start();
  562. adc_start_convert();
  563. phase_current_calibrate_wait();
  564. PMSM_FOC_Set_Angle(0);
  565. PMSM_FOC_SetOpenVdq(vd, 0);
  566. delay_ms(2000);
  567. motor_encoder_set_direction(POSITIVE);
  568. for (int i = 0; i < 200; i++) {
  569. for (float angle = 0; angle < 360; angle++) {
  570. PMSM_FOC_Set_Angle(angle);
  571. delay_ms(1);
  572. if (i > 20) {
  573. motor_encoder_offset(angle);
  574. }
  575. }
  576. wdog_reload();
  577. if (motor_encoder_offset_is_finish()) {
  578. break;
  579. }
  580. }
  581. motor_encoder_set_direction(NEGATIVE);
  582. delay_ms(100);
  583. for (int i = 0; i < 200; i++) {
  584. for (float angle = 360; angle > 0; angle--) {
  585. PMSM_FOC_Set_Angle(angle);
  586. delay_ms(1);
  587. if (i > 10) {
  588. motor_encoder_offset(angle);
  589. }
  590. }
  591. wdog_reload();
  592. if (motor_encoder_offset_is_finish()) {
  593. break;
  594. }
  595. }
  596. delay_ms(500);
  597. PMSM_FOC_SetOpenVdq(0, 0);
  598. delay_ms(500);
  599. wdog_reload();
  600. adc_stop_convert();
  601. pwm_stop();
  602. PMSM_FOC_Stop();
  603. pwm_up_enable(true);
  604. motor_encoder_data_upload();
  605. motor.b_calibrate = false;
  606. }
  607. static void _encoder_zero_off_timer_handler(shark_timer_t *t){
  608. if (!motor.b_calibrate) {
  609. return;
  610. }
  611. float enc_off = 0.0f;
  612. float phase = motor_encoder_zero_phase_detect(&enc_off);
  613. PMSM_FOC_SetOpenVdq(0, 0);
  614. delay_ms(50);
  615. adc_stop_convert();
  616. pwm_stop();
  617. PMSM_FOC_Stop();
  618. _mc_internal_init(CTRL_MODE_OPEN, false);
  619. motor.b_calibrate = false;
  620. if (phase != INVALID_ANGLE) {
  621. nv_save_angle_offset(phase);
  622. }
  623. }
  624. bool mc_encoder_zero_calibrate(s16 vd) {
  625. if (motor.b_calibrate) {
  626. if (vd == 0) {
  627. encoder_clear_cnt_offset();
  628. shark_timer_cancel(&_encoder_zero_off_timer);
  629. PMSM_FOC_SetOpenVdq(0, 0);
  630. delay_ms(500);
  631. adc_stop_convert();
  632. pwm_stop();
  633. PMSM_FOC_Stop();
  634. _mc_internal_init(CTRL_MODE_OPEN, false);
  635. motor.b_calibrate = false;
  636. motor.b_ignor_throttle = false;
  637. }
  638. return true;
  639. }
  640. encoder_clear_cnt_offset();
  641. motor.b_ignor_throttle = true;
  642. MC_Check_MosVbusThrottle();
  643. if (mc_unsafe_critical_error()) {
  644. PMSM_FOC_SetErrCode(FOC_Have_CritiCal_Err);
  645. return false;
  646. }
  647. _mc_internal_init(CTRL_MODE_OPEN, true);
  648. motor.b_calibrate = true;
  649. pwm_turn_on_low_side();
  650. task_udelay(500);
  651. PMSM_FOC_Start(CTRL_MODE_OPEN);
  652. phase_current_offset_calibrate();
  653. pwm_start();
  654. adc_start_convert();
  655. pwm_enable_channel();
  656. phase_current_calibrate_wait();
  657. PMSM_FOC_Set_Angle(0);
  658. PMSM_FOC_SetOpenVdq(vd, 0);
  659. shark_timer_post(&_encoder_zero_off_timer, 6*1000);
  660. return true;
  661. }
  662. bool mc_current_sensor_calibrate(float current) {
  663. if (!mc_start(CTRL_MODE_OPEN)) {
  664. return false;
  665. }
  666. phase_current_sensor_start_calibrate(current);
  667. phase_current_calibrate_wait();
  668. return true;
  669. }
  670. bool mc_lock_motor(bool lock) {
  671. if (motor.b_lock_motor == lock) {
  672. return true;
  673. }
  674. int ret = true;
  675. u32 mask = cpu_enter_critical();
  676. if (motor.b_start) {
  677. PMSM_FOC_SetErrCode(FOC_NotAllowed);
  678. ret = false;
  679. goto ml_ex_cri;
  680. }
  681. if (lock && (motor_encoder_get_speed() > CONFIG_ZERO_SPEED_RPM)) {
  682. PMSM_FOC_SetErrCode(FOC_NowAllowed_With_Speed);
  683. ret = false;
  684. goto ml_ex_cri;
  685. }
  686. motor.b_lock_motor = lock;
  687. if (lock) {
  688. pwm_start();
  689. pwm_update_duty(FOC_PWM_Half_Period/2, FOC_PWM_Half_Period/2, FOC_PWM_Half_Period/2);
  690. pwm_enable_channel();
  691. }else {
  692. pwm_stop();
  693. }
  694. ml_ex_cri:
  695. cpu_exit_critical(mask);
  696. return ret;
  697. }
  698. bool mc_auto_hold(bool hold) {
  699. if (motor.b_auto_hold == hold) {
  700. return true;
  701. }
  702. if (nv_get_foc_params()->n_autoHold == 0) {
  703. PMSM_FOC_SetErrCode(FOC_NotAllowed);
  704. return false;
  705. }
  706. if (!motor.b_start) {
  707. PMSM_FOC_SetErrCode(FOC_NotAllowed);
  708. return false;
  709. }
  710. if (hold && !mc_throttle_released()) {
  711. PMSM_FOC_SetErrCode(FOC_Throttle_Err);
  712. return false;
  713. }
  714. u32 mask = cpu_enter_critical();
  715. motor.b_auto_hold = hold;
  716. if (!PMSM_FOC_Is_Start()) {
  717. PMSM_FOC_Start(motor.mode);
  718. PMSM_FOC_AutoHold(hold);
  719. pwm_enable_channel();
  720. }else {
  721. PMSM_FOC_AutoHold(hold);
  722. }
  723. cpu_exit_critical(mask);
  724. return true;
  725. }
  726. void mc_set_critical_error(u8 err) {
  727. motor.n_CritiCalErrMask |= (1u << err);
  728. }
  729. void mc_clr_critical_error(u8 err) {
  730. motor.n_CritiCalErrMask &= ~(1u << err);
  731. }
  732. u32 mc_get_critical_error(void) {
  733. return motor.n_CritiCalErrMask;
  734. }
  735. bool mc_throttle_released(void) {
  736. if (motor.b_ignor_throttle) {
  737. return motor.u_throttle_ration == 0;
  738. }
  739. return get_throttle_float() <= nv_get_foc_params()->n_startThroVol;
  740. }
  741. static bool mc_is_gpio_mlock(void) {
  742. int count = 50;
  743. int settimes = 0;
  744. while(count-- > 0) {
  745. bool b1 = gpio_motor_locked();
  746. if (b1) {
  747. settimes ++;
  748. }
  749. delay_us(1);
  750. }
  751. if (settimes == 0) {
  752. return false;
  753. }else if (settimes == 50) {
  754. return true;
  755. }
  756. //有干扰,do nothing
  757. return false;
  758. }
  759. static bool mc_is_hwbrake(void) {
  760. int count = 50;
  761. int settimes = 0;
  762. while(count-- > 0) {
  763. bool b1 = mc_get_gpio_brake() && mc_get_gpio_brake1();
  764. if (b1) {
  765. settimes ++;
  766. }
  767. delay_us(1);
  768. }
  769. if (settimes == 0) {
  770. #if GPIO_BREAK_MODE==GPIO_LOW_BRK_MODE
  771. return true;
  772. #else
  773. return false;
  774. #endif
  775. }else if (settimes == 50) {
  776. #if GPIO_BREAK_MODE==GPIO_LOW_BRK_MODE
  777. return false;
  778. #else
  779. return true;
  780. #endif
  781. }
  782. //有干扰,do nothing
  783. motor.n_brake_errors++;
  784. return false;
  785. }
  786. static void _fan_det_timer_handler(shark_timer_t *t) {
  787. if (t == &_fan_det_timer1) {
  788. motor.fan[0].rpm = 0;
  789. motor.fan[0].det_ts = 0;
  790. }else {
  791. motor.fan[1].rpm = 0;
  792. motor.fan[1].det_ts = 0;
  793. }
  794. }
  795. void Fan_IRQHandler(int idx) {
  796. fan_t *fan = motor.fan + idx;
  797. u32 pre_ts = fan->det_ts;
  798. u32 delta_ts = get_delta_ms(pre_ts);
  799. fan->det_ts = get_tick_ms();
  800. float rpm = 60.0f * 1000 / (float)delta_ts;
  801. LowPass_Filter(fan->rpm, rpm, 0.1f);
  802. if (idx == 0) {
  803. shark_timer_post(&_fan_det_timer1, 100);
  804. }else {
  805. shark_timer_post(&_fan_det_timer2, 100);
  806. }
  807. }
  808. void MC_Brake_IRQHandler(void) {
  809. if (mc_is_hwbrake()) {
  810. motor.b_break = true;
  811. }else {
  812. motor.b_break = false;
  813. }
  814. if (!motor.b_start) {
  815. return;
  816. }
  817. if (motor.b_break) {
  818. PMSM_FOC_Brake(true);
  819. }else {
  820. PMSM_FOC_Brake(false);
  821. }
  822. }
  823. static void _pwm_brake_prot_timer_handler(shark_timer_t *t){
  824. pwm_brake_enable(true);
  825. sys_debug("MC protect error\n");
  826. }
  827. void MC_Protect_IRQHandler(void){
  828. pwm_brake_enable(false);
  829. shark_timer_post(&_brake_prot_timer, 1000);
  830. if (!motor.b_start) {
  831. return;
  832. }
  833. mc_set_critical_error(FOC_CRIT_Phase_Err);
  834. _mc_internal_init(CTRL_MODE_OPEN, false);
  835. adc_stop_convert();
  836. pwm_stop();
  837. PMSM_FOC_Stop();
  838. pwm_up_enable(true);
  839. }
  840. void TIMER_UP_IRQHandler(void){
  841. if (!motor.b_start && !PMSM_FOC_Is_Start()) {
  842. motor_encoder_update();
  843. }
  844. }
  845. measure_time_t g_meas_foc = {.exec_max_time = 20, .intval_max_time = 62, .intval_low_err = 0, .intval_hi_err = 0, .first = true,};
  846. #define TIME_MEATURE_START() time_measure_start(&g_meas_foc)
  847. #define TIME_MEATURE_END() time_measure_end(&g_meas_foc)
  848. /*ADC 电流采集中断,调用FOC的核心处理函数*/
  849. void ADC_IRQHandler(void) {
  850. if (phase_current_offset()) {//check if is adc offset checked
  851. return;
  852. }
  853. if (phase_current_sensor_do_calibrate()){
  854. pwm_update_duty(100, FOC_PWM_Half_Period-100, 100);
  855. pwm_update_sample(FOC_PWM_Half_Period-1, FOC_PWM_Half_Period+1, PHASE_BC);
  856. return;
  857. }
  858. TIME_MEATURE_START();
  859. PMSM_FOC_Schedule();
  860. TIME_MEATURE_END();
  861. }
  862. #ifndef CONFIG_DQ_STEP_RESPONSE
  863. static bool mc_can_stop_foc(void) {
  864. if (mc_throttle_released() && PMSM_FOC_GetSpeed() == 0.0f) {
  865. if (!PMSM_FOC_AutoHoldding() && motor.epm_dir == EPM_Dir_None) {
  866. return true;
  867. }
  868. }
  869. /* 启用无感观测器,同时速度低于观测器允许的最小速度,关闭输出,滑行 */
  870. if (!foc_observer_is_encoder() && PMSM_FOC_GetSpeed() < CONFIG_SMO_MIN_SPEED) {
  871. return true;
  872. }
  873. return false;
  874. }
  875. static bool mc_can_restart_foc(void) {
  876. return (!PMSM_FOC_Is_Start()) && (!mc_throttle_released()) && (!mc_unsafe_critical_error());
  877. }
  878. #endif
  879. static bool mc_run_stall_process(u8 run_mode) {
  880. if ((run_mode == CTRL_MODE_TRQ || run_mode == CTRL_MODE_SPD) && !PMSM_FOC_AutoHoldding()) {
  881. //堵转判断
  882. if (motor.b_runStall) {
  883. if (!mc_throttle_released()) {
  884. return true;
  885. }
  886. motor.runStall_time = 0;
  887. motor.b_runStall = false; //转把释放,清除堵转标志
  888. }else if (PMSM_FOC_Get_Real_dqVector() >= CONFIG_STALL_MAX_CURRENT){
  889. if (ABS(PMSM_FOC_GetSpeed()) < 1.0f && (motor.runStall_time == 0)) {
  890. motor.runStall_time = get_tick_ms();
  891. motor.runStall_pos = motor_encoder_get_position();
  892. }
  893. if (motor.runStall_time > 0) {
  894. if (get_delta_ms(motor.runStall_time) >= CONFIG_STALL_MAX_TIME) {
  895. motor.b_runStall = true;
  896. motor.runStall_time = 0;
  897. PMSM_FOC_Set_Torque(0);
  898. #if 0
  899. torque_reset();
  900. #else
  901. thro_torque_reset();
  902. #endif
  903. return true;
  904. }
  905. if (ABS(motor.runStall_pos - motor_encoder_get_position()) >= 0.2f) {
  906. motor.runStall_time = 0;
  907. }
  908. }
  909. }else {
  910. motor.runStall_time = 0;
  911. }
  912. }
  913. return false;
  914. }
  915. static void _autohold_beep_timer_handler(shark_timer_t *t) {
  916. gpio_beep(60);
  917. }
  918. static void mc_autohold_process(void) {
  919. if (nv_get_foc_params()->n_autoHold == 0) {
  920. if (PMSM_FOC_AutoHoldding()) {
  921. mc_auto_hold(false);
  922. }
  923. return;
  924. }
  925. if (PMSM_FOC_AutoHoldding()) {
  926. if (!mc_throttle_released()) {
  927. mc_auto_hold(false);
  928. motor.b_wait_brk_release = false;
  929. }else if (!motor.b_break && motor.b_wait_brk_release) {
  930. motor.b_wait_brk_release = false;
  931. }else if (motor.b_break && !motor.b_wait_brk_release) {
  932. mc_auto_hold(false);
  933. }
  934. }
  935. if (!PMSM_FOC_AutoHoldding() && motor.b_break && (motor_encoder_get_speed() < CONFIG_ZERO_SPEED_RPM)) {
  936. if (motor.n_autohold_time == 0) {
  937. motor.n_autohold_time = get_tick_ms();
  938. }else {
  939. if (get_delta_ms(motor.n_autohold_time) >= CONFIG_AUTOHOLD_DETECT_TIME) {
  940. if (mc_auto_hold(true)) {
  941. motor.b_wait_brk_release = true;
  942. shark_timer_post(&_autohold_beep_timer, 0);
  943. }
  944. }
  945. }
  946. }else {
  947. motor.n_autohold_time = 0;
  948. }
  949. }
  950. static void mc_process_throttle_epm(void) {
  951. if (!motor.b_epm_cmd_move) {//通过命令前进后退,不处理转把
  952. if (mc_throttle_released()) {
  953. mc_throttle_epm_move(EPM_Dir_None);
  954. }else {
  955. mc_throttle_epm_move(EPM_Dir_Forward);
  956. }
  957. }
  958. }
  959. static bool mc_process_force_running(void) {
  960. if (motor.b_calibrate || (motor.mode == CTRL_MODE_OPEN)) {
  961. if (motor.b_force_run) {
  962. if (_force_wait > 0) {
  963. --_force_wait;
  964. }else {
  965. _force_angle += 1.0f;
  966. rand_angle(_force_angle);
  967. PMSM_FOC_Set_Angle(_force_angle);
  968. }
  969. }
  970. return true;
  971. }
  972. return false;
  973. }
  974. #ifdef CONFIG_CRUISE_ENABLE_ACCL
  975. static void mc_process_curise(void) {
  976. static bool can_pause_resume = false;
  977. if (motor.b_cruise) {
  978. if (PMSM_FOC_GetSpeed() < CONFIG_MIN_CRUISE_RPM) {
  979. mc_enable_cruise(false);
  980. return;
  981. }
  982. /* 定速巡航模式下,必须转把归位后才能开始通过拧动转把加速 */
  983. if (mc_throttle_released() && !can_pause_resume) {
  984. can_pause_resume = true;
  985. }
  986. if (!can_pause_resume) {
  987. return;
  988. }
  989. if (PMSM_FOC_Is_CruiseEnabled()) {
  990. u32 cruise_time = shark_get_seconds() - motor.cruise_time;
  991. if ((cruise_time >= 3) && motor.cruise_torque == 0.0f) {
  992. motor.cruise_torque = PMSM_FOC_Get()->in.s_targetTorque;
  993. }else if ((cruise_time >= 3) && (motor.cruise_torque > 0.0f)){
  994. #if 0
  995. float trq_req = get_thro_request_torque();
  996. #else
  997. float trq_req = get_user_request_torque();
  998. #endif
  999. if (trq_req > motor.cruise_torque * 1.2f) {
  1000. PMSM_FOC_PauseCruise(); //需要加速,暂停定速巡航
  1001. }
  1002. }
  1003. }else {
  1004. #if 0
  1005. float trq_req = get_thro_request_torque();
  1006. #else
  1007. float trq_req = get_user_request_torque();
  1008. #endif
  1009. if (trq_req <= motor.cruise_torque * 1.1f) {
  1010. PMSM_FOC_ResumeCruise(); //重新开始定速巡航,巡航速度还是前一次定速巡航给的速度
  1011. motor.cruise_time = shark_get_seconds();
  1012. }
  1013. }
  1014. }else {
  1015. can_pause_resume = false;
  1016. }
  1017. }
  1018. #endif
  1019. /*FOC 的部分处理,比如速度环,状态机,转把采集等*/
  1020. measure_time_t g_meas_MCTask;
  1021. #define mc_TaskStart time_measure_start(&g_meas_MCTask)
  1022. #define mc_TaskEnd time_measure_end(&g_meas_MCTask)
  1023. void Sched_MC_mTask(void) {
  1024. mc_TaskStart;
  1025. adc_vref_filter();
  1026. #ifdef CONFIG_CRUISE_ENABLE_ACCL
  1027. mc_process_curise();
  1028. #endif
  1029. u8 runMode = PMSM_FOC_CtrlMode();
  1030. /*保护功能*/
  1031. bool limted = PMSM_FOC_RunTime_Limit();
  1032. /* 母线电流,实际采集的相电流矢量大小的计算 */
  1033. PMSM_FOC_Calc_Current();
  1034. if (mc_process_force_running()) {
  1035. mc_TaskEnd;
  1036. return;
  1037. }
  1038. if (mc_detect_vbus_mode() || limted) {
  1039. mc_gear_vmode_changed();
  1040. }
  1041. /* 堵转处理 */
  1042. if (mc_run_stall_process(runMode) || (runMode == CTRL_MODE_CURRENT)) {
  1043. eCtrl_Running();
  1044. PMSM_FOC_Slow_Task();
  1045. mc_TaskEnd;
  1046. return;
  1047. }
  1048. if ((runMode != CTRL_MODE_OPEN) || (motor.mode != CTRL_MODE_OPEN)) {
  1049. #ifndef CONFIG_DQ_STEP_RESPONSE
  1050. mc_autohold_process();
  1051. if (motor.mode != CTRL_MODE_OPEN) {
  1052. u32 mask;
  1053. if (mc_can_stop_foc()) {
  1054. if (PMSM_FOC_Is_Start()) {
  1055. mask = cpu_enter_critical();
  1056. PMSM_FOC_Stop();
  1057. pwm_disable_channel();
  1058. cpu_exit_critical(mask);
  1059. }
  1060. }
  1061. if (mc_can_restart_foc()) {
  1062. mask = cpu_enter_critical();
  1063. PMSM_FOC_Start(motor.mode);
  1064. mc_gear_vmode_changed();
  1065. #if 0
  1066. torque_reset();
  1067. #else
  1068. thro_torque_reset();
  1069. #endif
  1070. pwm_enable_channel();
  1071. cpu_exit_critical(mask);
  1072. }
  1073. }
  1074. if (runMode != CTRL_MODE_OPEN) {
  1075. eCtrl_Running();
  1076. if ((runMode == CTRL_MODE_SPD) && mc_is_epm()) {
  1077. mc_process_throttle_epm();
  1078. }else {
  1079. #if 0
  1080. if (motor.b_ignor_throttle) { //使用软件设置的油门开度
  1081. float r = (float)motor.u_throttle_ration/100.0f;
  1082. request_torque(r);
  1083. }else {
  1084. throttle_process(runMode, get_throttle_float());
  1085. }
  1086. #else
  1087. float thro = get_throttle_float();
  1088. if (motor.b_ignor_throttle) {
  1089. float r = (float)motor.u_throttle_ration/100.0f;
  1090. thro = thro_ration_to_voltage(r);
  1091. }
  1092. thro_torque_process(runMode, thro);
  1093. #endif
  1094. }
  1095. PMSM_FOC_Slow_Task();
  1096. }
  1097. #endif
  1098. }
  1099. mc_TaskEnd;
  1100. }