Sfoglia il codice sorgente

解决编码器校准的时候,除数多1的问题

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 anni fa
parent
commit
713520e8e8
1 ha cambiato i file con 3 aggiunte e 3 eliminazioni
  1. 3 3
      Applications/foc/motor/encoder.c

+ 3 - 3
Applications/foc/motor/encoder.c

@@ -45,7 +45,7 @@ static void _init_pll(void) {
 	g_encoder.est_pll.DT = FOC_CTRL_US;
 	g_encoder.est_pll.max_wp = g_encoder.cpr;
 	g_encoder.pll_bandwidth = 0;
-	g_encoder.pll_bandwidth_shadow = 50;//nv_get_motor_params()->est_pll_band;
+	g_encoder.pll_bandwidth_shadow = nv_get_motor_params()->est_pll_band;
 	encoder_pll_update_gain();
 	PLL_Reset(&g_encoder.est_pll, (float)_abi_count());
 }
@@ -309,9 +309,9 @@ float encoder_zero_phase_detect(float *enc_off) {
 		total_enc_off += g_encoder.pwm_count;
 	}
 	sys_debug("count = %d\n", count);
-	float offset_now = total_ph/(float)(count + 1);
+	float offset_now = total_ph/(float)(count);
 	g_encoder.enc_offset = offset_now;
-	g_encoder.enc_count_off = (u32)(total_enc_off/(float)(count + 1));
+	g_encoder.enc_count_off = (u32)(total_enc_off/(float)(count));
 	if (enc_off) {
 		*enc_off = (float)g_encoder.enc_count_off;
 		sys_debug("encoder off %f\n", *enc_off);