|
|
@@ -940,8 +940,9 @@ static __INLINE void PMSM_FOC_idq_Assign(void) {
|
|
|
/*called in media task */
|
|
|
void PMSM_FOC_idqCalc(void) {
|
|
|
if (gFoc_Ctrl.in.b_AutoHold) {
|
|
|
- gFoc_Ctrl.pi_lock.max = CONFIG_MAX_LOCK_TORQUE;
|
|
|
- gFoc_Ctrl.pi_lock.min = -CONFIG_MAX_LOCK_TORQUE;
|
|
|
+ float hold_torque = min(gFoc_Ctrl.protLim.s_TorqueLim, CONFIG_MAX_LOCK_TORQUE);
|
|
|
+ gFoc_Ctrl.pi_lock.max = hold_torque;
|
|
|
+ gFoc_Ctrl.pi_lock.min = -hold_torque;
|
|
|
float vel_count = motor_encoder_get_vel_count();
|
|
|
float errRef = 0 - vel_count;
|
|
|
gFoc_Ctrl.in.s_targetTorque = PI_Controller_Run(&gFoc_Ctrl.pi_lock ,errRef);
|