|
@@ -15,7 +15,7 @@ void thro_torque_reset(void) {
|
|
|
_torque.accl = false;
|
|
_torque.accl = false;
|
|
|
_torque.thro_filted = 0.0f;
|
|
_torque.thro_filted = 0.0f;
|
|
|
_torque.thro_ration = _torque.thro_ration_last = 0.0f;
|
|
_torque.thro_ration = _torque.thro_ration_last = 0.0f;
|
|
|
- _torque.torque_req = _torque.torque_real = 0.0f;
|
|
|
|
|
|
|
+ _torque.torque_req = _torque.torque_real = _torque.torque_acc_ = 0.0f;
|
|
|
_torque.gear = mc_get_internal_gear();
|
|
_torque.gear = mc_get_internal_gear();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -81,6 +81,8 @@ float thro_get_ration(float f_thro) {
|
|
|
|
|
|
|
|
static float _thro_torque_for_accelerate(float ration) {
|
|
static float _thro_torque_for_accelerate(float ration) {
|
|
|
float max_torque = thro_torque_gear_map((s16)_torque.spd_filted, _torque.gear);
|
|
float max_torque = thro_torque_gear_map((s16)_torque.spd_filted, _torque.gear);
|
|
|
|
|
+ float thro_torque = max_torque * ration;
|
|
|
|
|
+
|
|
|
float acc_r = 1.0f;
|
|
float acc_r = 1.0f;
|
|
|
if (_torque.thro_ration_last < 1.0f) {
|
|
if (_torque.thro_ration_last < 1.0f) {
|
|
|
acc_r = (ration - _torque.thro_ration_last)/ (1.0f - _torque.thro_ration_last);
|
|
acc_r = (ration - _torque.thro_ration_last)/ (1.0f - _torque.thro_ration_last);
|
|
@@ -90,7 +92,20 @@ static float _thro_torque_for_accelerate(float ration) {
|
|
|
if (acc_torque < 0) {
|
|
if (acc_torque < 0) {
|
|
|
acc_torque = 0;
|
|
acc_torque = 0;
|
|
|
}
|
|
}
|
|
|
- return acc_torque;
|
|
|
|
|
|
|
+ /*
|
|
|
|
|
+ 直接获取油门开度对应的加速扭矩thro_torque 不小于间接计算得到的 acc_torque
|
|
|
|
|
+ 如果差值在正负5以上,需要step 补偿
|
|
|
|
|
+ */
|
|
|
|
|
+ float torque_acc_ = thro_torque - acc_torque;
|
|
|
|
|
+ float step = 0.0f;
|
|
|
|
|
+ if (ABS(torque_acc_) < 5) {
|
|
|
|
|
+ torque_acc_ = 0;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ float acc_t = mc_get_gear_config()->n_accl_time;
|
|
|
|
|
+ step = torque_acc_ / (acc_t + 0.00001f);
|
|
|
|
|
+ }
|
|
|
|
|
+ step_towards(&_torque.torque_acc_, torque_acc_, step);
|
|
|
|
|
+ return (acc_torque + _torque.torque_acc_);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -188,13 +203,14 @@ static void thro_torque_filter(float f_throttle) {
|
|
|
LowPass_Filter(_torque.spd_filted, curr_rpm, 0.01f);
|
|
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) {
|
|
void thro_torque_process(u8 run_mode, float f_throttle) {
|
|
|
|
|
|
|
|
thro_torque_filter(f_throttle);
|
|
thro_torque_filter(f_throttle);
|
|
|
|
|
|
|
|
float thro_r = thro_ration(_torque.thro_filted);
|
|
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 (thro_r > _torque.thro_ration) {
|
|
|
if (!_torque.accl) {
|
|
if (!_torque.accl) {
|
|
@@ -203,15 +219,23 @@ void thro_torque_process(u8 run_mode, float f_throttle) {
|
|
|
if (_torque.torque_real < 0) { //电子刹车的时候,扭矩可能为负
|
|
if (_torque.torque_real < 0) { //电子刹车的时候,扭矩可能为负
|
|
|
_torque.torque_real = 0;
|
|
_torque.torque_real = 0;
|
|
|
}
|
|
}
|
|
|
|
|
+ _torque.torque_acc_ = 0;
|
|
|
|
|
+ acc_r = thro_r;
|
|
|
|
|
+ acc_r_last = _torque.thro_ration_last;
|
|
|
|
|
+ acc_trq = _torque.torque_real;
|
|
|
}
|
|
}
|
|
|
- _torque.gear = n_gear;
|
|
|
|
|
_torque.accl = true;
|
|
_torque.accl = true;
|
|
|
}else if (thro_r < _torque.thro_ration) {
|
|
}else if (thro_r < _torque.thro_ration) {
|
|
|
if (_torque.accl) {
|
|
if (_torque.accl) {
|
|
|
_torque.thro_ration_last = _torque.thro_ration;
|
|
_torque.thro_ration_last = _torque.thro_ration;
|
|
|
_torque.torque_real = PMSM_FOC_Get()->in.s_targetTorque;
|
|
_torque.torque_real = PMSM_FOC_Get()->in.s_targetTorque;
|
|
|
|
|
+ if (_torque.torque_real < 0) { //电子刹车的时候,扭矩可能为负
|
|
|
|
|
+ _torque.torque_real = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ dec_r = thro_r;
|
|
|
|
|
+ dec_r_last = _torque.thro_ration_last;
|
|
|
|
|
+ dec_trq = _torque.torque_real;
|
|
|
}
|
|
}
|
|
|
- _torque.gear = n_gear;
|
|
|
|
|
_torque.accl = false;
|
|
_torque.accl = false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -235,10 +259,12 @@ void thro_torque_process(u8 run_mode, float f_throttle) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (eCtrl_get_FinalTorque() < 0.0001f && vel < CONFIG_MIN_RPM_EXIT_EBRAKE) {
|
|
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))) {
|
|
if (!mc_throttle_released() || (mc_throttle_released() && (vel == 0.0f))) {
|
|
|
eCtrl_enable_eBrake(false);
|
|
eCtrl_enable_eBrake(false);
|
|
|
|
|
+ thro_torque_reset();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -254,4 +280,6 @@ float get_user_request_torque(void) {
|
|
|
void thro_torque_log(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("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("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\n", acc_r, acc_r_last, acc_trq);
|
|
|
|
|
+ sys_debug("dec:%f,%f,%f\n", dec_r, dec_r_last, dec_trq);
|
|
|
}
|
|
}
|