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

dq阶跃响应直接设置foc的输入

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

+ 4 - 8
Applications/app/app.c

@@ -137,9 +137,9 @@ static void plot_smo_angle(void) {
 }
 static u32 _app_plot_task(void * args) {
 	if (plot_type == 1) {
-		can_plot2((s16)foc_observer_sensorless_speed(), (s16)mot_contrl_get_speed(mot_contrl()));
+		can_plot2((s16)foc_observer_sensorless_speed(), (s16)mot_contrl_get_speed(&motor.controller));
 	}else if (plot_type == 2) {
-		can_plot2(mot_contrl_get_final_torque(mot_contrl()), mot_contrl()->target_torque);
+		can_plot2(mot_contrl_get_final_torque(&motor.controller), mot_contrl()->target_torque);
 	}else if (plot_type == 3) {
 		plot_smo_angle();
 	}else if (plot_type == 4) {
@@ -149,13 +149,9 @@ static u32 _app_plot_task(void * args) {
 	}else if (plot_type == 6) {
 		//do it in other place
 	}else if (plot_type == 7) {
-		#ifdef CONFIG_DQ_STEP_RESPONSE
-		can_plot2((s16)(target_d*10.0f), (s16)(motor.controller.foc.out.curr_dq.d * 10.0f));
-		#endif
+		can_plot2((s16)(foc()->in.target_id.target*10.0f), (s16)(foc()->out.curr_dq.d * 10.0f));
 	}else if (plot_type == 8) {
-		#ifdef CONFIG_DQ_STEP_RESPONSE
-		can_plot2((s16)(target_q*10.0f), (s16)(motor.controller.foc.out.curr_dq.q * 10.0f));
-		#endif
+		can_plot2((s16)(foc()->in.target_iq.target*10.0f), (s16)(foc()->out.curr_dq.q * 10.0f));
 	}else if (plot_type == 9) {
 		s16 thro_v = get_throttle_float() * 100.0f;
 		s16 thro2_v = get_throttle2_float() * 100.0f;

+ 5 - 6
Applications/foc/commands.c

@@ -14,10 +14,7 @@
 #include "foc/mc_config.h"
 #include "foc/motor/throttle.h"
 
-#ifdef CONFIG_DQ_STEP_RESPONSE
-extern float target_d;
-extern float target_q;
-#endif
+
 extern int plot_type;
 static void _reboot_timer_handler(shark_timer_t *);
 static shark_timer_t _reboot_timer = TIMER_INIT(_reboot_timer, _reboot_timer_handler);
@@ -204,8 +201,10 @@ static void process_foc_command(foc_cmd_body_t *command) {
 		{
 		#ifdef CONFIG_DQ_STEP_RESPONSE
 			if (command->len == 2) {
-				target_d = (float)decode_s08(command->data);
-				target_q = (float)decode_s08((u8 *)command->data + 1);
+				dq_t tgt_dq;
+				tgt_dq.d = (float)decode_s08(command->data);
+				tgt_dq.q = (float)decode_s08((u8 *)command->data + 1);
+				foc_set_target_idq(foc(), &tgt_dq);
 				sys_debug("step res %f, %f\n", target_d, target_q);
 			}else {
 				erroCode = FOC_Param_Err;

+ 0 - 5
Applications/foc/core/PMSM_FOC_Core.c

@@ -475,11 +475,6 @@ static __INLINE bool PMSM_FOC_Update_Input(void) {
 	return true;
 }
 
-#ifdef CONFIG_DQ_STEP_RESPONSE
-float target_d = 0.0f;
-float target_q = 0.0f;
-#endif
-
 static __INLINE float id_feedforward(float eW) {
 #ifdef CONFIG_CURRENT_LOOP_DECOUPE
 	return -(gFoc_Ctrl.params.lq * gFoc_Ctrl.out.s_RealIdq.q * eW);

+ 0 - 6
Applications/foc/motor/motor.c

@@ -18,10 +18,6 @@
 #include "foc/motor/throttle.h"
 #include "foc/limit.h"
 
-#ifdef CONFIG_DQ_STEP_RESPONSE
-extern float target_d;
-extern float target_q;
-#endif
 extern u32 enc_pwm_err_ms;
 extern s16 enc_delta_err1, enc_delta_err2;
 
@@ -351,8 +347,6 @@ bool mc_start(u8 mode) {
 	}
 #ifdef CONFIG_DQ_STEP_RESPONSE
 	mode = CTRL_MODE_CURRENT;
-	target_d = 0.0f;
-	target_q = 0.0f;
 #endif
 	mc_detect_vbus_mode();
 	etcs_enable(&motor.controller.etcs, motor.u_set.b_tcs);