// Simulation of a single-phase fully-controlled bridge // rectifier circuit. // This program produces the transient response, the periodic // response. Commuation overlap angle is also computed. // Calculations normalized. The average voltage that would // occur for diode-bridge rectifier with a resistive load is // taken to be unity. The average current through the load // resistor with a pure resistive load on the diode bridge // rectifier is taken as the unity current. The parameters to // be fed are just three: the ratio of load inductive reactance // to the load resistance, wL1/R , the ratio of source reactance // to the load resistance to load resistance wL2/R and the firing // angle in degrees. #include #include #include #include #include void kreateRespFile(void); void tranResponse(void); void OneCycle(void); void computeOneStep(void); void produceEntries(void); const double pi=3.1415926; const double deg_rad=pi/180.0; const double step=pi/720.0; double L1,L2,alpha,fang,elapseAng,cycleAng,tote_knt; double cur_load,cur_line,outVolt,vSource,vInput; double OverLapangle; int commute,toggle,yes_Entry,modeSw; FILE *fnew; char *tstr,*p; int main(void) { float ka1,kb2,kc3; printf(" \n"); printf(" Load Time Constant in radians = "); scanf("%f",&ka1); L1=(double)ka1; if (L1<0.05) L1=0.05; printf(" \n"); printf(" Line Reactance Time Constant in radians = "); scanf("%f",&kb2); L2=(double)kb2; printf(" \n"); printf(" Firing angle in degrees = "); scanf("%f",&kc3); alpha=(double)kc3; fang=alpha*deg_rad; alpha=0.0; printf(" \n"); // Initialise though not necessary for global variables elapseAng=0.0 ; cycleAng=0.0; cur_load=0.0; cur_line=0.0; outVolt=0.0; tote_knt=0.0; OverLapangle=0.0; commute=0; yes_Entry=0; // Create a file for entering transient response fnew=fopen("tran_v1.csv","w+r"); tranResponse(); fclose(fnew); return 0; } void kreateRespFile(void) { int n1,n2; tstr="Angle,InputV,VoutBr,LoadCur,LineCur,IndVolt"; p=strtok(tstr,","); fprintf(fnew,p); fprintf(fnew,","); n2=6; for (n1=0;n1<(n2-1);n1++) { p=strtok(NULL,","); if (n1!=(n2-2)) { fprintf(fnew,p); fprintf(fnew,","); } else { fprintf(fnew,p); fprintf(fnew,"\n"); } } } void tranResponse(void) { double d1; int NumCycles,count; d1=(6.0*(L1+L2))/(2.0*pi)+0.5; NumCycles=(int)d1 + 1; kreateRespFile(); modeSw=1; for (count=0;count<=NumCycles;count++) OneCycle(); } void OneCycle(void) { int knt; double dknt; dknt=0.0; for (knt=0;knt<1440;knt++) { cycleAng=dknt*step; vInput=pi/2.0*sin(cycleAng); if ((cycleAng(fang+pi))) { if (cycleAngcur_load) commute=0; } if (toggle==0) { if ((cur_line+cur_load)<0.0) commute=0; } outVolt=0.0; break; } tote_knt+=1.0; elapseAng=tote_knt*step; alpha=tote_knt/4.0; yes_Entry+=1; if (yes_Entry==4) produceEntries(); if (yes_Entry==4) yes_Entry=0; } void produceEntries(void) { double negate; gcvt(alpha,5,p); fprintf(fnew,p); fprintf(fnew,","); gcvt(vInput,5,p); fprintf(fnew,p); fprintf(fnew,","); gcvt(outVolt,5,p); fprintf(fnew,p); fprintf(fnew,","); gcvt(cur_load,5,p); fprintf(fnew,p); fprintf(fnew,","); gcvt(cur_line,5,p); fprintf(fnew,p); fprintf(fnew,","); if (toggle==0) negate = 1.0; else negate=-1.0; gcvt(vInput-negate*outVolt,5,p); fprintf(fnew,p); fprintf(fnew,"\n"); }