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.
Hi,
trying to solve a small mistery. First, just to confirm the pid.c in motorware 13 only contains the PI part of the full PID controller. On this assumption i tried to add some variables to _PID_Obj_, only to find that things get messed up.
the controller is TMS320F28069M.
Can anyone help to understand what is going on here.
Regards,
Paul
in MotorWare there are modules for both PI and PID
We use the modules for PID in everything we do. You can see they are included in the project files and we use PID_ functions in ctrl.c, and all the objects have APIs that access the Kd term.
// set the default Id PID controller parameters
Kp = _IQ(0.1);
Ki = _IQ(pUserParams->ctrlPeriod_sec/0.004);
Kd = _IQ(0.0);
outMin = _IQ(-0.95);
outMax = _IQ(0.95);
PID_setGains(obj->pidHandle_Id,Kp,Ki,Kd);
CTRL_setGains(handle,CTRL_Type_PID_Id,Kp,Ki,Kd);
But you are correct that with current and speed loops the D term is set to 0 so you are really just using PI controls. It brings no benefits to these types of control loops. In motor/motion control they are typically only used in position control systems.
Dave Wilson has a series of blogs about PI/PID controls that may interest you.
http://e2e.ti.com/members/1452723/blogs/default.aspx
Hello Chris,
Please check this code that is copied from pid.h. I believe this is also used by the controller.
//! \brief Runs the PID controller
//! \param[in] handle The PID controller handle
//! \param[in] refValue The reference value to the controller
//! \param[in] fbackValue The feedback value to the controller
//! \param[in] pOutValue The pointer to the controller output value
static inline void PID_run(PID_Handle handle,const _iq refValue,const _iq fbackValue,_iq *pOutValue)
{
PID_Obj *obj = (PID_Obj *)handle;
_iq Error;
_iq Up,Ui;
Error = refValue - fbackValue;
Ui = obj->Ui; // load the previous integral output
Up = _IQmpy(obj->Kp,Error); // Compute the proportional output
Ui = _IQsat(Ui + _IQmpy(obj->Ki,Up),obj->outMax,obj->outMin); // Compute the integral output
obj->Ui = Ui; // store the intetral output
obj->refValue = refValue;
obj->fbackValue = fbackValue;
*pOutValue = _IQsat(Up + Ui,obj->outMax,obj->outMin); // Saturate the output
return;
} // end of PID_run() function
In this code Kd is not used.
Anyway, my problem is not that, but when i add a variable to the pid object, the all kind of strange things happen.
//! \brief Defines the PID controller object
//!
typedef struct _PID_Obj_
{
_iq Kp; //!< the proportional gain for the PID controller
_iq Ki; //!< the integral gain for the PID controller
_iq Kd; //!< the derivative gain for the PID controller
_iq Ui; //!< the integrator start value for the PID controller
_iq refValue; //!< the reference input value
_iq fbackValue; //!< the feedback input value
_iq outMin; //!< the minimum output value allowed for the PID controller
_iq outMax; //!< the maximum output value allowed for the PID controller
_ie last_error;
} PID_Obj;
Like in the code above.
Thanks,
Paul
Paul van Ruth said:In this code Kd is not used.
You are correct. Kd is in the structure but is not used. I'll file this as a bug. I agree that if this is a PID controller the Kd term needs to be in the control law in case Kd != 0.
Paul van Ruth said:Anyway, my problem is not that, but when i add a variable to the pid object, the all kind of strange things happen.
Are you using a lab where pid.c/.h is in your user code and is NOT being called from the on-chip ROM?
Thank you for your response.
I'm using lab12b. This runs the ctrl and pid.c/h from ram, right?
Regards,
Paul
correct. only 2a uses the forward FOC control in ROM.
I don't understand why adding another member to the PID structure would be causing issues. what exactly is happening?