1. Electronic Color Codes

advertisement
ECE285: Design Project 1 – Electronic Component Color Codes
1. Electronic Color Codes
Electronic color codes are used to indicate values or ratings of through-hole electronic components
including resistors, capacitors, and inductors. Similarly, surface mount components use a numbering
scheme to identify value and rating information. Standard through-hole resistor color coding uses a
series of color bands to identify the resistance value as well as a tolerance value as shown in Figure 1.
Figure 1. Resistor Color-Coding Bands.
Band A is the first significant figure of the component value. Band B is the second significant figure,
and band C is a decimal multiplier. Band D (if present) indicates the tolerance of the value in percent
(no band implies 20% tolerance). Table 1 gives the standard color code for the four bands.
Significant
figures
Black
0
Brown 1
Red
2
Orange 3
Yellow 4
Green 5
Blue
6
Violet
7
Gray
8
Color
White
Gold
Silver
None
9
–
–
–
Multiplier Tolerance
×100
×101
×102
×103
×104
×105
×106
×107
×108
×109
×10-1
×10-2
–
±5%
±10%
±20%
Table 1. Resistor Color Codes.
For example, a resistor with bands of yellow, violet, red, and gold will have first digit 4 (yellow in Table
1), second digit 7 (violet), followed by 2 (red) zeros: 4,700 ohms. Gold signifies that the tolerance is
±5%, so the real resistance could lie anywhere between 4,465 and 4,935 ohms.
2. TASK 1
Write a program that calculates a resistor value from a string of characters entered by the user. The
program should first prompt the user to enter a string of characters, then print the calculated resistor
value as well as minimum and maximum resistance values based on the entered tolerance. Table 2
gives the character and corresponding color.
Character
B
b
R
O
Y
G
u
V
Color
Black
Brown
Red
Orange
Yellow
Green
Blue
Violet
g
Gray
W
o
S
N
White
Gold
Silver
None
Table 2. Entered Character and Corresponding Color.
The program output should resemble the following:
Enter the resistor color code: RGOo
The resistance value is 25000 ohms +/- 5% (23750 to 26250 ohms).
Your program should continue prompting the user for a color code until the user enters ‘x’ for the first
character of the color code. Your program should terminate at that point. Hint: User the char data type
and %c format specifier for entering character values. Make sure your code is properly commented with
accurate comments describing each section of the code.
3. Task 2
Write a program that prompts the user to enter two resistor color code values, as in Task 1, then
calculates the minimum and maximum resistance values for the two resistors in series and in parallel.
The program output should resemble the following:
Enter the R1 resistor color code: YVbo
Enter the R2 resistor color code: RRRN
The R1 resistance value is 470 ohms +/- 5% (446.5 to 493.5 ohms).
The R2 resistance value is 2200 ohms +/- 20% (1760.0 to 2640.0 ohms).
The calculated series resistance is 2206.5 (min) to 3133.5 (max) ohms.
The calculated parallel resistance is 356.1 (min) to 415.8 (max) ohms.
Download