Home      Affiliated Colleges      Course content      First Sem     Second Sem     Third Sem     Fourth Sem     Fifth Sem     Sixth Sem     Seventh Sem     Eighth Sem     Lab report 4th sem     Contact    

Thursday, January 27, 2011

Simulation and Modeling: Simulation of Kirchhoff’s Law Using C:

Verification of Kirchhoff's Law using Simulation:

Theory:
Kirchhoff's circuit laws are two equalities that deal with the conservation of charge and energy in electrical circuits, and were first described in 1845 by Gustav Kirchhoff. Widely used in electrical engineering, they are also called Kirchhoff's rules or simply Kirchhoff's laws.

Kirchhoff's current law states that current at junction is zero. i.e The outgoing current is equal to incoming current.
I=i1+i2


Source Code:

#include<stdio.h>
#include<conio.h>

void main()
{
                float r1,r2,v;
                int j;
                float i,i1,i2,ieq,req;
                FILE *fp;
                clrscr();

                printf("\n \t Enter the value of resistence r1 and r2:\n");
                scanf("%f%f",&r1,&r2);

                printf("\n Enter the value of voltage: \n");
                scanf("%f", &v);

                fp=fopen("kir.xls","wt");

                fprintf(fp,"\n  resistence is:r1=%f, r2=%f",r1,r2);
                fprintf(fp,"\n  voltage is: %f",v);

                req=r1*r2/(r1+r2);

                fprintf(fp,"\n \n \t i1: \ti2: \ti: \t ieq:");
                for(j=0;j<v;j++)
                {

                                i1=j/r1;
                                i2=j/r2;
                                i=i1+i2;
                                ieq=j/req;
                                fprintf(fp,"\n \t %f\t %f \t %f \t%f",i1,i2,i,ieq);
                }
                fprintf(fp,"\n \n The equivalent resistence is %f",req);
                getch();
}


Output:


Conclusion:
In this way, the Kirchhoff's Law was verified using Borland C.

No comments:

Post a Comment

^ Scroll to Top Related Posts with Thumbnails ^ Go to Top