chiark / gitweb /
divider table initial version seems okish
authorian <ian>
Sun, 23 May 2004 14:40:25 +0000 (14:40 +0000)
committerian <ian>
Sun, 23 May 2004 14:40:25 +0000 (14:40 +0000)
.cvsignore
misc/divider-table.pl [new file with mode: 0755]
pcb/Makefile
pic.make
spice/Makefile

index 321b5c7af71e4456c944877a55dff8bcde98efb4..8e21700651a6561ca16eb111d67e84f90014d197 100644 (file)
@@ -17,3 +17,4 @@ circuit.bom
 bulkres-items.partlist
 bulkres-select.partlist
 bulkres.bom
+divider-table.txt
diff --git a/misc/divider-table.pl b/misc/divider-table.pl
new file mode 100755 (executable)
index 0000000..6b5a6ab
--- /dev/null
@@ -0,0 +1,132 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+our(@e12) = qw(10 12 15 18 22 27 33 39 47 56 68 82);
+our(@ex24) = qw(11 13 16 20 24 30 36 43 51 62 75 91);
+our(@e24)= sort @e12, @ex24;
+
+our ($tlin,$tlog,@byrat);
+
+sub thead ($$) {
+    my ($t,$h) = @_;
+    $$t = sprintf "%-10s |", $h;
+}
+sub chead ($$) {
+    my ($t,$h) = @_;
+    $$t .= sprintf " %5s", $h;
+}
+sub theadend ($) {
+    my ($t) = @_;
+    $$t .= "\n".('-'x(10+1)).'+'.('-'x(24*6))."\n";
+}
+sub rhead ($$) {
+    my ($t,$h) = @_;
+    $$t .= sprintf "%10s |", $h;
+}
+sub cell ($$) {
+    my ($t,$v) = @_;
+    $$t .= sprintf " %5.3f", $v;
+}
+sub rend ($$) {
+    my ($t,$n) = @_;
+    $$t .= "\n";
+    $$t .= "\n" if ($n % 4) == 3;
+}
+sub tend ($) {
+    my ($t) = @_;
+}
+
+sub scan () {
+    my ($row,$col,$lin,$log,$rownum);
+    @byrat = ();
+    thead(\$tlin,'Row/Col');
+    thead(\$tlog,'L(R/C)+1');
+    for $col (@e24) {
+       chead(\$tlin,$col);
+       chead(\$tlog,$col);
+    }
+    theadend(\$tlin);
+    theadend(\$tlog);
+    $rownum= 0;
+    for $row (@e24) {
+       rhead(\$tlin,$row);
+       rhead(\$tlog,$row);
+       for $col (@e24) {
+           $lin= $col*1.0 / $row;
+           $log= log($lin)/log(10) + 1.0;
+           cell(\$tlin,$lin);
+           cell(\$tlog,$log);
+           if ($col < $row) { $lin *= 10; }
+           next if $row==$col;
+           push @byrat, { Num => $col,
+                          Den => $row,
+                          Lin => $lin,
+                          Log => $log };
+       }
+       rend(\$tlin,$rownum);
+       rend(\$tlog,$rownum);
+       $rownum++;
+    }
+    tend(\$tlin);
+    tend(\$tlog);
+    push @byrat, { Num => '*',
+                  Den => '*',
+                  Lin => 1.0,
+                  Log => 1.0 };
+}
+
+sub ptable ($) {
+    my ($tt) = @_;
+    print $tt or die $!;
+}
+
+sub sortbyrat () {
+    @byrat= sort {
+       $a->{Lin} <=> $b->{Lin}
+    } @byrat;
+}
+
+sub byratcol ($$$) {
+    my ($or,$cwr,$colnum) = @_;
+    $$or .= '  ' if $colnum;
+    $$cwr = ($colnum<4 ? 7 : 6);
+}
+
+sub printbyrat () {
+    use integer;
+    my ($brcols) = 7;
+    my ($brrows) = (@byrat+$brcols-1) / $brcols;
+    my ($byrat,$o,$colnum,$rownum,$cw);
+    $o= ''; 
+    for ($colnum=0; $colnum<$brcols; $colnum++) {
+       byratcol(\$o,\$cw,$colnum);
+       $o .= sprintf(" N/D  %${cw}s %7s",
+                     'Q[*10]','Lg(Q)+1');
+    }
+    $o .= "\n";
+    for ($colnum=0; $colnum<$brcols; $colnum++) {
+       byratcol(\$o,\$cw,$colnum);
+       $o .= '-' x (5+1+$cw+1+7);
+    }
+    $o .= "\n";
+    for ($rownum=0; $rownum<$brrows; $rownum++) { 
+       for ($colnum=0; $colnum<$brcols; $colnum++) {
+           $byrat= $byrat[$colnum*$brrows + $rownum];
+           next unless defined $byrat;
+           byratcol(\$o,\$cw,$colnum);
+           $o .= sprintf("%2s/%-2s %${cw}.".($cw-2)."f %7.5f",
+                         $byrat->{Num}, $byrat->{Den},
+                         $byrat->{Lin}, $byrat->{Log});
+       }
+       $o .= "\n";
+    }
+    print $o or die $!;
+}
+
+scan();
+ptable($tlin);
+ptable($tlog);
+
+sortbyrat();
+printbyrat();
index 97a065140c24f9fa0b03110c1f7776e596ccd620..1014ab6d51aff967173e7df0df64764814d69ff0 100644 (file)
@@ -13,7 +13,7 @@ LAYERS=               $(LAYERS_L) $(LAYERS_E)
 default:       ours-a.ps ours-al.ps parts.ps
 layers:                $(LAYERS)
 
