tweaking spacings for TM v0.2
[hw/bdale] / pkg / newlib / tyco / micromatch-th-v.py
1 #!/usr/bin/python
2 # Copyright 2009 by Bdale Garbee <bdale@gag.com>.  GPLv2
3 #
4 # Program to emit PCB footprint for
5 #   Tyco/AMP Micro-MaTch vertical through-hole female connectors
6 #
7 # Needs pin count on command line, in range of 4..20 even numbers only
8 #
9
10 # dimensions in mm from C_215079_v.pdf datasheet
11 PinDiam = 0.8
12 PinSpacing = 1.27
13 RowSpacing = 2.54
14
15 MntX = 1.4
16 MntY = 1.8
17 MntDiam = 1.5
18
19 BoxY = 5.1
20 BoxXbase = 4.79
21
22 LineWidth = 600
23
24 import sys
25
26 # we're going to use the 1/100 of a mil fundamental unit form
27 def mm2mils100( mm ):
28         return int( mm / 25.4 * 1000.0 * 100.0 + 0.5 )
29
30 pins = int(sys.argv[1])
31
32 if pins < 4:
33         sys.stderr.write('Must be at least 4 pins\n')
34         sys.exit(1)
35 if pins == 22:
36         sys.stderr.write('There is no 22 pin version!\n')
37         sys.exit(1)
38 if pins > 24:
39         sys.stderr.write('Must be no more than 24 pins\n')
40         sys.exit(1)
41
42 if len(sys.argv) > 2:
43     if sys.argv[2] == "latch":
44         BoxXbase = 5.89
45         if pins == 24:
46                 sys.stderr.write('There is no 24 pin latching version!\n')
47                 sys.exit(1)
48
49 print '# author: Bdale Garbee'
50 print '# email: bdale@gag.com'
51 print '# dist-license: GPL 2'
52 print '# use-license: unlimited'
53
54 print 'Element[0x0 "MicroMatch%i"' % pins,'"" "" 0 0 0 0 0 100 0x0]'
55 print "("
56 for col in range ((pins+1)/2):
57     for row in range (2):
58         if row == 1:
59             spacing=0
60         else:
61             spacing=RowSpacing
62         pinnum = (col * 2) + row + 1
63         if pinnum == 1:
64             Flags = '0x0101'
65         else:
66             Flags = '0x0001'
67         print '   Pin[', \
68             mm2mils100((pinnum-1)*PinSpacing), \
69             mm2mils100(spacing), \
70             mm2mils100(PinDiam*2), \
71             1200, \
72             mm2mils100(PinDiam*2)+1000, \
73             mm2mils100(PinDiam), \
74             '"pin%i"' % pinnum, '"%i"' % pinnum, Flags, ']'
75
76 # add a hole for the index pin.  plated to save non-plated-hole extra fab cost.
77 print '   Pin[', \
78     mm2mils100(-MntX), \
79     mm2mils100(RowSpacing-MntY), \
80     mm2mils100(MntDiam)+1300, \
81     1200, \
82     mm2mils100(MntDiam), \
83     mm2mils100(MntDiam), \
84     '"mnt" "0"', '0x0001', ']'
85
86 BoxX = (pins - 1) * PinSpacing + BoxXbase
87 BoxX1 = -(BoxXbase/2)
88 BoxX2 = BoxX1 + BoxX
89 BoxY1 = -(BoxY - RowSpacing)/2
90 BoxY2 = BoxY1 + BoxY
91
92 print '   ElementLine[', \
93         mm2mils100(BoxX1), \
94         mm2mils100(BoxY1), \
95         mm2mils100(BoxX1), \
96         mm2mils100(BoxY2), \
97         LineWidth, ']'
98
99 print '   ElementLine[', \
100         mm2mils100(BoxX1), \
101         mm2mils100(BoxY2), \
102         mm2mils100(BoxX2), \
103         mm2mils100(BoxY2), \
104         LineWidth, ']'
105
106 print '   ElementLine[', \
107         mm2mils100(BoxX2), \
108         mm2mils100(BoxY2), \
109         mm2mils100(BoxX2), \
110         mm2mils100(BoxY1), \
111         LineWidth, ']'
112
113 print '   ElementLine[', \
114         mm2mils100(BoxX2), \
115         mm2mils100(BoxY1), \
116         mm2mils100(BoxX1), \
117         mm2mils100(BoxY1), \
118         LineWidth, ']'
119   
120 print ")"