This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
EEU 101/2 Computer Programming
Group Project
Title: Total Resistance Calculation
Group 4
Group members:
ANG KOK WEI 108467
GOH CHIA YEE 108474
KOAY BOON AIK 108146
MOHAMAD SHAZELEE BIN SIMON 108153
NURUL WAHIEDA BINTI MUHAMAD BUSTAMAN 108488
TIONG KWONG YII 108170
School of Mechanical Engineering
Date of submission: 31 March 2011
Lecturer: Associate Prof. Dr. Umi Kalthum Ngah
Acknowledgement
2
Here, we would like to acknowledge a few groups of supportive people, who became the
foundation for our achievement in concluding this Group Project for the course EEU 101/2
Computer Programming.
At the outset, there would be no greater accomplishment without the guide and precious
knowledge from our valued lecturer. Consequently, no one else is meant for this part of our
acknowledgement but the person in mind, Associate Prof. Dr. Umi Kalthum Ngah.
Furthermore, we would like to announce our gratitude towards our mentor in the course
EEU 101/2 for all the guidance given in learning the C++ programming language.
To finish with, we would like to express our truthful appreciation towards those around us,
especially those from the other groups, who had been there to assist us with regard to their
priceless time and effort.
Table of Contents
3
Contents Page
4
1 Acknowledgement 2
2 Table of Contents 3
3 Abstract 4
4 Introduction 5
5 Minutes of Meetings 6-9
6 Problem Analysis 105.15.2
Problem StatementInput and Output Analysis
7 Design Decomposition & Methodology 11-13
8 Coding and Debugging 14-26
9 Integration 27-45
10 Testing and Validation 46-59
11 Gantt Chart 60
12 Conclusion 61
13 Bibliography 62
Abstract
5
Our program is to enable the user to easily calculate the resistance of a resistor using a colour coded band and the total resistance in a circuit of different type. In a series circuit, the current through each of the components is the same. To find the total resistance, add the resistances Ri of each component and take the the sum.
In a parallel circuit, the voltage across each of the components is the same. To find the total resistance, add the reciprocals of the resistances Ri of each component and take the reciprocal of the sum.
.
For series-parallel circuits, the total resistance is computed using series and parallel formula, where most circuit can be broken down to a simple parallel or series circuit.
Most resistors have three coloured bands close together at one end. The colour codes are as follows:
1) Calculate the resistance of resistor in a series, parallel or parallel-series circuit.
2) Calculate the resistance of a resistor based on the colour coded band on a resistor.
Project Scope:
1) This program can calculate resistances of resistors.
2) The circuit taken into consideration include series, parallel and parallel-series circuit.
3) This programme can calculate resistances of resistors based on the colour bands of the resistors.
4) The circuit taken into consideration must only consist of a power source, and resistors either in the connection of series or parallel or the combination of both.
5) The equivalent resistance is calculated without considering the effective range of resistance but only the average resistance value of the resistors in the circuit.
In this project, we tried to utilize as many commands as we are capable of to demonstrate our familiarity with these commands besides showing variation. Among the commands used are: for, if, if-else, switch, do-while, looping, function, pointer and arrays.
Minutes of 1st Meeting
Summary
7
Meeting Topic
Analysis of the program and design decomposition of the Program’s problem
Date 26th January 2011 From 08:30 PM To 10:00 PM
Location Café Lembaran Note Taker
Nurul Wahieda Muhamad Bustaman 108488
Duration 1.5 hr
Topic
1. Discussion on problem statement, input and output analysis.
2. Discussion on the flow chart for the decomposition of the problem
Attendee List
# Name Present Absence Reason
1 NURUL WAHIEDA BT MUHAMAD BUSTAMAN 108488 Y -
2 ANG KOK WEI 108467 Y -
3 TIONG KWONG YII 108170 Y -
4 MOHAMAD SHAZELEE BIN SIMON 108153 Y -
5 KOAY BOON AIK 108146 Y -
6 GOH CHIA YEE 108474 Y -
Meeting Notes
12
The problem statement, input and output analysis are done.The design composition of the whole program is done.
Action Items For Next Meeting
# Task Person Responsible
1 Come up with ideas for the C++ codes of each part of the program. All
Minutes of 2nd Meeting
Summary
8
Meeting Topic Coding and debugging.
Date28th February 2011
From 08:30 PM To 10:00 PM
Location Café Lembaran Note Taker
Nurul Wahieda Muhamad Bustaman 108488
Duration 1.5 hr
Topic
1. Writing codes for each part of the program.
Attendee List
# Name Present Absence Reason
1 NURUL WAHIEDA BT MUHAMAD BUSTAMAN 108488 Y -
2 ANG KOK WEI 108467 Y -
3 TIONG KWONG YII 108170 Y -
4 MOHAMAD SHAZELEE BIN SIMON 108153 Y -
5 KOAY BOON AIK 108146 Y -
6 GOH CHIA YEE 108474 Y -
Meeting Notes
1 Each member are assigned to write the parts of the program.
Action Items For Next Meeting
# Task Person Responsible
1 Write code for each part of the program which is to be integrated in the next meeting.
All
Minutes of 3rd Meeting
Summary
9
Meeting Topic
Testing, validation and integration
Date 16th March 2011 From 08:30 PM To 10:00 PM
Location Café Lembaran Note Taker
Nurul Wahieda Muhamad Bustaman 108488
Duration 1.5 hr
Topic
1. Each code for every part of the program is debugged to check error. Each one is then compiled and run.
2. The integrated code is debugged, compiled and run.
Attendee List
# Name Present Absence Reason
1 NURUL WAHIEDA BT MUHAMAD BUSTAMAN 108488 Y -
2 ANG KOK WEI 108467 Y -
3 TIONG KWONG YII 108170 Y -
4 MOHAMAD SHAZELEE BIN SIMON 108153 Y -
5 KOAY BOON AIK 108146 Y -
6 GOH CHIA YEE 108474 Y -
Meeting Notes
1 The errors which occurred in compiling the integrated codes while debugging have been solved.
Action Items For Next Meeting
# Task Person Responsible
1 Complete parts of the project’s paperwork which has been assigned to each team members.
All
Minutes of 4th Meeting
Summary
10
Meeting Topic
Presentation preparation
Date 28th March 2011 From 08:30 PM To 10:00 PM
Location Café Lembaran Note Taker
Nurul Wahieda Muhamad Bustaman 108488
Duration 1.5 hr
Topic
1. Rechecking program’s code.
2. Preparing for the presentation of the program.
Attendee List
# Name Present Absence Reason
1 NURUL WAHIEDA BT MUHAMAD BUSTAMAN 108488 Y -
2 ANG KOK WEI 108467 Y -
3 TIONG KWONG YII 108170 Y -
4 MOHAMAD SHAZELEE BIN SIMON 108153 Y -
5 KOAY BOON AIK 108146 Y -
6 GOH CHIA YEE 108474 Y -
Meeting Notes
1 The codes, paperwork and the forecasted flow of our presentation are done.
Action Items
# Task Person Responsible
1 Prepare for the presentation of the program. All
Problem Analysis
11
Problem Statement
Amongst the common type of combination of the electric circuit encompasses
parallel, series, and a combination of both. Due to the rigorous and complicated
method in calculating the total resistance in the circuit manually (by hand), thus we
intend to create a program which assist the user to solve the problem more easily.
This program will then allow the user to manipulate the type of circuit and the input
needed in order to attain the correct solution in solving the total resistance in the
circuit. In the request of the user, the program would also be able to attain the
resistance of a resistor using the colour coded band calculation.
Input and Output Analysis
Input data:
Type of resistance calculation (parallel, series, series-parallel and
colour coded band), number of resistors in the circuit, the value (in ohm
unit) of each of the resistors, the code for the colour coded band.
Output data:
Total resistance in the circuit or of the resistor.
Design DecompositionTotal Resistance
Calculation
12
Parallel circuit
The Programmers
Series circuit
DisclaimerParallel-Series circuit
Coloured Bands of Resistor
Total resistance (ohm)
Value of each resistor (ohm)
Number of resistor
Value of resistors (ohm) of each line
Number of lines having more than one resistor
Number of lines between node x and node y
Number of resistor in each line
First colour’s
code
Codes of each colour
Second colour’s
code
Third colour’s
code
13
Start
Display the main display menu.
Output six choices for the user to choose from. Ask the user for what type of calculation required.
Input: circuit
circuit == 1and circuit ==2
Input: number
Start for loop for main display menu
(a) (d) (c)
circuit==3
Display "Enter Total Number of Parallel Resistor:"
Display "Enter Value of Parallel Resistor #"
input=R
Display colour-code table and “Enter three resistor code”.
cout <<setcolour(GREEN, chandle) << setfill('=') <<setw(80)<<"="<<endl;//lines for border and simple
decoration
cout << setfill(' ') <<setw(50)<<" "<<endl;
cout <<setcolour(DARKRED, chandle)<< setw(100)<<" Our group accepts no liability for the content
of this program,\n or for the consequences of any actions taken on the basis of the \n information provided, unless
that information is subsequently confirmed in \n writing. If you are not the intended recipient you are notified that
\n disclosing, copying, distributing or taking any action in reliance on the \n contents of this information is strictly
prohibited without \n the agreement from the programmers themself"<<endl; }
47
Testing and Validation
The Parallel Circuit
When the user keys in 1
48
The user will then be asked to key in the number of parallel resistor
As an example, the total number of parallel resistor is 10.
Press enter,
49
The program will asked the user to key in all the value of parallel resistor
For example,
R1=2, R2=1.5,
R3=1, R4=3,
R5=1.4, R6=2,
R7=2.2, R8=3,
R9=1, R10=1.1
Hence, the effective resistance in 10 parallel resistors is 0.1721 ohms.
50
If the user want to continue just press any key and it will return to the original pages.
If the users do not want continue just key in q. then the program will exit.
51
50
R3
105
R1
R2
R4
75
The Series Circuit
1. First, compile the program in order to convert the language into the machine code. Click Program > Compile.
2. If there is no error, then proceed to running the program.3. After compiling the program, the status is “SUCCESS” without any error. This,
however, does not mean that the program is correct because the equivalent resistance calculated by this program might be wrong as the program might have been written inappropriately.
4. Click Debug > Run to... to run the program.5. To verify the correctness of the program, we will test the program with a simple series
circuits.
Circuit 1
68
79
R5
52
6. Next, we will calculate the equivalent resistance of the circuit. The equivalent resistance of circuit 1 calculated (by calculator) using the formulas below is 377ohm.
Series: Req= R1+R2+R3+........+Rn
7. The equivalent resistance calculated by our program is 377ohm. Hence, the program is correct. Figure below verifies that our program can calculate the equivalent resistance of circuit 1 correctly.
53
The Parallel-Series Circuit
For an example of the “Parallel-series circuit”, a circuit consisting of 6 resistor connected in parallel-series circuit which are R1 (10 ohms) , R2 (5 ohms), R3 (2 ohms), R4 (2 ohms), R5 (100 ohms) and R6(30 ohms).
The resistors are arranged as in the circuit above.
Via calculator, the equivalent resistance is calculated using the formulas:
Series: Req= R1+R2+R3+........+Rn
Parallel: 1/Req=1/R1+1/R2+1/R3+..........1/Rn
2R3R5
100R110
R630
R42
R25
54
55
Comparing the answer from the calculator which is 1.685393258 ohms and the answer obtained from the program above, it is verified that they are similar to it. Hence, in can be
proven that the program is valid and is able to calculate the parallel-series circuit (Series circuit in parallel)
56
Explanation
1. In order to determine the equivalent resistance of a circuit, the type of the circuit must be identified. (Series, parallel or parallel-series circuit)
2. The calculation of resistance are done with a for loop and equationSeries: Req= R1+R2+R3+........+Rn
Parallel: 1/Req=1/R1+1/R2+1/R3+..........1/Rn
3. Figure below shows the explanation of the program to calculate the equivalent resistance of the circuit above.
4. First, enter the number of line containing the resistors, as asked by the program. Hence, there would be five lines in the circuit.
2R3R5
100 R110 R6
30
R42
R25
2R3R5
100R110
R630
R42
R25
5 lines containing resistor
57
5. Since all of these five lines each containing resistors, are considered parallel to each other, the equivalent resistance of the whole circuit will definitely be the sum of resistance using formula:
Parallel: 1/Req=1/R1+1/R2+1/R3+..........1/Rn
6. Yet, in each of the parallel-circuit lines, there would be other resistance connected to it as shown in the diagram above which a resistor is connected in series to R4.
7. Hence, we can determine the number of lines which contains more than one resistor in each parallel line.
2R3R5
100 R110 R6
30
R42
R25
R3 & R4 connected in
series
58
8. Hence, to get the accurate equivalent resistance, the sum of the resistor (R3 & R4) should be obtained in order to calculate the total sum of resistance in the circuit using the formulas:
Series: Req= R1+R2+R3+........+Rn
2R3R5
100 R110 R6
30
R42
R25
Only 1 line which contain more
than 1 resistor
59
9. Hence, the circuit would contain only of resistor connected in parallel. Therefore, the equivalent resistance of the circuit can now be calaculated using the formula:
Parallel: 1/Req=1/R1+1/R2+1/R3+..........1/Rn
Finally, the equivalent resistance calculated by our program is 1.68539 ohms as shown in the console window below:
2R3R5
100 R110 R6
30
R42
R25
R5100
R110
R630
Rs
R25
Combining R3 & R4 to obtain a
sum of resistance in the line
Rs = R3 + R4
60
The Coloured Bands of Resistor 1. First of all, we can give the single-character code for the coloured bands that marks a
resistor and compute it into resistance.
Colour Number Code
BlackBrownRedOrange Yellow
01234
BNROY
2. Next, we can calculate the equivalent resistance by giving the codes. The equivalent
resistance of the codes (ROY) if calculated (by calculator) by using the formula below is 230000ohm.
R(Red) is the colour 1 with number of 2 O(Orange) is the colour 2 with number of 3 Y(Yellow) is the colour 3 with number of 4
3. The equivalent resistance which has been calculated by our program is 23000ohm. Hence, our program is correct. Figure below verifies that our program can calculate the equivalent resistance with this method correctly.
Gantt chart
No. ActivityWeek
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 Analysis of the program
2 Decomposition of the poblem
3 Coding And Debugging
4 Integration
5 Testing And Validation
6 Program Completed
7 Presentation
62
Conclusion
After all the steps taken, we have managed to create a program which solved our problems
mentioned earlier. Thus this program conclusively is able to calculate the total resistance in
series, parallel and parallel-series circuit. Plus, including the calculation for the resistance of a
resistor according to the colour coded band on a unit of resistor.
Since there is a rigorous and complicated method in calculating the total resistance in the
circuit manually (by hand), thus we have successfully created a program which is able to
assist the user to solve the problem more easily.
63
This program allows the user to manipulate the type of circuit and the input needed in order
to attain the correct solution in solving the total resistance in the circuit. In the request of the
user, the program would also be able to attain the resistance of a resistor using the colour
coded band calculation.
Bibliography
C++ Language Tutorial February 29 2000. <http://www.cplusplus.com/doc/tutorial/ >
C++ Reference April 2002. < http://www.cppreference.com/wiki/start>
C Programming and C++ Programming August 2005. < http://www.cprogramming.com/>