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.

DRV8312-C2-KIT: Technical Background of ADC-Result conversion

Part Number: DRV8312-C2-KIT
Other Parts Discussed in Thread: INSTASPIN-BLDC

Hey there,

I am working with the DRV8312-C2-Kit and I am looking into the elektromotive force measurement and the InstaSPIN-BLDC-function.

I found the definition of InstaSPIN-BLDC:

typedef struct

{

int32 Vag; // Internal: Vag input -- contains real Va + VaOffset --> referenced to ground (_iq)

int32 Vbg; // Internal: Vbg input -- contains real Vb + VbOffset --> referenced to ground (_iq)

int32 Vcg; // Internal: Vcg input -- contains real Vc + VcOffset --> referenced to ground (_iq)

int32 Van; // Internal: Va to neutral (_iq)

int32 Vbn; // Internal: Vb to neutral (_iq)

int32 Vcn; // Internal: Vc to neutral (_iq)

int32 VaOffset; // VaOffset (_iq)

int32 VbOffset; // VbOffset (_iq)

int32 VcOffset; // VcOffset (_iq)

int32 Int_Threshold; // Input: Integration threshold where a commutate happens (_iq)

Eintbool Vint_lockout; // Internal: Flyback voltage lockout flag

int32 *Vphase; // Internal: Pointer to the Phase voltage to count (_iq)

int32 V_int; // Output: Integrator (_iq)

Eintbool Comm_Trig; // Output: Commutation trigger impulse

Uint16 State; // Input: Values 0 to 5

} INSTASPIN_BLDC;

The Vag means voltage between OUT_A and ground, Van means voltage between OUT_A and the star connection point and VaOffset is the voltage between star connection point and ground.
That would mean Vag = Van + VaOffset.
Am I right here?

 

Going on, there are some lines in the MainISR I don't understand:
Why is the ADC-Result leftshifted three times/multiplied with eight?

iqVaIn = _IQ15toIQ((AdcResult.ADCRESULT1<<3));

 

The voltage divider for measuring phase voltages is giving the voltage between OUT_A and ground to the ADC.
The ADC-Result is written into Vag (which means the same, following my assumptions before).
So why is there an offset adjustment?

InstaSPIN_BLDC1.Vag = iqVaIn - InstaSPIN_BLDC1.VaOffset;

 

And last question is about the calibration. What is done in the following line?

InstaSPIN_BLDC1.VaOffset = _IQmpy(cal_filt_gain,iqVaIn) + InstaSPIN_BLDC1.VaOffset;


Thank you in advance!

Sarah

 

 

 

  • 1. No, Van is not equal to iqVaIn, and VaOffset is not the voltage between star connection point and ground. VaOffset, VbOffset, and VcOffset depend on the phase voltage sampling circuit of the hardware board, just need to get the calibration value every power on as below code, the value is sampled during the pwm outputs are off. Please refer to (BUILDLEVEL==LEVEL3) codes.
    InstaSPIN_BLDC1.VaOffset = _IQmpy(cal_filt_gain,iqVaIn) + InstaSPIN_BLDC1.VaOffset;
    2. For iqVaIn = _IQ15toIQ((AdcResult.ADCRESULT1<<3));, ADCRESULT1 is a 12bit value, use left shift to convert it to IQ15.
  • Hey,

    Thanks for answer, I checked it out and also read the code and documentation for BUILDLEVEL 3.
    I understood, that VaOffset is simply the correction of measurement failure and that the left-shifting operator is used for conversion.
    But I still have no idea how it actually works.
    Let me try to ask some more detailed questions:

    1. What is meant by Vag and Van in InstaSPIN-BLDC? Which physical quantity is hiding here?

    2. Is the expression Vag = Van + VaOffset applying? If not, is there some other expression, which determines the relationship between these three quantities?

    3. Why is the Offset substracted before handing over to InstaSPIN-BLDC in the following line?
    InstaSPIN_BLDC1.Vag = iqVaIn - InstaSPIN_BLDC1.VaOffset; // Adjust for offset of Va_in

    4. Which quantities are need to be handed over to InstaSPIN-BLDC at least, so it works correctly? Are there other combinations of input quantities possible?

    5. From where is the value for cal_filt_gain coming? I found the following code and looked into the circuit diagramm, but I have no idea how "cal_filt_gain" belongs to the hardware / technical background.
    //cutoff freq and time constant of the offset calibration LPF
    #define WC_CAL 100.0
    #define TC_CAL 1/WC_CAL

    // Define the ISR frequency (kHz)
    ISR_FREQUENCY=20;
    PWM_FREQUENCY=ISR_FREQUENCY;
    T = 0.001/ISR_FREQUENCY; // Samping period (sec), see parameter.h

    // Initialize the current offset calibration filter
    cal_filt_gain = _IQ(T/(T+TC_CAL));

    6. Why is the Offset calculated like "Offset = Measurement * Gain + Offset"? This looks more like an addition than averaging. And why is there a gain?
    InstaSPIN_BLDC1.VaOffset = _IQmpy(cal_filt_gain,iqVaIn) + InstaSPIN_BLDC1.VaOffset;

    I am really looking forward to your answer!

    Greetings,
    Sarah
  • Sorry, some information is not publicly disclosed that's included in instaSPIN BLDC library. I try to reply to your questions based on the example project.
    1. As you mentioned and found in project, Vag is the voltage of phase to ground, and Van is the voltage of phase to the neutral point of the motor.
    2. No, Van will be calculated from Vag, Vbg, and Vcg. Vaoffset is used for the calibration and calculation of Vag from the sampling phase voltage.
    3. As replied in the last message, InstaSPIN_BLDC1.VaOffset is calculated in "LEVEL 3" which depends on the hardware board.
    4. The three voltage variables (Vag, Vbg, and Vcg) are necessary for instaSPIN-BLDC to get the BEMF zero cross point for commutation control.
    5. That's not critical, it's calculated from the cut off frequency of the low pass frequency, is just used to get the Va/b/coffset. You could change the cut off frequency which must be far lower than the PWM frequency.
    6. As replied in question 5, it's an LPF to get an averaged calibration offset.
  • Hey!

    Thank you very much, this was really helpfull.
    I have just two more questions:

    I attached the circuit diagramm of the measuring circuit.
    It is directly copied from the documentation of the DRV8312-C2-Kit.

    1)
    According to this I calculated the cut off frequency:
    f_c = 1/(2*Pi*R38*C50) = 1/(2*Pi*95.3Kohms*0.047µF) = 35.5 Hz
    But in the software the cut off frequency WC_CAL is defined as 100.0.
    What did I miss? Where does WC_CAL come from?

    2)
    According to the circuit diagramm I calculated the relation between measured voltage and real voltage:
    IqVaIn / Offset = (R39||Z_C50)/(R38+R39||Z_C50)
     --> || means "parallel"
     --> Z_C50 means capacitive reactance of C50
    After some transformation I get:
    |Offset|/|IqVaIn| = sqrt[ (f/f_c)^2 + ((R38+R39)/R39)^2 ]
    But there is no accordance to the calculation in the Software: cal_filt_gain = T / T + TC_CAL
    So where does the equation "cal_filt_gain = T / T + TC_CAL" come from?

    I am looking forward to your answer!

    Sarah

  • 1. The W_CAL and T_CAL are just the parameters of a software low pass filter for offset calibration, is not related to the h/w voltage sampling circuit. You might set it to any value that's lower than the rated frequency of a motor.
    2. You might ignore the impedance of the filter capacitor to calculate the phase voltage since its value is far higher than the resistance.