现在使用F28027做单相逆变器,使用PI控制器,详细程序见下面!
现在遇到逆变输出的正弦波过零附近出现畸变,电压和电流波形见附图
// -----------------------------------------------------------
// PIE Group 1 - MUXed into CPU INT1
// -----------------------------------------------------------
// INT1.1 Can also be ISR for INT10.1 when enabled
interrupt void ADCINT1_ISR(void)
{
signed int Width_Pulse=0;
signed int temp=0;
if(++sym_clock==400)
{
sym_clock=0;
Vol_Peak_Shadow=Vol_Peak;
Width_Compensate=-Width_Sum/400;
if((sym_state==0)&&((Width_Compensate>300)||(Width_Compensate<-300)))
{
EALLOW;
//GpioDataRegs.GPACLEAR.bit.GPIO5 = 1;
sym_state=3;
EDIS;
}
}
if(sym_clock>=200)
{
Vol_Ref=-SinTable[sym_clock-200]*Vol_Peak_Shadow;
}
else
{
Vol_Ref=SinTable[sym_clock]*Vol_Peak_Shadow;
}
temp=AdcResult.ADCRESULT3>>2;
Vol_Feed=(float)(temp-517)*SCALE_VOLTAGE;
//Vol_Feed=(float)(temp-Offset_Adcb3)*SCALE_VOLTAGE;
//Vol_Feed=(float)(660-Offset_Adcb3)*SCALE_VOLTAGE;
Vol_Err =Vol_Ref-Vol_Feed;
Vol_Out =Vol_Err*0.12365;//-Vol_Err_Last*0.012365*0.7334+Vol_Out;
Vol_Err_Last=Vol_Err;
Width_Pulse=(int)(Vol_Out/330*1500);
Width_Pulse=Width_Pulse+Width_Compensate;
if(Width_Pulse>3)
{
if(Width_Pulse>=1472)
{
Width_Sum=Width_Sum+1500;
Width_Pulse=0;
}
else
{
Width_Sum=Width_Sum+Width_Pulse;
Width_Pulse=1475-Width_Pulse;
}
EALLOW;
EPwm1Regs.CMPA.half.CMPA =Width_Pulse;
EPwm2Regs.CMPA.half.CMPA =1600;
EDIS;
}
else
{
if(Width_Pulse<-3)
{
Width_Pulse=-Width_Pulse;
if(Width_Pulse>=1472)
{
Width_Sum=Width_Sum-1500;
Width_Pulse=0;
}
else
{
Width_Sum=Width_Sum-Width_Pulse;
Width_Pulse=1475-Width_Pulse;
}
EALLOW;
EPwm1Regs.CMPA.half.CMPA =1600;
EPwm2Regs.CMPA.half.CMPA =Width_Pulse;
EDIS;
}
else
{
EALLOW;
EPwm1Regs.CMPA.half.CMPA =1600;
EPwm2Regs.CMPA.half.CMPA =1600;
EDIS;
}
}
sym_tick=1;
Vol_Square_Sum=Vol_Square_Sum+Vol_Feed*Vol_Feed;
if(sym_clock==200)
{
Vol_Sqr_Sum_Shw=Vol_Square_Sum;
Vol_Square_Sum=0;
sym_RMS=1;
}
EALLOW;
AdcRegs.ADCINTFLGCLR.bit.ADCINT1 = 1; //Clear ADCINT1 flag reinitialize for next SOC
AdcRegs.ADCINTOVFCLR.bit.ADCINT1 = 1;
PieCtrlRegs.PIEACK.bit.ACK10 = 1; //Acknowledge interrupt to PIE
EDIS;
}