数字式开关电源的PID控制
合集下载
相关主题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
for (unsigned int i = 1000; i; i--);
}Baidu Nhomakorabea
while (IFG1 & OFIFG); // Test osc fault flag
FLL_CTL1 = SELS; // Select SMCLK source as XT2CLK
}
/**********初始化AD,计算输出**********/
数字式开关电源的PID控制
/********开关电源的数字化控制******/
/********所用拓扑为Buck,单片机msp430**********/
/*****PID算法实现开关电源的恒流、恒压、恒功率功能******/
/*********糖coffee@uestc************/
{
KeyScan();
if(Mode==0);PutDig(iU%10);PutDig(fU/10);;PutDig(iI%10);PutDig(fI/10);;PutDig(fP/10);PutDig(fP%10);
}
/***************处理电压PWM****************/
#define __init
/**********初始化时钟**********/
void init_clk()
{
FLL_CTL0 |= XCAP18PF; // Set load capacitance
FLL_CTL1 &= ~XT2OFF; // Turn on XT2
do
{
IFG1 &= ~OFIFG; // Clear oscillator fault flag
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 800;
TACTL |= MC_1; // Start Timer_A in UP mode
}
/**********初始化TB,驱动信号**********/
void init_TB()
{
TBCTL |= TBSSEL_2 + TBCLR + MC_1 + ID_0; // SCLK, Clear Tar
}break; //mod
case 0x17:{
if(Mode==0) {Us+=5;}
else if(Mode==1) {Is+=2;}
else {Ps+=10;}
}break; //++
case 0x0f:{
if(Mode==0) {Us-=5;}
else if(Mode==1) {Is-=2;}
switch(KeyTemp)
{
case 0x1e:{
if(Mode==0) {Us+=1;}
else if(Mode==1) {Is+=1;}
else {Ps+=5;}
}break; //+
case 0x1d:{
if(Mode==0) {Us-=1;}
else if(Mode==1) {Is-=1;}
else {Ps-=5;}
}break; //-
case 0x1b:{
Mode++;if(Mode>2)Mode=0;
if(Mode==0) {Us = 10;GUI_CU();}
else if(Mode==1) {Is = 10;GUI_CC();}
else {Ps = 10; GUI_CP();}
void deal_U()
{
if((Uout>Us*100+25)||(Uout+25<100*Us));PutDig(fUs);
}
/**********显示设置电流************/
void DisplaySetI()
{
unsigned char iIs,fIs;
iIs = Is/10; fIs = Is%10;
__interrupt void Timer_A (void)
{
ADC12CTL0 |= ADC12SC;
}
#endif
ADC12MCTL0 = INCH_0 + SREF_1;
ADC12MCTL1 = INCH_1 + SREF_1 + EOS;
ADC12CTL0 |= ENC;
}
/**********初始化TA,采样周期**********/
void init_TA()
{
TACTL = TASSEL_2 + TACLR; // sMCLK, clear TAR
Set_cursor(0,3);
PutcLCD('0');PutDig(iIs);PutcLCD('.');PutDig(fIs);
}
/**********显示设置功率************/
void DisplaySetP()
{
unsigned char iPs,fPs;
iPs = Ps/10; fPs = Ps%10;
else {Ps-=10;}
}break; //--
}
}
}
}
#endif
/**********************************************
PartinitHeadfile
**********************************************/
#ifndef __init
Set_cursor(0,3);
PutDig(iPs/10);PutDig(iPs%10);PutcLCD('.');PutDig(fPs);
}
/***********键盘初始化*************/
void initKey()
{
KeyDIR &= ~(Inc + Dec + MOD + ADD + PLU);
void init_ADC12()
{
P6SEL = 0x03; // Enable A/D channel inputs
ADC12CTL0 = ADC12ON + MSC + SHT0_8 + REFON + REF2_5V;//Turn on ADC12,set sampling time
ADC12CTL1 = SHP + ADC12SSEL_1 + CONSEQ_1; // Use sampling timer序列单次
/**********************************************
Part 1
**********************************************/
#include <>
#include ""
#include ""
#include ""
#include ""
}
/************键盘检测**************/
void KeyScan()
{
if(KeyIN != 0x1f)
{
Delay(100);
if(KeyIN != 0x1f)
{
unsigned char KeyTemp = KeyIN;
while(KeyIN != 0x1f);//等待按键松开
TBCCR0 = 400; // PWM = 20K
TBCCTL2 = OUTMOD_7;
TBCCR2 = 200; // CCR2 PWM duty cycle
P2DIR |= BIT3; // output
P2SEL |= BIT3; // TA1 otion
}
#pragma vector=TIMERA0_VECTOR
#include ""
#include ""
void main( void )
{
WDTCTL = WDTPW + WDTHOLD;
init_clk();
init_lcd();
GUI_CU();
init_ADC12();
init_TA();
init_TB();
initKey();
_EINT();
while(1)
}Baidu Nhomakorabea
while (IFG1 & OFIFG); // Test osc fault flag
FLL_CTL1 = SELS; // Select SMCLK source as XT2CLK
}
/**********初始化AD,计算输出**********/
数字式开关电源的PID控制
/********开关电源的数字化控制******/
/********所用拓扑为Buck,单片机msp430**********/
/*****PID算法实现开关电源的恒流、恒压、恒功率功能******/
/*********糖coffee@uestc************/
{
KeyScan();
if(Mode==0);PutDig(iU%10);PutDig(fU/10);;PutDig(iI%10);PutDig(fI/10);;PutDig(fP/10);PutDig(fP%10);
}
/***************处理电压PWM****************/
#define __init
/**********初始化时钟**********/
void init_clk()
{
FLL_CTL0 |= XCAP18PF; // Set load capacitance
FLL_CTL1 &= ~XT2OFF; // Turn on XT2
do
{
IFG1 &= ~OFIFG; // Clear oscillator fault flag
CCTL0 = CCIE; // CCR0 interrupt enabled
CCR0 = 800;
TACTL |= MC_1; // Start Timer_A in UP mode
}
/**********初始化TB,驱动信号**********/
void init_TB()
{
TBCTL |= TBSSEL_2 + TBCLR + MC_1 + ID_0; // SCLK, Clear Tar
}break; //mod
case 0x17:{
if(Mode==0) {Us+=5;}
else if(Mode==1) {Is+=2;}
else {Ps+=10;}
}break; //++
case 0x0f:{
if(Mode==0) {Us-=5;}
else if(Mode==1) {Is-=2;}
switch(KeyTemp)
{
case 0x1e:{
if(Mode==0) {Us+=1;}
else if(Mode==1) {Is+=1;}
else {Ps+=5;}
}break; //+
case 0x1d:{
if(Mode==0) {Us-=1;}
else if(Mode==1) {Is-=1;}
else {Ps-=5;}
}break; //-
case 0x1b:{
Mode++;if(Mode>2)Mode=0;
if(Mode==0) {Us = 10;GUI_CU();}
else if(Mode==1) {Is = 10;GUI_CC();}
else {Ps = 10; GUI_CP();}
void deal_U()
{
if((Uout>Us*100+25)||(Uout+25<100*Us));PutDig(fUs);
}
/**********显示设置电流************/
void DisplaySetI()
{
unsigned char iIs,fIs;
iIs = Is/10; fIs = Is%10;
__interrupt void Timer_A (void)
{
ADC12CTL0 |= ADC12SC;
}
#endif
ADC12MCTL0 = INCH_0 + SREF_1;
ADC12MCTL1 = INCH_1 + SREF_1 + EOS;
ADC12CTL0 |= ENC;
}
/**********初始化TA,采样周期**********/
void init_TA()
{
TACTL = TASSEL_2 + TACLR; // sMCLK, clear TAR
Set_cursor(0,3);
PutcLCD('0');PutDig(iIs);PutcLCD('.');PutDig(fIs);
}
/**********显示设置功率************/
void DisplaySetP()
{
unsigned char iPs,fPs;
iPs = Ps/10; fPs = Ps%10;
else {Ps-=10;}
}break; //--
}
}
}
}
#endif
/**********************************************
PartinitHeadfile
**********************************************/
#ifndef __init
Set_cursor(0,3);
PutDig(iPs/10);PutDig(iPs%10);PutcLCD('.');PutDig(fPs);
}
/***********键盘初始化*************/
void initKey()
{
KeyDIR &= ~(Inc + Dec + MOD + ADD + PLU);
void init_ADC12()
{
P6SEL = 0x03; // Enable A/D channel inputs
ADC12CTL0 = ADC12ON + MSC + SHT0_8 + REFON + REF2_5V;//Turn on ADC12,set sampling time
ADC12CTL1 = SHP + ADC12SSEL_1 + CONSEQ_1; // Use sampling timer序列单次
/**********************************************
Part 1
**********************************************/
#include <>
#include ""
#include ""
#include ""
#include ""
}
/************键盘检测**************/
void KeyScan()
{
if(KeyIN != 0x1f)
{
Delay(100);
if(KeyIN != 0x1f)
{
unsigned char KeyTemp = KeyIN;
while(KeyIN != 0x1f);//等待按键松开
TBCCR0 = 400; // PWM = 20K
TBCCTL2 = OUTMOD_7;
TBCCR2 = 200; // CCR2 PWM duty cycle
P2DIR |= BIT3; // output
P2SEL |= BIT3; // TA1 otion
}
#pragma vector=TIMERA0_VECTOR
#include ""
#include ""
void main( void )
{
WDTCTL = WDTPW + WDTHOLD;
init_clk();
init_lcd();
GUI_CU();
init_ADC12();
init_TA();
init_TB();
initKey();
_EINT();
while(1)