Part Number: CCSTUDIO-C2000
Tool/software: Code Composer Studio
I am using C2000, I have a problem using the PLL, when I try to lock it there's a small phase shift that I could not get rid off. I am generating a reference signal that is locked to the AC grid voltage, and then subtract the grid voltage from the generated reference, The output signal should be 180 phase shift from the AC grid voltage as the reference is larger. however it is not. here's my code related to the PLL.
#include "cla_adc_shared.h"
#include <math.h>
#include "SPLL_1ph.h"
SPLL_1ph spll1;
#define PI_2 6.2831853
#define PWM_TBPRD 50000 //100MHz/PWM_TBPRD/2=Tsw=1/1kHz
#define PWM_TBPRD_HALF 25000
#define PWM_TBPRD_HI 100
#define PWM_TBPRD_LO 1250
#define OCP_LIMIT_HI 4000//2600 //This limit is normal
#define OCP_LIMIT_LO 0//1500 //This limit should be smaller than 1800, issue remained???
// Initialization of PLL
SPLL_1ph_init((float)(60),(float)(0.000025),&spll1);
//PLL to the source voltage
spll1.AC_input= VS_LPF;
SPLL_1ph_run(&spll1);
PLL_PHASE=spll1.theta[0];
// PLL to the source voltage with amplitude of one
PLL_VS = 1*sin((PLL_PHASE/2)*(float)PI_2);
//Load voltage referance
VOr=(float)(Vm*sqrt(2)*PLL_VS);
VOref=(0.545*VOref + 0.455*(float)VOr);
//APF voltage referance
//VSact = (float)(5.6*sqrt(2)*PLL_VS)-0.3;
VSact = (float)(19*0.00073242187*((float)VS_LPF)-0.36);
//Boundry control Calculations
Vd=(float)((VS_LPF)-(VOref));
Thanks in advance,
Radwa