Bläddra i källkod

识别DQ电感加入超时机制

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 2 år sedan
förälder
incheckning
7a31d390ec
1 ändrade filer med 10 tillägg och 1 borttagningar
  1. 10 1
      Applications/foc/motor/mot_params_ind.c

+ 10 - 1
Applications/foc/motor/mot_params_ind.c

@@ -104,6 +104,7 @@ static float hj_v, hj_freq, hj_n, hj_w, hj_samples, K_terms, Vdead;
 static float hj_real, hj_image;
 static u16   n_ind_ld, n_samples;
 static float ld_est_value, lq_est_value;
+static s32   ldq_est_wait_cnt = 0;
 void mot_params_ind_inductance(float v, float freq, u16 l_type) {
 	if (b_ldq_ind || b_rs_ind) {
 		return;
@@ -122,6 +123,7 @@ void mot_params_ind_inductance(float v, float freq, u16 l_type) {
 	hj_real = hj_real * 2.0f;
 	n_ind_ld = l_type;
 	n_samples = 0;
+	ldq_est_wait_cnt = 0;
 	if (v_samples) {
 		os_free(v_samples);
 	}
@@ -142,7 +144,14 @@ static void _ldq_ind_timer_handler(shark_timer_t *t) {
 		mot_params_calc_inductance();
 		mot_params_ind_stop();
 	}else {
-		shark_timer_post(&_ldq_ind_timer, 50);
+		ldq_est_wait_cnt ++;
+		if (ldq_est_wait_cnt >= 20) {
+			mc_ind_motor_start(false);
+			mot_params_ind_stop();
+			sys_debug("ldq ind timeout %d\n", ldq_est_wait_cnt);
+		}else {
+			shark_timer_post(&_ldq_ind_timer, 50);
+		}
 	}
 }