FINAL PROJECT BEC10102 2012/2013 3.0 ANALYSIS Table 1 : Data Analysis
ITEM
DESCRIPTION a = Option for the circuit type to calculate the total of resistance. The option as below: 1. Series 2. Parallel 3. Enter value of current & voltage. n = The number of the resistance that been entered. array[i] = Declaration for every value of resistance been entered. x = Option for user to choose 1=yes or 0=no to continue with current divider or voltage divider. V = The value of voltage that been entered.
INPUT DATA
I = The value of current that been entered. b = Option for the circuit type to calculate voltage divider or current divider. The option as below: 1. Series 2. Parallel. R = The total of resistance that been entered (RT). Ri = The value of resistance that been entered (Rn). Option 1. 2. 3. 4. 5.
= Option for the calculation type. The option as below: Voltage Current Resistance Power Current Divider and Voltage Divider
Calculation for the Voltage (option=1) V=I*R Calculation for the Current (option=2) I=V/R Calculation for the Total of Resistance (option=3) When a = 1 (series), the process is as below : resistance = resistance + array[i]
PROCESS When a = 2 (parallel), the process is as below : denominator = denominator + 1/ array[i], resistance = 1 / denominator When a = 2 (parallel), the process is as below : R=V/I
2|Page
FINAL PROJECT BEC10102 2012/2013 *x is for the user to continue with current divider (parallel) or voltage divider (series) referring the circuit type option (a), when x = 1 (yes), the process is as below : Vi = (array[i] / resistance) * V or Ii = (resistance / array[i]) * I when x = 0 (no), the program will return to main menu. Calculation for the Power (option=4) P=I*V Calculation for the Current Divider and Voltage Divider (option=4) When b = 1 (series), the process is as below : Vi = (Ri / R) * V When b = 2 (parallel), the process is as below : Ii = (R / Ri) * I Return To Main Menu y=1
PROGRAM OUTPUT
3|Page
resistance = The total of resistance. Vi = The voltage drop (voltage divider) through resistance[i]. Ii = The current drop (voltage divider) through resistance[i]. R = The value of resistance. V = The value of voltage. I = The value of current. P = The value of power.
FINAL PROJECT BEC10102 2012/2013 4.0 DESIGN 4.1 Main Function
BEGIN Y=1
Input Option
Y Option = 1
EnterI
V = I*R
PrintV
and R
N Y Option = 2
N
I = V/R
Rtotal
Y
Option = 4
Enter
I
P = I*V
and V
N Y Option = 1
V – I divider
N END
Figure 1 : The flowchart of Main Function
4|Page
Print i
Y
Option = 3
N
Enter V and R
Print P
FINAL PROJECT BEC10102 2012/2013 4.2 Total Of Resistance Function
Resistance = resistance + array[i]
i ++
Rtotal
Enter a
Y Resistance = 0.00
Enter n
a=1
Enter array [i]
i=1
N
aa
a=2 N
Y i<=n
N
Y
Enter I and V
Print Resistance
R=V/I
Enter x
Print R
N x=1
bb Y
Return Enter v
i=1
i ++
Y
Array [i]
N Vi = (array[i]/resistance)V
i<=n Print Vi
Figure 2 : The flowchart of Total of Resistance Function (1)
5|Page
FINAL PROJECT BEC10102 2012/2013
i ++
From aa
Denominator=denominator+ (1/array[i])
Enter n
Resistance = 0.00 i<=n
Print resistance
Denominator= 0.00
Array[i]
i =1
Enter x
From bb x=1
Enter I Print Ii i=1 i ++ Array [i] Ii = (resistance/array[i])*I i<=n
Figure 3 : The flowchart of Total of Resistance Function (2)
6|Page
FINAL PROJECT BEC10102 2012/2013 4.3 Voltage Divider And Current Divider
V –I divider
ENTER b
N b=1
Enter V, R and Ri
Enter I, R and Ri
Ii = (R/Ri) * I
Print Ii
Vi = (Ri/R) * V
Print Vi
Return
Figure 4 : The flowchart of Voltage Divider and Current Divider Function
7|Page
FINAL PROJECT BEC10102 2012/2013 5.0 THE SOURCE CODE USING C++
8|Page
FINAL PROJECT BEC10102 2012/2013
9|Page
FINAL PROJECT BEC10102 2012/2013
10 | P a g e
FINAL PROJECT BEC10102 2012/2013
11 | P a g e
FINAL PROJECT BEC10102 2012/2013
12 | P a g e
FINAL PROJECT BEC10102 2012/2013 6.0 TESTING AND VERIFICATION
1.
The final result will come out as below when the program is executed.
Figure 5 : Main Menu
2.
When user key in 1 is to calculate the voltage of resistor Current =40A Resistor = 8 ohm Voltage =40x8 =320V
Figure 6 : Voltage Calculation
13 | P a g e
FINAL PROJECT BEC10102 2012/2013 3.
When user key in 2 is calculate the current of resistor Voltage = 68v Resistance =4 ohm Current = 68/4 = 17A
Figure 7 : Current Calculation
4.
Next press 3, to calculate the resistance, having two choice which it circuit are connect in parallel or series.
Figure 8 : Resistance Calculation
14 | P a g e
FINAL PROJECT BEC10102 2012/2013 5.
User key in 1 that mean resistor is series connection, shown as below. R1 = 10 ohm R2 = 10 ohm Total of resistors = 20 ohms Whether user want to continue calculate the current divider or not, the question still appear on the screen when resistor finish calculate Not continue calculate the current divider press 2 will return back the initially page.
Figure 9 : End of Resistance Calculation (series)
.Press 1 is continue voltage divider, shown as below R1=(10*20v)/20 = 10v R2=(10*20v)/20 = 10v
Figure 10 : Continue to Voltage Divider
15 | P a g e
FINAL PROJECT BEC10102 2012/2013 6.
User key in 2 resistors is connected with parallel shown as below. R1 = 15 ohm R2 = 15 ohm Total of resistors = 1/ (1/15 +1/15) = 7.5 ohms Not continue with current divider.
Figure 11 : End of Resistance Calculation (Parallel)
7.
Next press 4 in the program able to calculate the power on the circuit. Power = cunrrent x voltage = 20x5 = 100w
Figure 12 : Power Calculation
16 | P a g e
FINAL PROJECT BEC10102 2012/2013 8.
Key in 5 in the program is calculate voltage divider and current divider as below.
Figure 13 : Voltage Divider And Current Divider
Select 1 in series condition on the circuit . Voltage divider = 50x33 /66 = 25v
Figure 14 : Voltage Divider Calculation
Select 2 in parallel condition on the circuit. Current divider = (25/4 )x 68 = 212.5A
Figure 15 : Current Divider Calculation
17 | P a g e
FINAL PROJECT BEC10102 2012/2013 9.
If the users do not want continue just key in 0. Then, the program will exit.
Figure 16 : Exit
18 | P a g e
FINAL PROJECT BEC10102 2012/2013 7.0 DISCUSSION
Every starting the program have define header file before the program written in these program for example using ( iostream) to insert input and output program, and then we will declare what we need to use for the input for example “a” to declare for the input in integer .
Header need to define what needed in the program Void declare Rtotal for voiding return
Declare each of the integer and double variables use in this program
After user will select what user want to calculate either circuit in the series or parallel, if the user select “2” this program will execute for parallel circuit calculation.
If users select 1 the program If users select 2 the program
will calculate for series
will calculate for parallel
Then program will go to selection function that been made by using else, else if and if function for series circuit calculation, selection need to use in this program to select the process in the program build in. Selection function help the program to detect what the process will be execute for these case the user choose parallel circuit calculation in the one parallel circuit. The program will show the user to “Enter number of resistors in the circuit:” then the user decide the how many resistor that user need to calculate in these parallel circuit. If the user insert 2 resistor need to be calculate the process execute to calculate the resistor, here the function “for” is use for repetition in the calculation show that if input inserted is 2 the function will repeat until it fulfill requirement, after the requirement have been fulfill it will stop inserting the resistor value.
19 | P a g e
FINAL PROJECT BEC10102 2012/2013 When the user select for no 1 it calculate the series resistance in the circuit, the program was shown as below:
The user select no 1 for calculate series resistance Input for resistance
Formula to calculate the
Repetition for
series resistance
resistance value
Selection function for parallel cicuit
Repetition Function for the resistor value
Process of calculation or formula for parallel circuit
If the user want to continue to calculate current divider user need to select 1 to continue to the next process. In the process user will show “Please enter the value of current:” and decide value of current in the circuit. When the user select for no 3 it calculate the resistance (R) in circuit when the user insert the value for input V and I . Input V and I
V= voltage
I=current
Formula to calculate the resistance in circuit
20 | P a g e
FINAL PROJECT BEC10102 2012/2013
Repetition Function
These will show the result of current drop through R
The selection for user choose
When the user select no 1 it calculate the voltage divider for series circuit. User select 1 to calculate series voltage divider
Formula to calculate voltage divider in circuit
The program run first
The selection to choose whether to calculate selection
The present for To terminate the statement
21 | P a g e
calculation
FINAL PROJECT BEC10102 2012/2013 To exit the program the user will need to insert 0 as the input to exit the program that have been executed, these process using switch and break function. If the function either other input or 0 were inserted It will end the program.
Enter 0 to exit the program or to end the program
default: other than input inserted the program will return to zero or ro ram will ended
To terminate the program and create new program to run
These is formula to calculate the resistance in the parallel circuit n=number of the resistor inside of the circuit and 1 is over 1/R1+1/R2…1/Rn, so these program use array to keep or hold the value of resistor.
22 | P a g e
FINAL PROJECT BEC10102 2012/2013 8.0 CONCLUSION After all the steps taken, we have m anaged to create a program which solved ou r 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 of power, voltage divider and current divider in the circuit able functional in ours program. 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. 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 able to attain the voltage or current drop of each resistance in the circuit.
23 | P a g e