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

if控制加入hall角度的plot

Signed-off-by: kevin <huhui@sharkgulf.com>
kevin 2 лет назад
Родитель
Сommit
c95774fbe2
1 измененных файлов с 19 добавлено и 0 удалено
  1. 19 0
      Applications/app/app.c

+ 19 - 0
Applications/app/app.c

@@ -194,6 +194,25 @@ static void plot_smo_angle(void) {
 	delta = fast_atan2(s, c)/PI*180.0f;
 	can_plot3(mot_angle, smo_angle, delta);
 }
+
+#ifdef CONFIG_USE_ENCODER_HALL
+static void plot_hall_angle(void) {
+	u32 mask = cpu_enter_critical();
+	float hall_angle = hall_get_elec_angle();
+	float mot_angle = foc()->in.mot_angle;
+	if (mot_contrl()->if_ctl.b_ena) {
+		mot_angle += 90;
+	}
+	norm_angle_deg(mot_angle);
+	cpu_exit_critical(mask);
+	float delta = hall_angle - mot_angle;
+	float s, c;
+	arm_sin_cos(delta, &s, &c);
+	delta = fast_atan2(s, c)/PI*180.0f;
+	can_plot3(mot_angle, hall_angle, delta);
+}
+#endif
+
 static u32 app_plot_task(void * args) {
 	if (plot_type == 1) {
 		s16 plot_arg1 = mot_contrl()->ramp_vel_lim.interpolation;