-all:           default layers circuit.bom bulkres.bom
+all:           default layers circuit.bom bulkres.bom divider-tables
 
 o=>$@.new && mv -f $@.new $@
 
@@ -38,6 +38,14 @@ bulkres-items.descs: bulkres-items.suggest
 bulkres-items.partlist:
                ./farnell-resistor-convert.pl <bulkres-items.descs MRS25 std $o
 
+divider-table.txt:     divider-table.pl
+               ./$^ $o
+
+divider-tables:                divider-table.ps divider-table.txt
+
+divider-table.ps:      divider-table.txt
+               a2ps -o- -R -1 --borders no -B -l156 -L"$$(wc -l <$^)" <$^ $o
+
 %.d4:          %.m4 $(M4INCS) Makefile
                m4 -s <$< $o
 
index 97a065140c24f9fa0b03110c1f7776e596ccd620..1014ab6d51aff967173e7df0df64764814d69ff0 100644 (file)
--- a/pic.make
+++ b/pic.make
@@ -13,7 +13,7 @@ LAYERS=               $(LAYERS_L) $(LAYERS_E)
 default:       ours-a.ps ours-al.ps parts.ps
 layers:                $(LAYERS)
 
-all:           default layers circuit.bom bulkres.bom
+all:           default layers circuit.bom bulkres.bom divider-tables
 
 o=>$@.new && mv -f $@.new $@
 
@@ -38,6 +38,14 @@ bulkres-items.descs: bulkres-items.suggest
 bulkres-items.partlist:
                ./farnell-resistor-convert.pl <bulkres-items.descs MRS25 std $o
 
+divider-table.txt:     divider-table.pl
+               ./$^ $o
+
+divider-tables:                divider-table.ps divider-table.txt
+
+divider-table.ps:      divider-table.txt
+               a2ps -o- -R -1 --borders no -B -l156 -L"$$(wc -l <$^)" <$^ $o
+
 %.d4:          %.m4 $(M4INCS) Makefile
                m4 -s <$< $o
 
index 97a065140c24f9fa0b03110c1f7776e596ccd620..1014ab6d51aff967173e7df0df64764814d69ff0 100644 (file)
@@ -13,7 +13,7 @@ LAYERS=               $(LAYERS_L) $(LAYERS_E)
 default:       ours-a.ps ours-al.ps parts.ps
 layers:                $(LAYERS)
 
-all:           default layers circuit.bom bulkres.bom
+all:           default layers circuit.bom bulkres.bom divider-tables
 
 o=>$@.new && mv -f $@.new $@
 
@@ -38,6 +38,14 @@ bulkres-items.descs: bulkres-items.suggest
 bulkres-items.partlist:
                ./farnell-resistor-convert.pl <bulkres-items.descs MRS25 std $o
 
+divider-table.txt:     divider-table.pl
+               ./$^ $o
+
+divider-tables:                divider-table.ps divider-table.txt
+
+divider-table.ps:      divider-table.txt
+               a2ps -o- -R -1 --borders no -B -l156 -L"$$(wc -l <$^)" <$^ $o
+
 %.d4:          %.m4 $(M4INCS) Makefile
                m4 -s <$< $o