Sie sind auf Seite 1von 19

VISVESVARAYA TECHNOLOGICAL UNIVERSITY BELGAUM-590002

SIMPLE CIRCUIT WITH BULB


A Project Submitted To Visvesvaraya Technological University in Partial fulfillment of requirements For the 6th semester Computer Science & Engineering
By SAYYAN N SHAIKH USN: 2VD07CS041

Under the Guidance of

Mr. SALEEM HEBBAL

Department of Computer Science & Engineering KARNATAK LAW SOCIETYS VISHWANATHRAO DESHPANDE RURAL INSTITUTE OF TECHNOLOGY HALIYAL-581329, DIST. UTTAR KANNADA, KARNATAKA

Karnatak Law Societys VISHWANATHRAO DESHPANDE RURAL INSTITUTE OF TECHNOLOGY HALIYAL (UTTAR KANNADA) 581329

Department of Computer Science & Engineering CERTIFICATE Certified that the project on SIMPLE CIRCUIT WITH BULB is a bonafide work carried out by SAYYAN N. SHAIKH, in partial fulfillment for the award of Bachelor of Engineering in Computer Science & Engineering of Visvesvaraya Technological University, Belgaum during the year 2010.The Project report has been approved as it satisfies the academic requirements in respect of Project for the Bachelor of Engineering Degree.

___________________ __________________ ____________________ Signature of the Guide Signature of the HOD Signature of the Principal Prof. Saleem Hebbal Prof. A.V.Kolaki Dr. G.R.Udupi EXTERNAL VIVA

Name of the Examiners 1. 2.

Signature with Date . ..

Dedicated to My Beloved Parents And Teachers

ACKNOWLEDGEMENT
The magnitude of this project demanded the co-operation, guidance and assistance from a number of people and I have been fortunate to have this, and I take this opportunity to thank all those who have helped me in this project. I express a deep sense of gratitude to Prof. Saleem Hebbal for his constant timely advice, valuable suggestions and help given from time to time. I take this opportunity to thank Prof. A.V.Kolaki HOD of Computer Science and Engineering Dept, VDRIT Haliyal providing the inspiration for taking the project to its completion. I will be failing in my duty if I dont thank our principal Dr. G.R.Udupi for providing healthy environment in the college that helped in concentrating on the task. Then I would also thank all teaching and non teaching staff of the department who directly or indirectly contributed in accomplishing this task. Last but not the least I express my sincere thanks to all persons who have directly or indiretly assisted my endeavor.

-Project Associate

Sayyan.N.Shaikh

ABSTRACT
This project will demonstrates the working of a simple circuit which consist a bulb and a simple switch with user interaction the circuit gets closed and current flows from positive to negative end of battery.I have developed the above concept using OpenGL utilities.This is a simple graphics package that uses OpenGL functions. Computer graphics is concerned with all aspects of producing pictures or images using a computer. In this project we are using the openGL functions. Also we use hardware interface like mouse. Here I have demonstratrd the model with the use of Polygons,Circle and Lines of various size.Using OpenGL functions I have demonstrated this model.

ii

CONTENTS
Chapter Description Acknowledgement Abstract List of Figures 1 INTRODUCTION
1.1 Introduction to Computer Graphics 1.2 Introduction to Project 1.3 Fundamental Functions of Graphics

Page No. i ii iv 01
01 01 02

2 3

ALGORITHM INPUT AND OUTPUT


3.1 Input 3.2 Output

04 07
07 07

SOFTWARE AND HARDWARE REQUIREMENTS


4.1 Software Requirements 4.2 Hardware Requirements

08
08 08

5 6

SNAPSHOTS CONCLUSION
6.1 Future Enhancements

09 11
11

REFERENCES

12

iii

LIST OF FIGURES
Figure No. 5.1 5.2 Description Open Circuit Closed Circuit Page No. 09 10

iv

SIMPLE CIRCUIT WITH BULB Chapter 1

INTRODUCTION
Introduction to Computer Graphics:
Computer graphics is one of the most exciting and rapidly growing computer field and computer. It is also an extremely effective medium for communication between men. The human can understand the information content of a displayed diagram or perspective view much faster than it can understand a table of numbers. There is a lot of development in hardware and software required to generate images, and now-a-days the cost of such hardware and software is also dropping rapidly. Due to this the interactive computer graphics is becoming available to more and more people. Computer graphics today is largely interactive. The user controls the contents, structure, and appearance of the objects and of there displayed images by using input devices, such as keyboard, mouse, or touch-sensitive panel on the screen. Because of the close relationship between the input devices and the display, the handling of such devices is included in the study of computer graphics. Graphics based user interfaces allowed millions of new users to control simple, low-cost application programs, such as spread sheets, word processors, and drawing programs.

1.2 Introduction to Project (Simple circuit with bulb)


