Bladeren bron

解决能量回收等级为0的时候,不应该打开能量回收的问题

Signed-off-by: unknown <huhui@sharkgulf.com>
unknown 2 jaren geleden
bovenliggende
commit
519e0d21fc
3 gewijzigde bestanden met toevoegingen van 17 en 9 verwijderingen
  1. 9 3
      Applications/foc/core/controller.c
  2. 7 5
      Applications/foc/motor/motor.c
  3. 1 1
      Project/MC105_V3_SERVO.uvoptx

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

@@ -113,7 +113,7 @@ u8 mot_contrl_mode(mot_contrl_t *ctrl) {
 	if (preMode != ctrl->mode_running) {
 		if ((preMode != ctrl->mode_running) && (ctrl->mode_running == CTRL_MODE_TRQ)) {
 			line_ramp_set_acctime(&ctrl->input_torque, ctrl->torque_acc_time);
-			line_ramp_set_dectime(&ctrl->input_torque, ctrl->torque_acc_time);
+			line_ramp_set_dectime(&ctrl->input_torque, ctrl->torque_dec_time);
 			line_ramp_update(&ctrl->input_torque);
 			if (preMode == CTRL_MODE_SPD) {
 				ctrl->target_torque_raw = ctrl->target_torque;
@@ -444,7 +444,7 @@ static void mot_contrl_ulimit(mot_contrl_t *ctrl) {
 	ctrl->userlim.dc_vol_min = mc_conf()->c.max_dc_vol;
 	ctrl->userlim.dc_vol_max = mc_conf()->c.min_dc_vol;
 	ctrl->userlim.ebrk_dc_curr = 0xFF;
-	ctrl->userlim.ebrk_torque = mc_conf()->c.max_ebrk_torque;
+	ctrl->userlim.ebrk_torque = mc_get_ebrk_torque();
 }
 
 static void mot_contrl_rtlimit(mot_contrl_t *ctrl) {
@@ -649,7 +649,13 @@ bool mot_contrl_set_torque(mot_contrl_t *ctrl, float torque) {
 	if (is_hw_brake_shutting_power(ctrl) && !ctrl->b_ebrk_running){
 		return false;
 	}
-	torque = fclamp(torque, -ctrl->userlim.torque, ctrl->userlim.torque);
+	float torque_min = 0;
+	float torque_max = ctrl->userlim.torque;
+	if (ctrl->mode_running == CTRL_MODE_EBRAKE) {
+		torque_min = -ctrl->userlim.torque;
+		torque_max = 0;
+	}
+	torque = fclamp(torque, torque_min, torque_max);
 	line_ramp_set_target(&ctrl->input_torque, torque);
 	return true;
 }

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

@@ -372,17 +372,20 @@ bool mc_start(u8 mode) {
 		mot_contrl_set_error(&motor.controller, FOC_Throttle_Err);
 		return false;
 	}
-
+	
 	pwm_up_enable(false);
 
-	_mc_internal_init(mode, true);
+	u32 mask = cpu_enter_critical();
 
+	_mc_internal_init(mode, true);
 	throttle_torque_reset();
-	mc_gear_vmode_changed();
 	motor_encoder_start(true);
+	mot_contrl_start(&motor.controller, mode);
 	mot_contrl_set_torque_ramp_time(&motor.controller, mc_get_gear_config()->zero_accl, mc_conf()->c.thro_dec_time);
 	mc_set_ebrk_level(motor.u_set.ebrk_lvl);
-	mot_contrl_start(&motor.controller, mode);
+	mc_gear_vmode_changed();
+	cpu_exit_critical(mask);
+
 	pwm_turn_on_low_side();
 	delay_ms(10);
 	phase_current_offset_calibrate();
@@ -402,7 +405,6 @@ bool mc_start(u8 mode) {
 	if (mc_detect_hwbrake()) {
 		mot_contrl_set_hw_brake(&motor.controller, true);
 	}
-	gpio_beep(200);
 
 	return true;
 }

+ 1 - 1
Project/MC105_V3_SERVO.uvoptx

@@ -77,7 +77,7 @@
         <tvExpOptDlg>0</tvExpOptDlg>
         <IsCurrentTarget>1</IsCurrentTarget>
       </OPTFL>
-      <CpuCode>0</CpuCode>
+      <CpuCode>255</CpuCode>
       <DebugOpt>
         <uSim>0</uSim>
         <uTrg>1</uTrg>