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.

BLDC_sensorless code problem in DRV8312-C2-KIT

 

I hvae run the bldc_sensorless for the seven levels follow by the DRV8312-C2-KIT,and everything is ok,but when I what to get to know the detail how it works,I found some difficults in the code。

first of all:

1.we use the “pu” to let speed,pid control in  -1~1.and we can formulate the pu in to r/min by:

     v.Speed = _IQdiv(v.SpeedScaler,v.EventPeriod);    
     v.SpeedRpm = _IQmpy(v.BaseRpm,v.Speed);      

  But I was confuse by the definition,such as

  speed1.BaseRpm = 120*(BASE_FREQ/POLES);
  speed1.SpeedScaler = (Uint32)(ISR_FREQUENCY/(1*BASE_FREQ*0.001));

  how it comes from?What does it mean?

What I know only  is:

// Define the base quantites            基值   用于设置标幺话的基值用

#define BASE_VOLTAGE    66.32      // Base peak phase voltage (volt), maximum measurable DC Bus/sqrt(3)
#define BASE_CURRENT    5             // Base peak phase current (amp) , maximum measurable peak current
#define BASE_FREQ       200            // Base electrical frequency (Hz)
#define MAX_RPM         3000            // max RMP

// Define the ISR frequency (kHz)
#define ISR_FREQUENCY 40
#define PWM_FREQUENCY 20

 

2.Something about PID:

    pid1_idc.param.Kp = _IQ(3.176*BASE_CURRENT/BASE_VOLTAGE);
    pid1_idc.param.Kr = _IQ(1.0);
    pid1_idc.param.Ki = _IQ(T/0.0005);

   In the code  we just use PI control ,3.176*BASE_CURRENT/BASE_VOLTAGE,what does it means?how can I adjust by my self?Is this have some matter with “pu”?

 

3.please help me to point out where I error:

   the source code in BLDC_sensorless  to let the PID to control PWM is :(1061)

   pwm1.DutyFunc = (int16)_IQtoQ15(pid1_spd.term.Out);   // controlled Speed duty-cycle 

  the code just use the pid.out to control the PWM ,but what I think is:

   pwm1.DutyFunc = pwm1.DutyFunc + (int16)_IQtoQ15(pid1_spd.term.Out);  

 

4.   cmtn1.Va =  _IQ15toIQ((AdcResult.ADCRESULT4<<3)-BemfA_offset);
      cmtn1.Vb =  _IQ15toIQ((AdcResult.ADCRESULT5<<3)-BemfB_offset); 
      cmtn1.Vc =  _IQ15toIQ((AdcResult.ADCRESULT6<<3)-BemfC_offset);

      I know that  AdcResult.ADCRESULTx is the result we want in ADC. It can be 0~0xfff,am I right?but why ADCRESULTx shift 3 can turn out tobe IQ15?I think it is IQ3....

 

Thanks for help

 

  • 1.  Base rpm is a speed reference. The per unit (pu) values are with respect to this base speed. It is arbitrary though somewhat related to the rated speed of the motor. Speed scalar converts the per unit value to a corresponding rpm value.

    2. Once again, PID gains in pu can be altered any way you like. There are several posts on the forum about PID tuning. The expression 3.176*BASE_CURRENT/BASE_VOLTAGE seems to have worked well for the TI developers. Plugging in the supplied values, this expression evaluates to a 0.24 pu value which is used as the proportional gain in the current PI loop.To adjust these gains, you could simulate some sort of a step response. Use the datalogger or a simple array to plot the current response. 

    Normally when one calculates gains for the current loop, the units of proportional gain, for instance, are volts/amp. In per unit notation, they will be volts/(5 amps). If you can accurately account for the time delay in the discrete system and simulate, you could potentially calculate very accurate gains for the current and speed PID.

    3. Not sure why you would want to add the previous PWM Duty Cycle value to the speed PID output. The PID output determines whether to apply more or less voltage each cycle. Previous errors are incorporated in the integral term of the PID.

    4. The ADC has 12 bits resolution as you correctly note, because of which ADCRESULT can also be interpreted as IQ12. Therefore, shifting left by 3 bits converts it to IQ15 representation.

     

    Others, especially TI folks, could verify this and/or correct where appropriate.