|
|
@@ -112,31 +112,54 @@ static void thro_torque_request(void) {
|
|
|
return;
|
|
|
}
|
|
|
if (!mc_throttle_released()) {
|
|
|
+ float curr_rpm = PMSM_FOC_GetSpeed();
|
|
|
if (_torque.accl) { //加速需求
|
|
|
float ref_torque = thro_torque_for_accelerate();
|
|
|
float hold_torque = PMSM_FOC_Get()->out.f_autohold_trq;
|
|
|
- float curr_rpm = PMSM_FOC_GetSpeed();
|
|
|
if (hold_torque < 0) { //下坡驻车,最小给0扭矩
|
|
|
hold_torque = 0;
|
|
|
}
|
|
|
+ ref_torque = MAX(hold_torque, ref_torque);
|
|
|
if (curr_rpm <= CONFIG_ZERO_SPEED_RPM) {//从静止开始加速
|
|
|
- ref_torque = MAX(hold_torque, ref_torque);
|
|
|
- if (hold_torque != 0) {
|
|
|
+ if (_torque.torque_req < hold_torque) {
|
|
|
_torque.torque_req = hold_torque;
|
|
|
- PMSM_FOC_Get()->out.f_autohold_trq = 0;
|
|
|
+ eCtrl_reset_Torque(hold_torque);
|
|
|
}
|
|
|
+ }else {
|
|
|
+ PMSM_FOC_Get()->out.f_autohold_trq = 0;
|
|
|
}
|
|
|
+ /* 处理加速ramp时间的变化,需要缓慢变小,变大可以立即处理,
|
|
|
+ * 加速时间缓慢变小可以防止突然大扭矩加速
|
|
|
+ */
|
|
|
+ u16 now_ramp_time = eCtrl_get_torque_acc_time();
|
|
|
+ u16 next_ramp_time = mc_get_gear_config()->n_accl_time;
|
|
|
if (curr_rpm < CONFIG_ZERO_SPEED_RAMP_RMP) {
|
|
|
- u16 start_time = mc_get_gear_config()->n_zero_accl;
|
|
|
- if (start_time == 0) {
|
|
|
- start_time = 100;
|
|
|
+ next_ramp_time = mc_get_gear_config()->n_zero_accl;
|
|
|
+ }
|
|
|
+ if (next_ramp_time == 0) {
|
|
|
+ next_ramp_time = 100;
|
|
|
+ }
|
|
|
+ if (now_ramp_time != next_ramp_time) {
|
|
|
+ if (next_ramp_time > now_ramp_time) {
|
|
|
+ eCtrl_set_accl_time(next_ramp_time);
|
|
|
+ }else {
|
|
|
+ float f_now = (float)now_ramp_time;
|
|
|
+ float f_next = (float)next_ramp_time;
|
|
|
+ step_towards(&f_now, f_next, 0.5f);
|
|
|
+ if (f_now <= 10) {
|
|
|
+ f_now = 10;
|
|
|
+ }
|
|
|
+ eCtrl_set_accl_time((u16)f_now);
|
|
|
}
|
|
|
- step_towards(&_torque.torque_req, ref_torque, ref_torque/(float)start_time);
|
|
|
- }else {
|
|
|
- _torque.torque_req = ref_torque;
|
|
|
}
|
|
|
+ _torque.torque_req = ref_torque;
|
|
|
}else {
|
|
|
float ref_torque = thro_torque_for_decelerate();
|
|
|
+ /* autohold 启动的情况下,转把在0位置附近小幅抖动 */
|
|
|
+ if (curr_rpm <= CONFIG_ZERO_SPEED_RPM) {
|
|
|
+ float hold_torque = PMSM_FOC_Get()->out.f_autohold_trq;
|
|
|
+ ref_torque = MAX(hold_torque, ref_torque);
|
|
|
+ }
|
|
|
_torque.torque_req = ref_torque;
|
|
|
}
|
|
|
PMSM_FOC_Set_Torque(_torque.torque_req);
|
|
|
@@ -172,6 +195,9 @@ void thro_torque_process(u8 run_mode, float f_throttle) {
|
|
|
if (!_torque.accl) {
|
|
|
_torque.thro_ration_last = _torque.thro_ration;
|
|
|
_torque.torque_real = PMSM_FOC_Get()->in.s_targetTorque;
|
|
|
+ if (_torque.torque_real < 0) { //电子刹车的时候,扭矩可能为负
|
|
|
+ _torque.torque_real = 0;
|
|
|
+ }
|
|
|
}
|
|
|
_torque.gear = n_gear;
|
|
|
_torque.accl = true;
|