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.

single phase Grid tie PLL

Other Parts Discussed in Thread: TMS320F28069

Dear all,

Currently i am doing single phase solar grid inverter using TMS320F28069 for client .They are given task list of inverter PROJECT.

One of task is to generate single phase grid tie PLL output.

I used PLL with notch filter library file with sine look up table instead of ADC measured sin value.

But i did not get proper PLL output  theta value (Ramp output or saw tooth wave form).

I attached  the main source code for your examonation

Please give any valid suggestion to finish PLL task within stipulated time.

I am simulating the InvSine value using graph tool in CCS studio.



#include "F2806x_Device.h"
#include "Solar_IQ.h"


#define table_size 1024 //size of table=1024


#define GRID_FREQ    60
#define PI 3.141592653589
#define ISR_FREQUENCY 50000.0

#define B0_LPF (166.7618719)
#define B1_LPF (-166.4785831)
#define A1_LPF (-1.0)

SPLL_1ph_IQ spll1;

//SPLL_1ph_IQ_NOTCH_COEFF spll_notch_coef1;

// Prototype statements for functions found within this file.
__interrupt void cpu_timer0_isr(void);

extern void InitSysCtrl(void);
extern void InitPieVectTable(void);
extern void InitPieCtrl(void);


float c2, c1;
float sin_table[108]={0,0.1736,0.3420,0.5,0.6427,0.7660,0.8660,0.9396,0.9848,1,
        0.9848,0.9396,0.8660,0.7660,0.6427,0.5,0.3420,0.1736,0,-0.1736,-0.3420,
        -0.5,-0.6427,-0.7660,-0.8660,-0.9396,-0.9848,-1,-0.9848,-0.9396,-0.8660,
        -0.7660,-0.6427,-0.5,-0.3420,-0.1736,0,0.1736,0.3420,0.5,0.6427,0.7660,0.8660,0.9396,0.9848,1,
        0.9848,0.9396,0.8660,0.7660,0.6427,0.5,0.3420,0.1736,0,-0.1736,-0.3420,
        -0.5,-0.6427,-0.7660,-0.8660,-0.9396,-0.9848,-1,-0.9848,-0.9396,-0.8660,
        -0.7660,-0.6427,-0.5,-0.3420,-0.1736,0,0.1736,0.3420,0.5,0.6427,0.7660,0.8660,0.9396,0.9848,1,
        0.9848,0.9396,0.8660,0.7660,0.6427,0.5,0.3420,0.1736,0,-0.1736,-0.3420,
        -0.5,-0.6427,-0.7660,-0.8660,-0.9396,-0.9848,-1,-0.9848,-0.9396,-0.8660,
        -0.7660,-0.6427,-0.5,-0.3420,-0.1736};


//RAMPGEN_IQ rgen1;
SPLL_1ph_SOGI_IQ spll2;

_iq21 inv_meas_vol_inst;
_iq24 InvSine;

char index = 0;


void main(void)
{
    InitSysCtrl();

    DINT;
    InitPieCtrl();
    IER = 0x0000;
    IFR = 0x0000;
    InitPieVectTable();

    EALLOW;  // This is needed to write to EALLOW protected registers
    PieVectTable.TINT0 = &cpu_timer0_isr;
    EDIS;    // This is needed to disable write to EALLOW protected registers

    EALLOW;
    GpioCtrlRegs.GPADIR.bit.GPIO31 = 1;
    GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;
    EDIS;

    InitCpuTimers();   // For this example, only initialize the Cpu Timers
    ConfigCpuTimer(&CpuTimer0,90,50);

    CpuTimer0Regs.TCR.all = 0x4001;

    PieCtrlRegs.PIEIER1.bit.INTx7 = 1;

    IER |= M_INT1;

    EINT;
    ERTM;

    GpioDataRegs.GPASET.bit.GPIO31 = 1;
    GpioDataRegs.GPBSET.bit.GPIO34 = 1;

    // SPLL 1ph Notch Filter Method intialization
        SPLL_1ph_IQ_init(GRID_FREQ, _IQ21((float)(1.0/ISR_FREQUENCY)), &spll1);

        spll1.lpf_coeff.B0_lf = _IQ21(B0_LPF);
        spll1.lpf_coeff.B1_lf = _IQ21(B1_LPF);
        spll1.lpf_coeff.A1_lf = _IQ21(A1_LPF);

        c1 = 0.1;
        c2 = 0.00001;

        SPLL_1ph_IQ_notch_coeff_update(((float) (1.0 / ISR_FREQUENCY)),(float) (2 * PI * GRID_FREQ * 2), (float) c2, (float) c1, &spll1);

    //SPLL_1ph_IQ_init(GRID_FREQ,_IQ21((float)(1.0/ISR_FREQUENCY)),&spll1);
    //SPLL_1ph_IQ_notch_coeff_update(((float)(1.0/ISR_FREQUENCY)),(float)(2*PI*GRID_FREQ*2),(float)0.00001,(float)0.1,&spll1);


// Step 6. IDLE loop. Just sit and loop forever (optional):
   for(;;)
    {

       ;


    }
}

__interrupt void cpu_timer0_isr(void)
{
   CpuTimer0.InterruptCount++;
   GpioDataRegs.GPBTOGGLE.bit.GPIO34 = 1; // Toggle GPIO34 once per 50 MICROseconds
   spll1.AC_input=(long)sin_table[index] >> 3;
   //spll1.AC_input=(long)inv_meas_vol_inst>>3;
   SPLL_1ph_IQ_MACRO(spll1);
   InvSine     = (long)(spll1.sin)>> 3; // InvSine is in Q24

   index++;
   if(index > 107)
   {
       index = 0;
   }

   // Acknowledge this interrupt to receive more interrupts from group 1
   PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
}