|
@@ -59,7 +59,7 @@ float thro_torque_gear_map(s16 rpm, u8 gear) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/* 获取油门开度 */
|
|
/* 获取油门开度 */
|
|
|
-static float thro_ration(float f_throttle) {
|
|
|
|
|
|
|
+float get_throttle_ration(float f_throttle) {
|
|
|
if (f_throttle <= throttle_start_vol()) {
|
|
if (f_throttle <= throttle_start_vol()) {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -76,10 +76,6 @@ float thro_ration_to_voltage(float r) {
|
|
|
return fclamp(vol, 0, throttle_end_vol());
|
|
return fclamp(vol, 0, throttle_end_vol());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-float thro_get_ration(float f_thro) {
|
|
|
|
|
- return thro_ration(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 thro_torque = max_torque * ration;
|
|
@@ -189,27 +185,12 @@ static void thro_torque_request(void) {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-#define THRO_REF_LP_CEOF 0.2f
|
|
|
|
|
-static void thro_torque_filter(float f_throttle) {
|
|
|
|
|
- if (mc_throttle_released()){
|
|
|
|
|
- thro_torque_reset();
|
|
|
|
|
- }else {
|
|
|
|
|
- LowPass_Filter(_torque.thro_filted, f_throttle, THRO_REF_LP_CEOF);
|
|
|
|
|
- }
|
|
|
|
|
- float curr_rpm = PMSM_FOC_GetSpeed();
|
|
|
|
|
- if (curr_rpm == 0) {
|
|
|
|
|
- _torque.spd_filted = 0;
|
|
|
|
|
- }else {
|
|
|
|
|
- LowPass_Filter(_torque.spd_filted, curr_rpm, 0.01f);
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
|
|
+#define THRO_RPM_LP_CEOF 0.01f
|
|
|
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);
|
|
|
|
|
-
|
|
|
|
|
- float thro_r = thro_ration(_torque.thro_filted);
|
|
|
|
|
|
|
+ float thro_r = get_throttle_ration(f_throttle);
|
|
|
_torque.gear = mc_get_internal_gear();
|
|
_torque.gear = mc_get_internal_gear();
|
|
|
|
|
+ LowPass_Filter(_torque.spd_filted, PMSM_FOC_GetSpeed(), THRO_RPM_LP_CEOF);
|
|
|
|
|
|
|
|
if (thro_r > _torque.thro_ration) {
|
|
if (thro_r > _torque.thro_ration) {
|
|
|
if (!_torque.accl) {
|
|
if (!_torque.accl) {
|