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.

Compiler/TMS320F28027: Code used to average values in the solar experiment kit

Part Number: TMS320F28027
Other Parts Discussed in Thread: CONTROLSUITE

Tool/software: TI C/C++ Compiler

The following code is used in the kit.  It is to average 8 numbers.  I have question on the constant used and why the shift is 15.  I understand these are very elementary questions. 

    // BoxCar Averages - Input Raw samples into BoxCar arrays
    //----------------------------------------------------------------

     Uint32    HistPtr, temp_Scratch;         // Temp here means Temporary
     int16      Gui_Vout;                             // Q9
     int16      K_Vout;                                // Q15
     K_Vout=17050;

    temp_Scratch=0;
    for(i=0; i<8; i++)    temp_Scratch = temp_Scratch + Hist_Vout[i];
    Gui_Vout = ( (long) temp_Scratch * (long) K_Vout ) >> 15;

The "for loop" sums the 8 values in the array Hist_Vout.  What is the function  "(long) K_Vout )"?  How is the IQ math used here?  Why shift 15?

I run the code with a Xcode on a Mac to get a better understanding of how it works, but could not under stand the "K_Vout" and the shift 15.  Is the "(long) used to because of the multiply?

Any help would be great value.

Thanks

  • Refer to C:\ti\controlSUITE\development_kits\SolarExplorer_v1.1\~SolarExplorer-HWdevPkg\R5\Macros\SynchBuckBoost-DCDC-PanelEMU-LV

    see the xls file inside this folder, 

    All of this is construed such that K_Vout is taken from the KV value shown in the xls file, 

    and when you do the arithmetic , and shift you will get a valye in Q8 format that will be representative of the real value,

    In hindsight i do agree all of this is a very tough to understand .. but we had some legacy of 16bit processor code.. 

    We do not use this method anymore. 

  • Thanks for the input. I am getting a littler "smarter" with this but have a long way to go. I did find the xls file. How hard is it to change this to use the Q-Math format and is there any advantage other that making the code a little easier to read? My plan is to redesign the power stage for 200W and use a LaunachPad XL F28027 as the controller. Do you see any problems with such a design?

    I have not found "SolarExplorer_v1.1" . I am using "SolarExplorer_v1.0". After downloading CCSv7 to my PC, I looked for v1.1, but it was not in the development_kit directory. Additionally, I down loaded CCS7 to my mac. I have not found "SolarExplorer_v1.1" from ether down load. Are the changes in v1.1 needed.
  • Roger,

    For what you are looking at you do may not need v1.1,

    I believe that's a decision you need to make, the above code does use Q format , but you can use IQmath lib to make the code more readable.