|
|
@@ -187,30 +187,35 @@ static void thro_torque_filter(float f_throttle) {
|
|
|
LowPass_Filter(_torque.spd_filted, curr_rpm, 0.01f);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+static float acc_r, acc_r_last, acc_trq;
|
|
|
+static float dec_r, dec_r_last, dec_trq;
|
|
|
void thro_torque_process(u8 run_mode, float f_throttle) {
|
|
|
|
|
|
thro_torque_filter(f_throttle);
|
|
|
|
|
|
float thro_r = thro_ration(_torque.thro_filted);
|
|
|
- u8 n_gear = mc_get_internal_gear();
|
|
|
+ _torque.gear = mc_get_internal_gear();
|
|
|
|
|
|
if (thro_r > _torque.thro_ration) {
|
|
|
if (!_torque.accl) {
|
|
|
_torque.thro_ration_last = _torque.thro_ration;
|
|
|
- _torque.torque_real = PMSM_FOC_Get()->in.s_targetTorque;
|
|
|
+ _torque.torque_real = _torque.torque_req;
|
|
|
if (_torque.torque_real < 0) { //电子刹车的时候,扭矩可能为负
|
|
|
_torque.torque_real = 0;
|
|
|
}
|
|
|
+ acc_r = thro_r;
|
|
|
+ acc_r_last = _torque.thro_ration_last;
|
|
|
+ acc_trq = _torque.torque_real;
|
|
|
}
|
|
|
- _torque.gear = n_gear;
|
|
|
_torque.accl = true;
|
|
|
}else if (thro_r < _torque.thro_ration) {
|
|
|
if (_torque.accl) {
|
|
|
_torque.thro_ration_last = _torque.thro_ration;
|
|
|
- _torque.torque_real = PMSM_FOC_Get()->in.s_targetTorque;
|
|
|
+ _torque.torque_real = _torque.torque_req;
|
|
|
+ dec_r = thro_r;
|
|
|
+ dec_r_last = _torque.thro_ration_last;
|
|
|
+ dec_trq = _torque.torque_real;
|
|
|
}
|
|
|
- _torque.gear = n_gear;
|
|
|
_torque.accl = false;
|
|
|
}
|
|
|
|
|
|
@@ -234,10 +239,12 @@ void thro_torque_process(u8 run_mode, float f_throttle) {
|
|
|
}
|
|
|
|
|
|
if (eCtrl_get_FinalTorque() < 0.0001f && vel < CONFIG_MIN_RPM_EXIT_EBRAKE) {
|
|
|
- eCtrl_enable_eBrake(false);
|
|
|
+ eCtrl_enable_eBrake(false);
|
|
|
+ thro_torque_reset();
|
|
|
}
|
|
|
if (!mc_throttle_released() || (mc_throttle_released() && (vel == 0.0f))) {
|
|
|
eCtrl_enable_eBrake(false);
|
|
|
+ thro_torque_reset();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -253,4 +260,6 @@ float get_user_request_torque(void) {
|
|
|
void thro_torque_log(void) {
|
|
|
sys_debug("accl %d, real %f, req %f\n", _torque.accl, _torque.torque_real, _torque.torque_req);
|
|
|
sys_debug("ration %f - %f - %f - %d\n", _torque.thro_ration, _torque.thro_ration_last, thro_torque_for_accelerate(), _torque.gear);
|
|
|
+ sys_debug("acc:%f,%f,%f", acc_r, acc_r_last, acc_trq);
|
|
|
+ sys_debug("dec:%f,%f,%f", dec_r, dec_r_last, dec_trq);
|
|
|
}
|