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

gEDA-user: Connector pin numbering conventions and PCB



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__