encoder.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510
  1. #include "bsp/bsp.h"
  2. #include "bsp/bsp_driver.h"
  3. #include "foc/motor/encoder.h"
  4. #include "foc/motor/motor_param.h"
  5. #include "libs/logger.h"
  6. #include "app/nv_storage.h"
  7. #include "math/fast_math.h"
  8. #if CONFIG_MOT_TYPE==MOTOR_BLUESHARK_OLD
  9. #include "encoder_off2.h"
  10. #elif CONFIG_MOT_TYPE==MOTOR_BLUESHARK_NEW1
  11. #include "encoder_off3.h"
  12. #elif CONFIG_MOT_TYPE==MOTOR_BLUESHARK_NEW2
  13. #if ENCODER_TYPE==ENCODER_MPS
  14. #include "encoder_off4.h"
  15. #endif
  16. #elif CONFIG_MOT_TYPE==MOTOR_BLUESHARK_ZD_100
  17. #if ENCODER_TYPE==ENCODER_MPS
  18. #include "encoder_off5.h"
  19. #endif
  20. #endif
  21. /* 磁编码器使用一对极的磁铁,所以编码器获取的角度和机械角度相同需要转为电角度*/
  22. static encoder_t g_encoder;
  23. static __INLINE s16 _abi_count(void) {
  24. #ifdef ENCODER_CC_INVERT
  25. return ((g_encoder.cpr -1) - (s16)ENC_COUNT);
  26. #else
  27. return (s16)ENC_COUNT;
  28. #endif
  29. }
  30. static __INLINE void encoder_pll_update_gain(void) {
  31. if (g_encoder.pll_bandwidth_shadow != g_encoder.pll_bandwidth) {
  32. g_encoder.pll_bandwidth = g_encoder.pll_bandwidth_shadow;
  33. g_encoder.est_pll.kp = 2.0f * g_encoder.pll_bandwidth;
  34. g_encoder.est_pll.ki = 0.25f * g_encoder.est_pll.kp * g_encoder.est_pll.kp;
  35. }
  36. }
  37. static void _init_pll(void) {
  38. g_encoder.est_pll.DT = FOC_CTRL_US;
  39. g_encoder.est_pll.max_wp = g_encoder.cpr;
  40. g_encoder.pll_bandwidth = 0;
  41. g_encoder.pll_bandwidth_shadow = nv_get_motor_params()->est_pll_band;
  42. encoder_pll_update_gain();
  43. PLL_Reset(&g_encoder.est_pll, (float)_abi_count());
  44. }
  45. void encoder_init(void) {
  46. encoder_init_clear();
  47. enc_intf_init(ENC_MAX_RES);
  48. }
  49. void encoder_set_direction(s8 direction) {
  50. g_encoder.direction = direction;
  51. //g_encoder.cali_angle = INVALID_ANGLE;
  52. }
  53. void encoder_set_bandwidth(float bandwidth) {
  54. g_encoder.pll_bandwidth_shadow = bandwidth;
  55. }
  56. void encoder_init_clear(void) {
  57. g_encoder.cpr = ENC_MAX_RES;
  58. g_encoder.enc_offset = 0;
  59. g_encoder.motor_poles = nv_get_motor_params()->poles;
  60. g_encoder.b_index_found = false;
  61. g_encoder.direction = POSITIVE;
  62. g_encoder.abi_angle = 0.0f;
  63. g_encoder.pwm_angle = 0.0f;
  64. g_encoder.est_angle_counts = 0;
  65. g_encoder.est_vel_counts = 0;
  66. g_encoder.est_vel_cnt_filter = 0;
  67. g_encoder.position = 0.0f;
  68. g_encoder.interpolation = 0.0f;
  69. //g_encoder.cali_angle = INVALID_ANGLE;
  70. g_encoder.enc_count_off = 0xFFFFFFFF;
  71. g_encoder.b_cali_err = false;
  72. g_encoder.produce_error = false;
  73. g_encoder.last_delta_cnt = MAX_S16;
  74. g_encoder.enc_maybe_err = ENCODER_NO_ERR;
  75. g_encoder.start_dianostic_cnt = 0;
  76. g_encoder.align_cnt = 0;
  77. g_encoder.align_step = 0;
  78. g_encoder.pwm_time_ms = get_tick_ms();
  79. _init_pll();
  80. }
  81. void encoder_lock_position(bool enable) {
  82. if (g_encoder.b_lock_pos != enable) {
  83. g_encoder.b_lock_pos = enable;
  84. if (enable) {
  85. encoder_set_bandwidth(nv_get_motor_params()->pos_lock_pll_band);
  86. }else {
  87. encoder_set_bandwidth(nv_get_motor_params()->est_pll_band);
  88. }
  89. }
  90. }
  91. void encoder_epm_pll_band(bool epm) {
  92. if (epm) {
  93. encoder_set_bandwidth(nv_get_motor_params()->epm_pll_band);
  94. }else {
  95. encoder_set_bandwidth(nv_get_motor_params()->est_pll_band);
  96. }
  97. }
  98. static __INLINE float _pll_over_comp(void) {
  99. u8 dir = ENC_DIR_DOWN;
  100. #ifdef ENCODER_CC_INVERT
  101. dir = ENC_DIR_UP;
  102. #endif
  103. if(ENC_Direction() == dir){
  104. return -((float)g_encoder.cpr);
  105. }
  106. return (float)g_encoder.cpr;
  107. }
  108. static __INLINE bool encoder_run_pll(float cnt) {
  109. float pll_comp = 0.0f;
  110. if (g_encoder.b_timer_ov) {
  111. pll_comp = _pll_over_comp();
  112. g_encoder.b_timer_ov = false;
  113. }
  114. encoder_pll_update_gain();
  115. g_encoder.est_vel_counts = PLL_run(&g_encoder.est_pll, cnt, pll_comp);
  116. g_encoder.est_angle_counts = g_encoder.est_pll.observer;
  117. bool snap_to_zero_vel = false;
  118. g_encoder.est_vel_cnt_filter = LowPass_Filter(g_encoder.est_vel_cnt_filter, g_encoder.est_vel_counts, 0.1f);
  119. if (ABS(g_encoder.est_pll.out) < 0.5f * g_encoder.est_pll.DT * g_encoder.est_pll.ki) {
  120. g_encoder.est_vel_cnt_filter = g_encoder.est_vel_counts = g_encoder.est_pll.out = 0.0f; // align delta-sigma on zero to prevent jitter
  121. snap_to_zero_vel = true;
  122. }
  123. return snap_to_zero_vel;
  124. }
  125. /* 偏心补偿 */
  126. static __INLINE float _eccentricity_compensation(int cnt) {
  127. #ifdef FIR_PHASE_SHIFT
  128. int cnt_off = (cnt + FIR_PHASE_SHIFT);//g_encoder.cpr;
  129. if (g_encoder.encoder_off_map != NULL) { //do offset calibrate, can not do encentricity compensation
  130. return 0.0f;
  131. }
  132. return -(S16Q10toF(_encoder_off_map[cnt_off]));
  133. #else
  134. return 0.0f;
  135. #endif
  136. }
  137. #define CONFIG_ENC_DETECT_ERR
  138. ///#define CONFIG_ENC_ERR_TEST
  139. #define CONFIG_ENC_DIANOSTIC_MIN_CNT (10.0F * ENC_MAX_RES * FOC_CTRL_US) //600rpm, 每隔控制周期 0.2232 机械角度
  140. u32 enc_pwm_err_ms = 0;
  141. s16 enc_delta_err1 = 0;
  142. s16 enc_delta_err2 = 0;
  143. static float enc_r = 0;
  144. static s16 enc_cnt = 0;
  145. static s16 enc_last_cnt = 0;
  146. static s16 enc_test1 = 0;
  147. static s16 enc_test2 = 0;
  148. static s16 enc_test3 = 0;
  149. static s16 enc_test4 = 0;
  150. #define MAX_CPR_CNT_PER_CTL 40
  151. /* 9000RPM = 150 RPS = 150 * ENC_MAX_RES * FOC_CTRL_US = 39, 每个控制周期 39个count */
  152. static void encoder_detect_error(s16 cnt) {
  153. #ifdef CONFIG_ENC_DETECT_ERR
  154. static u32 _mayerr_cnt = 0;
  155. if (ENCODER_NO_ERR == g_encoder.enc_maybe_err) {
  156. s16 delta_cnt = cnt - g_encoder.last_cnt;
  157. bool skip = false;
  158. if (g_encoder.b_timer_ov) {
  159. bool is_jitter = ((cnt > (ENC_MAX_RES - MAX_CPR_CNT_PER_CTL*2) && g_encoder.last_cnt > (ENC_MAX_RES - MAX_CPR_CNT_PER_CTL*2)) ||
  160. (cnt < (MAX_CPR_CNT_PER_CTL*2) && g_encoder.last_cnt < (MAX_CPR_CNT_PER_CTL*2))); //需要处理低速在overflow附近震荡
  161. if (!is_jitter) {
  162. s16 com = _pll_over_comp();
  163. if (com > 0) {
  164. delta_cnt = delta_cnt + com;
  165. }else {
  166. delta_cnt = delta_cnt + com;
  167. }
  168. enc_test4 = delta_cnt;
  169. }
  170. }
  171. if ((delta_cnt > 200) || (delta_cnt < -200)) {
  172. enc_test1 = cnt;
  173. enc_test2 = g_encoder.last_cnt;
  174. enc_test3 = g_encoder.b_timer_ov;
  175. }
  176. #ifdef CONFIG_ENC_ERR_TEST
  177. if (g_encoder.produce_error) {
  178. delta_cnt = 0;
  179. }
  180. #endif
  181. if (g_encoder.last_delta_cnt == MAX_S16) {
  182. skip = true;
  183. }
  184. float ab_thr = CONFIG_ENC_DIANOSTIC_MIN_CNT*1.2f;
  185. if (g_encoder.last_delta_cnt < ab_thr) {
  186. if (get_delta_ms(g_encoder.pwm_time_ms) >= 8) {
  187. g_encoder.enc_maybe_err = ENCODER_PWM_ERR;
  188. enc_pwm_err_ms = get_delta_ms(g_encoder.pwm_time_ms);
  189. enc_delta_err2 = (s16)((g_encoder.est_vel_counts/g_encoder.cpr) * 60.0f);
  190. }
  191. if (!_mayerr_cnt) {
  192. skip = true;
  193. g_encoder.start_dianostic_cnt = 0;
  194. }
  195. }else if (g_encoder.start_dianostic_cnt < 0xFFFFFF) {
  196. g_encoder.start_dianostic_cnt ++;
  197. }
  198. if (!skip && ((g_encoder.last_delta_cnt > ab_thr) || (_mayerr_cnt != 0)) && (g_encoder.start_dianostic_cnt >= FOC_PWM_FS)) {
  199. float last_delta = (float)g_encoder.last_delta_cnt;
  200. float r = (float)delta_cnt / (last_delta + 0.0000001f);
  201. float r_abs = ABS(r);
  202. float r_thr;
  203. u32 cnt_thr;
  204. if (g_encoder.last_delta_cnt <= ab_thr * 2) {
  205. r_thr = 0.3f;
  206. cnt_thr = 4;
  207. }else if (g_encoder.last_delta_cnt <= ab_thr * 4) {
  208. r_thr = 0.5f;
  209. cnt_thr = 3;
  210. }else if (g_encoder.last_delta_cnt <= ab_thr * 6) {
  211. r_thr = 0.6f;
  212. cnt_thr = 2;
  213. }else {
  214. r_thr = 0.7f;
  215. cnt_thr = 1;
  216. }
  217. if (r_thr >= 0.5f) {
  218. if (r < 0) {
  219. r_thr = 2.0f;
  220. cnt_thr = 1;
  221. }else if (r_abs <= 0.01f) {
  222. cnt_thr = 1;
  223. }
  224. }
  225. if (r_abs <= r_thr || r_abs >= (2.0f - r_thr)) {
  226. _mayerr_cnt ++;
  227. if (_mayerr_cnt >= cnt_thr) {
  228. g_encoder.enc_maybe_err = ENCODER_AB_ERR;
  229. enc_delta_err1 = g_encoder.last_delta_cnt;
  230. enc_delta_err2 = (s16)((g_encoder.est_vel_counts/g_encoder.cpr) * 60.0f);
  231. enc_r = r;
  232. enc_cnt = delta_cnt;
  233. enc_last_cnt = _mayerr_cnt;
  234. }
  235. }else {
  236. _mayerr_cnt = 0;
  237. }
  238. }else {
  239. _mayerr_cnt = 0;
  240. }
  241. g_encoder.last_delta_cnt = delta_cnt;
  242. }
  243. #else
  244. g_encoder.enc_maybe_err = ENCODER_NO_ERR;
  245. #endif
  246. }
  247. float encoder_get_theta(void) {
  248. if (!g_encoder.b_index_found) {
  249. return g_encoder.pwm_angle;
  250. }
  251. s16 cnt = _abi_count();
  252. __NOP();__NOP();__NOP();__NOP();
  253. if (ENC_OverFlow()) {
  254. cnt = _abi_count();
  255. if((cnt > (ENC_MAX_RES - MAX_CPR_CNT_PER_CTL*2) && g_encoder.last_cnt > (ENC_MAX_RES - MAX_CPR_CNT_PER_CTL*2)) ||
  256. (cnt < (MAX_CPR_CNT_PER_CTL*2) && g_encoder.last_cnt < (MAX_CPR_CNT_PER_CTL*2))) { //需要处理低速在overflow附近震荡
  257. g_encoder.b_timer_ov = false;
  258. }else {
  259. g_encoder.b_timer_ov = true;
  260. }
  261. ENC_ClearUpFlags();
  262. }
  263. encoder_detect_error(cnt);
  264. bool snap_to_zero_vel = encoder_run_pll((float)(cnt));
  265. if (snap_to_zero_vel) {
  266. g_encoder.interpolation = 0.1f;
  267. }else {
  268. if (cnt == g_encoder.last_cnt) {
  269. g_encoder.interpolation += g_encoder.est_vel_cnt_filter * FOC_CTRL_US;
  270. if (g_encoder.interpolation > ENC_MAX_interpolation) {
  271. g_encoder.interpolation = ENC_MAX_interpolation;
  272. }else if (g_encoder.interpolation < -ENC_MAX_interpolation) {
  273. g_encoder.interpolation = -ENC_MAX_interpolation;
  274. }
  275. }else {
  276. g_encoder.interpolation = 0.0f;
  277. }
  278. }
  279. step_towards_s16(&g_encoder.align_step, g_encoder.align_cnt, 2);
  280. g_encoder.abi_angle = ENC_Pluse_Nr_2_angle((float)(cnt/* + g_encoder.align_step*/) + g_encoder.interpolation) * g_encoder.motor_poles + g_encoder.enc_offset;
  281. g_encoder.abi_angle += _eccentricity_compensation(cnt);
  282. rand_angle(g_encoder.abi_angle);
  283. g_encoder.last_cnt = cnt;
  284. g_encoder.last_us = task_get_usecond();
  285. g_encoder.position += (g_encoder.est_vel_counts/g_encoder.cpr) * FOC_CTRL_US;
  286. return g_encoder.abi_angle;
  287. }
  288. void encoder_produce_error(bool error) {
  289. g_encoder.produce_error = error;
  290. }
  291. u8 encoder_may_error(void) {
  292. return g_encoder.enc_maybe_err;
  293. }
  294. float encoder_get_speed(void) {
  295. if (g_encoder.enc_maybe_err != ENCODER_NO_ERR) {
  296. return 0;
  297. }
  298. return (g_encoder.est_vel_counts/g_encoder.cpr) * 60.0f;
  299. }
  300. float encoder_get_vel_count(void) {
  301. return g_encoder.est_vel_counts;
  302. }
  303. float encoder_get_position(void) {
  304. return g_encoder.position;
  305. }
  306. float encoder_zero_phase_detect(float *enc_off) {
  307. delay_ms(5);
  308. float total_enc_off = g_encoder.pwm_count;
  309. float prev_offset = g_encoder.enc_offset;
  310. float phase = encoder_get_pwm_angle();
  311. float total_ph = phase;
  312. int count = 0;
  313. for(; count < 10; count++) {
  314. delay_ms(5); //wait time for pwm
  315. float angle_now = encoder_get_pwm_angle();
  316. if (ABS(phase - angle_now) > 2.0f) {
  317. g_encoder.enc_offset = prev_offset;
  318. g_encoder.enc_count_off = 0xFFFFFFFF;
  319. g_encoder.b_cali_err = true;
  320. sys_debug("err %f, %f, %d\n", phase, angle_now, count);
  321. return INVALID_ANGLE;
  322. }
  323. phase = angle_now;
  324. total_ph += phase;
  325. total_enc_off += g_encoder.pwm_count;
  326. }
  327. sys_debug("count = %d, %f, %d\n", count, total_enc_off, g_encoder.pwm_count);
  328. float offset_now = total_ph/(float)(count + 1);
  329. g_encoder.enc_offset = offset_now;
  330. g_encoder.enc_count_off = (u32)(total_enc_off/(float)(count + 1));
  331. if (enc_off) {
  332. *enc_off = (float)g_encoder.enc_count_off;
  333. sys_debug("encoder off %f\n", *enc_off);
  334. }
  335. sys_debug("encoder ph off = %f\n", offset_now);
  336. return offset_now;
  337. }
  338. void encoder_clear_cnt_offset(void) {
  339. g_encoder.b_cali_err = false;
  340. g_encoder.enc_count_off = 0xFFFFFFFF;
  341. }
  342. u32 encoder_get_cnt_offset(void) {
  343. return g_encoder.enc_count_off;
  344. }
  345. bool encoder_get_cali_error(void) {
  346. return g_encoder.b_cali_err;
  347. }
  348. static void encoder_sync_pwm_abs(void) {
  349. u32 mask = cpu_enter_critical();
  350. ENC_COUNT = g_encoder.pwm_count;
  351. g_encoder.last_cnt = g_encoder.pwm_count;
  352. g_encoder.est_pll.observer = (float)g_encoder.pwm_count;
  353. g_encoder.abi_angle = g_encoder.pwm_angle;
  354. g_encoder.b_index_found = true;
  355. g_encoder.last_delta_cnt = MAX_S16;
  356. g_encoder.align_cnt = g_encoder.align_step = 0;
  357. PLL_Reset(&g_encoder.est_pll, (float)_abi_count());
  358. cpu_exit_critical(mask);
  359. }
  360. /*I 信号的中断处理,一圈一个中断*/
  361. static int abi_I_delta = 0xFFFFFFF;
  362. static int abi_z_count = 0;
  363. void ENC_ABI_IRQHandler(void) {
  364. g_encoder.z_index_cnt = _abi_count();
  365. abi_z_count++;
  366. #if 0
  367. if (!g_encoder.b_index_found){
  368. encoder_sync_pwm_abs();
  369. }
  370. if (g_encoder.z_index_cnt > 10 && g_encoder.z_index_cnt < (g_encoder.cpr - 10)) {
  371. if (abi_I_delta == 0xFFFFFFF) {
  372. abi_I_delta = g_encoder.z_index_cnt;
  373. }
  374. }
  375. #else
  376. if (g_encoder.z_index_cnt > 10 && g_encoder.z_index_cnt < 50) {
  377. g_encoder.align_cnt = -(g_encoder.z_index_cnt - 5);
  378. }else if (g_encoder.z_index_cnt > (g_encoder.cpr - 50) && g_encoder.z_index_cnt < (g_encoder.cpr - 10)) {
  379. g_encoder.align_cnt = g_encoder.cpr - g_encoder.z_index_cnt - 5;
  380. }else {
  381. if (g_encoder.z_index_cnt <=10 || g_encoder.z_index_cnt >= (g_encoder.cpr - 10)) {
  382. g_encoder.align_cnt = 0;
  383. }else if (g_encoder.enc_maybe_err == ENCODER_NO_ERR){
  384. abi_I_delta = g_encoder.z_index_cnt;
  385. }
  386. }
  387. #endif
  388. }
  389. /* 编码器AB信号读书溢出处理 */
  390. void ENC_TIMER_Overflow(void) {
  391. //g_encoder.b_timer_ov = true;
  392. }
  393. /*PWM 信号捕获一个周期的处理 */
  394. static int pwm_count = 0;
  395. static int pwm_check_count = 0;
  396. static int pwm_duty_err = 0;
  397. static float pwm_err_min = 0;
  398. static float pwm_err_max = 0;
  399. void ENC_PWM_Duty_Handler(float t, float d) {
  400. float duty = ENC_Duty(d, t);
  401. if (duty < ENC_PWM_Min_P || duty > ENC_PWM_Max_P) {
  402. pwm_duty_err++;
  403. if (duty < ENC_PWM_Min_P) {
  404. pwm_err_min = duty;
  405. duty = ENC_PWM_Min_P;
  406. }else {
  407. pwm_err_max = duty;
  408. duty = ENC_PWM_Max_P;
  409. }
  410. }
  411. float Nr = ENC_Duty_2_Pluse_Nr(duty);
  412. if (Nr < 0) {
  413. Nr = 0;
  414. }else if (Nr > ENC_MAX_RES) {
  415. Nr = ENC_MAX_RES;
  416. }
  417. u32 n_nr = (u32)Nr;
  418. if (Nr - n_nr >= 0.5f) {
  419. g_encoder.pwm_count = n_nr + 1;
  420. }else {
  421. g_encoder.pwm_count = n_nr;
  422. }
  423. g_encoder.pwm_angle = ENC_Pluse_Nr_2_angle(Nr) * g_encoder.motor_poles + g_encoder.enc_offset;
  424. rand_angle(g_encoder.pwm_angle);
  425. if (!g_encoder.b_index_found && pwm_count++ >= 10) {
  426. encoder_sync_pwm_abs();
  427. }
  428. pwm_check_count ++;
  429. #ifdef CONFIG_ENC_ERR_TEST
  430. if (!g_encoder.produce_error) {
  431. g_encoder.pwm_time_ms = get_tick_ms();
  432. }
  433. #else
  434. g_encoder.pwm_time_ms = get_tick_ms();
  435. #endif
  436. }
  437. static u32 _check_time = 0;
  438. bool ENC_Check_error(void) {
  439. bool error = false;
  440. if (get_delta_ms(_check_time) > 200) {
  441. if (pwm_check_count == 0) {
  442. error = true;
  443. }
  444. pwm_check_count = 0;
  445. _check_time = get_tick_ms();
  446. }
  447. return error;
  448. }
  449. float encoder_get_pwm_angle(void) {
  450. #ifdef ENCODER_CC_INVERT
  451. g_encoder.pwm_angle = 360.0f - (g_encoder.pwm_angle - g_encoder.enc_offset) + g_encoder.enc_offset;
  452. rand_angle(g_encoder.pwm_angle);
  453. #endif
  454. return g_encoder.pwm_angle;
  455. }
  456. float encoder_get_abi_angle(void) {
  457. s16 cnt = _abi_count();
  458. float angle = ENC_Pluse_Nr_2_angle((float)(cnt + g_encoder.align_step)) * g_encoder.motor_poles + g_encoder.enc_offset;
  459. rand_angle(angle);
  460. return angle;
  461. }
  462. void encoder_log(void) {
  463. sys_debug("pwm %f, abi %f\n", encoder_get_pwm_angle(), encoder_get_abi_angle());
  464. sys_debug("pwm count %d, I count %d,%d,%d\n", g_encoder.pwm_count, abi_I_delta, g_encoder.z_index_cnt, abi_z_count);
  465. sys_debug("pwm freq %f, err %d, %f, %f\n", enc_get_pwm_freq(), pwm_duty_err, pwm_err_min, pwm_err_max);
  466. if (g_encoder.enc_maybe_err) {
  467. sys_debug("E:%d,%d,%d,%d,%d,%d\n", enc_test1, enc_test2, enc_test3, enc_cnt, enc_last_cnt, enc_test4);
  468. sys_debug("E:%d, %d, %f, %d\n", enc_delta_err1, enc_delta_err2, enc_r, g_encoder.enc_maybe_err);
  469. }
  470. }