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/UCD3138PFCEVM-026: UCD3138PFCEVM-026-iv.i_target_average

Part Number: UCD3138PFCEVM-026

Tool/software: Code Composer Studio

hello everyone,

why is that iv.i_target_average variable in Q14?

Can't come out with that.

any thought?

Tom 

  • I assume you're talking about this code:

     iv.i_target_average = ((iv.vff_multiplier >> 5) * proportional_integral(iv.vbus_target - iv.adc_avg[VBUS_CHANNEL])) >> 11;  //Q10*Q15>>11 = Q14

    The iv.vff_multiplier is Q15, and it gets shifted by 5, so it's Q10.  The iv.vbus_target and iv.adc_avg[VBUS_CHANNEL] are Q12 from the ADC, but proportional_integral multiplies them by Q15 coefficients, and then shifts them right by only 12, so they become Q15.  So when the two are multiplied and then shifted right by 11, you get a Q14. 

    Q notation is pretty arbitrary, and I don't really like designing with Q notation alone.  I prefer to do a spreadsheet of the process, with a column showing the actual voltage and current next to the numbers being used in the calculation. 

    For speed in the interrupt, we put everything in ADC and DAC scaling.  But all that can be translated to voltage and current.  And the vff_multiplier is a multiplier that goes from voltage to current.  So if you figure out the translation for all the fixed point numbers, you can look and see what is happening in terms of actual voltages and currents, and make sure it's right.  Doing a spreadsheet may also be helpful for scaling things properly, getting good dynamic range without overflow.  I almost always use this technique when I'm doing something like this.