[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: gEDA-user: Connector pin numbering conventions and PCB



Sorry about the misnumbering in that example program. That header
example was meant to be didactic not functional ;-)

When creating that example I copied the DIP example and made a few
modifications.
Unfortunately the pin numbering, which should have been modified, was not.
I generated the header symbols on my site using a different script. 

As penance I modified the script (attached) to number pins in the
three different formats you mentioned --- dip, header and power. I
will post the program on my site along with a corrected version of the
header program.

I would not indicate the pin-numbering scheme in the footprint name.
It doesn't seem
like an important specification when choosing a connector. I am going
to label my
header connectors

straight 100mil       con_hdr_<cols>x<rows>__<mfg>_<mfg_pn or series>
right angle 100mil  con_hdr_ra_<cols>x<rows>__<mfg>_<mfg_pn or series>
straight 2mm         con_hdr_<cols>x<rows>-2mm__<mfg>_<mfg_pn or series>  
etc.

One thing that I didn't like about IPC-7351 was the connector naming.
100 mil centers headers have the name format HDR<rows>x<pins per row>.
Connectors from AMP, BERG, CUI-STACK, HIROSE, JST, KYCON, MOLEX,
SAMTEC, SWITCHCRAFT use the manufacturer part number as the land
pattern name.
Other connectors are named using the format 
<manufacturer>_<manufacturer_part_number>

Three different style names for one component type and a system that
could contain
duplicate names for different parts if AMP, BERG, CUI-STACK, HIROSE,
JST, KYCON, MOLEX, SAMTEC or SWITCHCRAFT change there naming
convention.

(* jcl *)

-------------------------------------- modified script
-----------------------------------

#!/usr/bin/perl

# Creates the PCB elements for Molex 8624 header connectors

use strict;
use warnings;

use Pcb_8;

my $Pcb = Pcb_8 -> new(debug => 0);

my @Fields = qw(circuits body_length pin_row_length);

my @Def; # definitions that are common to all components

while (<DATA>) {
    s/\#.*//; # Remove comments
    s/^\s*//; # Remove leading spaces
    s/\s*$//; # Revove trailing spaces
    next unless length; # Skip empty lines

    # Lines that contain an '=' are global definitions.

    push(@Def, $1, $2), next if /(\S+)\s*=\s*(\S.*)/;

    my @values = split /\s*\|\s*/;

    # hash for each footprint

    my %f = ( @Def,
	      map { $_ => shift(@values) } @Fields);

    $Pcb -> element_begin(description => 'TH',
			  output_file => "tmp/" . &package_name($f{circuits}, $f{pin_rows}),
			  input_dim   => 'mils',
			  pin_one_square => 1);

    my $pin_num = 1;
    my $pins_per_row = $f{circuits} / 2;

    # lower left corner is pin one

    my $x0 = -$f{pin_spacing} * ($pins_per_row - 1) / 2;
    my $y0 =  $f{row_spacing} / 2;

    my $x = $x0;
    my $y = $y0;

    # These header connectors consist of two rows of pins.  With pin
    # one in the lower left corner we will place pins from left to
    # right until half the pins are placed. At the halfway point we
    # will shift to the top row and place pins from right to left.

    while ($pin_num <= $f{circuits}) {
	$Pcb -> element_add_pin(x => $x, y => $y,
				thickness  => $f{pad_thickness},
				drill_hole => $f{drill_hole},
				mask       => 10,
				clearance  => 10,
				pin_number => $pin_num);

	# If this is the last pin in the row then
	# update the y value otherwise update the x 
	# value. If we are past the halfway point move
	# left (-) instead of right (+).

	if ($f{pin_numbering_scheme} eq 'header') {
	    $y *= -1;
	    $x += $f{pin_spacing} if $y > 0;
	} elsif ($f{pin_numbering_scheme} eq 'dip') {
	    if ($pin_num == $pins_per_row) {
		$y -= $f{row_spacing};
	    } else {
		$x += $pin_num > $pins_per_row 
		    ? -$f{pin_spacing}
		    : $f{pin_spacing};
	    }
	} elsif ($f{pin_numbering_scheme} eq 'power') {
	    if ($pin_num == $pins_per_row) {
		$y -= $f{row_spacing};
		$x = $x0;
	    } else {
		$x += $f{pin_spacing}
	    }
	} else {
	    die "unknown pin numbering scheme |$f{pin_numbering_scheme}|";
	}
	$pin_num++;
    }

    $Pcb -> element_add_rectangle(width => $f{body_width},
				  length=> $f{body_length},
				  x => 0,
				  y => 0);


    $Pcb -> element_set_text_xy(x => -$f{body_length}/2,
				y => -$f{body_width}/2 - 20);


    $Pcb -> element_output();
}

