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

解决转把错误不能release转把的问题

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

+ 4 - 4
Applications/app/app.c

@@ -55,16 +55,16 @@ static void app_print_log(void) {
 	//sys_debug("FOC time err %d %d %d %d\n", g_meas_foc.intval_time_h_error, g_meas_foc.intval_time_l_error, g_meas_foc.exec_max_error_time, g_meas_foc.exec_time_error);
 	//sys_debug("acc vol %d, bid %d\n", get_acc_vol(), gpio_board_id());
 	//sys_debug("throttle %f\n", get_throttle_float());
-	//sys_debug("ADC Vref %f, %f\n", get_adc_vref(), adc_5vref_compesion());
-	//sys_debug("dead time %d\n", get_deadtime());
+	sys_debug("ADC Vref %f, %f\n", get_adc_vref(), adc_5vref_compesion());
+	sys_debug("dead time 0x%x\n", get_deadtime());
 	//thro_torque_log();
 	//sys_debug("_>%f, %f, %f\n", ladrc_observer_get()->ld, ladrc_observer_get()->lq, ladrc_observer_get()->poles);
 	encoder_log();
 	//motor_debug();
-	//sample_log();
+	sample_log();
 	//throttle_log();
 	sys_debug("Trq: %f-%f-%f\n", motor.controller.ramp_input_torque.target, motor.controller.ramp_input_torque.interpolation, motor.controller.ramp_input_torque.step);
-	sys_debug("acc vol: %d\n", get_acc_vol());
+	sys_debug("FOC is %s, %d,%d\n", mot_contrl_is_start(mot_contrl())?"start":"stop", motor.foc_start_cnt, motor.foc_stop_cnt);
 	//F_debug();
 	//eCtrl_debug_log();
 	//sys_debug("enc err %d, %d\n", foc_observer_enc_errcount(), foc_observer_sensorless_stable());

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

@@ -1512,7 +1512,7 @@ static bool mc_can_stop_foc(void) {
 			return true;
 		}
 	}
-	if (mc_throttle_released() && mot_contrl_get_speed(&motor.controller) == 0.0f) {
+	if (mc_throttle_released() && ((mot_contrl_get_speed(&motor.controller)) == 0.0f)) {
 		if (!mot_contrl_is_auto_holdding(&motor.controller) && motor.epm_dir == EPM_Dir_None) {
 			return true;
 		}
@@ -1545,6 +1545,7 @@ static void mc_motor_runstop(void) {
 		mot_contrl_stop(&motor.controller);
 		pwm_disable_channel();
 		g_meas_foc.first = true;
+		motor.foc_stop_cnt ++;
 		cpu_exit_critical(mask);
 	}
 	if (!mot_contrl_is_start(&motor.controller) && mc_can_restart_foc()) {
@@ -1554,6 +1555,7 @@ static void mc_motor_runstop(void) {
 		throttle_torque_reset();
 		pwm_enable_channel();
 		g_meas_foc.first = true;
+		motor.foc_start_cnt ++;
 		cpu_exit_critical(mask);
 	}
 }

+ 4 - 0
Applications/foc/motor/motor.h

@@ -76,6 +76,10 @@ typedef struct {
 	mot_contrl_t controller;
 	user_rt_set u_set; //用户运行时设置
 	fan_t  fan[2];
+
+	//for debug
+	int foc_stop_cnt;
+	int foc_start_cnt;
 }motor_t;
 
 extern motor_t motor;

+ 3 - 1
Applications/foc/motor/throttle.c

@@ -93,7 +93,9 @@ float throttle_get_signal(void) {
 bool throttle_is_released(void) {
 #if CONFIG_DAUL_THROTTLE==1
 	float signal = 0;
-	if (throttle1_is_error() && !throttle2_is_error()) {
+	if (throttle1_is_error() && throttle2_is_error()) {
+		return true;
+	}else if (throttle1_is_error() && !throttle2_is_error()) {
 		float thr = get_thro2_5v_float() - get_throttle2_float();
 		signal = fclamp(thr, _start_v, _end_v);
 	}else if (!throttle1_is_error() && throttle2_is_error()) {