Date:2010-10-16 04:58:57 (13 years 5 months ago)
Author:Werner Almesberger
Commit:c1574ce3f6dec19ca224c4f05a2a4170434a0238
Message:Catalog listing and enhanced versions of various BOOM items from ben-wpan/bom.

- boom/dist/dk/dk-catq.pl: new - query the Digi-Key catalog for a list of
items
- boom/dist/dk/dk-db.pl: enhanced - never generate more than 1000 queries
per wget run (to keep argv from getting too long)
- boom/dist/dk/panasonic-erj.catq, boom/dist/dk/stackpole-rmcf.catq: query
scripts for dk-catq.pl
- boom/lib/e12.inc: enhanced - added Rxx and Rxxx codes
- boom/manu/panasonic/panasonic.gen: enhanced - added decoding for all ERJ
series resistors listed at Digi-Key
- boom/manu/stackpole/: (new) part number decoder for RMCF series resistors
Files: boom/dist/dk/Makefile (1 diff)
boom/dist/dk/dk-catq.pl (1 diff)
boom/dist/dk/dk-db.pl (1 diff)
boom/dist/dk/panasonic-erj.catq (1 diff)
boom/dist/dk/stackpole-rmcf.catq (1 diff)
boom/lib/e12.inc (1 diff)
boom/manu/panasonic/Makefile (1 diff)
boom/manu/panasonic/panasonic.gen (1 diff)
boom/manu/stackpole/Makefile (1 diff)
boom/manu/stackpole/stackpole.gen (1 diff)

Change Details

