Author Topic: Small and stupid decoder for EIA96 resistor markings  (Read 1987 times)

0 Members and 1 Guest are viewing this topic.

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7453
  • Country: pl
Small and stupid decoder for EIA96 resistor markings
« on: March 01, 2022, 10:59:04 am »
I was getting tired of using tables to decode those resistors, so I wrote a Perl script which takes the 3-symbol code and spits out its corresponding resistance value. It is probably mainly of interest to Linux users, because you just put it in your ~/bin and call it from terminal like any other program, but nothing stops one from porting the algorithm to some other language and/or platform. I verified one full decade of its output against this table. If somebody knows a more authoritative source, I will re-check.

Code: [Select]
$ eia96 01b
1000

You can even call it with an incorrect code or no argument at all and it will print some nonsense.
Code: [Select]
$ eia96 hello
98

Full code below. Straightforward stuff. The int(xxx + 0.5) part is rounding to nearest integer.
Code: [Select]
#!/usr/bin/perl -l

my $d = substr($ARGV[0], 0, 2);
my $e = lc(substr($ARGV[0], -1));

my $v = int(100 * 10**(($d-1)/96) + 0.5);

$v *= 0.001 if $e eq "z";
$v *= 0.01 if $e eq "y" || $e eq "r";
$v *= 0.1 if $e eq "x" || $e eq "s";
$v *= 1 if $e eq "a";
$v *= 10 if $e eq "b" || $e eq "h";
$v *= 100 if $e eq "c";
$v *= 1000 if $e eq "d";
$v *= 10000 if $e eq "e";
$v *= 100000 if $e eq "f";

print $v;
« Last Edit: March 06, 2022, 11:15:51 am by magic »
 
The following users thanked this post: floobydust

Online BeBuLamar

  • Super Contributor
  • ***
  • Posts: 1420
  • Country: us
Re: Small and stupid decoder for EIA96 resistor markings
« Reply #1 on: March 02, 2022, 03:14:45 pm »
You can read the resistor values without anything now?
 

Offline Benta

  • Super Contributor
  • ***
  • Posts: 6420
  • Country: de
Re: Small and stupid decoder for EIA96 resistor markings
« Reply #2 on: March 02, 2022, 07:36:57 pm »
Nice idea.
Downside is that it doesn't solve the problem of undecipherable colours on modern resistors, where blue/green or red/brown are indistinguishable from each other.
 

Offline notsob

  • Frequent Contributor
  • **
  • Posts: 706
  • Country: au
Re: Small and stupid decoder for EIA96 resistor markings
« Reply #3 on: March 02, 2022, 10:09:49 pm »
just put electrodoc on your smartphone
 

Offline ledtester

  • Super Contributor
  • ***
  • Posts: 3279
  • Country: us
Re: Small and stupid decoder for EIA96 resistor markings
« Reply #4 on: March 02, 2022, 10:24:14 pm »

Code: [Select]
#!/usr/bin/perl -l
...

It's nice to see a perl program these days!
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13157
  • Country: ch
Re: Small and stupid decoder for EIA96 resistor markings
« Reply #5 on: March 05, 2022, 01:19:26 pm »
Nice idea.
Downside is that it doesn't solve the problem of undecipherable colours on modern resistors, where blue/green or red/brown are indistinguishable from each other.
This has nothing to do with color bands. It’s about the stupid EIA96 codes on some SMD resistors: the code number tells you nothing about the value without a decoder sheet. It’s not like the other type of SMD resistor markings (the ones with a mantissa and multiplier) that are easily decoded without needing to memorize anything.

For example, a 3.32k resistor is “3322” (332 x 102, easily remembered as “332 and two zeros”) but “51C” (51 because 3.32 is the 51st mantissa in the E96 series, and C meaning times 104).

The EIA96 system may be systematic*, but it’s not obvious.

*other than the multiplier starting with Y for 100, X for 101, then rolling around to A for 102, B for 103, all the way up to F for 107
« Last Edit: March 06, 2022, 01:30:51 pm by tooki »
 

Offline tooki

  • Super Contributor
  • ***
  • Posts: 13157
  • Country: ch
Re: Small and stupid decoder for EIA96 resistor markings
« Reply #6 on: March 05, 2022, 01:22:21 pm »
I was getting tired of using tables to decode those resistors, so I wrote a Perl script which takes the 3-symbol code and spits out its corresponding resistance value. It is probably mainly of interest to Linux users, because you just put it in your ~/bin and call it from terminal like any other program, but nothing stops one from porting the algorithm to some other language and/or platform. I verified one full decade of its output against this table. If somebody knows a more authoritative source, I will re-check.

Code: [Select]
$ eia96 01b
1000

You can even call it with an incorrect code or no argument at all and it will print some nonsense.
Code: [Select]
$ eia96 hello
98

Full code below. Straightforward stuff. The int(xxx + 0.5) part is rounding to nearest integer.
Code: [Select]
#!/usr/bin/perl -l

my $d = substr($ARGV[0], 0, 2);
my $e = lc(substr($ARGV[0], -1));

my $v = int(100 * 10**(($d-1)/96) + 0.5);

$v *= 0.01 if $e eq "y";
$v *= 0.1 if $e eq "x";
$v *= 1 if $e eq "a";
$v *= 10 if $e eq "b";
$v *= 100 if $e eq "c";
$v *= 1000 if $e eq "d";
$v *= 10000 if $e eq "e";
$v *= 100000 if $e eq "f";

print $v;
Neato!

FYI, another page on the same site also lists a few more multiplier codes: it appears some multipliers have more than one letter! https://www.hobby-hour.com/electronics/smdcalc.php#smd_resistor_code
 
The following users thanked this post: magic

Offline magicTopic starter

  • Super Contributor
  • ***
  • Posts: 7453
  • Country: pl
Re: Small and stupid decoder for EIA96 resistor markings
« Reply #7 on: March 06, 2022, 11:21:38 am »
I added those alternative codes. Also, Z was missing (values <1Ω).

I checked against Yageo RT series datasheet. That's not exactly a standard document but at least something that a real world manufacturer published. Both my script and the table at hobby-hour appear to be right.

Which is not to be taken of granted, because some standard series like E12 are not equally spaced within each decade, the midpoint being a good example - ideal value is sqrt(10) or about 3.16, but actual resistors are 3.3.
 
The following users thanked this post: tooki

Offline exmadscientist

  • Frequent Contributor
  • **
  • Posts: 404
  • Country: us
  • Technically A Professional
Re: Small and stupid decoder for EIA96 resistor markings
« Reply #8 on: May 09, 2022, 06:17:10 am »
If somebody knows a more authoritative source, I will re-check.
Authoritative source, you say? I may or may not have found this in over in Russian territory, but I guess these days that just means it's mine now? Even if I don't own a tractor?

If anyone's looking at E192, be warned that some people use 919 and some people use 920. The correct answer, of course, is to pretend that E192 doesn't exist, because no one stocks it anyway, and just order custom instead because it's the same damn price and lead time.

(The corrigendum is pretty worthless, though this one is less trivial than they usually are. There's no need to bother with it. But I post it because some people just have to know.)
 
The following users thanked this post: magic

Offline wizard69

  • Super Contributor
  • ***
  • Posts: 1184
  • Country: us
Re: Small and stupid decoder for EIA96 resistor markings
« Reply #9 on: May 11, 2022, 01:34:35 am »
Thanks to everyone.   Never really thought much about E96, so this was enlightening.   As for the PERL code, it hurts my head, if I ever get a chance maybe a rewrite in Python.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf