Просмотр исходного кода

电感识别1000rad/s 需要补偿相电压

Signed-off-by: kevin <huhui@sharkgulf.com>
kevin 2 лет назад
Родитель
Сommit
6fe3d0722f

+ 5 - 2
Applications/app/app.c

@@ -156,12 +156,15 @@ static u32 app_report_task(void *p) {
 }
 int plot_type = 0;
 static void plot_smo_angle(void) {
+	u32 mask = cpu_enter_critical();
 	float smo_angle = foc_observer_sensorless_angle();
-	float delta = smo_angle - foc()->in.mot_angle;
+	float mot_angle = foc()->in.mot_angle;
+	cpu_exit_critical(mask);
+	float delta = smo_angle - mot_angle;
 	float s, c;
 	arm_sin_cos(delta, &s, &c);
 	delta = fast_atan2(s, c)/PI*180.0f;
-	can_plot3(foc()->in.mot_angle, smo_angle, delta);
+	can_plot3(mot_angle, smo_angle, delta);
 }
 static u32 app_plot_task(void * args) {
 	if (plot_type == 1) {

+ 1 - 1
Applications/bsp/gd32/board_mc105_v3.h

@@ -225,7 +225,7 @@
 
 #define PHASE_VOL_R (40*1000.0f)
 #define PHASE_VOL_R1 (1*1000.0f)
-#define PHASE_VOL_C1 (470e-9f) //470nF
+#define PHASE_VOL_C1 (100e-9f) //470nF
 #define PHASE_VOL_Gain  ((PHASE_VOL_R + PHASE_VOL_R1)/PHASE_VOL_R1)
 #define Phase_Vol_LPF_R  ((PHASE_VOL_R * PHASE_VOL_R1)/(PHASE_VOL_R + PHASE_VOL_R1))
 #define PHASE_VOL_LPF_BAND  (1/(2*3.14F*Phase_Vol_LPF_R*PHASE_VOL_C1))

+ 3 - 0
Applications/foc/core/controller.c

@@ -223,6 +223,9 @@ static __INLINE void mot_contrl_update_phase_vol(mot_contrl_t *ctrl) {
 	/* 当前电气频率   除于相电压低通滤波器截止频率 */
 	float We_hz = (ctrl->foc.in.mot_velocity / 60.0f * mc_conf()->m.poles);
 	float w_r_wc = We_hz / PHASE_VOL_LPF_BAND;
+	if (ctrl->mot_param_ind_freq > 10.0f) {//dq轴电感识别
+		w_r_wc = (ctrl->mot_param_ind_freq / (2.0f * M_PI)) / PHASE_VOL_LPF_BAND;
+	}
 	/* 计算低通滤波器的幅度补偿系数*/
 	float mag_mul = sqrtf(1 + SQ(w_r_wc));
 	ctrl->phase_v_ab.a *= mag_mul;

+ 5 - 0
Applications/foc/core/controller.h

@@ -143,6 +143,7 @@ typedef struct{
 	float           duty_filterd;
 	u8 				mode_req;
 	u8 				mode_running;
+	float			mot_param_ind_freq;
 	u8      		error;
 	foc_t 			foc;
 	etcs_t          etcs;
@@ -301,5 +302,9 @@ static __INLINE s16 mot_contrl_get_speed_abs(mot_contrl_t *ctrl) {
 	return ABS(speed);
 }
 
+static __INLINE void mot_ctrl_set_ind_freq(mot_contrl_t *ctrl, float freq) {
+	ctrl->mot_param_ind_freq = freq;
+}
+
 #endif /* _CONTROLLER_H__ */
 

+ 1 - 1
Applications/foc/core/ladrc_observer.c

@@ -103,7 +103,7 @@ float ladrc_observer_update(float va, float vb, float ia, float ib) {
 	/* 补偿ladrc相位延时,LADRC等效截止频率为Wo/2pi的两个低通滤波器串联 */
 	angle = fast_atan2(observer.Vel_El, Wo) * 2.0f;
 	/* 电压滞后一个控制周期,需要通过当前的电角速度对计算的角度进行补偿 */
-	observer.angle_out = observer.angle_atan + (angle + observer.Vel_El * observer.ts);
+	observer.angle_out = observer.angle_atan + (angle/* + observer.Vel_El * observer.ts*/);
 	norm_angle_rad(observer.angle_out);
 
 	LowPass_Filter(observer.Vel_El_filter, observer.Vel_El, 0.01f); //需要再加一级低通滤波,给计算Wo和输出使用

+ 6 - 7
Applications/foc/motor/mot_params_ind.c

@@ -18,7 +18,7 @@ static shark_timer_t _ldq_ind_timer = TIMER_INIT(_ldq_ind_timer, _ldq_ind_timer_
 static void _flux_ind_timer_handler(shark_timer_t *);
 static shark_timer_t _flux_ind_timer = TIMER_INIT(_flux_ind_timer, _flux_ind_timer_handler);
 
-static float rs_id_max, rs_vd_max, rs_vd_now, rs_est_value;
+static float rs_id_max, rs_vd_max, rs_vd_now, rs_est_value = 0.011f;
 static s32 rs_meas_time;
 static bool b_rs_ind = false, b_rs_ested = false, b_ldq_ind = false, b_ld_ested = false, b_lq_ested = false, b_flux_ind = false, b_flux_ested = false;
 static u8   rs_ind_step = 0;
@@ -47,6 +47,7 @@ void mot_params_ind_stop(void) {
 	b_rs_ind = false;
 	b_ldq_ind = false;
 	b_flux_ind = false;
+	mot_ctrl_set_ind_freq(mot_contrl(), 0);
 	cpu_exit_critical(mask);
 	mot_contrl_set_vdq(&motor.controller, 0, 0);
 	mot_contrl_set_current(&motor.controller, 0);
@@ -94,12 +95,8 @@ static void _rs_ind_timer_handler(shark_timer_t *t) {
 		}
 		break;
 	case 3: {
-		float dtc = ((float)CONFIG_HW_DeadTime/(float)FOC_PWM_period) * motor.controller.foc.in.dc_vol * 0.2f;
-#if CONFIG_MOT_IND_USE_PHASE_SAMPLE==0
+		float dtc = ((float)CONFIG_HW_DeadTime/(float)FOC_PWM_period) * motor.controller.foc.in.dc_vol * 0.667f;
 		float vd = rs_vd_now * TWO_BY_THREE - dtc;
-#else
-		float vd = motor.controller.phase_v_dq.d;
-#endif
 		float id = motor.controller.foc.out.curr_dq.d;
 		float rs = vd / (id + 0.0001f);
 		rs_est_value = LowPass_Filter(rs_est_value, rs, 0.2f);
@@ -166,6 +163,7 @@ void mot_params_ind_inductance(float v, float freq, u16 l_type) {
 	v_samples = os_alloc(sizeof(float) * hj_samples);
 	i_samples = os_alloc(sizeof(float) * hj_samples);
 	if (v_samples != NULL && i_samples != NULL) {
+		mot_ctrl_set_ind_freq(mot_contrl(), freq);
 		b_ldq_ind = true;
 		shark_timer_post(&_ldq_ind_timer, 10);
 	}else {
@@ -258,8 +256,9 @@ void mot_params_calc_inductance(void) {
 	sys_debug("v %f, %f, %f\n", v_mag/(hj_samples*0.5f), v_real, v_image);
 	sys_debug("i %f, %f, %f\n", i_mag/(hj_samples*0.5f), i_real, i_image);
 	sys_debug("vmag %f, %f\n", v_mag, Vdead * hj_samples*0.5f);
+#if CONFIG_MOT_IND_USE_PHASE_SAMPLE==0
 	v_mag -= Vdead * hj_samples*0.5f;
-	
+#endif
 	float z_angle = fast_atan2(i_image, i_real) - fast_atan2(v_image, v_real);
 	float s,c;
 	arm_sin_cos(pi_2_degree(z_angle), &s, &c);