This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28379S: output of PID Control

Part Number: TMS320F28379S

Tool/software: Code Composer Studio

Hi,

I am using "DCL_runPID_C4" and I am doing  test for finding proper Kp. Ki and Kd value.

I set the parameter of PID as follow,

pid1.Kp = 5.0f;
pid1.Ki = 100;//0.015f;
pid1.Kd = 0;//1.35f;
pid1.Kr = 1.0f;
pid1.c1 = 188.0296600613396f;
pid1.c2 = 0.880296600613396f;
pid1.d2 = 0.0f;
pid1.d3 = 0.0f;
pid1.i10 = 0.0f;
pid1.i14 = 1.0f;
pid1.Umax = 1000.0f;
pid1.Umin = -1000.0f;
pid1.sps = &spid;
pid1.css = &cpid;

And my test control loop is as follow,

rk = 1000.0f; // initial value for control reference
lk = 0.0f; // control loop not saturated

while(1)
{
  pos = EQEP_getPosition(EQEP1_BASE);

  if (pos & 0x80000)
  {
     s_pos = (0xffffffff - pos);
  }
  else
  {
    s_pos = -pos;
  }
  yk = (float) s_pos;

// external clamp for anti-windup reset
DCL_runClamp_C1(&lk, 10.0f, -10.0f);

// run PID controller
uk = DCL_runPID_C4(&pid1, rk, yk, lk);
Duty = abs(uk) % 1001;

......

 }

But, uk becomes zero at yk is 21000.0000f

I expected uk was zero at yk that is same with rk(=1000.0f)

What is the wrong of my expectation?

BR

Paul

  • Paul,

    Firstly, please use 100.0f and 0.0f for your Ki & Kd gains respectively so the compiler knows to treat them as floating point.

    An integrating controller should force yk to converge on rk. The problem here is you have disabled the integral path.

    The variable "lk" should be either 1.0f or 0.0f. Nothing else. That term is multiplied by the error inside the integral path, so setting it to 0.0f will *disable* (not enable) the integral path.  Refer to the controller diagram in the user's guide and the supporting description.  

    I recommend you set lk to 1.0f (not 0.0f) and not clamp it.

    Regards,

    Richard