This project demonstrates the flow of current in a simple circuit which consist a bulb and a simple switch. The current will flow in a closed circuit from positive to negative end of battery through wire. As a flow of current a bulb which is connected to wire will be start glowing.

1.3 Name of the project and why?


The project name is Simple circuit with bulb. This project will demonstrate the basic concept of simple circuit. As the name of the project is simple circuit as it shows the flow of current in a closed electric circuit.

1.4 Objective of the project:


The main objective of this project is to serve as a tutorial to understand the basic concept of a simple circuit. Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 1

SIMPLE CIRCUIT WITH BULB 1.5 Fundamental functions of graphics


These functions are extensively used in this project. glutInit(&argc, argv) : To start the graphics system, we must first call initgraph. This function is used to initialize the graphics system by loading a graphics driver from the disk and then putting the system into graphics mode. This is a function call initiated between the windowing system and OpenGL. These two arguments allow the user to pass command-line arguments. glutInitDisplayMode(GLUT_DOUBLE|GLUT_RGB|GLUT_DEPTH) : This initializes Display Mode with GLUT_DOUBLE buffering, RGB color, and a depth buffer for hidden-surface removal. glClear(GL_COLOR_BUFFER_BIT) : Clears the Color Buffer bit and sets the present RGBA clear color used. The parameters used are of type floating-point numbers between 0.0, 1.0. glutSwapBuffers( ) : This function is used to Swap the both front and back buffers. void glBegin(glEnum mode) : This function initiates a new primitive of type mode and starts the collection of vertices. Values of mode include GL_POINTS, GL_LINES and GL_POLYGON. void glEnd( ) : This function terminates a list of vertices. GL_POINTS: Treats each vertex as a single point. GL_LINES: Treats each pair of vertices as an independent line segment. GL_LINE_LOOP: Draws a connected group of line segments from the first vertex to the last, then back to the first. GL_LINE_STRIP: Draws a connected group of line segments from the first vertex to the last. Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 2

SIMPLE CIRCUIT WITH BULB


void glutMouseFunc(void *f(int button, int state, int x, int y)) : This function registers the mouse callback function. And also returns the button (GLUT_LEFT_BUTTON, GLUT_MIDDLE_BUTTON,

GLUT_RIGHT_BUTTON), the state of the button after the event (GLUT_UP, GLUT_DOWN), and the position of the mouse relative to the top-left corner of the window. void glutBitmapCharacter(void *font, int character) : This function renders a bitmap character using OpenGL. GLUT_BITMAP_HELVETICA_12: A 12-point proportional spaced Helvetica font. The exact bitmaps to be used is defined by the standard X glyph bitmaps for the X font named:-adobetimes-medium-r-normal--10-100-75-75-p-54-iso8859-1. void glClearColor(GLclampf r, GLclampf g, GLclampf b, GLclampf a) : This function sets the present RGBA clear color used when clearing the color buffer. Variables of type GLclampf are floating point numbers between 0.0 and 1.0. glColor3f(0.0f,1.0f,0.0f) : glColor3f( ) takes three float arguments indicating red, green and blue components of the color. Before continuing our main discussion let's talk a little about OpenGL command syntax. Various groups of OpenGL commands perform the same operation but they are different in arguments. Common OpenGL commands syntax is: gl+<functionname>+<aclass='x3dmainlinkargumentsnumber>+<aclass='x3d mainlinkargumenttype> + <vector> We can use glBegin( )/glEnd( ) block to indicate the primitive type. You can specify vertices inside this block by glVertex( ) command. glBegin( ) takes a parameter specifying the primitive type. Note that the order in which we call glVertex( ) command is very important. Here we specified the vertices in a counter clock wise order. The importance rises from the fact that OpenGL can cull the back faces and speed up the rendering procedure as a result.

Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 3

SIMPLE CIRCUIT WITH BULB Chapter 2

ALGORITHM
// Purpose: Open GL program to demonstrate the basic concept of simple circuit.

// Input: User interface using mouse


Left mouse button to open the switch in a circuit. Right mouse button to close the switch in a circuit.

// Output: The output will demonstrates the flow of current in simple circuit which
consist a bulb.

Step 1: [Main Function]


1.1 Initialize display mode, window size and window position. 1.2 Register the call back functions. 1.3 Repeatedly call main function till exited.

Step 2: [Display Function]


2.1 Clear the color buffer and depth buffer. 2.2 Use the push( ) and pop( ) functions for stack operations. 2.3 Using the wire,cylinder_draw(),cylinder_draw1(),cylinder_draw2(), open(), parallelepiped_draw(),functions it will draw simple circuit with wire, bulb, switch and battery. 2.4 Using glFlush to display the Circuit onto the output screen.

Step 3: [Cylinder draw Function]


This function will draw the circle and cylinder using midpoint circle draw algorithm, which is used to draw bulb and other parts of blub in a circuit. It consist circle_draw, plot_pixels, draw_pixels as sub functions which helps to draw pixels. Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 4

