|
|
@@ -127,8 +127,8 @@ u8 mot_contrl_mode(mot_contrl_t *ctrl) {
|
|
|
PI_Controller_Reset(&ctrl->pi_vel, ctrl->target_torque);
|
|
|
}else if ((preMode != ctrl->mode_running) && (ctrl->mode_running == CTRL_MODE_EBRAKE)) {
|
|
|
line_ramp_reset(&ctrl->ramp_input_torque, ctrl->target_torque);
|
|
|
- line_ramp_set_time(&ctrl->ramp_input_torque, ctrl->ebrk_ramp_time);
|
|
|
- line_ramp_set_target(&ctrl->ramp_input_torque, motor_get_ebreak_toruqe(ctrl->foc.in.mot_velocity));
|
|
|
+ line_ramp_set_time(&ctrl->ramp_input_torque, ctrl->torque_dec_time);
|
|
|
+ line_ramp_set_target(&ctrl->ramp_input_torque, 0);//先把扭矩快速减小到0
|
|
|
}else if ((preMode == CTRL_MODE_EBRAKE) && (ctrl->mode_running == CTRL_MODE_SPD)) {
|
|
|
PI_Controller_Reset(&ctrl->pi_vel, F_get_air());
|
|
|
}
|
|
|
@@ -573,7 +573,7 @@ float mot_contrl_get_ebrk_torque(mot_contrl_t *ctrl) {
|
|
|
|
|
|
void mot_contrl_set_ebrk_time(mot_contrl_t *ctrl, u32 time) {
|
|
|
ctrl->ebrk_ramp_time = time;
|
|
|
- if (ctrl->mode_running == CTRL_MODE_EBRAKE) {
|
|
|
+ if ((ctrl->mode_running == CTRL_MODE_EBRAKE) && (time != ctrl->ramp_input_torque.time_dec)) {
|
|
|
line_ramp_set_time(&ctrl->ramp_input_torque, time);
|
|
|
line_ramp_update(&ctrl->ramp_input_torque);
|
|
|
}
|
|
|
@@ -653,7 +653,7 @@ bool mot_contrl_set_torque(mot_contrl_t *ctrl, float torque) {
|
|
|
float torque_min = 0;
|
|
|
float torque_max = ctrl->userlim.torque;
|
|
|
if (ctrl->mode_running == CTRL_MODE_EBRAKE) {
|
|
|
- torque_min = -ctrl->userlim.torque;
|
|
|
+ torque_min = -ctrl->userlim.ebrk_torque;
|
|
|
torque_max = 0;
|
|
|
}
|
|
|
torque = fclamp(torque, torque_min, torque_max);
|
|
|
@@ -713,7 +713,7 @@ static bool is_hw_brake_shutting_power(mot_contrl_t *ctrl) {
|
|
|
return (ctrl->b_hw_braker && mc_hwbrk_can_shutpower());
|
|
|
}
|
|
|
|
|
|
-bool mot_contrl_energy_recovery(mot_contrl_t *ctrl, bool start) {
|
|
|
+bool mot_contrl_set_ebreak(mot_contrl_t *ctrl, bool start) {
|
|
|
bool enable = ctrl->b_ebrk_running;
|
|
|
if (mot_contrl_get_ebrk_torque(ctrl) == 0) {
|
|
|
enable = false;
|
|
|
@@ -739,7 +739,7 @@ void mot_contrl_set_hw_brake(mot_contrl_t *ctrl, bool hw_brake) {
|
|
|
ctrl->b_hw_braker = hw_brake;
|
|
|
}
|
|
|
if (is_hw_brake_shutting_power(ctrl)) {
|
|
|
- if (!ctrl->b_ebrk_running && !mot_contrl_energy_recovery(ctrl, true)) {
|
|
|
+ if (!ctrl->b_ebrk_running && !mot_contrl_set_ebreak(ctrl, true)) {
|
|
|
line_ramp_reset(&ctrl->ramp_input_torque, 0);
|
|
|
}
|
|
|
}
|