To Generate Sine wave with Sag and Swell Using DSP controller.



SOFTWARE USED: Code Composer Studio

HARDWARE REQUIRED: DSP controller board (TMS320F28335), JTAG, XDS100V2 board

THEORY:

Sags and swells are the most common types of power quality disturbances.

sag or swell is determined by a variation in the amplitude of the sine wave. A sag is a reduction in the RMS value of the sine wave, typically below 90% of nominal, whereas a swell is an increase, typically above 110% of nominal.

Code for: Sine Wave

#include<stdio.h>

#include<math.h>

 float a[500];

 

int t;

 void main(void)

 {

    for(t=0; t<500; t++)

    {

a[t]=-sin(2*3.14*50*t);

    }

 

 }

Code for:  Voltage Sag

#include <stdio.h>

#include <math.h>

int i=0;

float c[100];

float t;

int main(void)

{

    for(t=0;t<=0.2;t=t+0.001)

    {

        if(i>0 &&i<=20)

        c[i]=sin(2*3.14*50*t);

        else if(i>20 && i<=60)

            c[i]=0.5*sin(2*3.14*50*t);

        else

            c[i]=sin(2*3.14*50*t);

        i=i+1;

    }

}

 Code for:Voltage Swell

#include <stdio.h>

#include <math.h>

int i=0;

float c[100];

float t;

int main(void)

{

    for(t=0;t<=0.2;t=t+0.001)

    {

        if(i>0 &&i<=20)

        c[i]=sin(2*3.14*50*t);

        else if(i>20 && i<=60)

            c[i]=1.5*sin(2*3.14*50*t);

        else

            c[i]=sin(2*3.14*50*t);

        i=i+1;

    }

}


OBSERVATIONS: In code using Sin(2*3.14*f*t) command and incrementing time from 0 to some value Sine wave start from negative so to make it Positive we do Amplitude Scaling by -1. Also sag and swell is done just for one cycle if we want the sag or swell for more cycle, we have to take a range and decrease or increase its amplitude during that time.

Post a Comment

Please do not enter any spam links in the comments...

Previous Post Next Post