7f3276597442c4914a402413a415706339242ad7
[hw/altusmetrum] / packages / te-connectivity / micromatch-th-v.py
1 #!/usr/bin/python2
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 # freedfm.com round-off error bites us if we make this 700...
25 MinAnnular = 725
26 MinClearance = 600
27 MaskDelta = 300
28
29 import sys
30
31 # we're going to use the 1/100 of a mil fundamental unit form
32 def mm2mils100( mm ):
33         return int( mm / 25.4 * 1000.0 * 100.0 + 0.5 )
34
35 pins = int(sys.argv[1])
36
37 if pins < 4:
38         sys.stderr.write('Must be at least 4 pins\n')
39         sys.exit(1)
40 if pins == 22:
41         sys.stderr.write('There is no 22 pin version!\n')
42         sys.exit(1)
43 if pins > 24:
44         sys.stderr.write('Must be no more than 24 pins\n')
45         sys.exit(1)
46
47 if len(sys.argv) > 2:
48     if sys.argv[2] == "latch":
49         BoxXbase = 5.89
50         if pins == 24:
51                 sys.stderr.write('There is no 24 pin latching version!\n')
52                 sys.exit(1)
53
54 print '# author: Bdale Garbee'
55 print '# email: bdale@gag.com'
56 print '# dist-license: GPL 2'
57 print '# use-license: unlimited'
58
59 print 'Element[0x0 "MicroMatch%i"' % pins,'"" "" 0 0 0 0 0 100 0x0]'
60 print "("
61 for col in range ((pins+1)/2):
62     for row in range (2):
63         if row == 1:
64             spacing=0
65         else:
66             spacing=RowSpacing
67         pinnum = (col * 2) + row + 1
68         if pinnum == 1:
69             Flags = '0x0101'
70         else:
71             Flags = '0x0001'
72         print '   Pin[', \
73             mm2mils100((pinnum-1)*PinSpacing), \
74             mm2mils100(spacing), \
75             mm2mils100(PinDiam)+(MinAnnular*2), \
76             (MinClearance*2), \
77             mm2mils100(PinDiam)+(MinAnnular*2)+(MaskDelta*2), \
78             mm2mils100(PinDiam), \
79             '"pin%i"' % pinnum, '"%i"' % pinnum, Flags, ']'
80
81 # add a hole for the index pin.  plated to save non-plated-hole extra fab cost.
82 print '   Pin[', \
83     mm2mils100(-MntX), \
84     mm2mils100(RowSpacing-MntY), \
85     mm2mils100(MntDiam)+(MinAnnular*2), \
86     (MinClearance*2), \
87     mm2mils100(MntDiam)+(MinAnnular*2)+(MaskDelta*2), \
88     mm2mils100(MntDiam), \
89     '"mnt" "0"', '0x0001', ']'
90
91 BoxX = (pins - 1) * PinSpacing + BoxXbase
92 BoxX1 = -(BoxXbase/2)
93 BoxX2 = BoxX1 + BoxX
94 BoxY1 = -(BoxY - RowSpacing)/2
95 BoxY2 = BoxY1 + BoxY
96
97 print '   ElementLine[', \
98         mm2mils100(BoxX1), \
99         mm2mils100(BoxY1), \
100         mm2mils100(BoxX1), \
101         mm2mils100(BoxY2), \
102         LineWidth, ']'
103
104 print '   ElementLine[', \
105         mm2mils100(BoxX1), \
106         mm2mils100(BoxY2), \
107         mm2mils100(BoxX2), \
108         mm2mils100(BoxY2), \
109         LineWidth, ']'
110
111 print '   ElementLine[', \
112         mm2mils100(BoxX2), \
113         mm2mils100(BoxY2), \
114         mm2mils100(BoxX2), \
115         mm2mils100(BoxY1), \
116         LineWidth, ']'
117
118 print '   ElementLine[', \
119         mm2mils100(BoxX2), \
120         mm2mils100(BoxY1), \
121         mm2mils100(BoxX1), \
122         mm2mils100(BoxY1), \
123         LineWidth, ']'
124   
125 print ")"