|
|
@@ -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;
|
|
|
}
|