|
@@ -41,6 +41,7 @@ m_contrl_t motor = {
|
|
|
.motor_lim = 0,
|
|
.motor_lim = 0,
|
|
|
.b_ind_start = false,
|
|
.b_ind_start = false,
|
|
|
.s_target_speed = MAX_S16,
|
|
.s_target_speed = MAX_S16,
|
|
|
|
|
+ .s_force_torque = MAX_S16,
|
|
|
.u_set.idc_lim = IDC_USER_LIMIT_NONE,
|
|
.u_set.idc_lim = IDC_USER_LIMIT_NONE,
|
|
|
.u_set.rpm_lim = RPM_USER_LIMIT_NONE,
|
|
.u_set.rpm_lim = RPM_USER_LIMIT_NONE,
|
|
|
.u_set.ebrk_lvl = 0,
|
|
.u_set.ebrk_lvl = 0,
|
|
@@ -338,6 +339,7 @@ bool mc_start(u8 mode) {
|
|
|
#ifdef CONFIG_DQ_STEP_RESPONSE
|
|
#ifdef CONFIG_DQ_STEP_RESPONSE
|
|
|
mode = CTRL_MODE_CURRENT;
|
|
mode = CTRL_MODE_CURRENT;
|
|
|
#endif
|
|
#endif
|
|
|
|
|
+ motor.s_force_torque = MAX_S16;
|
|
|
mc_detect_vbus_mode();
|
|
mc_detect_vbus_mode();
|
|
|
etcs_enable(&motor.controller.etcs, motor.u_set.b_tcs);
|
|
etcs_enable(&motor.controller.etcs, motor.u_set.b_tcs);
|
|
|
if (motor.b_lock_motor) {
|
|
if (motor.b_lock_motor) {
|
|
@@ -498,6 +500,18 @@ bool mc_set_target_vel(s16 vel) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+bool mc_set_force_torque(s16 torque) {
|
|
|
|
|
+ if (motor.mode != CTRL_MODE_TRQ) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (torque == MAX_S16) {
|
|
|
|
|
+ motor.s_force_torque = MAX_S16;
|
|
|
|
|
+ }else {
|
|
|
|
|
+ motor.s_force_torque = fclamp(torque, -mc_gear_conf()->max_torque, mc_gear_conf()->max_torque);
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
bool mc_is_cruise_enabled(void) {
|
|
bool mc_is_cruise_enabled(void) {
|
|
|
return motor.b_cruise;
|
|
return motor.b_cruise;
|
|
|
}
|
|
}
|
|
@@ -986,6 +1000,9 @@ u32 mc_get_critical_error(void) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
bool mc_throttle_released(void) {
|
|
bool mc_throttle_released(void) {
|
|
|
|
|
+ if (motor.s_force_torque != MAX_S16) {
|
|
|
|
|
+ return motor.s_force_torque == 0;
|
|
|
|
|
+ }
|
|
|
if (motor.b_ignor_throttle) {
|
|
if (motor.b_ignor_throttle) {
|
|
|
return motor.u_throttle_ration == 0;
|
|
return motor.u_throttle_ration == 0;
|
|
|
}
|
|
}
|
|
@@ -1603,12 +1620,16 @@ void Sched_MC_mTask(void) {
|
|
|
mot_contrl_set_target_vel(&motor.controller, motor.s_target_speed);
|
|
mot_contrl_set_target_vel(&motor.controller, motor.s_target_speed);
|
|
|
}
|
|
}
|
|
|
}else {
|
|
}else {
|
|
|
- float thro = throttle_get_signal();
|
|
|
|
|
- if (motor.b_ignor_throttle) {
|
|
|
|
|
- float r = (float)motor.u_throttle_ration/100.0f;
|
|
|
|
|
- thro = throttle_opening_to_vol(r);
|
|
|
|
|
|
|
+ if (motor.s_force_torque != MAX_S16) {
|
|
|
|
|
+ mot_contrl_set_force_torque(&motor.controller, motor.s_force_torque);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ float thro = throttle_get_signal();
|
|
|
|
|
+ if (motor.b_ignor_throttle) {
|
|
|
|
|
+ float r = (float)motor.u_throttle_ration/100.0f;
|
|
|
|
|
+ thro = throttle_opening_to_vol(r);
|
|
|
|
|
+ }
|
|
|
|
|
+ mc_process_throttle_torque(thro);
|
|
|
}
|
|
}
|
|
|
- mc_process_throttle_torque(thro);
|
|
|
|
|
}
|
|
}
|
|
|
mot_contrl_slow_task(&motor.controller);
|
|
mot_contrl_slow_task(&motor.controller);
|
|
|
}
|
|
}
|