TI中文支持网
TI专业的中文技术问题搜集分享网站

High Voltage PFC Developer's Kit program quetion

如題所說,controlSUITE裡的範例,部份程式看不懂,希望有人能解惑,謝謝。

一、 參數宣告部份:

1. InvVac為什麼設定32767

2. MaxQ24ref為什麼設定0x00FFFFFF,如果改MaxQ16ref又會等於多少呢?

部份程式如下:

// —————————- DPLIB Variables ———————————
// Declare the net variables being used by the DP Lib Macro here

volatile long InvVac = 32767;
volatile long MaxQ24ref = 0x00FFFFFF; // Maximum Q24 number

二、 副程式:

程式中的Scale_Factor、shoulder 參數的設計是依據什麼呢?如Scale_Factor = 1、shoulder = 102400;

void B3(void) // CompAmpltd and shoulder calculation based on Line-Load conditions
//—————————————-
{
if (auto_compensate == 1)
{
switch (range)
{
case 0:
//if (Gui_VacLineAvg < 7680) // 120V
if (VacLineAvg < _IQ24(0.29)) // 120Vac=0.29*3.3*3022/22/1.1 (Rup=3M,Rdown=22K,1.1=本程式多設的波行因數值)
{
Scale_Factor = 1;
shoulder = 102400; // 102400(Q24) = 200(Q15)
range = 0;
}
else range = 1;
break;

case 1:
//if (Gui_VacLineAvg > 7488 && Gui_VacLineAvg < 8960) // 117V & 140V
if (VacLineAvg > _IQ24(0.285) && VacLineAvg < _IQ24(0.34)) // 117V & 140V
{
Scale_Factor = 2;
shoulder = 128000; // 128000(Q24) = 250(Q15)
range = 1;
}
else
{
//if (Gui_VacLineAvg > 8960) range = 2;
if (VacLineAvg > _IQ24(0.34)) range = 2;
else range = 0;
}
break;

case 2:
//if (Gui_VacLineAvg > 8640 && Gui_VacLineAvg < 11520) // 135V & 180V
if (VacLineAvg > _IQ24(0.33) && VacLineAvg < _IQ24(0.44)) // 135V & 180V
{
Scale_Factor = 4; // 3 or 4??
shoulder = 153600; // 153600(Q24) = 300(Q15)
range = 2;
}
else
{
//if (Gui_VacLineAvg > 11520) range = 3;
if (VacLineAvg > _IQ24(0.44)) range = 3;
else range = 1;
}
break;

case 3:
//if (Gui_VacLineAvg > 11200 && Gui_VacLineAvg < 14720) // 175V & 230V
if (VacLineAvg > _IQ24(0.42) && VacLineAvg < _IQ24(0.56)) // 175V & 230V
{
Scale_Factor = 6; // 6 or 8??
shoulder = 204800; // 204800(Q24) = 400(Q15)
range = 3;
}
else
{
//if (Gui_VacLineAvg > 14720) range = 4;
if (VacLineAvg > _IQ24(0.56)) range = 4;
else range = 2;
}
break;

case 4:
//if (Gui_VacLineAvg > 14400) // 225V
if (VacLineAvg > _IQ24(0.55)) // 225V
{
Scale_Factor = 7; // 8 or 9??
shoulder = 256000; // 256000(Q24) = 500(Q15)
range = 4;
}
else
range = 3;
break; }

// Following calculations are done in Q15 for simplicity
//if (Gui_VpfcSet > 19200) // VpfcSet > 300V ,Gui_VpfcSet=IQ6 -> 19200/2^6=300
if (VpfcSet > _IQ24(0.67)) // VpfcSet > 300V
{
Comp_temp1 = (1250 – Input_Power)*Scale_Factor;

if (Comp_temp1 < 0) Comp_temp1 = 0; // Changed This

// Comp_temp2 = (long)Comp_temp1 * ((long)Gui_VacLineAvg – 5440)/12800.0; // (Vacin – 85)/(285-85) –> 12800 = 200*Kscale
Comp_temp2 = (long)Comp_temp1 * ((long)VacLineAvg – 5440)/12800.0; // (Vacin – 85)/(285-85) –> 12800 = 200*Kscale
}
else
Comp_temp2 = 0;

CompAmpltd = (long)(Comp_temp2)<<15; //Q30 = Q15<<15

}

else // if not auto_compensate
{
CompAmpltd = (long)(Gui_SetCompAmpltd)<<15; //Q30 = Q15<<15
shoulder = (long)(Gui_Setshoulder)<<9; //Q24 = Q15<<9}
//—————–
//the next time CpuTimer1 'counter' reaches Period value go to B1
B_Task_Ptr = &B1; //—————–
}

三、這段是什麼意思呢?

// Configure the Trip Mechanism for the PFC
EALLOW;//===========================================================================
// Define an event (DCAEVT2) based on Comparator 1 Output
EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP1OUT; // DCAH = Comparator 1 output
EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = DC_COMP2OUT; // DCBH = Comparator 2 output
EPwm1Regs.TZDCSEL.bit.DCAEVT1 = TZ_DCAH_HI; // DCAEVT1 = DCAH high(will become active
EPwm1Regs.TZDCSEL.bit.DCBEVT1 = TZ_DCBH_HI; // DCBEVT1 = DCAH high(will become active
// as Comparator output goes high)
EPwm1Regs.DCACTL.bit.EVT1SRCSEL = DC_EVT1; // DCAEVT2 = DCAEVT2 (not filtered)
EPwm1Regs.DCACTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;// Take async path

EPwm1Regs.DCBCTL.bit.EVT1SRCSEL = DC_EVT1; // DCAEVT2 = DCAEVT2 (not filtered)
EPwm1Regs.DCBCTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;// Take async path

// Enable DCAEVT1 and DCBEVT1 as a one-shot source
// Note: DCxEVT1 events can be defined as one-shot.
// DCxEVT2 events can be defined as cycle-by-cycle.
EPwm1Regs.TZSEL.bit.DCAEVT1 = 1;
EPwm1Regs.TZSEL.bit.DCBEVT1 = 1;
// What do we want the OST/CBC events to do?
// TZA events can force EPWMxA
// TZB events can force EPWMxB
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO; // EPWM1A will go low EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_LO; // EPWM1B will go low

EDIS;

Jheng jaiming:

是否有哪位先進知道呢?還是有資料可以看呢?

如題所說,controlSUITE裡的範例,部份程式看不懂,希望有人能解惑,謝謝。

一、 參數宣告部份:

1. InvVac為什麼設定32767

2. MaxQ24ref為什麼設定0x00FFFFFF,如果改MaxQ16ref又會等於多少呢?

部份程式如下:

// —————————- DPLIB Variables ———————————
// Declare the net variables being used by the DP Lib Macro here

volatile long InvVac = 32767;
volatile long MaxQ24ref = 0x00FFFFFF; // Maximum Q24 number

二、 副程式:

程式中的Scale_Factor、shoulder 參數的設計是依據什麼呢?如Scale_Factor = 1、shoulder = 102400;

void B3(void) // CompAmpltd and shoulder calculation based on Line-Load conditions
//—————————————-
{
if (auto_compensate == 1)
{
switch (range)
{
case 0:
//if (Gui_VacLineAvg < 7680) // 120V
if (VacLineAvg < _IQ24(0.29)) // 120Vac=0.29*3.3*3022/22/1.1 (Rup=3M,Rdown=22K,1.1=本程式多設的波行因數值)
{
Scale_Factor = 1;
shoulder = 102400; // 102400(Q24) = 200(Q15)
range = 0;
}
else range = 1;
break;

case 1:
//if (Gui_VacLineAvg > 7488 && Gui_VacLineAvg < 8960) // 117V & 140V
if (VacLineAvg > _IQ24(0.285) && VacLineAvg < _IQ24(0.34)) // 117V & 140V
{
Scale_Factor = 2;
shoulder = 128000; // 128000(Q24) = 250(Q15)
range = 1;
}
else
{
//if (Gui_VacLineAvg > 8960) range = 2;
if (VacLineAvg > _IQ24(0.34)) range = 2;
else range = 0;
}
break;

case 2:
//if (Gui_VacLineAvg > 8640 && Gui_VacLineAvg < 11520) // 135V & 180V
if (VacLineAvg > _IQ24(0.33) && VacLineAvg < _IQ24(0.44)) // 135V & 180V
{
Scale_Factor = 4; // 3 or 4??
shoulder = 153600; // 153600(Q24) = 300(Q15)
range = 2;
}
else
{
//if (Gui_VacLineAvg > 11520) range = 3;
if (VacLineAvg > _IQ24(0.44)) range = 3;
else range = 1;
}
break;

case 3:
//if (Gui_VacLineAvg > 11200 && Gui_VacLineAvg < 14720) // 175V & 230V
if (VacLineAvg > _IQ24(0.42) && VacLineAvg < _IQ24(0.56)) // 175V & 230V
{
Scale_Factor = 6; // 6 or 8??
shoulder = 204800; // 204800(Q24) = 400(Q15)
range = 3;
}
else
{
//if (Gui_VacLineAvg > 14720) range = 4;
if (VacLineAvg > _IQ24(0.56)) range = 4;
else range = 2;
}
break;

case 4:
//if (Gui_VacLineAvg > 14400) // 225V
if (VacLineAvg > _IQ24(0.55)) // 225V
{
Scale_Factor = 7; // 8 or 9??
shoulder = 256000; // 256000(Q24) = 500(Q15)
range = 4;
}
else
range = 3;
break; }

// Following calculations are done in Q15 for simplicity
//if (Gui_VpfcSet > 19200) // VpfcSet > 300V ,Gui_VpfcSet=IQ6 -> 19200/2^6=300
if (VpfcSet > _IQ24(0.67)) // VpfcSet > 300V
{
Comp_temp1 = (1250 – Input_Power)*Scale_Factor;

if (Comp_temp1 < 0) Comp_temp1 = 0; // Changed This

// Comp_temp2 = (long)Comp_temp1 * ((long)Gui_VacLineAvg – 5440)/12800.0; // (Vacin – 85)/(285-85) –> 12800 = 200*Kscale
Comp_temp2 = (long)Comp_temp1 * ((long)VacLineAvg – 5440)/12800.0; // (Vacin – 85)/(285-85) –> 12800 = 200*Kscale
}
else
Comp_temp2 = 0;

CompAmpltd = (long)(Comp_temp2)<<15; //Q30 = Q15<<15

}

else // if not auto_compensate
{
CompAmpltd = (long)(Gui_SetCompAmpltd)<<15; //Q30 = Q15<<15
shoulder = (long)(Gui_Setshoulder)<<9; //Q24 = Q15<<9}
//—————–
//the next time CpuTimer1 'counter' reaches Period value go to B1
B_Task_Ptr = &B1; //—————–
}

三、這段是什麼意思呢?

// Configure the Trip Mechanism for the PFC
EALLOW;//===========================================================================
// Define an event (DCAEVT2) based on Comparator 1 Output
EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP1OUT; // DCAH = Comparator 1 output
EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = DC_COMP2OUT; // DCBH = Comparator 2 output
EPwm1Regs.TZDCSEL.bit.DCAEVT1 = TZ_DCAH_HI; // DCAEVT1 = DCAH high(will become active
EPwm1Regs.TZDCSEL.bit.DCBEVT1 = TZ_DCBH_HI; // DCBEVT1 = DCAH high(will become active
// as Comparator output goes high)
EPwm1Regs.DCACTL.bit.EVT1SRCSEL = DC_EVT1; // DCAEVT2 = DCAEVT2 (not filtered)
EPwm1Regs.DCACTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;// Take async path

EPwm1Regs.DCBCTL.bit.EVT1SRCSEL = DC_EVT1; // DCAEVT2 = DCAEVT2 (not filtered)
EPwm1Regs.DCBCTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;// Take async path

// Enable DCAEVT1 and DCBEVT1 as a one-shot source
// Note: DCxEVT1 events can be defined as one-shot.
// DCxEVT2 events can be defined as cycle-by-cycle.
EPwm1Regs.TZSEL.bit.DCAEVT1 = 1;
EPwm1Regs.TZSEL.bit.DCBEVT1 = 1;
// What do we want the OST/CBC events to do?
// TZA events can force EPWMxA
// TZB events can force EPWMxB
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO; // EPWM1A will go low EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_LO; // EPWM1B will go low

EDIS;

囧:

最后一段是通过外部比较器做一个过流保护,采用one-shot保护。

如題所說,controlSUITE裡的範例,部份程式看不懂,希望有人能解惑,謝謝。

一、 參數宣告部份:

1. InvVac為什麼設定32767

2. MaxQ24ref為什麼設定0x00FFFFFF,如果改MaxQ16ref又會等於多少呢?

部份程式如下:

// —————————- DPLIB Variables ———————————
// Declare the net variables being used by the DP Lib Macro here

volatile long InvVac = 32767;
volatile long MaxQ24ref = 0x00FFFFFF; // Maximum Q24 number

二、 副程式:

程式中的Scale_Factor、shoulder 參數的設計是依據什麼呢?如Scale_Factor = 1、shoulder = 102400;

void B3(void) // CompAmpltd and shoulder calculation based on Line-Load conditions
//—————————————-
{
if (auto_compensate == 1)
{
switch (range)
{
case 0:
//if (Gui_VacLineAvg < 7680) // 120V
if (VacLineAvg < _IQ24(0.29)) // 120Vac=0.29*3.3*3022/22/1.1 (Rup=3M,Rdown=22K,1.1=本程式多設的波行因數值)
{
Scale_Factor = 1;
shoulder = 102400; // 102400(Q24) = 200(Q15)
range = 0;
}
else range = 1;
break;

case 1:
//if (Gui_VacLineAvg > 7488 && Gui_VacLineAvg < 8960) // 117V & 140V
if (VacLineAvg > _IQ24(0.285) && VacLineAvg < _IQ24(0.34)) // 117V & 140V
{
Scale_Factor = 2;
shoulder = 128000; // 128000(Q24) = 250(Q15)
range = 1;
}
else
{
//if (Gui_VacLineAvg > 8960) range = 2;
if (VacLineAvg > _IQ24(0.34)) range = 2;
else range = 0;
}
break;

case 2:
//if (Gui_VacLineAvg > 8640 && Gui_VacLineAvg < 11520) // 135V & 180V
if (VacLineAvg > _IQ24(0.33) && VacLineAvg < _IQ24(0.44)) // 135V & 180V
{
Scale_Factor = 4; // 3 or 4??
shoulder = 153600; // 153600(Q24) = 300(Q15)
range = 2;
}
else
{
//if (Gui_VacLineAvg > 11520) range = 3;
if (VacLineAvg > _IQ24(0.44)) range = 3;
else range = 1;
}
break;

case 3:
//if (Gui_VacLineAvg > 11200 && Gui_VacLineAvg < 14720) // 175V & 230V
if (VacLineAvg > _IQ24(0.42) && VacLineAvg < _IQ24(0.56)) // 175V & 230V
{
Scale_Factor = 6; // 6 or 8??
shoulder = 204800; // 204800(Q24) = 400(Q15)
range = 3;
}
else
{
//if (Gui_VacLineAvg > 14720) range = 4;
if (VacLineAvg > _IQ24(0.56)) range = 4;
else range = 2;
}
break;

case 4:
//if (Gui_VacLineAvg > 14400) // 225V
if (VacLineAvg > _IQ24(0.55)) // 225V
{
Scale_Factor = 7; // 8 or 9??
shoulder = 256000; // 256000(Q24) = 500(Q15)
range = 4;
}
else
range = 3;
break; }

// Following calculations are done in Q15 for simplicity
//if (Gui_VpfcSet > 19200) // VpfcSet > 300V ,Gui_VpfcSet=IQ6 -> 19200/2^6=300
if (VpfcSet > _IQ24(0.67)) // VpfcSet > 300V
{
Comp_temp1 = (1250 – Input_Power)*Scale_Factor;

if (Comp_temp1 < 0) Comp_temp1 = 0; // Changed This

// Comp_temp2 = (long)Comp_temp1 * ((long)Gui_VacLineAvg – 5440)/12800.0; // (Vacin – 85)/(285-85) –> 12800 = 200*Kscale
Comp_temp2 = (long)Comp_temp1 * ((long)VacLineAvg – 5440)/12800.0; // (Vacin – 85)/(285-85) –> 12800 = 200*Kscale
}
else
Comp_temp2 = 0;

CompAmpltd = (long)(Comp_temp2)<<15; //Q30 = Q15<<15

}

else // if not auto_compensate
{
CompAmpltd = (long)(Gui_SetCompAmpltd)<<15; //Q30 = Q15<<15
shoulder = (long)(Gui_Setshoulder)<<9; //Q24 = Q15<<9}
//—————–
//the next time CpuTimer1 'counter' reaches Period value go to B1
B_Task_Ptr = &B1; //—————–
}

三、這段是什麼意思呢?

// Configure the Trip Mechanism for the PFC
EALLOW;//===========================================================================
// Define an event (DCAEVT2) based on Comparator 1 Output
EPwm1Regs.DCTRIPSEL.bit.DCAHCOMPSEL = DC_COMP1OUT; // DCAH = Comparator 1 output
EPwm1Regs.DCTRIPSEL.bit.DCBHCOMPSEL = DC_COMP2OUT; // DCBH = Comparator 2 output
EPwm1Regs.TZDCSEL.bit.DCAEVT1 = TZ_DCAH_HI; // DCAEVT1 = DCAH high(will become active
EPwm1Regs.TZDCSEL.bit.DCBEVT1 = TZ_DCBH_HI; // DCBEVT1 = DCAH high(will become active
// as Comparator output goes high)
EPwm1Regs.DCACTL.bit.EVT1SRCSEL = DC_EVT1; // DCAEVT2 = DCAEVT2 (not filtered)
EPwm1Regs.DCACTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;// Take async path

EPwm1Regs.DCBCTL.bit.EVT1SRCSEL = DC_EVT1; // DCAEVT2 = DCAEVT2 (not filtered)
EPwm1Regs.DCBCTL.bit.EVT1FRCSYNCSEL = DC_EVT_ASYNC;// Take async path

// Enable DCAEVT1 and DCBEVT1 as a one-shot source
// Note: DCxEVT1 events can be defined as one-shot.
// DCxEVT2 events can be defined as cycle-by-cycle.
EPwm1Regs.TZSEL.bit.DCAEVT1 = 1;
EPwm1Regs.TZSEL.bit.DCBEVT1 = 1;
// What do we want the OST/CBC events to do?
// TZA events can force EPWMxA
// TZB events can force EPWMxB
EPwm1Regs.TZCTL.bit.TZA = TZ_FORCE_LO; // EPWM1A will go low EPwm1Regs.TZCTL.bit.TZB = TZ_FORCE_LO; // EPWM1B will go low

EDIS;

Jheng jaiming:

回复 囧:

原來如此,那不知道囧大是否知道前兩個問題的答案呢?

赞(0)
未经允许不得转载:TI中文支持网 » High Voltage PFC Developer's Kit program quetion
分享到: 更多 (0)