sub package_name ($$) { 
    my ($circuits, $rows) = @_;
    sprintf("con_hdr_%ix%i__Molex_8624-series", $circuits/$rows, $rows);
}

__DATA__

pad_thickness = 66
drill_hole = 46
pin_numbering_scheme = header
body_width = 200
pin_spacing = 100
row_spacing = 100
pin_diameter = 35
pin_rows = 2

# circuits | body_length | pin_row_length

4  | 190 | 100 
6  | 290 | 200 
8  | 390 | 300 
10 | 490 | 400 
12 | 590 | 500 
14 | 690 | 600 
16 | 790 | 700 
18 | 890 | 800 
20 | 990 | 900 
22 | 1090 | 1000 
24 | 1190| 1100 
26 | 1290| 1200 
28 | 1390| 1300

30 | 1490 | 1400 
32 | 1590 | 1500 
34 | 1690 | 1600 
36 | 1790 | 1700 
38 | 1890 | 1800 
40 | 1990 | 1900
42 | 2090 | 2000
44 | 2190 | 2100 
46 | 2290 | 2200
48 | 2390 | 2300 
50 | 2490 | 2400 
52 | 2590 | 2500 
54 | 2690 | 2600

56 | 2790 | 2700 
58 | 2890 | 2800 
60 | 2990 | 2900 
62 | 3090 | 3000 
64 | 3190 | 3100 
66 | 3290 | 3200 
68 | 3390 | 3300 
70 | 3490 | 3400 
72 | 3590 | 3500 
74 | 3690 | 3600 
76 | 3790 | 3700 
78 | 3890 | 3800 
80 | 3990 | 3900








