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.

PFC2PhiL範例 Q格式問題



如題,要如何判斷該程式中的參數是用哪種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;

  • 应该是这一段:

    #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

    参数一般不会这么大

  • 你好:关于这个PFC2PhiL套件中代码,我有一个小疑问请教:在PWMDRV_PFC2PhiL.asm中,有个指针声明,但是我在整个工程中怎么都没找到这个指针指向的变量,代码如下:

    PWMDRV_PFC2PhiL_Duty:n: .usect "PWMDRV_PFC2PhiL_Section",2,1,1 ; Input Terminal 1, Duty
    _PWMDRV_PFC2PhiL_Adj:n: .usect "PWMDRV_PFC2PhiL_Section",2,1,1 ; Input Terminal 2
    _PWMDRV_PFC2PhiL_Period:n: .usect "PWMDRV_PFC2PhiL_Section",2,1,1

    ;Publish Terminal Pointers for access from the C environment
    ;===========================================================
    .def _PWMDRV_PFC2PhiL_Duty:n:
    .def _PWMDRV_PFC2PhiL_Adj:n:
    .def _PWMDRV_PFC2PhiL_Period:n:

    就是这个:def _PWMDRV_PFC2PhiL_Period指针,按注释我知道是PWM的周期寄存器值,可是在main.c中没有找到这个量的指针的声明,和指向的变量,

    以上,如有时间请帮忙看看这个例程,谢谢!

  • 下列這段程式,根據我的理解應該是算Q0吧,也就是實數部分,而我的問題是,要如何知道這是使用哪種格式,因為在assembly運算中會影響到結果.

    #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

  • 在main.c裡這函數,300就是對應def _PWMDRV_PFC2PhiL_Period,只是原程式在應用上不是用變數來設計,而是直接給定值.

    PWM_PFC2PHIL_CNF(1, 300);

  • 在汇编程序中