|
|
@@ -100,6 +100,25 @@ static u16 _motor_limit(void) {
|
|
|
}else if (_can_recovery){
|
|
|
mc_clr_critical_error(FOC_CRIT_MOTOR_TEMP_Err);
|
|
|
}
|
|
|
+ mc_gear_t *gear = mc_get_gear_config();
|
|
|
+
|
|
|
+ float prv_lim_value;
|
|
|
+ float next_lim_tmp;
|
|
|
+ if (i < (ARRAY_SIZE(motor_temp_lim)-1)) {
|
|
|
+ prv_lim_value = (float)motor_temp_lim[i + 1].limit_value;
|
|
|
+ }else {
|
|
|
+ prv_lim_value = 100.0f; //最低一级限流
|
|
|
+ }
|
|
|
+ if (i != 0) {
|
|
|
+ next_lim_tmp = (float)motor_temp_lim[i - 1].enter_pointer;
|
|
|
+ }else {
|
|
|
+ next_lim_tmp = (float)lim->enter_pointer + 10.0f; //最大一级限流
|
|
|
+ }
|
|
|
+ float delta_tmp = (next_lim_tmp - (float)lim->enter_pointer);
|
|
|
+ float delta_value = (prv_lim_value - (float)lim->limit_value);
|
|
|
+ float curr_value = prv_lim_value - (float)(temp - lim->enter_pointer)/delta_tmp * delta_value;
|
|
|
+ curr_value = fclamp(curr_value, 0, prv_lim_value);
|
|
|
+ lim_value = (u16)(((float)gear->n_max_trq * curr_value) / 100.0f);
|
|
|
mc_set_motor_lim_level(i + 1);
|
|
|
err_add_record(FOC_CRIT_MOTOR_TEMP_Err, temp);
|
|
|
return lim_value;
|
|
|
@@ -120,6 +139,25 @@ static u16 _mos_limit(void) {
|
|
|
}else if (_can_recovery){
|
|
|
mc_clr_critical_error(FOC_CRIT_MOS_TEMP_Err);
|
|
|
}
|
|
|
+ mc_gear_t *gear = mc_get_gear_config();
|
|
|
+
|
|
|
+ float prv_lim_value;
|
|
|
+ float next_lim_tmp;
|
|
|
+ if (i < (ARRAY_SIZE(mos_temp_lim)-1)) {
|
|
|
+ prv_lim_value = (float)mos_temp_lim[i + 1].limit_value;
|
|
|
+ }else {
|
|
|
+ prv_lim_value = 100.0f; //最低一级限流
|
|
|
+ }
|
|
|
+ if (i != 0) {
|
|
|
+ next_lim_tmp = (float)mos_temp_lim[i - 1].enter_pointer;
|
|
|
+ }else {
|
|
|
+ next_lim_tmp = (float)lim->enter_pointer + 10.0f; //最大一级限流
|
|
|
+ }
|
|
|
+ float delta_tmp = (next_lim_tmp - (float)lim->enter_pointer);
|
|
|
+ float delta_value = (prv_lim_value - (float)lim->limit_value);
|
|
|
+ float curr_value = prv_lim_value - (float)(temp - lim->enter_pointer)/delta_tmp * delta_value;
|
|
|
+ curr_value = fclamp(curr_value, 0, prv_lim_value);
|
|
|
+ lim_value = (u16)(((float)gear->n_max_trq * curr_value) / 100.0f);
|
|
|
err_add_record(FOC_CRIT_MOS_TEMP_Err, temp);
|
|
|
mc_set_mos_lim_level(i + 1);
|
|
|
return lim_value;
|
|
|
@@ -129,17 +167,26 @@ static u16 _mos_limit(void) {
|
|
|
return HW_LIMIT_NONE;
|
|
|
}
|
|
|
|
|
|
-u16 torque_temp_high_limit(void) {
|
|
|
+/* this maybe limit power or torque, based on the current power */
|
|
|
+u16 motor_temp_high_limit(void) {
|
|
|
+ if (!_inited) {
|
|
|
+ _inited = true;
|
|
|
+ limiter_init();
|
|
|
+ }
|
|
|
+ return _motor_limit();
|
|
|
+}
|
|
|
+
|
|
|
+/* limit the max torque(max phase current) */
|
|
|
+u16 mos_temp_high_limit(void) {
|
|
|
if (!_inited) {
|
|
|
_inited = true;
|
|
|
limiter_init();
|
|
|
}
|
|
|
- u16 motor_lim = _motor_limit();
|
|
|
- u16 mos_lim = _mos_limit();
|
|
|
- return min(motor_lim, mos_lim);
|
|
|
+ return _mos_limit();
|
|
|
}
|
|
|
|
|
|
-u16 vbus_current_vol_lower_limit(void) {
|
|
|
+/* limit the DC bus current */
|
|
|
+u16 vbus_under_vol_limit(void) {
|
|
|
if (!_inited) {
|
|
|
_inited = true;
|
|
|
limiter_init();
|