The Resistors widget is a special purpose calculator to decode the colored bands on resistors (and small capacitors).
The widget uses the old color code where resistors are marked with three or four colored bands. The first band (closest to an end of the resistor) indicates the first digit of the resistor value. The second band indicates the second digit, and the third band indicates a multiplier. The fourth band (if present) is colored silver or gold and indicates a tolerance value, with which we will not concern ourselves.
The color code is as follows:
band1 band2 band3 (multiplier) black 0 1 brown 1 1 10 red 2 2 100 orange 3 3 1000 yellow 4 4 10000 green 5 5 100000 blue 6 6 1000000 violet 7 7 10000000 gray 8 8 100000000 white 9 9 1000000000 silver 0.01 gold 0.1
The value (in ohms) is given by (10*band1 + band2)*band3.
Note that band1 is never black, except in the case of zero ohm resistors
which are marked with a single black band.
So [yellow, violet, red] has the value ((10*4)+7)*100 = 4700.
We have a keypad with twelve keys, one for each of the colors, and a thirteenth reset key.
The widget uses a finite state machine model.
The state machine has three states:
1 the output field is clear (or contains the result of a previous calculation) and we are waiting for the first color
2 the first digit is in the output field and we are waiting for the second color
3 the first two digits are in the output field and we are waiting for the third color
The inputs to the state machine are the values of the 12 color keys.
As the colored keys are pressed the machine moves from state to state. Not all keys are valid in each state, so our program checks for valid keys and alerts when they are not.
Some resistors have four bands that encode the resistor value. The widget has a popup menu to set the number of encoding bands. When there are four encoding bands, the fourth band is used as the multiplier band. Bands 1, 2 and 3 then specify three digits.
The value (in ohms) is given by (100*band1 + 10*band2 + band3)*band4.
The widget has a popup menu to request output in International Notation.
Examples:
0.67 would be shown as 0R67 1.5 would be shown as 1R5 27 would be shown as 27R 320 would be shown as 320R 2200 would be shown as 2k2 6300000 would be shown as 6M3
The widget has a popup menu to choose between decoding resistors and (small) capacitors. The basic unit for resistors is ohms, but the coded capacitor values are in picoFarads.
Examples:
0.67 would be shown as 0p67 1.5 would be shown as 1p5 27 would be shown as 27p 320 would be shown as 320p 2200 would be shown as 2n2 6300000 would be shown as 6μ3
Resistors - A special purpose calculator to decode the colored bands on resistors (and small capacitors).
Copyright © 2004-2015 Harry Whitfield
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
This program and associated documentation are Copyright 2004-2015 Harry Whitfield.