如題,要如何判斷該程式中的參數是用哪種Q格式來運算,以Controlsuit的範例:PFC2PhiL 為例
在參數宣告中定義int16 K_VpfcOut ,但備註寫Q15,這Q15是怎麼來的
//Scaling Constants (values found via spreadsheet (HVPFC2PHIL-Calculations.xls)
int16 K_VpfcOut; // Q15
int16 K_VacLine; // Q15
int16 K_Ipfc1; // Q15
int16 K_Ipfc2; // Q15
int16 K_IpfcTotal; // Q15
int16 iK_VpfcSet; // Q14
for(i=0;i<HistorySize;i++)
{
Hist_VpfcOut[i]=0;
Hist_Ipfc1[i]=0;
Hist_Ipfc2[i]=0;
Hist_VacLineAvg[1]=0;
Hist_IpfcTotal[1]=0;
}
HistPtr=0;
#if defined(DSP2802x_DEVICE_H) || defined(DSP2803x_DEVICE_H)
K_Ipfc1 = 20357;
K_Ipfc2 = 20357;
K_IpfcTotal = 20357;
K_VpfcOut = 29011;
iK_VpfcSet = 18506;
K_VacLine = 25795;
#endif
// Voltage measurement calculated by:
// Gui_VacLineAvg = VacLineAvg * K_VacLine,
// Gui_Vpfcout = VpfcoutAvg * K_Vpfcout, where VpfcoutAvg = sum of 8 Vpfc_outR samples
//----------------------------------------------------------------
// view following variables in Watch Window as:
// Gui_VacLineAvg = Q6
// Gui_VpfcOut = Q6
// Gui_VpfcSet = Q6
temp_Scratch=0;
for(i=0; i<8; i++) temp_Scratch = temp_Scratch + Hist_VpfcOut[i];
Gui_VpfcOut = ( (long) temp_Scratch * (long) K_VpfcOut ) >> 15;