mirror of https://github.com/rusefi/bldc.git
Include integrator in current control output one cycle earlier
This commit is contained in:
parent
dcb0b47f94
commit
465a801076
|
@ -3776,9 +3776,6 @@ static void control_current(motor_all_state_t *motor, float dt) {
|
|||
float Ierr_d = state_m->id_target - state_m->id;
|
||||
float Ierr_q = state_m->iq_target - state_m->iq;
|
||||
|
||||
state_m->vd = state_m->vd_int + Ierr_d * conf_now->foc_current_kp * d_gain_scale; //Feedback (PI controller). No D action needed because the plant is a first order system (tf = 1/(Ls+R))
|
||||
state_m->vq = state_m->vq_int + Ierr_q * conf_now->foc_current_kp;
|
||||
|
||||
float ki = conf_now->foc_current_ki;
|
||||
if (conf_now->foc_temp_comp) {
|
||||
ki = motor->m_current_ki_temp_comp;
|
||||
|
@ -3787,6 +3784,10 @@ static void control_current(motor_all_state_t *motor, float dt) {
|
|||
state_m->vd_int += Ierr_d * (ki * d_gain_scale * dt);
|
||||
state_m->vq_int += Ierr_q * (ki * dt);
|
||||
|
||||
// Feedback (PI controller). No D action needed because the plant is a first order system (tf = 1/(Ls+R))
|
||||
state_m->vd = state_m->vd_int + Ierr_d * conf_now->foc_current_kp * d_gain_scale;
|
||||
state_m->vq = state_m->vq_int + Ierr_q * conf_now->foc_current_kp;
|
||||
|
||||
// Decoupling. Using feedforward this compensates for the fact that the equations of a PMSM
|
||||
// are not really decoupled (the d axis current has impact on q axis voltage and visa-versa):
|
||||
// Resistance Inductance Cross terms Back-EMF (see www.mathworks.com/help/physmod/sps/ref/pmsm.html)
|
||||
|
|
Loading…
Reference in New Issue