SIMPLE CIRCUIT WITH BULB Step 4: [parallelepiped draw Function]


This function will draw the parallepiped by extruding a quadrilateral, which is used as battery in a circuit.

Step 5: [Wire Function]


This function is used draw wire connection between bulb, battery and switch using GL_LINE command.X1, Y1 and X2, Y2 are end points of line. glColor3f (1.0, 0.0, 0.0); glBegin(GL_LINES); glVertex2f(X1, Y1); glVertex2f(X2, Y2); glEnd( );

Step 6: [Current Function]


This function is use to show current flow in a circuit using GL_LINE command. Incrementing or decrementing the X2 or Y2 co-ordinate by i, we can change the flowing direction of current. glColor3f (0.0, 0.0, 1.0); glBegin(GL_LINES); glVertex2f(X1, Y1); For i 1 154.0 do { For n 1 10000000 do glVertex2f(X2- i, Y2); } glEnd( ); glFlush( );

Step 7: [Ray Function]


This function is used draw light rays of bulb using GL_LINE command.X1, Y1 and X2, Y2 are end points of line. Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 5

SIMPLE CIRCUIT WITH BULB


glColor3f (1.0, 0.0, 0.0); glBegin(GL_LINES); glVertex2f(X1, Y1); glVertex2f(X2, Y2); glEnd( );

Step 8: [Open Function]


This function is used to draw the switch. glColor3f (1.0, 0.0, 0.0); glBegin(GL_LINES); glVertex2f (130.0, 110.0); glVertex2f (160.0, 140.0); glLineWidth(1.0); glEnd( );

Step 9: [Close Function]


This function will make switch close and current will start flowing throughout the circuit. glColor3f (1.0, 0.0, 0.0); glBegin(GL_LINES); glVertex2f (130.0, 110.0); glVertex2f (160.0, 110.0); glLineWidth(1.0); glEnd( );

Step 10: [MyMouse Function] This function will provide a user interaction to the program.
10.1 When right mouse button is pressed the circuit gets closed by calling close function call and the current flows across the circuit. 10.2 When left mouse button is pressed the circuit gets open by calling open function call and current will not flow across the circuit.

Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 6

SIMPLE CIRCUIT WITH BULB Chapter 3

INPUT AND OUTPUT


INPUT:
Here we provide input using mouse interface by following mouse keys Left mouse button to open the switch in a circuit. Right mouse button to close the switch in a circuit.

OUTPUT:
The output will demonstrate the flow of current across the circuit which consist a bulb.

Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 7

SIMPLE CIRCUIT WITH BULB Chapter 4

SOFTWARE AND HARDWARE REQUIREMENTS


SOFTWARE REQUIREMENTS:
Microsoft Visual Studio 6.0 of 2005 or 2008 version. OpenGL, GL Utility Toolkits, GLUT Files are required. Operating System: Windows 2000 or XP version, as supporting system.

HARDWARE REQUIREMENTS:
Minimum hardware configuration required for our project. Processor: Pentium processor with minimum capacity of 32MB of RAM. Hard disk capacity: There is no much restriction on the capacity of a hard disk. But we prefer to have at least 20 GB of Hard disk. Monitor: The color monitor with 14 and above configuration can be used. Mouse.

Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 8

SIMPLE CIRCUIT WITH BULB Chapter 5

SNAPSHOT

Figure 5.1 Open circuit.

Figure 5.1 will shows the Open Circuit in which switch gets open on the interaction of user with left mouse button and current will stop flowing.

Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 9

SIMPLE CIRCUIT WITH BULB

Figure 5.2 Close circuit.

Figure 5.2 will shows the Closed circuit in which switch gets closed on the interaction of user with right mouse button and current will start flowing across the circuit.

Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 10

SIMPLE CIRCUIT WITH BULB

Chapter 6

CONCLUSION
The output will demonstrates the flow of current in simple circuit consisting bulb and simple switch. Using OpenGL functions and commands i have demonstrated the the working of simple circuit.

6.1 FUTURE ENHANCEMENT


It can be used as a tutor to understand the basic concept of the simple circuit. The project can be further developed in 3D environment which gives more realistic interface to the user. Further lighting concept can be applied to this project.

Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 11

SIMPLE CIRCUIT WITH BULB

REFERENCES
Text References:
[1] Computer Graphics Using OpenGL -2 Edition, Pearson education, 2001.
nd

- F. S. Hill, Jr.

[2] Interactive Computer Graphics A Top-Down Approach with OpenGL -2 nd Edition, Addison Wesley, 2008.

- Edward Angel

[3] Computer Graphics - OpenGL Version -2 ndEdition, Pearson education, 2003.

-Donald Hearn and Pauline Baker

Department of Computer Science & Engineering KLSs Vishwanathrao Deshpande Rural Institute of Technology, Haliyal 12

Das könnte Ihnen auch gefallen