On 6/15/05, Stuart Brorson <sdb@xxxxxxxxxx> wrote:
> Hi Guys --
> 
> First off, I'd like to say a great big "thank you" to John Luciani for
> posting his footprint generating Perl programs on his website!  I
> needed to create some 2mm header footprints today, and by
> modifying one of his programs I was able to create a set of new
> footprints for these headers within about one hour of hacking around.
> Excellent work!
> 
> By the way, I am posting my modified Perl prog below.  John, feel free
> to do anything with this prog you like.  Laugh at it, ignore it, stick
> it on your website, whatever. . . .   I post it here because others
> might find it useful.
> 
> Now on to my discussion point.  My program -- like the one on John's
> website -- numbers the pins on the header like this:
> 
> -----------------
> | 10 9  8  7  6 |
> |               |
> | 1  2  3  4  5 |
> -----------------
> 
> This is how DIPs and other chips are numbered.  However, connectors
> use a couple of different numbering schemes.   I believe that
> usual way to number header connectors is this:
> 
> -----------------
> | 2  4  6  8  10|
> |               |
> | 1  3  5  7  9 |
> -----------------
> 
> Therefore, once I ran my program, I had to edit the pin numbering by
> hand.  This is not a problem, since PCB has the ASCII file format, but
> it is an additional step in creating a footprint.
> 
> To make things more complex, there are other connector numbering
> schemes.  Power connectors, like the Molex Mini-Fit series seem to be
> numbered like this:
> 
> -----------------
> | 6  7  8  9  10|
> |               |
> | 1  2  3  4  5 |
> -----------------
> 
> Therefore, my topic for discussion is:  How to indicate the numbering
> scheme used in a connector footprint?  Should we use some kind of
> filename convention?  What?  And how does one correlate the numbering
> scheme with the schematic symbol?  (Personally, I try to draw my
> symbols to correspond to the physical view of the connector and its
> numbering scheme.)  And finally, how to hack John's program so that it
> can configurably emit pins corresponding to the differing numbering
> schemes?
> 
> Any thoughts?
> 
> Stuart
> 
> 
> 
> -----------------------------------------------------------------
> #!/usr/bin/perl
> 
> # Creates the PCB elements for Molex 87089 2mm header connectors
> 
> 
> use strict;
> use warnings;
> 
> use Pcb_8;
> 
> my $Pcb = Pcb_8 -> new(debug => 1);
> 
> my @Fields = qw(circuits body_length pin_row_length);
> 
> my @Def; # definitions that are common to all components
> 
> while (<DATA>) {
>     last if /^__END__$/;
>     s/\#.*//; # Remove comments
>     s/^\s*//; # Remove leading spaces
>     s/\s*$//; # Revove trailing spaces
>     next unless length; # Skip empty lines
> 
>     # Lines that contain an '=' are global definitions.
> 
>     push(@Def, $1, $2), next if /(\S+)\s*=\s*(\S.*)/;
> 
>     my @values = split /\s*\|\s*/;
> 
>     # hash for each footprint
> 
>     my %f = ( @Def,
>               map { $_ => shift(@values) } @Fields);
> 
>     $Pcb -> element_begin(description => 'Molex_2mmHeader_87089',
>                           output_file => "tmp/" . &package_name($f{package_prefix}, $f{circuits}, $f{pin_rows}),
>                           input_dim   => 'mils',
>                           pin_one_square => 1);
> 
>     my $pin_num = 1;
>     my $pins_per_row = $f{circuits} / 2;
> 
>     # lower left corner is pin one
> 
>     my $x = -$f{pin_spacing} * ($pins_per_row - 1) / 2;
>     my $y =  $f{row_spacing} / 2;
> 
>     # These header connectors consist of two rows of pins.  With pin
>     # one in the lower left corner we will place pins from left to
>     # right until half the pins are placed. At the halfway point we
>     # will shift to the top row and place pins from right to left.
> 
>     while ($pin_num <= $f{circuits}) {
>         $Pcb -> element_add_pin(x => $x, y => $y,
>                                 thickness  => 62,  # Changed by SDB for 2mm header
>                                 drill_hole => 37,  # Changed by SDB for 2mm header
>                                 mask       => 10,
>                                 clearance  => 10,
>                                 pin_number => $pin_num);
> 
>         # If this is the last pin in the row then
>         # update the y value otherwise update the x
>         # value. If we are past the halfway point move
>         # left (-) instead of right (+).
> 
>         if ($pin_num == $pins_per_row) {
>             $y -= $f{row_spacing};
>         } else {
>             $x += $pin_num > $pins_per_row
>                      ? -$f{pin_spacing}
>                      : $f{pin_spacing};
>         }
>         $pin_num++;
>     }
> 
>     $Pcb -> element_add_rectangle(width => $f{body_width},
>                                   length=> $f{body_length},
>                                   x => 0,
>                                   y => 0);
> 
> 
>     $Pcb -> element_set_text_xy(x => -$f{body_length}/2,
>                                 y => -$f{body_width}/2 - 20);
> 
> 
>     $Pcb -> element_output();
> }
> 
> sub package_name ($$$) {
>     my ($prefix, $circuits, $rows) = @_;
>     sprintf("%s-%ix%i", $prefix, $circuits/$rows, $rows);
> }
> 
> 
> __DATA__
> 
> # Data modified by SDB for Molex 2mm conns
> package_prefix = Header_Molex_87089
> body_width = 158
> pin_spacing = 79
> row_spacing = 79
> pin_diameter = 37
> pin_rows = 2
> 
> # circuits | body_length | pin_row_length
> 
> 4  | 179 | 79
> 6  | 258 | 158
> 8  | 337 | 237
> 10 | 416 | 316
> 12 | 495 | 395
> 14 | 574 | 474
> 16 | 653 | 553
> 18 | 732 | 632
> 20 | 811 | 711
> 
> __END__
> 
>