|
|
@@ -225,15 +225,20 @@ static void _led_off_timer_handler(shark_timer_t *t) {
|
|
|
|
|
|
static void mc_gear_mode_set(void) {
|
|
|
gear_t *gears = mc_gear_conf();
|
|
|
- if (gears != &sensorless_gear) {
|
|
|
- sensorless_gear.max_torque = gears->max_torque;
|
|
|
- }else { //slowly changed
|
|
|
+ float max_vel = (float)min(gears->max_speed, motor.u_set.rpm_lim);
|
|
|
+ float max_idc = (float)min(gears->max_idc, motor.u_set.idc_lim);
|
|
|
+ float max_torque = (float)gears->max_torque;
|
|
|
+ if (!foc_observer_is_encoder()) { //无感模式,受限运行
|
|
|
line_ramp_set_time(&motor.controller.ramp_vel_lim, CONFIG_SENSORLESS_RAMP_TIME);
|
|
|
line_ramp_set_time(&motor.controller.ramp_dc_curr_lim, CONFIG_SENSORLESS_RAMP_TIME);
|
|
|
+ max_vel = min(max_vel, (float)sensorless_gear.max_speed);
|
|
|
+ max_idc = min(max_idc, (float)sensorless_gear.max_idc);
|
|
|
+ max_torque = min(max_torque, (float)sensorless_gear.max_torque);
|
|
|
}
|
|
|
- mot_contrl_set_vel_limit(&motor.controller, (float)min(gears->max_speed, motor.u_set.rpm_lim));
|
|
|
- mot_contrl_set_dccurr_limit(&motor.controller, (float)min(gears->max_idc, motor.u_set.idc_lim));
|
|
|
- mot_contrl_set_torque_limit(&motor.controller, (float)gears->max_torque);
|
|
|
+
|
|
|
+ mot_contrl_set_vel_limit(&motor.controller, max_vel);
|
|
|
+ mot_contrl_set_dccurr_limit(&motor.controller, max_idc);
|
|
|
+ mot_contrl_set_torque_limit(&motor.controller, max_torque);
|
|
|
}
|
|
|
|
|
|
void mc_init(void) {
|
|
|
@@ -262,9 +267,6 @@ motor_t * get_motor(void) {
|
|
|
|
|
|
gear_t *mc_gear_conf_by_gear(u8 n_gear) {
|
|
|
gear_t *gears;
|
|
|
- if (!foc_observer_is_encoder()) { //无感模式,受限运行
|
|
|
- return &sensorless_gear;
|
|
|
- }
|
|
|
if (motor.b_high_vol_mode) {
|
|
|
gears = &mc_conf()->g_n[0];
|
|
|
}else {
|