boom/dist/dk/Makefile
1CACHE = query.data
2EQUS = panasonic-erj stackpole-rmcf
3
4.SUFFIXES: .catq .equ
5
6all: db/digi-key.dsc db/digi-key.inv
7
8$(CACHE): db/digi-key.equ
9            awk '/^#END/ { exit } /^DIGI-KEY / { print $$2 }' $< | \
10              perl ./dk-db.pl query \
11              `[ -r $(CACHE) ] && echo '' -i $(CACHE)` >_$@ || \
12              { rm -f $@ _$@; exit 1; }
13            mv _$@ $@
14
15db/digi-key.equ: $(EQUS:%=db/%.equ)
16            cat $^ >$@ || { rm -rf $@; exit 1; }
17
18db/digi-key.dsc: $(CACHE)
19            perl ./dk-db.pl dsc $< >$@ || \
20              { rm -f $@; exit 1; }
21
22db/digi-key.inv: $(CACHE)
23            perl ./dk-db.pl inv $< >$@ || \
24              { rm -f $@; exit 1; }
25
26.catq.equ:
27            perl ./dk-catq.pl $< >$@ || { rm -rf $@; exit 1; }
boom/dist/dk/dk-catq.pl
1#!/usr/bin/perl
2
3$BASE = "http://search.digikey.com/scripts/DkSearch/dksus.dll";
4$QMOD = "stock=1&pbfree=1&rohs=1";
5$URL = "$BASE?$QMOD&k=";
6
7$DEBUG = 0;
8
9
10sub query
11{
12    local @q = ();
13
14    open(PIPE, "wget -O - '$_[0]' |") || die "wget: $!";
15    while (<PIPE>) {
16        chop;
17        push(@q, $_);
18    }
19    close PIPE;
20    return @q;
21}
22
23
24# --- Read query specification ------------------------------------------------
25
26
27$spec = $ARGV[0];
28
29while (<>) {
30    s/#.*//;
31    next if /^\s*$/;
32    chop;
33    push(@q, $_);
34}
35
36$id = shift @q;
37$key = shift @q;
38$cat = shift @q;
39for (@q) {
40    die "not a field=value pair: \"$_\"" unless /\s*=\s*/;
41    $f{$`} = $';
42}
43
44
45# --- Select category ---------------------------------------------------------
46
47
48$url = $URL.$key;
49
50@q = &query($url);
51
52if ($q[1] =~ /<title>Digi-Key</) {
53    undef $found;
54    for (@q) {
55        next unless /Cat=(\d+)[&"].*?>\s*([^,]*?)\s*</;
56        next if $2 ne $cat;
57        $found = $1;
58        last;
59    }
60
61    die "category \"$cat\" not found" unless defined $found;
62
63
64# --- Get parameter tables ----------------------------------------------------
65
66
67    $url .= "&Cat=$found";
68
69    @q = &query($url);
70}
71
72for (@q) {
73    if (/^<th>\s*(.*?)\s*<\/th>/) {
74        print STDERR "col name \"$1\"\n" if $DEBUG;
75        push(@col_name, $1);
76        next;
77    }
78    if (/<select .* name=([^ >]+)/) {
79        $cols++;
80        $col = $col_name[$cols-1];
81        die "cols = $cols" unless defined $col;
82        print STDERR "$col -> \"$1\"\n" if $DEBUG;
83        $col_field{$col} = $1;
84        next;
85    }
86    next unless /<option value=(\d+)>\s*(.*?)\s*(<.*)?$/;
87    print STDERR "val{$col}{$2} = \"$1\"\n" if $DEBUG;
88    $val{$col}{$2} = $1;
89}
90
91for (keys %f) {
92    $field = $col_field{$_};
93    die "no such field: $_" unless defined $field;
94    $value = $val{$_}{$f{$_}};
95    die "no such value: \"$_\"=\"$f{$_}\"" unless defined $value;
96    $url .= "&$field=$value";
97}
98
99
100# --- Output file header ------------------------------------------------------
101
102
103print "#EQU\n# Generated from $spec\n# ".`date`."\n";
104
105
106# --- Get the pages -----------------------------------------------------------
107
108
109$url =~ s/\?/?Selection\&/; # magic key to the pages
110$page = 1;
111
112while (1) {
113    @q = &query("$url&page=$page");
114    $more = 0;
115    for (@q) {
116        $more = 1 if />Next</;
117        next unless /-ND">\s*([^>]*-ND)\s*<\/a><\/td><td>\s*(.*?)\s*</;
118        print "DIGI-KEY $1\t $id $2\n";
119    }
120    last unless $more;
121    $page++;
122}
boom/dist/dk/dk-db.pl
1#!/usr/bin/perl
2
3sub rows
4{
5    local $s = $_[0];
6    my @res = ();
7
8    while ($s =~ m#.*?<tr>(.*?)</tr>#) {
9    push(@res, $1);
10    $s = $';
11    }
12    return @res;
13}
14
15
16sub cols
17{
18    local $s = $_[0];
19    my @res = ();
20
21    while ($s =~ m#.*?<td[^>]*>(.*?)</td>#) {
22    push(@res, $1);
23    $s = $';
24    }
25    return @res;
26}
27
28
29sub flush
30{
31    $cmd = "wget -nv -O - ".join(" ",
32      map
33      "http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail\\&name=$_",
34      @pn);
35    $q .= `$cmd`;
36    @pn = ();
37}
38
39
40sub usage
41{
42    print STDERR "usage: $0 (query [-i cache_file] | dsc | inv) [file ...]\n";
43    exit(1);
44}
45
46
47$mode = shift @ARGV;
48&usage unless $mode eq "query" || $mode eq "dsc" || $mode eq "inv";
49
50if ($mode eq "query") {
51    if ($ARGV[0] eq "-i") {
52    shift @ARGV;
53    $name = shift @ARGV;
54    open(OLD, $name) || die "$name: $!";
55    $q = join("", <OLD>);
56    ($old = $q) =~ tr/\r\n//d;
57    close OLD;
58    }
59
60    while (<>) {
61    chop;
62    s/#.*//;
63    next if /^\s*$/;
64    next if /^\s/;
65    s/\s.*//;
66    next if $old =~ m#align=right>Digi-Key Part Number</th><td>$_</td#;
67    push(@pn, $_);
68    &flush if @pn > 1000;
69    }
70
71    &flush if 0+@pn;;
72
73    print $q;
74    exit;
75}
76
77
78$q = join("", <>);
79$q =~ tr/\r\n//d;
80
81print "#DSC\n" if $mode eq "dsc";
82print "#INV\n" if $mode eq "inv";
83print "# MACHINE-GENERATED. DO NOT EDIT !\n";
84print "# ", `date -u`;
85
86for (split(/<!DOCTYPE HTML/, $q)) {
87    next unless m#align=right>Digi-Key Part Number</th><td>([^<]+)</td#;
88    $pn = $1;
89    $qty = 0;
90    if (m#align=right>Quantity Available</th><td[^>]*>([0-9,]+)<#) {
91    ($qty = $1) =~ tr/,//d;
92    }
93    next unless m#align=right>Description</th><td>(.*?)</td#;
94    $dsc = $1;
95    next unless m#<table.*<th>Price Break<(.*?)</table>#;
96    if ($mode eq "dsc") {
97    print "DIGI-KEY $pn $dsc\n";
98    next;
99    }
100    print "DIGI-KEY $pn $qty USD";
101    for (&rows($1)) {
102    @c = &cols($_);
103    next unless $c[0] =~ /^[0-9,]+$/;
104    next unless $c[1] =~ /^[0-9.]+$/;
105    $c[0] =~ tr/,//d;
106    $c[1] =~ tr/,//d; # let's hope we don't need this one often :)
107    $c[1] =~ s/0+$// if $c[1] =~ /\./;
108    print " $c[0] $c[1]";
109    }
110    print "\n";
111}
boom/dist/dk/panasonic-erj.catq
1#
2# File structure:
3#
4# - manufacturer name as used in BOOM
5# - keyword
6# - product category
7# - zero or more field=value pairs
8#
9# Comment lines and empty lines are ignored.
10#
11PANASONIC
12erj
13Chip Resistor - Surface Mount
14Packaging = Cut Tape (CT)
boom/dist/dk/stackpole-rmcf.catq
1#
2# File structure:
3#
4# - manufacturer name as used in BOOM
5# - keyword
6# - product category
7# - zero or more field=value pairs
8#
9# Comment lines and empty lines are ignored.
10#
11STACKPOLE
12rmcf
13Chip Resistor - Surface Mount
14Packaging = Cut Tape (CT)
boom/lib/e12.inc
1# E12 scale
2
3_E12_1=(??)0 -> _E12=${_E12_1:1}
4_E12_1=(??)1 -> _E12=${_E12_1:1}0
5_E12_1=(?)(?)2 -> _E12=$_E12_1:1.${_E12_1:2}k
6_E12_1=(??)3 -> _E12=${_E12_1:1}k
7_E12_1=(??)4 -> _E12=${_E12_1:1}0k
8_E12_1=(?)(?)5 -> _E12=$_E12_1:1.${_E12_1:2}M
9_E12_1=(??)6 -> _E12=${_E12_1:1}M
10_E12_1=(??)7 -> _E12=${_E12_1:1}0M
11_E12_1=R(??) -> _E12=0.$_E12_1:1
12_E12_1=(?)R(?) -> _E12=$_E12_1:1.$_E12_1:2
13
14# E96 scale
15
16_E12_1=(???)0 -> _E12=${_E12_1:1}
17_E12_1=(?)(??)1 -> _E12=$_E12_1:1.${_E12_1:2}k
18_E12_1=(??)(?)2 -> _E12=$_E12_1:1.${_E12_1:2}k
19_E12_1=(???)3 -> _E12=${_E12_1:1}k
20_E12_1=(?)(??)4 -> _E12=$_E12_1:1.${_E12_1:2}M
21_E12_1=(??)(?)5 -> _E12=$_E12_1:1.${_E12_1:2}M
22_E12_1=R(???) -> _E12=0.$_E12_1:1
23_E12_1=(?)R(??) -> _E12=$_E12_1:1.$_E12_1:2
24_E12_1=(??)R(?) -> _E12=$_E12_1:1.$_E12_1:2
25
26# E12 scale, base multiplier is 10^-12 (pico)
27
28_E12_P=(??)8 -> _E12=${_E12_P:1}0f
29_E12_P=(?)(?)9 -> _E12=$_E12_P:1.${_E12_P:2}p
30_E12_P=(??)0 -> _E12=${_E12_P:1}p
31_E12_P=(??)1 -> _E12=${_E12_P:1}0p
32_E12_P=(?)(?)2 -> _E12=$_E12_P:1.${_E12_P:2}n
33_E12_P=(??)3 -> _E12=${_E12_P:1}n
34_E12_P=(??)4 -> _E12=${_E12_P:1}0n
35_E12_P=(?)(?)5 -> _E12=$_E12_P:1.${_E12_P:2}u
36_E12_P=(??)6 -> _E12=${_E12_P:1}u
37_E12_P=(??)7 -> _E12=${_E12_P:1}0u
38_E12_P=(?)R(?) -> _E12=$_E12_P:1.${_E12_P:2}p # strange
39
40# remove leading and trailing zeroes
41
42_E12=0([0-9]*) -> _E12=$_E12:1
43_E12=(*.[0-9]*)0([fpnumkM]) -> _E12=$_E12:1$_E12:2
44_E12=(*).0([fpnumkM]) -> _E12=$_E12:1$_E12:2
45_E12=(*.[0-9]*)0 -> _E12=$_E12:1
46_E12=(*).0 -> _E12=$_E12:1
boom/manu/panasonic/Makefile
1BOOM=PATH=/home/moko/svn.openmoko.org/trunk/eda/boom:../boom:$$PATH boom
2
3panasonic.chr: ../../dist/dk/db/digi-key.equ panasonic.gen
4    $(BOOM) gen2chr PANASONIC $^ >$@ || { rm -rf $@; exit 1; }
boom/manu/panasonic/panasonic.gen
1#GEN
2
3# http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE1.pdf
4# http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE2.pdf
5# http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE3.pdf
6# http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE4.pdf
7# http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE7.pdf
8# http://media.digikey.com/pdf/Data Sheets/Panasonic Resistors Thermistors PDFs/ERJ1TYFyyyU, ERJ1TY0R00U.pdf
9
10ERJ* -> T=R {
11
12    # http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE1.pdf
13
14    # XGE is special, see below
15    # K tolerance is undocumented
16
17    ERJ-([X1]GN|[X12368]GE|14|12|12Z|1T)(Y|)(J|K|0)([0-9R][0-9R][0-9])* ->
18    _FP=$REF:1 _TOL=$REF:3 _E12_1=$REF:4
19
20    # http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE2.pdf
21
22    ERJ-([1236]R)([HBKE])(D)([0-9R][0-9R][0-9R][0-9])* ->
23    _FP=$REF:1 _TOL=$REF:3 _E12_1=$REF:4
24
25    # 1GE is special, see below
26
27    ERJ-([X1]GN|1GE|2RK|3EK|[68]EN|1[42T]N|12S)(F)([0-9R][0-9R][0-9R][0-9])* ->
28    _FP=$REF:1 _TOL=$REF:2 _E12_1=$REF:3
29
30    # http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE3.pdf
31
32    ERJ-([2368]B|[368]R|1[4T]R|12[RZ])(S|Q)([FGJ])([0-9R][0-9R][0-9])* ->
33    _FP=$REF:1 _FP2=$REF:1 _TOL=$REF:3 _E12_1=$REF:4
34
35    ERJ-([2368]BW)([FGJ])([0-9R][0-9R][0-9R][0-9])* ->
36    _FP=$REF:1 _FP2=$REF:1 _TOL=$REF:2 _E12_1=$REF:3
37
38    ERJ-(L0[368]|L1[42DW])(K|U)(F|J)([0-9][0-9][MC])* ->
39    _FP=$REF:1 _TOL=$REF:3 _LOW_R=$REF:4
40
41    # http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE4.pdf
42
43    ERJ-(P0[368]|P14)(D|F)([R0-9][R0-9][R0-9][0-9])* ->
44    _FP=$REF:1 _TOL=$REF:3 _E12_1=$REF:3
45
46    ERJ-(P0[368]|P14)(J)([R0-9][R0-9][0-9])* ->
47    _FP=$REF:1 _TOL=$REF:3 _E12_1=$REF:3
48
49    # http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE7.pdf
50
51    ERJ-(M03)N(F|J)([0-9][0-9M][0-9M])* ->
52    _FP=$REF:1 _TOL=$REF:2 _LOW_R=$REF:3
53
54    ERJ-(M1W)(S|T)(F|J)([0-9][0-9M][0-9M])* ->
55    _FP=$REF:1 _TOL=$REF:3 _LOW_R=$REF:4
56
57    # ERJ1TY0R00U.pdf
58
59    ERJ-(1T)(Y)(F)([0-9][0-9][0-9])* ->
60    _FP=$REF:1 _TOL=$REF:3 _E12_1=$REF:4
61
62    # XGE and 1GE are not listed in the part number decoding scheme.
63    # Assume they're equal to XGN and 1GN, respectively.
64
65    _FP=XGE -> _FP=XGN
66    _FP=1GE -> _FP=1GN
67
68
69    # http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE1.pdf
70
71    _FP=XGN -> FP=01005 P=1/32W V=15V
72    _FP=1GN -> FP=0201 P=1/20W V=25V
73    _FP=2GE -> FP=0402 P=1/10W V=50V
74    _FP=3GE -> FP=0603 P=1/10W V=75V
75    _FP=6GE -> FP=0805 P=1/8W V=150V
76    _FP=8GE -> FP=1206 P=1/4W V=200V
77    _FP=12Z -> FP=2010 P=3/4W V=200V
78    _FP=14 -> FP=1210 P=1/2W V=200V
79    _FP=12 -> FP=1812 P=3/4W V=200V
80    _FP=1T -> FP=2512 P=1W V=200V
81
82    # http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE2.pdf
83
84    _FP=1R -> FP=0201 P=1/20W V=15V
85    _FP=2R -> FP=0402 P=1/16W V=50V
86    _FP=3R -> FP=0603 P=1/16W V=50V
87    _FP=6R -> FP=0805 P=1/10W V=150V
88
89    _FP=2RK -> FP=0402 P=1/10W V=50V
90    _FP=3EK -> FP=0603 P=1/10W V=75V
91    _FP=6EN -> FP=0805 P=1/8W V=150V
92    _FP=8EN -> FP=1206 P=1/4W V=200V
93    _FP=14N -> FP=1210 P=1/2W V=200V
94    _FP=12N -> FP=1812 P=3/4W V=200V
95    _FP=12S -> FP=2010 P=3/4W V=200V
96    _FP=1TN -> FP=2512 P=1W V=200V
97
98    # http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE3.pdf
99
100    _FP=2B -> FP=0402 P=1/8W
101    _FP2=3R -> FP=0603 P=1/10W # override regular 3R
102    _FP=3B -> FP=0603 P=1/5W
103    _FP2=6R -> FP=0805 P=1/8W # override regular 6R
104    _FP=6B -> FP=0805 P=1/4W
105    _FP=8R -> FP=1206 P=1/4W
106    _FP=8B -> FP=1206 P=1/3W
107    _FP=14R -> FP=1210 P=1/4W
108    _FP=14B -> FP=1210 P=1/2W
109    _FP=12R -> FP=1812 P=1/2W
110    _FP=12Z -> FP=2010 P=1/2W
111    _FP=1TR -> FP=2512 P=1W
112
113    _FP=2BW -> FP=0402 P=1/8W
114    _FP=3BW -> FP=0603 P=1/4W
115    _FP=6BW -> FP=0805 P=1/3W
116    _FP=8BW -> FP=1206 P=1/2W
117
118    _FP=L03 -> FP=0603 P=1/10W
119    _FP=L06 -> FP=0805 P=1/8W
120    _FP=L08 -> FP=1206 P=1/4W
121    _FP=L14 -> FP=1210 P=1/3W
122    _FP=L12 -> FP=1812 P=1/2W
123    _FP=L1D -> FP=2010 P=1/2W
124    _FP=L1W -> FP=2512 P=1W
125
126    # http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE4.pdf
127
128    _FP=P03 -> FP=0603 P=1/5W V=150V
129    _FP=P06 -> FP=0805 P=1/4W V=150V
130    _FP=P08 -> FP=1206 P=1/3W V=200V
131    _FP=P12 -> FP=1210 P=1/2W V=200V
132
133    # http://industrial.panasonic.com/www-data/pdf/AOA0000/AOA0000CE7.pdf
134
135    _FP=M03 -> FP=0603 P=1/4W
136    _FP=M1W -> FP=2512 P=1W
137
138    # L and M series don't use E12
139
140    _LOW_R=(?)M(?) -> _E12=$_LOW_R:1.${_LOW_R:2}m
141    _LOW_R=(??)M -> _E12_1=R0${_LOW_R:1}
142    _LOW_R=(??)C -> _E12_1=R${_LOW_R:1}
143
144    _TOL=D -> TOL=0.5%
145    _TOL=F -> TOL=1%
146    _TOL=G -> TOL=2%
147    _TOL=J -> TOL=5%
148    _TOL=K -> TOL=10%
149}
150
151include ../../lib/e12.inc
152
153T=R -> R=${_E12}R !
boom/manu/stackpole/Makefile
1BOOM=PATH=/home/moko/svn.openmoko.org/trunk/eda/boom:../boom:$$PATH boom
2
3stackpole.chr: ../../dist/dk/db/digi-key.equ stackpole.gen
4    $(BOOM) gen2chr STACKPOLE $^ >$@ || { rm -rf $@; exit 1; }
boom/manu/stackpole/stackpole.gen
1#GEN
2
3# http://www.seielect.com/Catalog/SEI-RMC.pdf
4
5RMCF* -> T=R {
6    RMCF(????)(?)(?)([0-9R][0-9RKM][0-9RKM])* ->
7    FP=$REF:1 _TOL=$REF:2 _R=$REF:3
8
9    _TOL=F -> TOL=1%
10    _TOL=J -> TOL=5%
11
12    FP=0201 -> P=1/20W V=25V
13    FP=0402 -> P=1/16W V=50V
14    FP=0603 -> P=1/10W V=50V
15    FP=0805 -> P=1/8W V=150V
16    FP=1206 -> P=1/4W V=200V
17    FP=1210 -> P=1/3W V=200V
18    FP=2010 -> P=3/4W V=200V
19    FP=2512 -> P=1W V=200V
20}
21
22
23# Adjust multipliers
24
25_R=(*)R(*) -> _R=0$_R:1.$_R:2
26_R=(*)K(*) -> _R=$_R:1.${_R:2}k
27_R=(*)M(*) -> _R=$_R:1.${_R:2}M
28
29# Remove leading and trailing zeroes
30
31_R=0([0-9]*) -> _R=$_R:1
32_R=(*.[0-9]*)0([kM]) -> _R=$_R:1$_R:2
33_R=(*).0([kM]) -> _R=$_R:1$_R:2
34_R=(*.[0-9]*)0 -> _R=$_R:1
35_R=(*).0 -> _R=$_R:1
36
37T=R -> R=${_R}R !

Archive Download the corresponding diff file

Branches:
master



interactive