Przeglądaj źródła

母线采集adc offset开机只校准一次

Signed-off-by: huhui <huhui@sharkgulf.com>
huhui 3 lat temu
rodzic
commit
a603356155
1 zmienionych plików z 5 dodań i 1 usunięć
  1. 5 1
      Applications/foc/motor/motor.c

+ 5 - 1
Applications/foc/motor/motor.c

@@ -41,6 +41,7 @@ static motor_t motor = {
 };
 
 static void MC_Check_MosVbusThrottle(void) {
+	static bool _ibus_offset = false;
 	int count = 1000;
 	float ibus_adc = 0;
 	gpio_phase_u_detect(true);
@@ -51,7 +52,10 @@ static void MC_Check_MosVbusThrottle(void) {
 		sample_vbus();
 		ibus_adc += adc_get_ibus();
 	}
-	sample_ibus_offset(ibus_adc/1000.0f);
+	if (!_ibus_offset) {
+		sample_ibus_offset(ibus_adc/1000.0f);
+		_ibus_offset = true;
+	}
 	gpio_phase_u_detect(false);
 	float abc[3];
 	get_phase_vols(abc);