SPRUHJ1I January 2013 – October 2021 TMS320F2802-Q1 , TMS320F28026-Q1 , TMS320F28026F , TMS320F28027-Q1 , TMS320F28027F , TMS320F28027F-Q1 , TMS320F28052-Q1 , TMS320F28052F , TMS320F28052F-Q1 , TMS320F28052M , TMS320F28052M-Q1 , TMS320F28054-Q1 , TMS320F28054F , TMS320F28054F-Q1 , TMS320F28054M , TMS320F28054M-Q1 , TMS320F2806-Q1 , TMS320F28062-Q1 , TMS320F28062F , TMS320F28062F-Q1 , TMS320F28068F , TMS320F28068M , TMS320F28069-Q1 , TMS320F28069F , TMS320F28069F-Q1 , TMS320F28069M , TMS320F28069M-Q1
The third parameter to consider when doing the R over L measurement is the time to do this measurement. This is configured in user.c as follows, and can be changed if needed, although the default setting would work for most of the cases:
pUserParams->estWaitTime[EST_State_RoverL] = (uint_least32_t)(5.0 * USER_EST_FREQ_Hz);
Figure 7-12 shows how this current is injected. The configured parameters are highlighter in red, 5 seconds duration, 1.0 A / 2 = 0.5 A of current amplitude, and 100 Hz.
The resulting value of the R-over-L state can be read from the estimator by calling the following function, returning the RoverL ratio.
// Code example to get RoverL into a variable
float_t RoverL = CTRL_getRoverL(ctrlHandle);
Another method of checking the resulting estimation of the RoverL state is by calling two functions, one for the high frequency resistance estimation (Rhf) and one for the high frequency inductance estimation (Lhf). The following code example uses these two functions to have local copies of the resulting value during the RoverL state:
// Code example to get high frequency R (Rhf) and high frequency inductance
// (Lhf) to variables
float_t Rhf = CTRL_getRhf(ctrlHandle);
float_t Lhf = CTRL_getLhf(ctrlHandle);
float_t RoverL = Rhf/Lhf;
The resulting RoverL calculated in the above code example is identical to what the function CTRL_getRoverL() returns.
If motor identification is bypassed, users can use the following code example to calculate RoverL constant based on parameters provided in user.h file:
// Code example to get RoverL into a variable based on user.h parameters
#define USER_MOTOR_Rs (4.0)
#define USER_MOTOR_Ls_d (0.03)
float_t RoverL = USER_MOTOR_Rs/USER_MOTOR_Ls_d;
Ultimately, the RoverL ratio is used by the controller object (CTRL_Obj) to initialize the current controller gains according to this ratio. Figure 7-13 shows how the current controller gains are internally set by the controller object (CTRL_Obj). The code listing shown here is for illustration purposes only, to show the math behind the initial setting of the current controllers. Since the code is implemented internally in the controller, user does not need to implement it.
// get the full scale current and voltage values from #defines in user.h
#define USER_IQ_FULL_SCALE_CURRENT_A (10.0)
#define USER_IQ_FULL_SCALE_VOLTAGE_V (48.0)
// deriving controller period in seconds from #defines in user.h
#define USER_NUM_ISR_TICKS_PER_CTRL_TICK (1)
#define USER_PWM_FREQ_kHz (15.0)
#define USER_PWM_PERIOD_usec (1000.0/USER_PWM_FREQ_kHz)
#define USER_ISR_PERIOD_usec USER_PWM_PERIOD_usec
#define USER_CTRL_PERIOD_usec (USER_ISR_PERIOD_usec*USER_NUM_ISR_TICKS_PER_CTRL_TICK)
#define USER_CTRL_PERIOD_sec ((float_t)USER_CTRL_PERIOD_usec/(float_t)1000000.0)
// get Lhf and RoverL from the controller object
float_t RoverL = CTRL_getRoverL(ctrlHandle);
float_t Lhf = CTRL_getLhf(ctrlHandle);
// get full scale current and voltage values in local variables
float_t fullScaleCurrent = USER_IQ_FULL_SCALE_CURRENT_A;
float_t fullScaleVoltage = USER_IQ_FULL_SCALE_VOLTAGE_V;
// get the controller period in seconds in a local variable
float_t ctrlPeriod_sec = USER_CTRL_PERIOD_sec;
// get the controller object handle
CTRL_Obj *obj = (CTRL_Obj *)ctrlHandle;
// set the Id controller gains
Kp = _IQ((0.25*Lhf*fullScaleCurrent)/(ctrlPeriod_sec*fullScaleVoltage));
Ki = _IQ(RoverL*ctrlPeriod_sec);
Kd = _IQ(0.0);
PID_setGains(obj->pidHandle_Id,Kp,Ki,Kd);
PID_setUi(obj->pidHandle_Id,_IQ(0.0));
CTRL_setGains(ctrlHandle,CTRL_Type_PID_Id,Kp,Ki,Kd);
// set the Iq controller gains
Kp = _IQ((0.25*Lhf*fullScaleCurrent)/(ctrlPeriod_sec*fullScaleVoltage));
Ki = _IQ(RoverL*ctrlPeriod_sec);
Kd = _IQ(0.0);
PID_setGains(obj->pidHandle_Iq,Kp,Ki,Kd);
PID_setUi(obj->pidHandle_Iq,_IQ(0.0));
CTRL_setGains(ctrlHandle,CTRL_Type_PID_Iq,Kp,Ki,Kd);